git: ce9676de86f2 - main - pNFS: Add nfsstats counters for number of Layouts

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sat, 13 Nov 2021 01:36:37 UTC
The branch main has been updated by rmacklem:

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

commit ce9676de86f267986f61979151101e3d8a6d61bc
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2021-11-13 01:32:55 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2021-11-13 01:32:55 +0000

    pNFS: Add nfsstats counters for number of Layouts
    
    For pNFS, Layouts are issued by the server to indicate
    where a file's data resides on the DS(s).  This patch
    adds counters for how many layouts are allocated to
    the nfsstatsv1 structure, using two reserved fields.
    
    MFC after:      2 weeks
---
 sys/fs/nfs/nfsport.h             | 4 ++--
 sys/fs/nfsclient/nfs_clstate.c   | 2 ++
 sys/fs/nfsserver/nfs_nfsdstate.c | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h
index 5dcce15f7f64..e099cf6e46f0 100644
--- a/sys/fs/nfs/nfsport.h
+++ b/sys/fs/nfs/nfsport.h
@@ -459,8 +459,8 @@ struct nfsstatsv1 {
 	uint64_t	rpccnt[NFSV42_NPROCS + 11];
 	uint64_t	rpcretries;
 	uint64_t	srvrpccnt[NFSV42_NOPS + NFSV4OP_FAKENOPS + 15];
-	uint64_t	reserved_0;
-	uint64_t	reserved_1;
+	uint64_t	srvlayouts;
+	uint64_t	cllayouts;
 	uint64_t	rpcrequests;
 	uint64_t	rpctimeouts;
 	uint64_t	rpcunexpected;
diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index 1df8530d0e39..082469aef1bc 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -5212,6 +5212,7 @@ nfscl_layout(struct nfsmount *nmp, vnode_t vp, u_int8_t *fhp, int fhlen,
 			    nfsly_hash);
 			lyp->nfsly_timestamp = NFSD_MONOSEC + 120;
 			nfscl_layoutcnt++;
+			nfsstatsv1.cllayouts++;
 		} else {
 			if (retonclose != 0)
 				lyp->nfsly_flags |= NFSLY_RETONCLOSE;
@@ -5586,6 +5587,7 @@ nfscl_freelayout(struct nfscllayout *layp)
 		free(rp, M_NFSLAYRECALL);
 	}
 	nfscl_layoutcnt--;
+	nfsstatsv1.cllayouts--;
 	free(layp, M_NFSLAYOUT);
 }
 
diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c
index e6a919093738..e9acacb27cbd 100644
--- a/sys/fs/nfsserver/nfs_nfsdstate.c
+++ b/sys/fs/nfsserver/nfs_nfsdstate.c
@@ -7400,6 +7400,7 @@ nfsrv_addlayout(struct nfsrv_descript *nd, struct nfslayout **lypp,
 	/* Insert the new layout in the lists. */
 	*lypp = NULL;
 	atomic_add_int(&nfsrv_layoutcnt, 1);
+	nfsstatsv1.srvlayouts++;
 	NFSBCOPY(lyp->lay_xdr, layp, lyp->lay_layoutlen);
 	*layoutlenp = lyp->lay_layoutlen;
 	TAILQ_INSERT_HEAD(&lhyp->list, lyp, lay_list);
@@ -7492,6 +7493,7 @@ nfsrv_freelayout(struct nfslayouthead *lhp, struct nfslayout *lyp)
 
 	NFSD_DEBUG(4, "Freelayout=%p\n", lyp);
 	atomic_add_int(&nfsrv_layoutcnt, -1);
+	nfsstatsv1.srvlayouts--;
 	TAILQ_REMOVE(lhp, lyp, lay_list);
 	free(lyp, M_NFSDSTATE);
 }