From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Subject: [PATCH v2 05/19] NFSv4: Add CB_GETATTR support for delegated attributes
Date: Sun, 16 Jun 2024 21:21:23 -0400 [thread overview]
Message-ID: <20240617012137.674046-6-trondmy@kernel.org> (raw)
In-Reply-To: <20240617012137.674046-5-trondmy@kernel.org>
From: Trond Myklebust <trond.myklebust@primarydata.com>
When the client holds an attribute delegation, the server may retrieve
all the timestamps through a CB_GETATTR callback.
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/callback.h | 5 +++--
fs/nfs/callback_proc.c | 14 +++++++++-----
fs/nfs/callback_xdr.c | 39 +++++++++++++++++++++++++++++++++++++--
3 files changed, 49 insertions(+), 9 deletions(-)
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index 650758ee0d5f..154a6ed1299f 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -46,14 +46,15 @@ struct cb_compound_hdr_res {
struct cb_getattrargs {
struct nfs_fh fh;
- uint32_t bitmap[2];
+ uint32_t bitmap[3];
};
struct cb_getattrres {
__be32 status;
- uint32_t bitmap[2];
+ uint32_t bitmap[3];
uint64_t size;
uint64_t change_attr;
+ struct timespec64 atime;
struct timespec64 ctime;
struct timespec64 mtime;
};
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 76cea34477ae..199c52788640 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -37,7 +37,7 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
if (!cps->clp) /* Always set for v4.0. Set in cb_sequence for v4.1 */
goto out;
- res->bitmap[0] = res->bitmap[1] = 0;
+ memset(res->bitmap, 0, sizeof(res->bitmap));
res->status = htonl(NFS4ERR_BADHANDLE);
dprintk_rcu("NFS: GETATTR callback request from %s\n",
@@ -59,12 +59,16 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
res->change_attr = delegation->change_attr;
if (nfs_have_writebacks(inode))
res->change_attr++;
+ res->atime = inode_get_atime(inode);
res->ctime = inode_get_ctime(inode);
res->mtime = inode_get_mtime(inode);
- res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) &
- args->bitmap[0];
- res->bitmap[1] = (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) &
- args->bitmap[1];
+ res->bitmap[0] = (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE) &
+ args->bitmap[0];
+ res->bitmap[1] = (FATTR4_WORD1_TIME_ACCESS |
+ FATTR4_WORD1_TIME_METADATA |
+ FATTR4_WORD1_TIME_MODIFY) & args->bitmap[1];
+ res->bitmap[2] = (FATTR4_WORD2_TIME_DELEG_ACCESS |
+ FATTR4_WORD2_TIME_DELEG_MODIFY) & args->bitmap[2];
res->status = 0;
out_iput:
rcu_read_unlock();
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 9369488f2ed4..29c49a7e5fe1 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -25,8 +25,9 @@
#define CB_OP_GETATTR_BITMAP_MAXSZ (4 * 4) // bitmap length, 3 bitmaps
#define CB_OP_GETATTR_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \
CB_OP_GETATTR_BITMAP_MAXSZ + \
- /* change, size, ctime, mtime */\
- (2 + 2 + 3 + 3) * 4)
+ /* change, size, atime, ctime,
+ * mtime, deleg_atime, deleg_mtime */\
+ (2 + 2 + 3 + 3 + 3 + 3 + 3) * 4)
#define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ)
#if defined(CONFIG_NFS_V4_1)
@@ -635,6 +636,13 @@ static __be32 encode_attr_time(struct xdr_stream *xdr, const struct timespec64 *
return 0;
}
+static __be32 encode_attr_atime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec64 *time)
+{
+ if (!(bitmap[1] & FATTR4_WORD1_TIME_ACCESS))
+ return 0;
+ return encode_attr_time(xdr,time);
+}
+
static __be32 encode_attr_ctime(struct xdr_stream *xdr, const uint32_t *bitmap, const struct timespec64 *time)
{
if (!(bitmap[1] & FATTR4_WORD1_TIME_METADATA))
@@ -649,6 +657,24 @@ static __be32 encode_attr_mtime(struct xdr_stream *xdr, const uint32_t *bitmap,
return encode_attr_time(xdr,time);
}
+static __be32 encode_attr_delegatime(struct xdr_stream *xdr,
+ const uint32_t *bitmap,
+ const struct timespec64 *time)
+{
+ if (!(bitmap[2] & FATTR4_WORD2_TIME_DELEG_ACCESS))
+ return 0;
+ return encode_attr_time(xdr,time);
+}
+
+static __be32 encode_attr_delegmtime(struct xdr_stream *xdr,
+ const uint32_t *bitmap,
+ const struct timespec64 *time)
+{
+ if (!(bitmap[2] & FATTR4_WORD2_TIME_DELEG_MODIFY))
+ return 0;
+ return encode_attr_time(xdr,time);
+}
+
static __be32 encode_compound_hdr_res(struct xdr_stream *xdr, struct cb_compound_hdr_res *hdr)
{
__be32 status;
@@ -697,12 +723,21 @@ static __be32 encode_getattr_res(struct svc_rqst *rqstp, struct xdr_stream *xdr,
if (unlikely(status != 0))
goto out;
status = encode_attr_size(xdr, res->bitmap, res->size);
+ if (unlikely(status != 0))
+ goto out;
+ status = encode_attr_atime(xdr, res->bitmap, &res->atime);
if (unlikely(status != 0))
goto out;
status = encode_attr_ctime(xdr, res->bitmap, &res->ctime);
if (unlikely(status != 0))
goto out;
status = encode_attr_mtime(xdr, res->bitmap, &res->mtime);
+ if (unlikely(status != 0))
+ goto out;
+ status = encode_attr_delegatime(xdr, res->bitmap, &res->atime);
+ if (unlikely(status != 0))
+ goto out;
+ status = encode_attr_delegmtime(xdr, res->bitmap, &res->mtime);
*savep = htonl((unsigned int)((char *)xdr->p - (char *)(savep+1)));
out:
return status;
--
2.45.2
next prev parent reply other threads:[~2024-06-17 1:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 1:21 [PATCH v2 00/19] OPEN optimisations and Attribute delegations trondmy
2024-06-17 1:21 ` [PATCH v2 01/19] NFSv4: Clean up open delegation return structure trondmy
2024-06-17 1:21 ` [PATCH v2 02/19] NFSv4: Refactor nfs4_opendata_check_deleg() trondmy
2024-06-17 1:21 ` [PATCH v2 03/19] NFSv4: Add new attribute delegation definitions trondmy
2024-06-17 1:21 ` [PATCH v2 04/19] NFSv4: Plumb in XDR support for the new delegation-only setattr op trondmy
2024-06-17 1:21 ` trondmy [this message]
2024-06-17 1:21 ` [PATCH v2 06/19] NFSv4: Add a flags argument to the 'have_delegation' callback trondmy
2024-06-17 1:21 ` [PATCH v2 07/19] NFSv4: Add support for delegated atime and mtime attributes trondmy
2024-06-17 1:21 ` [PATCH v2 08/19] NFSv4: Add recovery of attribute delegations trondmy
2024-06-17 1:21 ` [PATCH v2 09/19] NFSv4: Add a capability for delegated attributes trondmy
2024-06-17 1:21 ` [PATCH v2 10/19] NFSv4: Enable attribute delegations trondmy
2024-06-17 1:21 ` [PATCH v2 11/19] NFSv4: Delegreturn must set m/atime when they are delegated trondmy
2024-06-17 1:21 ` [PATCH v2 12/19] NFSv4: Fix up delegated attributes in nfs_setattr trondmy
2024-06-17 1:21 ` [PATCH v2 13/19] NFSv4: Don't request atime/mtime/size if they are delegated to us trondmy
2024-06-17 1:21 ` [PATCH v2 14/19] NFSv4: Add support for the FATTR4_OPEN_ARGUMENTS attribute trondmy
2024-06-17 1:21 ` [PATCH v2 15/19] NFSv4: Detect support for OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION trondmy
2024-06-17 1:21 ` [PATCH v2 16/19] NFSv4: Add support for OPEN4_RESULT_NO_OPEN_STATEID trondmy
2024-06-17 1:21 ` [PATCH v2 17/19] NFSv4: Ask for a delegation or an open stateid in OPEN trondmy
2024-06-17 1:21 ` [PATCH v2 18/19] Return the delegation when deleting sillyrenamed files trondmy
2024-06-17 1:21 ` [PATCH v2 19/19] NFSv4: Don't send delegation-related share access modes to CLOSE trondmy
2024-10-18 18:56 ` [PATCH v2 11/19] NFSv4: Delegreturn must set m/atime when they are delegated Jeff Layton
2024-10-23 13:35 ` [PATCH] NFS: Fix attribute delegation behaviour on exclusive create trondmy
2024-10-23 14:45 ` Jeff Layton
2024-06-17 23:51 ` [PATCH v2 00/19] OPEN optimisations and Attribute delegations Olga Kornievskaia
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=20240617012137.674046-6-trondmy@kernel.org \
--to=trondmy@kernel.org \
--cc=linux-nfs@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