git: 93a32050abac - main - nfsd: Fix pNFS handling of Deallocate
Rick Macklem
rmacklem at FreeBSD.org
Sat Oct 2 21:14:34 UTC 2021
The branch main has been updated by rmacklem:
URL: https://cgit.FreeBSD.org/src/commit/?id=93a32050abac11d22d849d9cf2014370662269a7
commit 93a32050abac11d22d849d9cf2014370662269a7
Author: Rick Macklem <rmacklem at FreeBSD.org>
AuthorDate: 2021-10-02 21:11:15 +0000
Commit: Rick Macklem <rmacklem at FreeBSD.org>
CommitDate: 2021-10-02 21:11:15 +0000
nfsd: Fix pNFS handling of Deallocate
For a pNFS server configuration, an NFSv4.2 Deallocate operation
is proxied to the DS(s). The code that parsed the reply for the
proxy RPC is broken and did not process the pre-operation attributes.
This patch fixes this problem.
This bug would only affect pNFS servers built from recent main/FreeBSD14
sources.
---
sys/fs/nfsserver/nfs_nfsdport.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index 49cbd2c9de0f..0f678cd5640e 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -5732,8 +5732,14 @@ nfsrv_deallocatedsdorpc(struct nfsmount *nmp, fhandle_t *fhp, off_t off,
txdr_hyper(len, tl); tl += 2;
NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: len=%jd\n", (intmax_t)len);
+ /* Do a Getattr for the attributes that change upon writing. */
+ NFSZERO_ATTRBIT(&attrbits);
+ NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_SIZE);
+ NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_CHANGE);
+ NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESS);
+ NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEMODIFY);
+ NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_SPACEUSED);
*tl = txdr_unsigned(NFSV4OP_GETATTR);
- NFSGETATTR_ATTRBIT(&attrbits);
nfsrv_putattrbit(nd, &attrbits);
error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p,
cred, NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
@@ -5741,8 +5747,23 @@ nfsrv_deallocatedsdorpc(struct nfsmount *nmp, fhandle_t *fhp, off_t off,
free(nd, M_TEMP);
return (error);
}
- NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: aft allocaterpc=%d\n",
+ NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: aft deallocaterpc=%d\n",
nd->nd_repstat);
+ /* Get rid of weak cache consistency data for now. */
+ if ((nd->nd_flag & (ND_NOMOREDATA | ND_NFSV4 | ND_V4WCCATTR)) ==
+ (ND_NFSV4 | ND_V4WCCATTR)) {
+ error = nfsv4_loadattr(nd, NULL, nap, NULL, NULL, 0, NULL, NULL,
+ NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL);
+ NFSD_DEBUG(4, "nfsrv_deallocatedsdorpc: wcc attr=%d\n", error);
+ if (error != 0)
+ goto nfsmout;
+ /*
+ * Get rid of Op# and status for next op.
+ */
+ NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED);
+ if (*++tl != 0)
+ nd->nd_flag |= ND_NOMOREDATA;
+ }
if (nd->nd_repstat == 0) {
NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED);
error = nfsv4_loadattr(nd, NULL, nap, NULL, NULL, 0, NULL, NULL,
More information about the dev-commits-src-main
mailing list