From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
Olga Kornievskaia <kolga@netapp.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Jonathan Corbet <corbet@lwn.net>
Cc: Tom Haynes <loghyr@gmail.com>,
linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
Jeff Layton <jlayton@kernel.org>
Subject: [PATCH v2 5/7] fs: add an ATTR_CTIME_DLG flag
Date: Mon, 26 Aug 2024 08:46:15 -0400 [thread overview]
Message-ID: <20240826-delstid-v2-5-e8ab5c0e39cc@kernel.org> (raw)
In-Reply-To: <20240826-delstid-v2-0-e8ab5c0e39cc@kernel.org>
When updating the ctime on an inode for a setattr with a multigrain
filesystem, we usually want to take the latest time we can get for the
ctime. The exception to this rule is when there is a nfsd write
delegation and the server is proxying timestamps from the client.
When nfsd gets a CB_GETATTR response, we want to update the timestamp
value in the inode to the values that the client is tracking. The client
doesn't send a ctime value (since that's always determined by the
exported filesystem), but it does send a mtime value. In the case where
it does, then we may also need to update the ctime to a value
commensurate with that.
Add a ATTR_CTIME_DELEG flag, which tells the underlying setattr
machinery to respect that value and not to set it to the current time.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/attr.c | 10 +++++++++-
include/linux/fs.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/fs/attr.c b/fs/attr.c
index 7144b207e715..0eb7b228b94d 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -295,7 +295,15 @@ static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr)
return;
}
- now = inode_set_ctime_current(inode);
+ /*
+ * In the case of an update for a write delegation, we must respect
+ * the value in ia_ctime and not use the current time.
+ */
+ if (ia_valid & ATTR_CTIME_DLG)
+ inode_set_ctime_to_ts(inode, attr->ia_ctime);
+ else
+ now = inode_set_ctime_current(inode);
+
if (ia_valid & ATTR_ATIME_SET)
inode_set_atime_to_ts(inode, attr->ia_atime);
else if (ia_valid & ATTR_ATIME)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7c1da3c687bd..43a802b2cb0d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -211,6 +211,7 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
#define ATTR_TIMES_SET (1 << 16)
#define ATTR_TOUCH (1 << 17)
#define ATTR_DELEG (1 << 18) /* Delegated attrs (don't break) */
+#define ATTR_CTIME_DLG (1 << 19) /* Delegation in effect */
/*
* Whiteout is represented by a char device. The following constants define the
--
2.46.0
next prev parent reply other threads:[~2024-08-26 12:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 12:46 [PATCH v2 0/7] nfsd: implement the "delstid" draft Jeff Layton
2024-08-26 12:46 ` [PATCH v2 1/7] nfsd: add pragma public to delegated timestamp types Jeff Layton
2024-08-26 12:46 ` [PATCH v2 2/7] nfs_common: make nfs4.h include generated nfs4_1.h Jeff Layton
2024-08-26 12:46 ` [PATCH v2 3/7] nfsd: add support for FATTR4_OPEN_ARGUMENTS Jeff Layton
2024-08-26 12:46 ` [PATCH v2 4/7] nfsd: implement OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION Jeff Layton
2024-08-26 12:46 ` Jeff Layton [this message]
2024-08-26 13:08 ` [PATCH v2 5/7] fs: add an ATTR_CTIME_DLG flag Christian Brauner
2024-08-26 13:16 ` Jeff Layton
2024-08-26 12:46 ` [PATCH v2 6/7] nfsd: drop the ncf_cb_bmap field Jeff Layton
2024-08-26 12:46 ` [PATCH v2 7/7] nfsd: add support for delegated timestamps Jeff Layton
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=20240826-delstid-v2-5-e8ab5c0e39cc@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=anna@kernel.org \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=corbet@lwn.net \
--cc=jack@suse.cz \
--cc=kolga@netapp.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=loghyr@gmail.com \
--cc=neilb@suse.de \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).