From patchwork Wed Jan 29 13:39:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13953764 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 768E414A4F9; Wed, 29 Jan 2025 13:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158013; cv=none; b=WngEuFla8zXGyE1P2gNSu1wolJ/9JQUPeKrqMuQgB8+3qJ7dRcRdCq5/r6jm40/BUaSprN5PWGoaJfFhOVIxczA2YNFUZn1DzMlD3tCDUJnx3IOqSZSyfWoi4rifqMseMXhQ1CmtV1qqmEx0b2OESnccev2MEbrCMjeydHCWso0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158013; c=relaxed/simple; bh=hqukJEYZB9obqZ4JDfojP1bNtJgCbankSnq7ZVy2Glo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EZoEpk+wVlMjp8lXf2q4I8ptvnFm6+fWgHGfLPc96NN5LyQvHvI+RmqtFT+93YIKuOzQuEU1vU2MCzqkgjYUuYXUmvaIPicvUdxaiFuV0je7TSBFhDomRi5bKhmEfSYHvHfBIicHtfkn2sqgApq5g5bWOsgem8UAIrIPGBYahqY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hH8e3GgN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hH8e3GgN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3914AC4CEE5; Wed, 29 Jan 2025 13:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738158013; bh=hqukJEYZB9obqZ4JDfojP1bNtJgCbankSnq7ZVy2Glo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hH8e3GgNSiLmGu7bdvFDqAE9kS71uLb0Dr2fzOnwS1jot9iHJYmNkBeaxYISYLuR5 jVfAfu2SCW3ZzYYobhLUPFFeWuKhxNBb/cYOEoLoNMB48H3ZMBGyuEEi8oLYiu9gZF QMK9ltgVqxZxI6w7g/JEDO4xfsLP0ICEJ+T1itxuwbZgcod7mCeojIPAvWTbOoss3p KbfruwV9A4HFIjZ6W331yn7R242+cxCAvhLLYFnlw8d7c7JcsHzGgjXSfGRhEbt4c+ OItF1aLK/mACqZx/VJrsYttl07sYbA0FDhxSEXLuUaU5Ylf50omFVvGlOgLoFZtzP4 hPSqCqk+TcAkw== From: Jeff Layton Date: Wed, 29 Jan 2025 08:39:54 -0500 Subject: [PATCH v2 1/7] nfsd: add routines to get/put session references for callbacks Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250129-nfsd-6-14-v2-1-2700c92f3e44@kernel.org> References: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> In-Reply-To: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "J. Bruce Fields" , Kinglong Mee , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2893; i=jlayton@kernel.org; h=from:subject:message-id; bh=hqukJEYZB9obqZ4JDfojP1bNtJgCbankSnq7ZVy2Glo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnmi+584re5+OuIM6wgkhBMfnfavohgqkq0l07A 7oECFJmABSJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ5ovuQAKCRAADmhBGVaC FXkKD/9wOd5QGkRZltA+FvjQWt7iXElInI2n8sU7I2+HVuJaeLC9qJKa87NzHgGm+VVOe9GeADm byxwwK1csyTiOOLn2fS+W0nOR+gCdJThqW0VuTR5OiIIioIHfLF1vYKd6xWb0NlkB83Bj9M8WBa phqXYXiy5g65HYSxg9S1Kj7B76O9HIWsz5K6ObnNZE1j9tJxlOHPIHhPLHLEDXDwMGRy0SqBqYR YfDSAXETKOTYgNMrxkTHCYEypO7HRiMngnfzfy7nlGN32yBGkyx0izo89p8LKNsw/dug0Kf4RaK DE1tTFIE1PiJIQiTkxqo+81uWIR5HaFL2xpzsr0+AisWoIfZt2eWEazRFnwH/kkUzTeClvQNNyH 3J7azZ75fMrGfJjdegfXUuwFHHYAJ4GnlwU9i7MGd3gvxZ3Z86Gl0b0OKtru/Jm4/RnDTFBBpYC GLiZwdioZtMqTVYol4GCm//4e6UdiHqR4N+CdR+v0oI+jM8NHodF7LkKy2Ozpul+yDkDZmKoGHQ zimIFhOdojF9WKRRgj4zFqh9YKPqfwkSaqwUNK3Umol+609hxObF4hvObhPvlkYMKvKcXZmttrz IV1xgarj00KUOrcA4naS6ekDEL7qc+0z7BZb1q0KZWbu8IIZENalZvABxvXF65j18Ak/C6KrhXb 6tUXBA3WkGqS2JQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 The existing session reference counting is too heavyweight for callbacks. There is an atomic refcount in nfsd4_session (se_ref), but the existing functions take a client reference alongside it, and require the nn->client_lock. This is unnecessary for callbacks as they are already owned by the client. Add new nfsd4_cb_get_session() and nfsd4_cb_put_session() calls that take and put a session reference on behalf of a callback. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 32 ++++++++++++++++++++++++++++++-- fs/nfsd/state.h | 2 ++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index cc819b8e8acdf5dcfe44c5bae45c6233f7b695e9..2c26c6aaea93e3e1eb438e7e23dc881c7bf35fe2 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -234,6 +234,35 @@ static void put_client_renew(struct nfs4_client *clp) spin_unlock(&nn->client_lock); } +/** + * nfsd4_cb_get_session - get a session reference for a callback + * @ses: session of which to get a reference + * + * Callbacks are different than client-driven RPCs. The caller doesn't + * need a reference to the nfs4_client, and doesn't want to renew the + * lease when putting the reference. + */ +bool nfsd4_cb_get_session(struct nfsd4_session *ses) +{ + if (is_session_dead(ses)) + return false; + return atomic_inc_not_zero(&ses->se_ref); +} + +/** + * nfsd4_cb_put_session - put a session reference for a callback + * @ses: session of which to put a reference + * + * Callbacks are different than client-driven RPCs. The caller doesn't + * need a reference to the nfs4_client, and doesn't want to renew the + * lease when putting the reference. + */ +void nfsd4_cb_put_session(struct nfsd4_session *ses) +{ + if (ses && atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses)) + free_session(ses); +} + static __be32 nfsd4_get_session_locked(struct nfsd4_session *ses) { __be32 status; @@ -254,8 +283,7 @@ static void nfsd4_put_session_locked(struct nfsd4_session *ses) lockdep_assert_held(&nn->client_lock); - if (atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses)) - free_session(ses); + nfsd4_cb_put_session(ses); put_client_renew_locked(clp); } diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 74d2d7b42676d907bec9159b927aeed223d668c3..79d985d2a656e1a5b22a6a9c88f309515725e847 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -753,6 +753,8 @@ struct nfsd4_compound_state; struct nfsd_net; struct nfsd4_copy; +bool nfsd4_cb_get_session(struct nfsd4_session *ses); +void nfsd4_cb_put_session(struct nfsd4_session *ses); extern __be32 nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct svc_fh *fhp, stateid_t *stateid, int flags, struct nfsd_file **filp, From patchwork Wed Jan 29 13:39:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13953765 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D17613CFA6; Wed, 29 Jan 2025 13:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158014; cv=none; b=sAMUZJmzI/7XB1IHoFal5iPZwQf2uLZjqbyE33gHnAVh1j0A0fKSNClpzLpG7IRqBB82UFcDVBX/UcUKkH0SJm2CyVsJpKVOs/AklDmXDxMvT4Xr6VXG1bGmen0aJPmI2jLbKuk4vE9ux3nAd88hZfyphRNboDtfhHEiUNBcXdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158014; c=relaxed/simple; bh=mWtiwAf1TWZ09yyz9/4JnDmExVA8h8RD1xcqnFMYDnk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XzSkmzi36tKsb6wvFJez5eq0vEuT+gSOibrgUC9m0xqoQ6+mod/40CVJnpjAfCl7Kfj2IT6anc5GAvywrxVcU0m2qQO8E6ot+KWPugVF9bovejXreDa4fon+Z5tacVtc5YFCfpF0bLt+7Va8kTLMzw1CeBD1uFJPn6JVAA6NqrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JiOulLSS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JiOulLSS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71B24C4CEE2; Wed, 29 Jan 2025 13:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738158014; bh=mWtiwAf1TWZ09yyz9/4JnDmExVA8h8RD1xcqnFMYDnk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JiOulLSSV4OfEywzA9OUYRdih2lp1BWM7vqb+wXtpTxJw9HkE6sGBCxl9UXbTEr8X AA1ooGkemqqJF5ArjjDOiYuGXiMAvddn0htbRuj8yQidxBGgyoWT6UEKiAdG0xh1oT WRkpo4L6GIPKWEy3ZHMUFzJIxpHpkJKdFFfIzANoj6tzpcqc51h+vZNex5vDBfTR9+ fB+bZxlHzwptuKIaDTJDCAZhGWfR28jhPcomV1ageP0nLrOkq1s8off3nB/B5aT5iV IQ5YZh1prmnkhIzH3QUA5OvBkl2UwufzLYlknaoquXJmM4gYApXi2jDLuQRhBQLz0f RsiiyvLkJbwGQ== From: Jeff Layton Date: Wed, 29 Jan 2025 08:39:55 -0500 Subject: [PATCH v2 2/7] nfsd: make clp->cl_cb_session be an RCU managed pointer Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250129-nfsd-6-14-v2-2-2700c92f3e44@kernel.org> References: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> In-Reply-To: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "J. Bruce Fields" , Kinglong Mee , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5132; i=jlayton@kernel.org; h=from:subject:message-id; bh=mWtiwAf1TWZ09yyz9/4JnDmExVA8h8RD1xcqnFMYDnk=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnmi+5JSnjBAWyiG4qQQ2kv3L6ZSJp2FBu86FSN NimqNzhvFKJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ5ovuQAKCRAADmhBGVaC FR0TD/sE2qHB5B5CHboApL7X1xcF+YN4HqZZmlt6zpJiecDTYecifScooaZN2cppXeaho7eC9hi jtXHSl/1I43GUBrV5+Or7mhMapeUvURjEhoqxTiCf5gCkQQkTw59Wd1NPqgcRFCrS7QcwS2dZq/ mHnGD0TjfQcvhSt7AutFajJLw9Drn+An+iG3q8XwDzGVlwNsfwYOr1RBWqRmslWgeTUs1fYHQyj qy4oQpQ33AO5kHX1uhPSd27CQZYFNla8UUCN3mZE20uNCRiERdarpJ8XxLxgEDHgi571fA8k/vF cld+zCj9kFTdDujaIFa+yb3QRIJCDBlnEdSbctk2JIOt8z9WODo3Rdyo9wKpBV7mSugLQb4QGPp zKkXIOVDzYEaoDQgG+T7T79If1I/3q2p3E8s8pGmhA+4KLagAToVe0nCFg857CIsL5VbSIrCXzR XtubnqTGcrLyS0mo/VirYRN4JP2dVOCRehlBdrlmIikbg88k0adVv9iEJY7dIzavaUUT75n+mnz L00wr3ZGaGmNSWF4pwjJo8tZKigWg5fScHjvIX86jp6V23X7gIJKZfzbYEK+1NCnhCmVWVP+WNH 6aKBUTtqHSeL13Gux9Zz3Gzp1b9kl2eE6kNKVKLpdi4tAYMy1u3SgrGKGq/q47x6JsMuuQZHEUs oFmkTZM4JAcSUsg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Currently, this is just a pointer to the most recent session, but there is no guarantee that the session is still valid and in memory. It's possible for this pointer go NULL or replaced. First, embed a struct rcu in nfsd4_session and free it via free_rcu. Ensure that when clp->cl_cb_session pointer is changed, that it is done via RCU-safe methods. This will allow callbacks to access the cl_cb_session pointer safely via RCU. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 21 ++++++++++++++++++--- fs/nfsd/nfs4state.c | 11 +++++++++-- fs/nfsd/state.h | 3 ++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 50e468bdb8d4838b5217346dcc2bd0fec1765c1a..e55bf66a33d6efb56d2f75f0a49a60307e3807ac 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -1122,6 +1122,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c }; struct rpc_clnt *client; const struct cred *cred; + int ret; if (clp->cl_minorversion == 0) { if (!clp->cl_cred.cr_principal && @@ -1137,7 +1138,9 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c } else { if (!conn->cb_xprt || !ses) return -EINVAL; - clp->cl_cb_session = ses; + if (!nfsd4_cb_get_session(ses)) + return -EINVAL; + rcu_assign_pointer(clp->cl_cb_session, ses); args.bc_xprt = conn->cb_xprt; args.prognumber = clp->cl_cb_session->se_cb_prog; args.protocol = conn->cb_xprt->xpt_class->xcl_ident | @@ -1148,13 +1151,15 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c client = rpc_create(&args); if (IS_ERR(client)) { trace_nfsd_cb_setup_err(clp, PTR_ERR(client)); - return PTR_ERR(client); + ret = PTR_ERR(client); + goto out_put_ses; } cred = get_backchannel_cred(clp, client, ses); if (!cred) { trace_nfsd_cb_setup_err(clp, -ENOMEM); rpc_shutdown_client(client); - return -ENOMEM; + ret = -ENOMEM; + goto out_put_ses; } if (clp->cl_minorversion != 0) @@ -1166,6 +1171,12 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c args.authflavor); rcu_read_unlock(); return 0; +out_put_ses: + if (clp->cl_minorversion != 0) { + rcu_assign_pointer(clp->cl_cb_session, NULL); + nfsd4_cb_put_session(ses); + } + return ret; } static void nfsd4_mark_cb_state(struct nfs4_client *clp, int newstate) @@ -1529,11 +1540,15 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) * kill the old client: */ if (clp->cl_cb_client) { + struct nfsd4_session *ses; + trace_nfsd_cb_bc_shutdown(clp, cb); rpc_shutdown_client(clp->cl_cb_client); clp->cl_cb_client = NULL; put_cred(clp->cl_cb_cred); clp->cl_cb_cred = NULL; + ses = rcu_replace_pointer(clp->cl_cb_session, NULL, true); + nfsd4_cb_put_session(ses); } if (clp->cl_cb_conn.cb_xprt) { svc_xprt_put(clp->cl_cb_conn.cb_xprt); diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2c26c6aaea93e3e1eb438e7e23dc881c7bf35fe2..59d3111f558396ec46f7d286b2c90500bda642d9 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2180,7 +2180,7 @@ static void __free_session(struct nfsd4_session *ses) { free_session_slots(ses, 0); xa_destroy(&ses->se_slots); - kfree(ses); + kfree_rcu(ses, se_rcu); } static void free_session(struct nfsd4_session *ses) @@ -3283,7 +3283,7 @@ static struct nfs4_client *create_client(struct xdr_netobj name, clp->cl_time = ktime_get_boottime_seconds(); copy_verf(clp, verf); memcpy(&clp->cl_addr, sa, sizeof(struct sockaddr_storage)); - clp->cl_cb_session = NULL; + rcu_assign_pointer(clp->cl_cb_session, NULL); clp->net = net; clp->cl_nfsd_dentry = nfsd_client_mkdir( nn, &clp->cl_nfsdfs, @@ -4251,6 +4251,13 @@ nfsd4_destroy_session(struct svc_rqst *r, struct nfsd4_compound_state *cstate, status = nfserr_wrong_cred; if (!nfsd4_mach_creds_match(ses->se_client, r)) goto out_put_session; + + /* + * Is this session the backchannel session? Count an extra + * reference if so. + */ + if (ses == rcu_access_pointer(ses->se_client->cl_cb_session)) + ref_held_by_me++; status = mark_session_dead_locked(ses, 1 + ref_held_by_me); if (status) goto out_put_session; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 79d985d2a656e1a5b22a6a9c88f309515725e847..0faa367c9fa3280fa4a8a982f974804bb89f2035 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -354,6 +354,7 @@ struct nfsd4_session { u16 se_slot_gen; bool se_dead; u32 se_target_maxslots; + struct rcu_head se_rcu; }; /* formatted contents of nfs4_sessionid */ @@ -465,7 +466,7 @@ struct nfs4_client { #define NFSD4_CB_FAULT 3 int cl_cb_state; struct nfsd4_callback cl_cb_null; - struct nfsd4_session *cl_cb_session; + struct nfsd4_session __rcu *cl_cb_session; /* for all client information that callback code might need: */ spinlock_t cl_lock; From patchwork Wed Jan 29 13:39:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13953766 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 391B61B0F18; Wed, 29 Jan 2025 13:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158016; cv=none; b=oxWAHf9Gl9li756OUNbNc2Nyhl1jZ0aMYSgX229Ly/WLxlHBNWWE+1cZtDmlBxycpg6sZQFDX4ada2+226jQs4WgQV3BI76jZYGQRUvE6DwYOYRz1CzMqxT5JQ0fzXiB1ruBzwblhCtGh/dztHpLo+l0LSXBm2V+SgDH2XxBjnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158016; c=relaxed/simple; bh=yQ+thEBAqsSgndfez3KwbQk4kYB4c0YOyYwqV2evsgk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JuAixqdRluMIYTtaKvtEIBfECHc8zsGRW1cWSdAYcae0aVOVLNUv6PupE3oURRKuskAWNAS56L0/E/q6r64m7zuz4tO9R9oPI4f1Rz2xgpp/y4J1fomGZNX4XGbeOcHNPfFu9UqO39Cq2+QztMTyMNsx/VCanGZDCfLEg6ES8wI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ALUdfmC4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ALUdfmC4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA54AC4CED3; Wed, 29 Jan 2025 13:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738158015; bh=yQ+thEBAqsSgndfez3KwbQk4kYB4c0YOyYwqV2evsgk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ALUdfmC4EBW2WaoKYevQYjagOd3H9BW788bewkwVwDmXK6PYsFwlu+a8RfSggJHTT hoowTRauLC0FqmMo4VPhd9AR7R8uD9eqU+je7Udu/z95p4LX1heTG7Xy83R4cg5e1K reGx66DJo+oMU8fzlfsE37i6CHC6kIrWStZ2nnLkQYgmXuNtGD+lEtCVzKGprMBh2d d6MCTaZRLE/Kj2HckCtbIePd2gHkIg6rf+3/IyXeSEWyG5nGoPPFCcjCWA1nTy7/Y9 jf0pTQ4C7caL8yvAy9gZtSgFSO8UjUw6mDeDXt+trUiyjMOmiY0j7w9k/BCllWH6SO RuK+k431YKsXw== From: Jeff Layton Date: Wed, 29 Jan 2025 08:39:56 -0500 Subject: [PATCH v2 3/7] nfsd: add a cb_ses pointer to nfsd4_callback and use it instead of clp->cb_cb_session Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250129-nfsd-6-14-v2-3-2700c92f3e44@kernel.org> References: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> In-Reply-To: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "J. Bruce Fields" , Kinglong Mee , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7124; i=jlayton@kernel.org; h=from:subject:message-id; bh=yQ+thEBAqsSgndfez3KwbQk4kYB4c0YOyYwqV2evsgk=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnmi+5lvhs4/VYc7opP+c9t96xSx7MIrvtR9aDq 2CEGsY0icWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ5ovuQAKCRAADmhBGVaC FYkbD/wJEgfe/OhoFrFV7D/ZV+Ox85RKKEApf86k3ZWtnRrHF2SFva7tYUO4J8Vix1LMdpgKDzX 47v/dLcuvxTivOJEf+OO9bggZoiWJReQmaMuYzD+4Wuh7e/4vrJLTzK3dzqaeg1q3V3GopRtIdT qqiHPJ7iplK1QU272fCqFwUJi9UzPM/BlcDfpGFPRzupgyHnkMbk1wxJOLHSafcCR9C3qo2skrx GrJw60Ze+V8UWZPyqxSn2j5FtJzu7CMLmMiN8q7b34NNOmkZxKXPgOMVXUiDHOzeTD0gD/m+k/2 HmlLOoAe1wPWOV0/D0uCcB8VhfpX/aMFd1SF9+9QjJKZiknedHMLJJhnv+7qP5ul9FqvOmz2qUH Rpi45Mv5tOIn/TlsnwCW11d4WX4chebqlzcUaVozcOXJV9EUgysnBYxexdFznbEt4qPd97/w8kd bjHVQxGDTTDXRGrZ/lYUOM2m0hOjRg2BAfB9O0R9S9DdPhbfxmRaTCzRrmiMXBSWQw4rQ9pXFTn jiY98jX7BuvXOHcOvRrMyVXRceYazO7QA7IcockkCZ/A/CWy4X2DslDQ825o+AB7/PIT79RCunL VhclwoQNYCrT3Vf7l+F7+Dot/2LPXqI18Rn227tAg2gmoPsumTkH2ckQCR6P2gbYIbj8jDwzrNi nU0yOagdooKzI7w== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Once a callback workqueue job has completed, the cl_cb_session could change to a completely different session, if there is more than one callback in flight at a time. Have the callback hold its own cb reference to the session, and fix the slot acquisition routines to get/put a session reference. This ensures that the call and reply handling are working with the same session. In the event that rpc_prepare can't get a session reference, allow the rpc_task to sleep until the session reference changes. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 67 +++++++++++++++++++++++++++++++++++++++++--------- fs/nfsd/state.h | 1 + fs/nfsd/trace.h | 6 ++--- 3 files changed, 58 insertions(+), 16 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index e55bf66a33d6efb56d2f75f0a49a60307e3807ac..9f4838a6d9c668cdf66a77793f63c064586f2b22 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -435,7 +435,7 @@ static void encode_cb_sequence4args(struct xdr_stream *xdr, const struct nfsd4_callback *cb, struct nfs4_cb_compound_hdr *hdr) { - struct nfsd4_session *session = cb->cb_clp->cl_cb_session; + struct nfsd4_session *session = cb->cb_ses; __be32 *p; if (hdr->minorversion == 0) @@ -503,7 +503,7 @@ static void update_cb_slot_table(struct nfsd4_session *ses, u32 target) static int decode_cb_sequence4resok(struct xdr_stream *xdr, struct nfsd4_callback *cb) { - struct nfsd4_session *session = cb->cb_clp->cl_cb_session; + struct nfsd4_session *session = cb->cb_ses; int status = -ESERVERFAULT; __be32 *p; u32 seqid, slotid, target; @@ -1142,7 +1142,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c return -EINVAL; rcu_assign_pointer(clp->cl_cb_session, ses); args.bc_xprt = conn->cb_xprt; - args.prognumber = clp->cl_cb_session->se_cb_prog; + args.prognumber = ses->se_cb_prog; args.protocol = conn->cb_xprt->xpt_class->xcl_ident | XPRT_TRANSPORT_BC; args.authflavor = ses->se_cb_sec.flavor; @@ -1161,9 +1161,10 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c ret = -ENOMEM; goto out_put_ses; } - - if (clp->cl_minorversion != 0) + if (clp->cl_minorversion != 0) { clp->cl_cb_conn.cb_xprt = conn->cb_xprt; + rpc_wake_up(&clp->cl_cb_waitq); + } clp->cl_cb_client = client; clp->cl_cb_cred = cred; rcu_read_lock(); @@ -1252,6 +1253,34 @@ void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *conn) spin_unlock(&clp->cl_lock); } +static bool grab_cb_ses(struct nfsd4_callback *cb) +{ + struct nfs4_client *clp = cb->cb_clp; + struct nfsd4_session *ses; + bool ret = false; + + if (cb->cb_ses) + return true; + + rcu_read_lock(); + ses = rcu_dereference(clp->cl_cb_session); + if (ses && nfsd4_cb_get_session(ses)) { + cb->cb_ses = ses; + ret = true; + } + rcu_read_unlock(); + + return ret; +} + +static void put_cb_ses(struct nfsd4_callback *cb) +{ + if (cb->cb_ses) { + nfsd4_cb_put_session(cb->cb_ses); + cb->cb_ses = NULL; + } +} + static int grab_slot(struct nfsd4_session *ses) { int idx; @@ -1269,24 +1298,33 @@ static int grab_slot(struct nfsd4_session *ses) } /* - * There's currently a single callback channel slot. - * If the slot is available, then mark it busy. Otherwise, set the - * thread for sleeping on the callback RPC wait queue. + * Get both a session reference and a slot. */ static bool nfsd41_cb_get_slot(struct nfsd4_callback *cb, struct rpc_task *task) { struct nfs4_client *clp = cb->cb_clp; - struct nfsd4_session *ses = clp->cl_cb_session; + struct nfsd4_session *ses; + + if (!grab_cb_ses(cb)) { + rpc_sleep_on(&clp->cl_cb_waitq, task, NULL); + if (!grab_cb_ses(cb)) + return false; + rpc_wake_up_queued_task(&clp->cl_cb_waitq, task); + } if (cb->cb_held_slot >= 0) return true; + + ses = cb->cb_ses; cb->cb_held_slot = grab_slot(ses); if (cb->cb_held_slot < 0) { rpc_sleep_on(&clp->cl_cb_waitq, task, NULL); /* Race breaker */ cb->cb_held_slot = grab_slot(ses); - if (cb->cb_held_slot < 0) + if (cb->cb_held_slot < 0) { + put_cb_ses(cb); return false; + } rpc_wake_up_queued_task(&clp->cl_cb_waitq, task); } return true; @@ -1295,7 +1333,10 @@ static bool nfsd41_cb_get_slot(struct nfsd4_callback *cb, struct rpc_task *task) static void nfsd41_cb_release_slot(struct nfsd4_callback *cb) { struct nfs4_client *clp = cb->cb_clp; - struct nfsd4_session *ses = clp->cl_cb_session; + struct nfsd4_session *ses = cb->cb_ses; + + if (!ses) + return; if (cb->cb_held_slot >= 0) { spin_lock(&ses->se_lock); @@ -1304,6 +1345,7 @@ static void nfsd41_cb_release_slot(struct nfsd4_callback *cb) cb->cb_held_slot = -1; rpc_wake_up_next(&clp->cl_cb_waitq); } + put_cb_ses(cb); } static void nfsd41_destroy_cb(struct nfsd4_callback *cb) @@ -1342,7 +1384,7 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata) static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback *cb) { struct nfs4_client *clp = cb->cb_clp; - struct nfsd4_session *session = clp->cl_cb_session; + struct nfsd4_session *session = cb->cb_ses; bool ret = true; if (!clp->cl_minorversion) { @@ -1629,6 +1671,7 @@ void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp, const struct nfsd4_callback_ops *ops, enum nfsd4_cb_op op) { cb->cb_clp = clp; + cb->cb_ses = NULL; cb->cb_msg.rpc_proc = &nfs4_cb_procedures[op]; cb->cb_msg.rpc_argp = cb; cb->cb_msg.rpc_resp = cb; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 0faa367c9fa3280fa4a8a982f974804bb89f2035..56fe34d8dd90344404512114113c00a027aeb6a4 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -66,6 +66,7 @@ typedef struct { struct nfsd4_callback { struct nfs4_client *cb_clp; + struct nfsd4_session *cb_ses; struct rpc_message cb_msg; const struct nfsd4_callback_ops *cb_ops; struct work_struct cb_work; diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index ad2c0c432d08705bcebf00f7309f19267afcae03..fff665bac3b252387f92139b5f868cf1b034d1c9 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -1644,8 +1644,7 @@ TRACE_EVENT(nfsd_cb_seq_status, __field(int, seq_status) ), TP_fast_assign( - const struct nfs4_client *clp = cb->cb_clp; - const struct nfsd4_session *session = clp->cl_cb_session; + const struct nfsd4_session *session = cb->cb_ses; const struct nfsd4_sessionid *sid = (struct nfsd4_sessionid *)&session->se_sessionid; @@ -1684,8 +1683,7 @@ TRACE_EVENT(nfsd_cb_free_slot, __field(u32, slot_seqno) ), TP_fast_assign( - const struct nfs4_client *clp = cb->cb_clp; - const struct nfsd4_session *session = clp->cl_cb_session; + const struct nfsd4_session *session = cb->cb_ses; const struct nfsd4_sessionid *sid = (struct nfsd4_sessionid *)&session->se_sessionid; From patchwork Wed Jan 29 13:39:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13953767 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 721BA1B87EE; Wed, 29 Jan 2025 13:40:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158017; cv=none; b=PcfldRMyc/gED03VC9fF4fBHLAicO/Zsx/8FD4SAaK/93O/IebW9mTOdvkpKIdcxqhgHvJgjlWviBtZppkv0ulr7Yh/EEZ6toFPkJ0yGmW7XvSo3qpKCXKew0ZpkxUa7grFL9BjbawCh6hhTb0laVnNNqzpQFdunt8xb/6l3WoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158017; c=relaxed/simple; bh=NbJxpKAEYs/HAN2fTpo7awYOhoPSyHXKWtM0VOeNu7s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f7feIDFs3fh7gFXWJdpASniS58LKOoSugzHSo6fqWoF2bFsumk2Wgc1XezgSvrWSJ1vTeV4ocBFCoxnoToTl06V9E+UGxwSMbQ+C5VC9Tsnvtp12ZJ5U5SBaWwwo7c9NPuHiihBOGV7e+nAQUcMnLL+bMVdDoHesyTYL7C7rr2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fXKR+3DT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fXKR+3DT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E353CC4CEE6; Wed, 29 Jan 2025 13:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738158016; bh=NbJxpKAEYs/HAN2fTpo7awYOhoPSyHXKWtM0VOeNu7s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fXKR+3DTmOg8nuPtE3hhUAvf5c07NkL9NnmfT4RoWl6dEYNuZkYhpKJve+PDAnVJq Iq18AVU+8gbo0hnMIHcph7BHqwucHWEsfVuVgfI5o2m+FPrsiCnJzZHqJg0JuHwtzs y/9tNyKRI0X0Dll9rjfrqibpIpxr5jHAlG6OoWLqjj1MoAjoFteWmRx4DDQpZvIXoL aX2AJeyvg+rL6SF/V/IDoibvLBZcTgTgItBYglYklo/5RZriCZBRk92Ip6ISIEZwxU /zSi9D47tP6IPhOzj1ABsZiWs4sp4KiFn28rLt0rfqOM9T3fB6WL8IiWT1dRf+zxJO Ce8j2ROIgVtDw== From: Jeff Layton Date: Wed, 29 Jan 2025 08:39:57 -0500 Subject: [PATCH v2 4/7] nfsd: overhaul CB_SEQUENCE error handling Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250129-nfsd-6-14-v2-4-2700c92f3e44@kernel.org> References: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> In-Reply-To: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "J. Bruce Fields" , Kinglong Mee , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4840; i=jlayton@kernel.org; h=from:subject:message-id; bh=NbJxpKAEYs/HAN2fTpo7awYOhoPSyHXKWtM0VOeNu7s=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnmi+65z4cMIUssnxsrHOSeprTUHhdasqrzUY+n Ad4S0Go8OGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ5ovugAKCRAADmhBGVaC FQh7EACXW0Lwz4npWxwgr/66sDBkBQ+zaYBh9tLi1aLJG4MSzpIwX/pI41mcMWqLyhnDVZrDlKh Y40akHp0xL5AwTHtD4kN/pgWwPVB3/bxJaYEdOc5yqnxcukXY+blyQtXqlSSnRx5tVucq25N2jJ dKyFarP1jQKBgWocViqPQ5TlaBnUdr7pZHsfuNB/UKzEdL5MuDAHDjdOirV4UPbixZTLvKA/YNG zECz0Qvv+6Leg/EdSZciqlAEsgAuZCukLY1i8lIij+REPC2t+Dv/J7BcbS6eFa0+3lcMn4xnMIE lFCbbIXcw8lPBVk0881EVL8nTILixpnpo5WKKW6XIfQNF7+5s58TZ0S2Hhq96Ybtd8oJ+GVDgbE J9oxmSBQr1v8LCNRuV8vntzLWrOnA1K5wcNRebIpOi1+bAwdeqzfzn4P1TfMLaE+WVjs24F8dh5 7w0NP4Btc1BdzrrQwTfKInF38MFCuuShDdPBp25tC7kbpK3Xi+OUhuf8cn786PQW+2nqZJtGzZ1 gJYdEcawliJSccJAlU+H+bFLsDJyhl2eP/lf0yhE1iXShvNISjGKjBY7LLiFDKjZceO52HdbfPQ xgfqVWLXNJvRMMt8T56jp/8cNyIMUo1vXXt3MwUWUiYMHvb5B94BnlFnYapnGwTmX4b1D+B2wpC KrMdwhJexQO+uzw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Some of the existing error handling in nfsd4_cb_sequence_done is incorrect. This patch first does some general cleanup and then reworks some of the error handling cases. There is only one case where we want to proceed with processing the rest of the CB_COMPOUND, and that's when the cb_seq_status is 0. Make the default return value be false, and only set it to true in that case. Now that there is a clear record of the session used to handle the CB_COMPOUND, we can take changes to the cl_cb_session into account when reattempting a call. When restarting the RPC (but not the entire callback), test RPC_SIGNALLED(). If it has been, then fall through to restart the callback instead of just restarting the RPC. Whenever restarting the entire callback, release the slot and session, in case there have been changes in the interim. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 78 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 20 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 9f4838a6d9c668cdf66a77793f63c064586f2b22..e70a7a03933b1f8a48d31b0ef226c3f157d14ed1 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -1381,11 +1381,16 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata) rpc_call_start(task); } +static bool cb_session_changed(struct nfsd4_callback *cb) +{ + return cb->cb_ses != rcu_access_pointer(cb->cb_clp->cl_cb_session); +} + static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback *cb) { struct nfs4_client *clp = cb->cb_clp; struct nfsd4_session *session = cb->cb_ses; - bool ret = true; + bool ret = false; if (!clp->cl_minorversion) { /* @@ -1418,11 +1423,16 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback * (sequence ID, cached reply) MUST NOT change. */ ++session->se_cb_seq_nr[cb->cb_held_slot]; + ret = true; break; case -ESERVERFAULT: + /* + * Call succeeded, but CB_SEQUENCE reply failed sanity checks. + * The client has gone insane. Mark the BC faulty, since there + * isn't much else we can do. + */ ++session->se_cb_seq_nr[cb->cb_held_slot]; nfsd4_mark_cb_fault(cb->cb_clp); - ret = false; break; case 1: /* @@ -1433,39 +1443,67 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback */ fallthrough; case -NFS4ERR_BADSESSION: - nfsd4_mark_cb_fault(cb->cb_clp); - ret = false; + /* + * If the session hasn't changed, mark it faulty. Restart + * the call. + */ + if (!cb_session_changed(cb)) + nfsd4_mark_cb_fault(cb->cb_clp); goto need_restart; case -NFS4ERR_DELAY: + /* + * If the rpc_clnt is being torn down, then we must restart + * the call from scratch. + */ + if (RPC_SIGNALLED(task)) + goto need_restart; cb->cb_seq_status = 1; - if (!rpc_restart_call(task)) - goto out; - - rpc_delay(task, 2 * HZ); + if (rpc_restart_call(task)) + rpc_delay(task, 2 * HZ); return false; - case -NFS4ERR_BADSLOT: - goto retry_nowait; case -NFS4ERR_SEQ_MISORDERED: - if (session->se_cb_seq_nr[cb->cb_held_slot] != 1) { - session->se_cb_seq_nr[cb->cb_held_slot] = 1; + /* + * Reattempt once with seq_nr 1. If that fails, treat this + * like BADSLOT. + */ + if (!cb_session_changed(cb)) { + if (session->se_cb_seq_nr[cb->cb_held_slot] != 1) { + session->se_cb_seq_nr[cb->cb_held_slot] = 1; + goto retry_nowait; + } + } + fallthrough; + case -NFS4ERR_BADSLOT: + /* + * BADSLOT means that the client and server are out of sync + * on the BC parameters. In this case, we want to mark the + * backchannel faulty and then try it again, but _leak_ the + * slot so no one uses it. If the callback session has + * changed since then though, don't mark it. + */ + if (!cb_session_changed(cb)) { + nfsd4_mark_cb_fault(cb->cb_clp); + cb->cb_held_slot = -1; goto retry_nowait; } - break; + goto need_restart; default: nfsd4_mark_cb_fault(cb->cb_clp); } trace_nfsd_cb_free_slot(task, cb); nfsd41_cb_release_slot(cb); - - if (RPC_SIGNALLED(task)) - goto need_restart; -out: return ret; retry_nowait: - if (rpc_restart_call_prepare(task)) - ret = false; - goto out; + /* + * RPC_SIGNALLED() means that the rpc_client is being torn down and + * (possibly) recreated. Restart the call completely in that case. + */ + if (!RPC_SIGNALLED(task)) { + rpc_restart_call_prepare(task); + return false; + } need_restart: + nfsd41_cb_release_slot(cb); if (!test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags)) { trace_nfsd_cb_restart(clp, cb); task->tk_status = 0; From patchwork Wed Jan 29 13:39:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13953768 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F7B91D89F1; Wed, 29 Jan 2025 13:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158018; cv=none; b=OXCxmRRSYMxoqwIv5jd1mPUPn219PkTQZuaUQY2hTEB9ES74qxVHVjfiT+drhh2M8GH9NYb471tfY1lO3hDhnDqIZiuTNCocNSNrmg7FVB3XwLTnZ+ZZhKThvMYI4SDnvCIsBhHC2kHSX6J7LZXzCfYd3vupMnUuNouPsrWqOTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158018; c=relaxed/simple; bh=oLYdEgIhLU5xlu9zPTmaGhlVwWRiDKTykVlG5qz4BvQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rbIEzgAD85P5TblFPDZp7AwVs7/X8RfGGCNcCBPyh2/MABdujVn4q5WKrTt5cmGXG5MxC/+NOulN0OdhPr1EHILE85Agg6I3Zszo/eFxK+g3rRr8Fi6YGEg02Soynn+yKB50hEIt5J16UmENs4fwlmyTH1+Npfj47sXjjToEb/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VjOHBcyj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VjOHBcyj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29552C4CEE5; Wed, 29 Jan 2025 13:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738158018; bh=oLYdEgIhLU5xlu9zPTmaGhlVwWRiDKTykVlG5qz4BvQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VjOHBcyjeKuzB64dt2qKSiVUalkTQvr8Y3+kKgN0HAw+r///jns+sUO5mTkMD8Qt9 obm0L2yVP1i1lQB2Q7yNH7C6bmVB/zEIBehaKBVpXH/tZ6H+jlZ/amVeq1R4xgvBda PPTXhYbLoihBSoCIChuGUdqYY2WpjCU5yosxPgPUM8Q3h300b123o1xXAtY+RFQ9gs l2AhMtZ7cm8BKCRyPF/fhBgFhDGczIM+AhySGajJCl8RCgaWe+r+SgtIRy9OhXjGy5 y3B+3Mkr1VYEeDCQRy7SxKxZku0P2n22OonBtvSlgmLbIbVbJg5gaVomXnj1TXModq py7V+9Ei8j2Ew== From: Jeff Layton Date: Wed, 29 Jan 2025 08:39:58 -0500 Subject: [PATCH v2 5/7] nfsd: remove unneeded forward declaration of nfsd4_mark_cb_fault() Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250129-nfsd-6-14-v2-5-2700c92f3e44@kernel.org> References: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> In-Reply-To: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "J. Bruce Fields" , Kinglong Mee , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=613; i=jlayton@kernel.org; h=from:subject:message-id; bh=oLYdEgIhLU5xlu9zPTmaGhlVwWRiDKTykVlG5qz4BvQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnmi+6FHOssWL+Rv+X8RIIfaNKg8kBgLqpNOb1q JN7dgDyzqqJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ5ovugAKCRAADmhBGVaC FfbED/99OoBzBFhx9L/A2HoP5fEO50W+/q9EeXFR1ZJZ+X1dpThGWgmKf84+ZNc12O0xPEW9YY4 9cb0wmAjSig2tJhH7Ifqm7CxcL+F/s1TO5GHjqNgAWnkzk0SL1IFmn2jK81nlvL5iurUQlZgZau vwav72SAhEICZFy524OEVX3IhQ67JZzKtht+Lk6GL+7/1D8LSMv5yfua8sz8HI12BhQIXnI98Vx Giqu5df/LLWqOuS1LPVgsUwu9Ue7XxtN8G0E53wVEZ8pqAMYfGSKUNi2Zw65FVtNgaCRAOrC+PE 2KBphjo9cbjh9Hi32zcZD4mVd3TC0zNUbQ1Dp83fBbPGpjI5JJ1ugYXVjbKsfFIbAN08e3Idl0S fLk01I5tzHqoFFJ3bHSYVpDf5lOQtVJ9eNpYw7lwWVL3rpmlq8OwR2JiAuPGzpIYtgELYJ+Jih8 zLg7deRwP6ZyrmaZpcfyGgx7ST2zGzVFXAUQuLAwnBI/KFulju4oF2MEjhlFkEb0Y9fBAJ1VTGV xLyxS4mxVW2tIRwpQIEVKMI8MYcu/SylKAdQOhYwAcoGLVD5vwfKvyNK3fvA/QRE80+Z7oQXQOl LgYVUYA78PFjq+oACEopu/87QFqkwT4Y3pr+cy+Ul4frb6DQ6RD+t+VUlzn4ysPWTShxyEChoDB IkjlhTnFI9Cd5+Q== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 This isn't needed. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index e70a7a03933b1f8a48d31b0ef226c3f157d14ed1..4d4e0c95a36724027a63b53487fd36260a9ab1cd 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -45,9 +45,6 @@ #include "nfs4xdr_gen.h" #define NFSDDBG_FACILITY NFSDDBG_PROC - -static void nfsd4_mark_cb_fault(struct nfs4_client *clp); - #define NFSPROC4_CB_NULL 0 #define NFSPROC4_CB_COMPOUND 1 From patchwork Wed Jan 29 13:39:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13953769 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ED2A1DC994; Wed, 29 Jan 2025 13:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158019; cv=none; b=E/8r/du1DQ1E6HIBuuYN6ZWkSaMuq/S+P3lhB3Uuw3eyEOCGlEjrLTHQOhrXljOy++tckmEoarEZpI3jD0E+JaS9GPWBfl3nMRSoxuTFnHPLBxWcfXBsB5yQY+gyEClPrpaftHi/bN2zt7dAKfnb1lWinFWSLuFutnI/EUGNUuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158019; c=relaxed/simple; bh=ER42+WjSUy3fwI13L52j2uoZ/l3fkkMi2yaNebC/kdY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AZumeWotbYyGchSU0brB4GpBFXjcQIO/PfSSQ4K8BQhDAr+RcMA7Q7NKS8HTf2cQhWWMWspEvaaOqlFchChF2CR8A+S1coJ2tMDamxJQC3ihTTDFMBFsvpRzI5TpQuOM0ZbHViDIRnjiYpqlhmAqeK0r7vijll2gCk38gifWu9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CipqYhUJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CipqYhUJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 624FEC4CEE2; Wed, 29 Jan 2025 13:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738158019; bh=ER42+WjSUy3fwI13L52j2uoZ/l3fkkMi2yaNebC/kdY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CipqYhUJQvHXMGCLOsA6KHhKz7XqrE6CIfKq9OvBdIkQh+zr5fOKW7tiHsnN+R0T3 tELoc4BMBFpTlRyWnW9Ve4IzwumVnDq25wRuu8INjFOiOGfDv9TBQ16xq+6z3FF0zj Os+N69yjGuCck+dmAI7u6yqkoMyhiLo8FJQAV1o3L3YuYr6lsV+OSBIoY7/qk/3Mbm Qvfn44tlnqj5uSpeWbCaI3WTmOJ1rvGzdTJdBl3Mqqa5HgIi2/avnUef87X0LG0siF 6ozKpk/kXZ+OxIstDyHuPMN2BSReOayNveiR9iNLXrjV0atGYmHbY9C31dwvbZYeJA 4CQnK0lmOmSjQ== From: Jeff Layton Date: Wed, 29 Jan 2025 08:39:59 -0500 Subject: [PATCH v2 6/7] nfsd: lift NFSv4.0 handling out of nfsd4_cb_sequence_done() Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250129-nfsd-6-14-v2-6-2700c92f3e44@kernel.org> References: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> In-Reply-To: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "J. Bruce Fields" , Kinglong Mee , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3351; i=jlayton@kernel.org; h=from:subject:message-id; bh=ER42+WjSUy3fwI13L52j2uoZ/l3fkkMi2yaNebC/kdY=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnmi+6H3iVaRyCvF4MmtUyE3nJHoxIaRUcllY5B m0ObtTNjpCJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ5ovugAKCRAADmhBGVaC Fa86D/oCuqsgejxA6X8086n1C67OWPgwg8g61Sue5TnmOUBknbw2sYOArvRDH9Ad0aWE2m8H6OG eZmSm1T4jNiLqTRwvDYzctxRJ0c8svK83b02RjJNEfKH8mXp42lTh5GVi6sTEJliubspAlDj8Vj odEMbs/N1jkfss4Jbo0x+dH79IrgOatady+TXLLFEd9sjC8fgWVQTTX9nC3vQ04gJQ7Vx+l/Alc hbYpOpw1+j9F0ysmb9SwrXX7mPze2kjE3U+fPSFKs0a7EpQ414v90oW5xtVUP4fg5k1W0NRpg9B LC9I1/R03MI4QUGH+68uB86X3VD45KN5aQ1Xbm0Fy730R4/eATepmKH7c6WSgQmT0ZvfcI7R+nU DQkrTmD31HjAlfg/JUUERM14nrqhqq9XJEsPllWbKe7YXsjbDXxtPB1wE7j6JcfTvSmeWbk1net jR5e0+FASWdoNMAm4D3wDNCB8hPuvKcmk50WfK5cIwPHPqT3JU0NIPq5BH+rO0nLmXd48ebqLhO epllvfNM+avqpdmA0qr32p1mMiHWsQlQkPx8WNJ0RaVNQkabhWnQF1qhtFrbvjpkiTZI80mCtSC vQkvPl0EGEOeS8fnRqFTvato9OuUe/ZqGabDszHW1jXIc7kXLcq8yhDyqdBDVbDcy+ia+sA2etD q6EdAkEWecf9qLw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 It's a bit strange to call nfsd4_cb_sequence_done() on a callback with no CB_SEQUENCE. Lift the handling of restarting a call into a new helper, and move the handling of NFSv4.0 into nfsd4_cb_done(). Signed-off-by: Jeff Layton --- fs/nfsd/nfs4callback.c | 53 ++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 4d4e0c95a36724027a63b53487fd36260a9ab1cd..2cfff984b42f0ef7fe885d57d57b3d318ed966e0 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -1383,27 +1383,22 @@ static bool cb_session_changed(struct nfsd4_callback *cb) return cb->cb_ses != rcu_access_pointer(cb->cb_clp->cl_cb_session); } -static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback *cb) +static void restart_callback(struct rpc_task *task, struct nfsd4_callback *cb) { struct nfs4_client *clp = cb->cb_clp; - struct nfsd4_session *session = cb->cb_ses; - bool ret = false; - if (!clp->cl_minorversion) { - /* - * If the backchannel connection was shut down while this - * task was queued, we need to resubmit it after setting up - * a new backchannel connection. - * - * Note that if we lost our callback connection permanently - * the submission code will error out, so we don't need to - * handle that case here. - */ - if (RPC_SIGNALLED(task)) - goto need_restart; - - return true; + nfsd41_cb_release_slot(cb); + if (!test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags)) { + trace_nfsd_cb_restart(clp, cb); + task->tk_status = 0; + cb->cb_need_restart = true; } +} + +static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback *cb) +{ + struct nfsd4_session *session = cb->cb_ses; + bool ret = false; if (cb->cb_held_slot < 0) goto need_restart; @@ -1493,19 +1488,14 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback retry_nowait: /* * RPC_SIGNALLED() means that the rpc_client is being torn down and - * (possibly) recreated. Restart the call completely in that case. + * (possibly) recreated. Restart the whole callback in that case. */ if (!RPC_SIGNALLED(task)) { rpc_restart_call_prepare(task); return false; } need_restart: - nfsd41_cb_release_slot(cb); - if (!test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags)) { - trace_nfsd_cb_restart(clp, cb); - task->tk_status = 0; - cb->cb_need_restart = true; - } + restart_callback(task, cb); return false; } @@ -1516,8 +1506,21 @@ static void nfsd4_cb_done(struct rpc_task *task, void *calldata) trace_nfsd_cb_rpc_done(clp); - if (!nfsd4_cb_sequence_done(task, cb)) + if (!clp->cl_minorversion) { + /* + * If the backchannel connection was shut down while this + * task was queued, we need to resubmit it after setting up + * a new backchannel connection. + * + * Note that if we lost our callback connection permanently + * the submission code will error out, so we don't need to + * handle that case here. + */ + if (RPC_SIGNALLED(task)) + restart_callback(task, cb); + } else if (!nfsd4_cb_sequence_done(task, cb)) { return; + } if (cb->cb_status) { WARN_ONCE(task->tk_status, From patchwork Wed Jan 29 13:40:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13953770 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21CB31DE2DA; Wed, 29 Jan 2025 13:40:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158021; cv=none; b=rENegM9FV/V2Z44ZsMpZZnMWxzSlAYtYgZGpLxPie2MO4Nqh+AUHRxFJyzavnTO8hVabHZ1tdo+KsZ0neNWInr7WrZd4AW4Hyw8xurIs/hLZfCjCm5tFgUeUNfFEGo/UpmaPbMWU0HwMy9FsyZdTSSrD5qJthLf9YuQKSFPtQRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738158021; c=relaxed/simple; bh=XRM38jRIULWRrASi88vSoSIfhko5eGFiVikgJOw1cSE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qdyB61LUmhZK7p109mNXBZgs+iQeY64VFZ9b7qZ/75ceoA1bXLcMviBZspMi/QG0EfJGig6Q07ENrynJrlHV6j/n7j/uV6YLU+Yz0Wkv85Ha+m3f5IoYyMV2cE0aBta5hyxdP/33oEqLlWwBjYwzzKiNS9wR9PNx3M/W6HraBIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TU+RGDwF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TU+RGDwF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B173C4CEDF; Wed, 29 Jan 2025 13:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738158020; bh=XRM38jRIULWRrASi88vSoSIfhko5eGFiVikgJOw1cSE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TU+RGDwFdUGOXhGbNYyzyWRlu4hY+f40pbYyZ4Dc6ipEw8bMEhJhDmcbkngs6rQaP GIvDcaBMqMEb8wsxcjj/5Rllgl0gwg7UgD/fYOUzVgKKRfWWkGvCjm633IUZbK2DLt 6IgoqC29RFpOxa9wBCq3ZFDAQ2T/KrXYnM7mauhpqSs2T1kRAQgJZWV2qYC4WUCyIJ 7ey5Xxg0NsOBsZq7elgZBGiBwmNRFC7e+YQxsIAn9asy7fCe4vWNOXtZWf89Hs5moZ VkX4VugN/4DMTyaKNWsWg5dj7ZX2AncTwJTIKxZQ5bjn0BeJ2ymZnpkrpGjRmtOdwy Iq9L9mbNQEepg== From: Jeff Layton Date: Wed, 29 Jan 2025 08:40:00 -0500 Subject: [PATCH v2 7/7] sunrpc: make rpc_restart_call() and rpc_restart_call_prepare() void return Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250129-nfsd-6-14-v2-7-2700c92f3e44@kernel.org> References: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> In-Reply-To: <20250129-nfsd-6-14-v2-0-2700c92f3e44@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "J. Bruce Fields" , Kinglong Mee , Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3539; i=jlayton@kernel.org; h=from:subject:message-id; bh=XRM38jRIULWRrASi88vSoSIfhko5eGFiVikgJOw1cSE=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBnmi+6MedxE93caz5mYVpn2gv168dCijgVSwuwv tmExDu9RIWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZ5ovugAKCRAADmhBGVaC Ff+PD/413D7uS7fy71dd1XzTlUOQO8X/fCCOX3fW0qnNE4JeKf3qhEnu7lGY6b6yrl2uoPLYb3S gRft5nxplKgPOYxBp9ePAc+E5gf3RREP/wH3q5Fr7ixJcj91PJ0WgDAKbbKCxa/iToAQV51Vbvl K8torRLyVBXBYhMqbmc1IqivGFUzrn61KjNUBVylG88oa7xwMy2bAum9JtqGyp7yLQFlcOCz97m APFu3hx85CnVjJ9j275tCfq2NA+mEZiAqJrB9AgcYdNUeJx4kEH4XEXGIT0ck9ujtWDSxRikUF/ dX/vzoNOd4BieJszhArBdXgc1UbmCrqhDPlyR3dp1Wv7KRgyyhFuU+4WcNeiCLxogplUyzqMglQ s+1v5IKwExK6KUZ2cwkS9eXIZyTKEyTO4cDsut2ZBQ+G9RPf/Jtly72wdC10VN6PEnP175Q2cP5 g1XS7t9RXhx+M5zTOTvqObEDFmB5Y7jHDcDbs+YuN1gLT0vjUQA8IxWqyWd3LdVplwaBcy7UWWg gRPwUU5Jxwk60BE8WVXDsrYib6YWaMv5yW+Vtr+2kUcOTNhLNnRMZBACnJN/oZs6PweSsL+VXZj DTtfFJ28yn/wCDmXkj5WL68cvqACTxNbl/XF5d7UMDrmNa7LKeNhIfBGBu/YQWyfjVMO5YenXgn cc14cCXLFLCaMFQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 These functions always return 1. Make them void return and fix up the places that check the return code. Signed-off-by: Jeff Layton --- fs/nfs/nfs4proc.c | 12 +++++------- fs/nfsd/nfs4callback.c | 4 ++-- include/linux/sunrpc/clnt.h | 4 ++-- net/sunrpc/clnt.c | 7 +++---- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 405f17e6e0b45b26cebae06c5bbe932895af9a56..cda20bfeca56db1ef8c51e524d08908b93bfeba6 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -968,15 +968,13 @@ static int nfs41_sequence_process(struct rpc_task *task, retry_new_seq: ++slot->seq_nr; retry_nowait: - if (rpc_restart_call_prepare(task)) { - nfs41_sequence_free_slot(res); - task->tk_status = 0; - ret = 0; - } + rpc_restart_call_prepare(task); + nfs41_sequence_free_slot(res); + task->tk_status = 0; + ret = 0; goto out; out_retry: - if (!rpc_restart_call(task)) - goto out; + rpc_restart_call(task); rpc_delay(task, NFS4_POLL_RETRY_MAX); return 0; } diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 2cfff984b42f0ef7fe885d57d57b3d318ed966e0..d101f18012bfe89169d8218b46183cab6c06d1bf 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -1450,8 +1450,8 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback if (RPC_SIGNALLED(task)) goto need_restart; cb->cb_seq_status = 1; - if (rpc_restart_call(task)) - rpc_delay(task, 2 * HZ); + rpc_restart_call(task); + rpc_delay(task, 2 * HZ); return false; case -NFS4ERR_SEQ_MISORDERED: /* diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 5321585c778fcc1fef0e0420cb481786c02a7aac..e56f15c97fa24c735090c21c51ef312bfd877cfd 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -213,8 +213,8 @@ int rpc_call_sync(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags); struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, int flags); -int rpc_restart_call_prepare(struct rpc_task *); -int rpc_restart_call(struct rpc_task *); +void rpc_restart_call_prepare(struct rpc_task *task); +void rpc_restart_call(struct rpc_task *task); void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); struct net * rpc_net_ns(struct rpc_clnt *); size_t rpc_max_payload(struct rpc_clnt *); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 0090162ee8c350568c91f1bcd951675ac3ae141c..3d2989120599ccee32e8827b1790d4be7d7a565a 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -1670,20 +1670,19 @@ void rpc_force_rebind(struct rpc_clnt *clnt) } EXPORT_SYMBOL_GPL(rpc_force_rebind); -static int +static void __rpc_restart_call(struct rpc_task *task, void (*action)(struct rpc_task *)) { task->tk_status = 0; task->tk_rpc_status = 0; task->tk_action = action; - return 1; } /* * Restart an (async) RPC call. Usually called from within the * exit handler. */ -int +void rpc_restart_call(struct rpc_task *task) { return __rpc_restart_call(task, call_start); @@ -1694,7 +1693,7 @@ EXPORT_SYMBOL_GPL(rpc_restart_call); * Restart an (async) RPC call from the call_prepare state. * Usually called from within the exit handler. */ -int +void rpc_restart_call_prepare(struct rpc_task *task) { if (task->tk_ops->rpc_call_prepare != NULL)