From nobody Thu Jun 09 20:30:52 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 88927844CAA; Thu, 9 Jun 2022 20:30:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LJwhr3SKqz3kTF; Thu, 9 Jun 2022 20:30:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654806652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OoKgKnQGOvQgWT6NeUfBR8sk9xkdVuvp+63R3vs30Bk=; b=OsGXCfU1zNuonw+iGgpnawzKxCEYShNdSBH/f/O5U3tia+i/SS57mt31ts21H81lmwzgC3 FpB/WfLKMw22fP5uyYDg71b8K3s3buCVodLS63lVaUJfdcxj3v0JhQGw1fQOcs63A/QuhL hW5p07QSY4pKhyHVr70RRE1qn2JIkX8C60XgFQmN60+CchymMHa8sR5v/Lf5vuR7sjZT8s SVWybxZdLC+QbrOQgvFxtz9uW5M28QeqIgBiTz2GY86jP8hztZlUG0utIwswzv/YpNzELA ZSBGq6P62MxhJrKq8O27emUIfiG3VPTUUnGiIamEBS4FeG4ovYBUHVMrqU6MjA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 562512C1A; Thu, 9 Jun 2022 20:30:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 259KUqYp018445; Thu, 9 Jun 2022 20:30:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 259KUqm0018444; Thu, 9 Jun 2022 20:30:52 GMT (envelope-from git) Date: Thu, 9 Jun 2022 20:30:52 GMT Message-Id: <202206092030.259KUqm0018444@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 2e6b10dc5bd9 - stable/13 - nfscl: Add support for a NFSv4 AppendWrite RPC List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2e6b10dc5bd991a7438724a18a532ab73eb1ace0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654806652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OoKgKnQGOvQgWT6NeUfBR8sk9xkdVuvp+63R3vs30Bk=; b=BLMhtNFkFP+Kt5t19WaMjcUDcFfkammexzxQEACe+n2N7syvFkrnCSyCWy152qQ/ZnqGqz FjRCHiPGcDyvWrkMB8p2HEUHvj8YBFlBi5AFyTHY1FvU1ooXK7LIEgsep8Ok9hXWaZCEfe /c6rMM2qGVLDwDPPevoAzBxQkzahhX9PV1wslIfuub0nltXwlfOuFF3vbi2cORWnbd+lOw 6choPxhLXQUH2C9IdmqL45wYkrgn3ObeHvW8GyHo/rwOvEoI1hc2pg+02cR+M8nPkqCKkh tiBRZBZImrE7+7cdkTwaoG9HGl29WWdtE6t0u2q/03J1KoT9HIRmLANhuk7y/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654806652; a=rsa-sha256; cv=none; b=RoZ9s4u1CVjST/Hw2ksoGEG4+Mn4aIeHgtddF99I3yzH6a63Ydu09t2caUcu6m1IWStH/A 2AffDjqH9mT4BFc5yRKYanbsGHZdSrfKgz2upvEe+7920KZcI/qIsqqLXraZEh6E/WSSzP W72BGv8Nl1A2qs120PVBNieQGv8TS0jAumHojf4wUR+Oby/I7MjnWpe9ElLNqSdWc3ZNTs yZBLr+70Bfu8FKxe5j2nESu+vYiJK8X+riC4eoPRLy3FvTIyvHM3Y47QCH8O+dKMfd9W4Q UlKZ/2a+G+KDnJ8DUNKa4Kr4T+Ur1EhPAenKRUoTaUpKiW07+Zvn4WrjO8c/Wg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=2e6b10dc5bd991a7438724a18a532ab73eb1ace0 commit 2e6b10dc5bd991a7438724a18a532ab73eb1ace0 Author: Rick Macklem AuthorDate: 2022-04-08 20:59:05 +0000 Commit: Rick Macklem CommitDate: 2022-06-09 19:57:30 +0000 nfscl: Add support for a NFSv4 AppendWrite RPC For IO_APPEND VOP_WRITE()s, the code first does a Getattr RPC to acquire the file's size, before it can do the Write RPC. Although NFS does not have an append write operation, an NFSv4 compound can use a Verify operation to check that the client's notion of the file's size is correct, followed by the Write operation. This patch modifies nfscl_wcc_data() to optionally acquire the file's size, for use with an AppendWrite. Although the "stuff" arguments are always NULL (these were used for the Mac OSX port and should be cleared out someday), make the argument to nfscl_wcc_data() explicitly NULL for clarity. This patch does not cause any semantics change until the AppendWrite is added in a future commit. (cherry picked from commit 21de450aa1a7ca226908e7421b93ca979ff42db7) --- sys/fs/nfs/nfs_commonsubs.c | 4 ++++ sys/fs/nfs/nfs_var.h | 2 +- sys/fs/nfsclient/nfs_clport.c | 6 ++++-- sys/fs/nfsclient/nfs_clrpcops.c | 33 ++++++++++++++++----------------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index 8ebb3e31b73a..d65c98c6d0a9 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -440,6 +440,10 @@ nfscl_reqstart(struct nfsrv_descript *nd, int procnum, struct nfsmount *nmp, NFSGETATTR_ATTRBIT(&attrbits); else { NFSWCCATTR_ATTRBIT(&attrbits); + /* For AppendWrite, get the size. */ + if (procnum == NFSPROC_APPENDWRITE) + NFSSETBIT_ATTRBIT(&attrbits, + NFSATTRBIT_SIZE); nd->nd_flag |= ND_V4WCCATTR; } (void) nfsrv_putattrbit(nd, &attrbits); diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index c565a8ab579a..7bdcbcd50575 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -374,7 +374,7 @@ int nfscl_mtofh(struct nfsrv_descript *, struct nfsfh **, int nfscl_postop_attr(struct nfsrv_descript *, struct nfsvattr *, int *, void *); int nfscl_wcc_data(struct nfsrv_descript *, vnode_t, - struct nfsvattr *, int *, int *, void *); + struct nfsvattr *, int *, int *, uint64_t *); int nfsm_loadattr(struct nfsrv_descript *, struct nfsvattr *); int nfscl_request(struct nfsrv_descript *, vnode_t, NFSPROC_T *, struct ucred *, void *); diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 6364cce6626c..2e6726f604d4 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -781,7 +781,7 @@ nfscl_start_renewthread(struct nfsclclient *clp) */ int nfscl_wcc_data(struct nfsrv_descript *nd, struct vnode *vp, - struct nfsvattr *nap, int *flagp, int *wccflagp, void *stuff) + struct nfsvattr *nap, int *flagp, int *wccflagp, uint64_t *repsizep) { u_int32_t *tl; struct nfsnode *np = VTONFS(vp); @@ -804,7 +804,7 @@ nfscl_wcc_data(struct nfsrv_descript *nd, struct vnode *vp, NFSUNLOCKNODE(np); } } - error = nfscl_postop_attr(nd, nap, flagp, stuff); + error = nfscl_postop_attr(nd, nap, flagp, NULL); if (wccflagp != NULL && *flagp == 0) *wccflagp = 0; } else if ((nd->nd_flag & (ND_NOMOREDATA | ND_NFSV4 | ND_V4WCCATTR)) @@ -820,6 +820,8 @@ nfscl_wcc_data(struct nfsrv_descript *nd, struct vnode *vp, NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED); if (*++tl) nd->nd_flag |= ND_NOMOREDATA; + if (repsizep != NULL) + *repsizep = nfsva.na_size; if (wccflagp != NULL && nfsva.na_vattr.va_mtime.tv_sec != 0) { NFSLOCKNODE(np); diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 149b57e49fb7..f6b6e75b4278 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -1376,7 +1376,7 @@ nfsrpc_setattrrpc(vnode_t vp, struct vattr *vap, if (error) return (error); if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) - error = nfscl_wcc_data(nd, vp, rnap, attrflagp, NULL, stuff); + error = nfscl_wcc_data(nd, vp, rnap, attrflagp, NULL, NULL); if ((nd->nd_flag & (ND_NFSV4 | ND_NOMOREDATA)) == ND_NFSV4 && !error) error = nfsrv_getattrbits(nd, &attrbits, NULL, NULL); if (!(nd->nd_flag & ND_NFSV3) && !nd->nd_repstat && !error) @@ -1895,7 +1895,7 @@ nfsrpc_writerpc(vnode_t vp, struct uio *uiop, int *iomode, } if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) { error = nfscl_wcc_data(nd, vp, nap, attrflagp, - &wccflag, stuff); + &wccflag, NULL); if (error) goto nfsmout; } @@ -2026,7 +2026,7 @@ nfsrpc_mknod(vnode_t dvp, char *name, int namelen, struct vattr *vap, if (error) return (error); if (nd->nd_flag & ND_NFSV4) - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); if (!nd->nd_repstat) { if (nd->nd_flag & ND_NFSV4) { NFSM_DISSECT(tl, u_int32_t *, 5 * NFSX_UNSIGNED); @@ -2039,7 +2039,7 @@ nfsrpc_mknod(vnode_t dvp, char *name, int namelen, struct vattr *vap, goto nfsmout; } if (nd->nd_flag & ND_NFSV3) - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); if (!error && nd->nd_repstat) error = nd->nd_repstat; nfsmout: @@ -2163,7 +2163,7 @@ nfsrpc_createv23(vnode_t dvp, char *name, int namelen, struct vattr *vap, goto nfsmout; } if (nd->nd_flag & ND_NFSV3) - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); if (nd->nd_repstat != 0 && error == 0) error = nd->nd_repstat; nfsmout: @@ -2486,7 +2486,7 @@ tryagain: nd->nd_flag |= ND_NOMOREDATA; } } - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); } if (nd->nd_repstat && !error) error = nd->nd_repstat; @@ -2633,8 +2633,7 @@ tryagain: if (*(tl + 1)) nd->nd_flag |= ND_NOMOREDATA; } - error = nfscl_wcc_data(nd, fdvp, fnap, fattrflagp, NULL, - fstuff); + error = nfscl_wcc_data(nd, fdvp, fnap, fattrflagp, NULL, NULL); /* and the second wcc attribute reply. */ if ((nd->nd_flag & (ND_NFSV4 | ND_NOMOREDATA)) == ND_NFSV4 && !error) { @@ -2644,7 +2643,7 @@ tryagain: } if (!error) error = nfscl_wcc_data(nd, tdvp, tnap, tattrflagp, - NULL, tstuff); + NULL, NULL); } if (nd->nd_repstat && !error) error = nd->nd_repstat; @@ -2694,7 +2693,7 @@ nfsrpc_link(vnode_t dvp, vnode_t vp, char *name, int namelen, error = nfscl_postop_attr(nd, nap, attrflagp, dstuff); if (!error) error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, - NULL, dstuff); + NULL, NULL); } else if ((nd->nd_flag & (ND_NFSV4 | ND_NOMOREDATA)) == ND_NFSV4) { /* * First, parse out the PutFH and Getattr result. @@ -2707,7 +2706,7 @@ nfsrpc_link(vnode_t dvp, vnode_t vp, char *name, int namelen, /* * Get the pre-op attributes. */ - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); } if (nd->nd_repstat && !error) error = nd->nd_repstat; @@ -2754,13 +2753,13 @@ nfsrpc_symlink(vnode_t dvp, char *name, int namelen, const char *target, if (error) return (error); if (nd->nd_flag & ND_NFSV4) - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); if ((nd->nd_flag & ND_NFSV3) && !error) { if (!nd->nd_repstat) error = nfscl_mtofh(nd, nfhpp, nnap, attrflagp); if (!error) error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, - NULL, dstuff); + NULL, NULL); } if (nd->nd_repstat && !error) error = nd->nd_repstat; @@ -2824,7 +2823,7 @@ nfsrpc_mkdir(vnode_t dvp, char *name, int namelen, struct vattr *vap, if (error) return (error); if (nd->nd_flag & ND_NFSV4) - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); if (!nd->nd_repstat && !error) { if (nd->nd_flag & ND_NFSV4) { NFSM_DISSECT(tl, u_int32_t *, 5 * NFSX_UNSIGNED); @@ -2842,7 +2841,7 @@ nfsrpc_mkdir(vnode_t dvp, char *name, int namelen, struct vattr *vap, } } if ((nd->nd_flag & ND_NFSV3) && !error) - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); if (nd->nd_repstat && !error) error = nd->nd_repstat; nfsmout: @@ -2878,7 +2877,7 @@ nfsrpc_rmdir(vnode_t dvp, char *name, int namelen, struct ucred *cred, if (error) return (error); if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, dstuff); + error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); if (nd->nd_repstat && !error) error = nd->nd_repstat; m_freem(nd->nd_mrep); @@ -3928,7 +3927,7 @@ nfsrpc_commit(vnode_t vp, u_quad_t offset, int cnt, struct ucred *cred, error = nfscl_request(nd, vp, p, cred, stuff); if (error) return (error); - error = nfscl_wcc_data(nd, vp, nap, attrflagp, NULL, stuff); + error = nfscl_wcc_data(nd, vp, nap, attrflagp, NULL, NULL); if (!error && !nd->nd_repstat) { NFSM_DISSECT(tl, u_int32_t *, NFSX_VERF); NFSLOCKMNT(nmp);