linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Block <ablock84@googlemail.com>
To: linux-btrfs@vger.kernel.org
Cc: Alexander Block <ablock84@googlemail.com>
Subject: [PATCH] Btrfs: don't update atime on RO subvolumes
Date: Fri, 25 May 2012 14:50:43 +0200	[thread overview]
Message-ID: <1337950243-5992-1-git-send-email-ablock84@googlemail.com> (raw)

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@googlemail.com>
---
 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


                 reply	other threads:[~2012-05-25 12:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337950243-5992-1-git-send-email-ablock84@googlemail.com \
    --to=ablock84@googlemail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).