From nobody Thu Jul 28 20:15:58 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 4Lv2330vYbz4XnV2; Thu, 28 Jul 2022 20:15:59 +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 4Lv2330PHGz3lSX; Thu, 28 Jul 2022 20:15:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659039359; 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=zl6+atOgkX6YpbJqfr+55n1XL0c9hda+zLxgRKV+u3Q=; b=aZzAsmTSUKfnXxtCppyrRDs8y2tN5zhyORPlPQhVPQc49OJarYYJN17Ak9hvC0rnfIqjHj nSs28CJC0grfFKNaOlvXNEckAsNq/rZB+pA9Ib0FCl8tnSfGjRn9I/L6umLqJlm/dgYK9U teu5YiDY2ca2Uppd8Ssoi2vNF6MxsoJbQ/Jt6BrnC9TkMN3UG7IcdhwQUEd/XbH+zDl7Zx 08IPY2oI/nYPe+i5paREnjLm4eYb6A+H9ztgh7vxlRzo2oXi3cf7tONZ0MIGjD4rL4qYN+ AJJAHbrq2WmKxxWqD7UKP//6u8765I7eM23kQNsuKrZ5zeHwLtnFqO4dUar5cg== 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 4Lv2326YMbz188w; Thu, 28 Jul 2022 20:15:58 +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 26SKFwvn093148; Thu, 28 Jul 2022 20:15:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26SKFwon093147; Thu, 28 Jul 2022 20:15:58 GMT (envelope-from git) Date: Thu, 28 Jul 2022 20:15:58 GMT Message-Id: <202207282015.26SKFwon093147@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: f5fb5e07df5b - stable/13 - nfscl: Enable detection of bad session slots 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: f5fb5e07df5bd7a6df170474a3df724ee3538785 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659039359; 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=zl6+atOgkX6YpbJqfr+55n1XL0c9hda+zLxgRKV+u3Q=; b=wkkLbcyCLibP07rZZjvcfgjzEgR888Za5UH/uphyNeVCWQv8eDVC0UwuU/lfuPwJEZrnKz PFLpFjPgdK+5KuVSiU4S5ysYWJWF71ty1TaDM3JnDW/SxheZmsihQnthy5XR81evQP/tMm bL3EhrkPvmaFf6/lHSp9EVvwcDg87AV2M8nwtLkEZPaBiK3ougjaC3hOyV0ASq8ygQA7H2 RSQBaQb5hy6zqnxCg2Pzuud5uwuRtwkRDW+ZTfPkyqgj7DuFuU3F9UwoQW4nHl8iudjaip tmqYT9D2ric7WHxq/IFa0rZGSA5Z/vLKK6o1MGI5MiAeDTTJIV+NALF2PTOhmA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659039359; a=rsa-sha256; cv=none; b=oHTRfH096h5TxajbaeJuGeJJvK0m7rtb80tEAe05wQNGa3lzxVDYaOslap2euSNJSB4bUC ifEkNeHBZ4SAYKVxsh41KSTo2JVgcAGhEjO7Ocuy4Lz9QWL3j9hY19Za3cw246QEkO8prQ X9OLz2GZtsLEfpJNleaVKzTdXXk6cGnAFWo6s5iqF9zhqlBOeUVXKsj3h6TsoVrnXCargO VBqGIiQeL2l12SglPb7oZN5Rvj1qsHdmdpMljNTGtpGl5bGm92tTjBEKhZN3uc1zwjzxrE 7OQL16uRrwrvry4QFCiPhdtNTHACiabnzyN3lVI7JO50e21oywttxMf2Jcp1QQ== 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=f5fb5e07df5bd7a6df170474a3df724ee3538785 commit f5fb5e07df5bd7a6df170474a3df724ee3538785 Author: Rick Macklem AuthorDate: 2022-07-10 20:33:19 +0000 Commit: Rick Macklem CommitDate: 2022-07-28 20:11:07 +0000 nfscl: Enable detection of bad session slots To deal with broken session slots caused by the use of the "soft" and/or "intr" mount options, nfsv4_sequencelookup() has been modified to track the potentially broken session slots (commit 40ada74ee1da). Then, when all session slots are potentially broken, nfsv4_sequencelookup() does a DeleteSession operation, so that the NFSv4.1/4.2 server will reply NFSERR_BADSESSION to uses of the session. The client will then recover by doing a CreateSession to acquire a new session. This patch adds the code that marks potentially bad slots, so that the above semantics become functional. It has been successfully tested against a FreeBSD NFSv4.1/4.2 server, but does not work against a Linux 5.15 NFSv4.1/4.2 server. (The Linux 5.15 server creates a new session with the same sessionid as the destroyed one and, as such, keeps returning NFSERR_BADSESSION. I believe this is a bug in the Linux server.) However, this should not cause a regression and will make "intr" mounts fairly usable against the NFSv4.1/4.2 servers where it works. PR: 260011 (cherry picked from commit 981ef32230b2fe46969c90b53864bdca4f1c3ae5) --- sys/fs/nfs/nfs_commonkrpc.c | 53 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 20b12767d29d..150d92414e7a 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -925,10 +925,8 @@ tryagain: } else if (stat == RPC_PROGVERSMISMATCH) { NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); error = EPROTONOSUPPORT; - } else if (stat == RPC_INTR) { - error = EINTR; } else if (stat == RPC_CANTSEND || stat == RPC_CANTRECV || - stat == RPC_SYSTEMERROR) { + stat == RPC_SYSTEMERROR || stat == RPC_INTR) { /* Check for a session slot that needs to be free'd. */ if ((nd->nd_flag & (ND_NFSV41 | ND_HASSLOTID)) == (ND_NFSV41 | ND_HASSLOTID) && nmp != NULL && @@ -951,12 +949,17 @@ tryagain: */ mtx_lock(&sep->nfsess_mtx); sep->nfsess_slotseq[nd->nd_slotid] += 10; + sep->nfsess_badslots |= (0x1ULL << nd->nd_slotid); mtx_unlock(&sep->nfsess_mtx); /* And free the slot. */ nfsv4_freeslot(sep, nd->nd_slotid, false); } - NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); - error = ENXIO; + if (stat == RPC_INTR) + error = EINTR; + else { + NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); + error = ENXIO; + } } else { NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); error = EACCES; @@ -1019,8 +1022,16 @@ tryagain: * If the first op is Sequence, free up the slot. */ if ((nmp != NULL && i == NFSV4OP_SEQUENCE && j != 0) || - (clp != NULL && i == NFSV4OP_CBSEQUENCE && j != 0)) + (clp != NULL && i == NFSV4OP_CBSEQUENCE && j != 0)) { NFSCL_DEBUG(1, "failed seq=%d\n", j); + if (sep != NULL && i == NFSV4OP_SEQUENCE && + j == NFSERR_SEQMISORDERED) { + mtx_lock(&sep->nfsess_mtx); + sep->nfsess_badslots |= + (0x1ULL << nd->nd_slotid); + mtx_unlock(&sep->nfsess_mtx); + } + } if (((nmp != NULL && i == NFSV4OP_SEQUENCE && j == 0) || (clp != NULL && i == NFSV4OP_CBSEQUENCE && j == 0)) && sep != NULL) { @@ -1039,11 +1050,35 @@ tryagain: retseq = fxdr_unsigned(uint32_t, *tl++); slot = fxdr_unsigned(int, *tl++); if ((nd->nd_flag & ND_HASSLOTID) != 0) { - if (slot != nd->nd_slotid) { + if (slot >= NFSV4_SLOTS || + (i == NFSV4OP_CBSEQUENCE && + slot >= NFSV4_CBSLOTS)) { printf("newnfs_request:" - " Wrong session " - "slot=%d\n", slot); + " Bogus slot\n"); slot = nd->nd_slotid; + } else if (slot != + nd->nd_slotid) { + printf("newnfs_request:" + " Wrong session " + "srvslot=%d " + "slot=%d\n", slot, + nd->nd_slotid); + if (i == NFSV4OP_SEQUENCE) { + /* + * Mark both slots as + * bad, because we do + * not know if the + * server has advanced + * the sequence# for + * either of them. + */ + sep->nfsess_badslots |= + (0x1ULL << slot); + sep->nfsess_badslots |= + (0x1ULL << + nd->nd_slotid); + } + slot = nd->nd_slotid; } } else if (slot != 0) { printf("newnfs_request: Bad "