The branch stable/13 has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=23584132c48c55f171e6b3218bbadc26c141d41d

commit 23584132c48c55f171e6b3218bbadc26c141d41d
Author:     Rick Macklem <rmack...@freebsd.org>
AuthorDate: 2022-04-05 15:11:37 +0000
Commit:     Rick Macklem <rmack...@freebsd.org>
CommitDate: 2022-06-09 19:20:03 +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 before doing the Write operation.
    
    This patch prepares the NFSv4 client for such an
    RPC, which will be added in a future commit.
    
    This patch does not cause any semantics change.
    
    (cherry picked from commit 330aa8acdec76d00d9e0ca526d421fe25ccf90cf)
---
 sys/fs/nfs/nfs_commonport.c |  2 +-
 sys/fs/nfs/nfs_commonsubs.c |  7 ++++---
 sys/fs/nfs/nfsport.h        | 12 +++++++++---
 sys/fs/nfs/nfsproto.h       |  5 ++++-
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c
index 54a7e66a5baf..f91cb3a8cebe 100644
--- a/sys/fs/nfs/nfs_commonport.c
+++ b/sys/fs/nfs/nfs_commonport.c
@@ -599,7 +599,7 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap, 
struct ucred *cred)
                                            nfsstatsv1.biocache_readdirs;
                                        nfsstatsov1.readdir_bios =
                                            nfsstatsv1.readdir_bios;
-                                       for (i = 0; i < NFSV42_NPROCS; i++)
+                                       for (i = 0; i < NFSV42_OLDNPROCS; i++)
                                                nfsstatsov1.rpccnt[i] =
                                                    nfsstatsv1.rpccnt[i];
                                        nfsstatsov1.rpcretries =
diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index eb6746ec3041..8ebb3e31b73a 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -150,7 +150,7 @@ struct nfsv4_opflag nfsv4_opflag[NFSV42_NOPS] = {
        { 0, 2, 1, 1, LK_EXCLUSIVE, 1, 0 },             /* Setattr */
        { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 },             /* SetClientID */
        { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 },             /* SetClientIDConfirm */
-       { 0, 1, 0, 0, LK_EXCLUSIVE, 1, 1 },             /* Verify */
+       { 0, 2, 0, 0, LK_EXCLUSIVE, 1, 0 },             /* Verify (AppWrite) */
        { 0, 2, 1, 1, LK_EXCLUSIVE, 1, 0 },             /* Write */
        { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 0 },             /* ReleaseLockOwner */
        { 0, 0, 0, 0, LK_EXCLUSIVE, 1, 1 },             /* Backchannel Ctrl */
@@ -215,7 +215,7 @@ static struct nfsrv_lughash *nfsgroupnamehash;
 static int nfs_bigreply[NFSV42_NPROCS] = { 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
-    1, 0, 0, 1, 0, 0, 0, 0 };
+    1, 0, 0, 1, 0, 0, 0, 0, 0 };
 
 /* local functions */
 static int nfsrv_skipace(struct nfsrv_descript *nd, int *acesizep);
@@ -303,6 +303,7 @@ static struct {
        { NFSV4OP_LOOKUP, 5, "LookupOpen", 10, },
        { NFSV4OP_DEALLOCATE, 2, "Deallocate", 10, },
        { NFSV4OP_LAYOUTERROR, 1, "LayoutError", 11, },
+       { NFSV4OP_VERIFY, 3, "AppendWrite", 11, },
 };
 
 /*
@@ -312,7 +313,7 @@ static int nfs_bigrequest[NFSV42_NPROCS] = {
        0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
-       0
+       0, 1
 };
 
 /*
diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h
index 8ac4bc54a5f2..2955ae43de85 100644
--- a/sys/fs/nfs/nfsport.h
+++ b/sys/fs/nfs/nfsport.h
@@ -424,10 +424,16 @@
 /* Do an NFSv4.2 LayoutError. */
 #define        NFSPROC_LAYOUTERROR     68
 
+/* Do an NFSv4 Verify+Write. */
+#define        NFSPROC_APPENDWRITE     69
+
 /*
  * Must be defined as one higher than the last NFSv4.2 Proc# above.
  */
-#define        NFSV42_NPROCS           69
+#define        NFSV42_NPROCS           70
+
+/* Value of NFSV42_NPROCS for old nfsstats structure. (Always 69) */
+#define        NFSV42_OLDNPROCS        69
 
 #endif /* NFS_V3NPROCS */
 
@@ -456,7 +462,7 @@ struct nfsstatsv1 {
        uint64_t        readlink_bios;
        uint64_t        biocache_readdirs;
        uint64_t        readdir_bios;
-       uint64_t        rpccnt[NFSV42_NPROCS + 11];
+       uint64_t        rpccnt[NFSV42_NPROCS + 10];
        uint64_t        rpcretries;
        uint64_t        srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15];
        uint64_t        srvlayouts;
@@ -521,7 +527,7 @@ struct nfsstatsov1 {
        uint64_t        readlink_bios;
        uint64_t        biocache_readdirs;
        uint64_t        readdir_bios;
-       uint64_t        rpccnt[NFSV42_NPROCS];
+       uint64_t        rpccnt[NFSV42_OLDNPROCS];
        uint64_t        rpcretries;
        uint64_t        srvrpccnt[NFSV42_PURENOPS + NFSV4OP_FAKENOPS];
        uint64_t        reserved_0;
diff --git a/sys/fs/nfs/nfsproto.h b/sys/fs/nfs/nfsproto.h
index 968cc6a41cc3..2e21a70b5d86 100644
--- a/sys/fs/nfs/nfsproto.h
+++ b/sys/fs/nfs/nfsproto.h
@@ -405,10 +405,13 @@
 /* Do an NFSv4.2 LayoutError. */
 #define        NFSPROC_LAYOUTERROR     68
 
+/* Do an NFSv4 Verify+Write. */
+#define        NFSPROC_APPENDWRITE     69
+
 /*
  * Must be defined as one higher than the last NFSv4.2 Proc# above.
  */
-#define        NFSV42_NPROCS           69
+#define        NFSV42_NPROCS           70
 
 #endif /* NFS_V3NPROCS */
 

Reply via email to