[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Btrfs: don't update atime on RO subvolumes



Before the update_time inode operation was indroduced, it was
not possible to prevent updates of atime on RO subvolumes.
btrfs_update_time does now check if the root is RO and skip
updating of atime.

This patch requires the update_time patches from Josef
Bacik.

Signed-off-by: Alexander Block <ablock84@xxxxxxxxxxxxxx>
---
 fs/btrfs/inode.c |   26 +++++++++++++++++++++-----
 fs/inode.c       |    3 +++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 54ae3df..b48db5a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4470,14 +4470,30 @@ int btrfs_dirty_inode(struct inode *inode)
 static int btrfs_update_time(struct inode *inode, struct timespec *now,
 			     int flags)
 {
-	if (flags & S_VERSION)
+	struct btrfs_root *root = BTRFS_I(inode)->root;
+	int did_update = 0;
+
+	if (flags & S_VERSION) {
 		inode_inc_iversion(inode);
-	if (flags & S_CTIME)
+		did_update = 1;
+	}
+	if (flags & S_CTIME) {
 		inode->i_ctime = *now;
-	if (flags & S_MTIME)
+		did_update = 1;
+	}
+	if (flags & S_MTIME) {
 		inode->i_mtime = *now;
-	if (flags & S_ATIME)
-		inode->i_atime = *now;
+		did_update = 1;
+	}
+	if (flags & S_ATIME) {
+		/* don't do atime updates on RO subvolumes */
+		if (!btrfs_root_readonly(root)) {
+			inode->i_atime = *now;
+			did_update = 1;
+		}
+	}
+	if (!did_update)
+		return 0;
 	return btrfs_dirty_inode(inode);
 }
 
diff --git a/fs/inode.c b/fs/inode.c
index 06d8bd4..949d06f 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1545,6 +1545,9 @@ void touch_atime(struct path *path)
 	 * Btrfs), but since we touch atime while walking down the path we
 	 * really don't care if we failed to update the atime of the file,
 	 * so just ignore the return value.
+	 * Also, the checks done above to see if updating atime is allowed
+	 * are not enough for some filesystems. Btrfs for example may have
+	 * RO subvolumes on a RW filesystems, which vfs is not aware of.
 	 */
 	update_time(inode, &now, S_ATIME);
 	mnt_drop_write(mnt);
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [XFree86]

Add to Google Powered by Linux