From nobody Sun Jul 10 20:34:43 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 31AD317F9E19; Sun, 10 Jul 2022 20:34:44 +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 4LgzK00zDpz3rL5; Sun, 10 Jul 2022 20:34:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657485284; 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=LhoAB5GDBp9qG8XKCE5rrS8cPQKx8Fg2lrvJ9VgDvCc=; b=eVxeQA5WSkHWWAmKh30u478UDI891wHvy+3bXTVUNdBzijbwq9fE10HJp/3fp5z4pjpHEx Cz9B0Bmbaym91skYNKFAR6wDPyn3Qh2Zd7+PBC4NfQHTkNV1DRErUvhweJgkMN/KK0+ZAx sLV4cvps2jJ5RI7q6hhRp1HSiV36aHQeoasVhSsqgGgTpr0snpslCHp5MFG97dCo+ZPXf0 L9hdgduWA38JzxJCx7auPTTpUL2+dDCdApO8di6yQA2egCzXHLjzaGUN1/tpbKbwAWKcFi +yNTtim16oNZnpl9TyCTpUyoukLHf3iFlYXmwG9+5anfHRFMiakX+EywTGWW+g== 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 4LgzJz73nLzdSP; Sun, 10 Jul 2022 20:34:43 +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 26AKYhpi004436; Sun, 10 Jul 2022 20:34:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26AKYh9k004435; Sun, 10 Jul 2022 20:34:43 GMT (envelope-from git) Date: Sun, 10 Jul 2022 20:34:43 GMT Message-Id: <202207102034.26AKYh9k004435@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 981ef32230b2 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 981ef32230b2fe46969c90b53864bdca4f1c3ae5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657485284; 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=LhoAB5GDBp9qG8XKCE5rrS8cPQKx8Fg2lrvJ9VgDvCc=; b=m25VbzU02dNVrVgWAOkingc/urXBwCnuStQLTp7lzABhR8Zn3mcAhelbPf9sprMhCcZkxz PUmGsvPBg9v4FCOl/1l0cjke6BiflZXXJURP9rC071h4er1X82GYFHLxMEpXyxD1YUTKQr yA2GS6R6XdqCLj8DBG8aoubfb/9eDDTas5HB2tP30P4h36OEdTckWjyvjM/zdw6rKfXADH kA6VtvKcpZgl0Weg2epvl4ir7KXwUMIEZsap6G8WBL7ghmEEPyDeRNA3NGioDqm/L8LXex mJNie86pxGl6W0r+ENQm+uCbiPG2lTp1mvDRAlAPKXQP8lcv4T1UPgomJ8A9mA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657485284; a=rsa-sha256; cv=none; b=E3fAga1kCNxsqHVMyn/uwSQHDzY7u7goA+r4s3ccSEjnWCi0+DrjXSOfodAlcwG+Lkmmxx DmpKyNs7jjXnxYL8cIKR3+mCmMk8eAcAux55+wwVuzvNaJVlYyaOnkxsumhF8ULpAtyvOu hdjmW7v2V03hTurBpEbjb+epE7HCIb72fdhFPKd8U7EYVZdvTXiocGywudypZDSYWGadll 5vvQWW4x7wFE5tvd8+phydRSSxKxl5Wx10alp0Lj4Bn1EzE5RFT6A/W0nldHli0LpsfKc1 OKfoFhibAxsaldP0r5aPPBbbIrquM4UMslJYIiz+/8Y4ILEsO9+gtTI2Zo4tWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=981ef32230b2fe46969c90b53864bdca4f1c3ae5 commit 981ef32230b2fe46969c90b53864bdca4f1c3ae5 Author: Rick Macklem AuthorDate: 2022-07-10 20:33:19 +0000 Commit: Rick Macklem CommitDate: 2022-07-10 20:33:19 +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 MFC after: 2 weeks --- 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 "