git: d2bc774c2724 - main - nfscommon: Fix a couple of slot handling cases

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Tue, 24 Nov 2026 22:11:14 UTC
The branch main has been updated by rmacklem:

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

commit d2bc774c27244a2ee46848bdae7b73b61e9b231d
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2026-11-24 22:09:10 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2026-11-24 22:09:10 +0000

    nfscommon: Fix a couple of slot handling cases
    
    If a server shrinks the slot table for a NFSv4.1/4.2 session
    (the FreeBSD server does not do this), it might have failed
    to reset the slot's sequence# to 0, do to not handling the
    case where the slot# equals the foreslot limit.
    
    Also, a typo would fail when the slot# is greater than 31,
    due to the type of the 1 being shifted.
    
    This patch fixes both of these.
    
    Reported by:    Chuck Lever <cel@kernel.org>
    MFC after:      2 weeks
---
 sys/fs/nfs/nfs_commonkrpc.c | 2 +-
 sys/fs/nfs/nfs_commonsubs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c
index 160329968fa2..05c4ec15c74d 100644
--- a/sys/fs/nfs/nfs_commonkrpc.c
+++ b/sys/fs/nfs/nfs_commonkrpc.c
@@ -1573,7 +1573,7 @@ nfs_resetslots(struct nfsclsession *sep)
 	uint64_t bitval;
 
 	mtx_assert(&sep->nfsess_mtx, MA_OWNED);
-	bitval = (1 << sep->nfsess_foreslots);
+	bitval = (0x1ULL << sep->nfsess_foreslots);
 	for (i = sep->nfsess_foreslots; i < NFSV4_SLOTS; i++) {
 		if ((sep->nfsess_slots & bitval) == 0 &&
 		    (sep->nfsess_badslots & bitval) == 0)
diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index 4ebc2a937a6c..2a2153a09f06 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -5474,7 +5474,7 @@ nfsv4_freeslot(struct nfsclsession *sep, int slot, bool resetseq)
 	mtx_lock(&sep->nfsess_mtx);
 	if (resetseq)
 		sep->nfsess_slotseq[slot]--;
-	else if (slot > sep->nfsess_foreslots)
+	else if (slot >= sep->nfsess_foreslots)
 		sep->nfsess_slotseq[slot] = 0;
 	if ((bitval & sep->nfsess_slots) == 0)
 		printf("freeing free slot!!\n");