From patchwork Wed Nov 15 18:55:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13457239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D621BC072A2 for ; Wed, 15 Nov 2023 19:02:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229531AbjKOTCV (ORCPT ); Wed, 15 Nov 2023 14:02:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231438AbjKOTCU (ORCPT ); Wed, 15 Nov 2023 14:02:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7428C19E for ; Wed, 15 Nov 2023 11:02:16 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C573BC433C7 for ; Wed, 15 Nov 2023 19:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700074936; bh=St3CybL7wd/LaFAt8FmnsE4d4EpjuxX938p2qLC2Xu0=; h=From:To:Subject:Date:From; b=YrXfpiAIhi+ub3dl9K7bxIGP/W7vhq+NfJCARV76aaJ0tU/lH1Ggqggoz+8tGHj6H 6j+Hnl40SJ+8U6GcOoRYs8T/9Li7IAyyQhGHS9H++JU9Ct+z3Awb9XIRmhYAfjMOQ3 VCTqirFIg+32HhkefSPc7vW4wFcEpM1fSkmfLFD9+xOUqe3RXxeZNr9MksmqpiPzOp GWg92WhygaS0wyiq5pDjmXCngeh4wetnpZ6OvXSKR+8/dD1h3lq2MVxDopsEAj85GJ HRJrgPFcVsdxEVioHY1JwEEjtuQqOSpft+XKNbLI5W1etsPwcexRPY4Dxsg7j1S/ol axErQO7wYEkZg== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 1/3] NFSv4: Track the number of referring calls in struct cb_process_state Date: Wed, 15 Nov 2023 13:55:27 -0500 Message-ID: <20231115185529.303842-1-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust When the server gives us a set of referring calls, to tell us that the NFSv4.1 callback needs to be ordered with respect to those calls, then we may want to make that information available to the operations. In certain cases, it may allow them to optimise their behaviour due to the extra knowledge. Signed-off-by: Trond Myklebust --- fs/nfs/callback.h | 5 +++-- fs/nfs/callback_proc.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index ccd4f245cae2..cc1b6620a0c2 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h @@ -40,11 +40,12 @@ enum nfs4_callback_opnum { struct nfs4_slot; struct cb_process_state { - __be32 drc_status; struct nfs_client *clp; struct nfs4_slot *slot; - u32 minorversion; struct net *net; + u32 minorversion; + __be32 drc_status; + unsigned int referring_calls; }; struct cb_compound_hdr_arg { diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 6bed1394d748..ebecd1f6409e 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -450,6 +450,7 @@ static int referring_call_exists(struct nfs_client *clp, __acquires(lock) { int status = 0; + int found = 0; int i, j; struct nfs4_session *session; struct nfs4_slot_table *tbl; @@ -478,11 +479,12 @@ static int referring_call_exists(struct nfs_client *clp, spin_lock(lock); if (status) goto out; + found++; } } out: - return status; + return status < 0 ? status : found; } __be32 nfs4_callback_sequence(void *argp, void *resp, @@ -493,6 +495,7 @@ __be32 nfs4_callback_sequence(void *argp, void *resp, struct nfs4_slot_table *tbl; struct nfs4_slot *slot; struct nfs_client *clp; + int ret; int i; __be32 status = htonl(NFS4ERR_BADSESSION); @@ -552,11 +555,13 @@ __be32 nfs4_callback_sequence(void *argp, void *resp, * related callback was received before the response to the original * call. */ - if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists, - &tbl->slot_tbl_lock) < 0) { + ret = referring_call_exists(clp, args->csa_nrclists, args->csa_rclists, + &tbl->slot_tbl_lock); + if (ret < 0) { status = htonl(NFS4ERR_DELAY); goto out_unlock; } + cps->referring_calls = ret; /* * RFC5661 20.9.3 From patchwork Wed Nov 15 18:55:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13457240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59C23C54FB9 for ; Wed, 15 Nov 2023 19:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231856AbjKOTCV (ORCPT ); Wed, 15 Nov 2023 14:02:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231745AbjKOTCU (ORCPT ); Wed, 15 Nov 2023 14:02:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02B841A7 for ; Wed, 15 Nov 2023 11:02:16 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F99CC433C8 for ; Wed, 15 Nov 2023 19:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700074936; bh=pcGqBYEcZv927P60bgaSDCGjf4eY9PCdOTg1NKfq5ew=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XVRcLmRgnH9LAYXrJmtI0Aj6tE+Awi3qL6j0p4ZsN5rnYgp0HmLcN7CdvLNsk3qvS F/ZmlydCU0hYglgZ1jpUZFyM4JhOfOOGPcFtwwujvqvyrqUMn8qY9dIgMy1f4vum98 4eQ6f+Wb83x58ZVS1FvPEenaEDDoyuwyrHGCHjejEXgvE/WZM73VfX7qNkf/W6wmOD Kb5PhPK2RxFwvRIYHn70EYynRIC7lUBx9qhOMwzDAImvsO9HOZ8d0jRij+aXDiRwtF SXYbutZjcKsy0JPA4q7uk8TfNxrxBzjlViij8za9Vwk16XCj2b2KNx0wgwyi4O2tYZ I9r0sLk6hjyWg== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 2/3] NFSv4.1: if referring calls are complete, trust the stateid argument Date: Wed, 15 Nov 2023 13:55:28 -0500 Message-ID: <20231115185529.303842-2-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231115185529.303842-1-trondmy@kernel.org> References: <20231115185529.303842-1-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust If the server is recalling a layout, and sends us a list of referring calls that we can see are complete, then we should just trust that the stateid argument is correct, even if the sequence id doesn't match the one we hold. Signed-off-by: Trond Myklebust --- fs/nfs/callback_proc.c | 44 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index ebecd1f6409e..c0d16ed3c3c5 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -207,7 +207,8 @@ static struct inode *nfs_layout_find_inode(struct nfs_client *clp, * Enforce RFC5661 section 12.5.5.2.1. (Layout Recall and Return Sequencing) */ static u32 pnfs_check_callback_stateid(struct pnfs_layout_hdr *lo, - const nfs4_stateid *new) + const nfs4_stateid *new, + struct cb_process_state *cps) { u32 oldseq, newseq; @@ -221,28 +222,29 @@ static u32 pnfs_check_callback_stateid(struct pnfs_layout_hdr *lo, newseq = be32_to_cpu(new->seqid); /* Are we already in a layout recall situation? */ - if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags) && - lo->plh_return_seq != 0) { - if (newseq < lo->plh_return_seq) - return NFS4ERR_OLD_STATEID; - if (newseq > lo->plh_return_seq) - return NFS4ERR_DELAY; - goto out; - } + if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) + return NFS4ERR_DELAY; - /* Check that the stateid matches what we think it should be. */ + /* + * Check that the stateid matches what we think it should be. + * Note that if the server sent us a list of referring calls, + * and we know that those have completed, then we trust the + * stateid argument is correct. + */ oldseq = be32_to_cpu(lo->plh_stateid.seqid); - if (newseq > oldseq + 1) + if (newseq > oldseq + 1 && !cps->referring_calls) return NFS4ERR_DELAY; + /* Crazy server! */ if (newseq <= oldseq) return NFS4ERR_OLD_STATEID; -out: + return NFS_OK; } static u32 initiate_file_draining(struct nfs_client *clp, - struct cb_layoutrecallargs *args) + struct cb_layoutrecallargs *args, + struct cb_process_state *cps) { struct inode *ino; struct pnfs_layout_hdr *lo; @@ -266,7 +268,7 @@ static u32 initiate_file_draining(struct nfs_client *clp, goto out; } pnfs_get_layout_hdr(lo); - rv = pnfs_check_callback_stateid(lo, &args->cbl_stateid); + rv = pnfs_check_callback_stateid(lo, &args->cbl_stateid, cps); if (rv != NFS_OK) goto unlock; @@ -326,10 +328,11 @@ static u32 initiate_bulk_draining(struct nfs_client *clp, } static u32 do_callback_layoutrecall(struct nfs_client *clp, - struct cb_layoutrecallargs *args) + struct cb_layoutrecallargs *args, + struct cb_process_state *cps) { if (args->cbl_recall_type == RETURN_FILE) - return initiate_file_draining(clp, args); + return initiate_file_draining(clp, args, cps); return initiate_bulk_draining(clp, args); } @@ -340,11 +343,12 @@ __be32 nfs4_callback_layoutrecall(void *argp, void *resp, u32 res = NFS4ERR_OP_NOT_IN_SESSION; if (cps->clp) - res = do_callback_layoutrecall(cps->clp, args); + res = do_callback_layoutrecall(cps->clp, args, cps); return cpu_to_be32(res); } -static void pnfs_recall_all_layouts(struct nfs_client *clp) +static void pnfs_recall_all_layouts(struct nfs_client *clp, + struct cb_process_state *cps) { struct cb_layoutrecallargs args; @@ -352,7 +356,7 @@ static void pnfs_recall_all_layouts(struct nfs_client *clp) memset(&args, 0, sizeof(args)); args.cbl_recall_type = RETURN_ALL; /* FIXME we ignore errors, what should we do? */ - do_callback_layoutrecall(clp, &args); + do_callback_layoutrecall(clp, &args, cps); } __be32 nfs4_callback_devicenotify(void *argp, void *resp, @@ -622,7 +626,7 @@ __be32 nfs4_callback_recallany(void *argp, void *resp, nfs_expire_unused_delegation_types(cps->clp, flags); if (args->craa_type_mask & BIT(RCA4_TYPE_MASK_FILE_LAYOUT)) - pnfs_recall_all_layouts(cps->clp); + pnfs_recall_all_layouts(cps->clp, cps); if (args->craa_type_mask & BIT(PNFS_FF_RCA4_TYPE_MASK_READ)) { set_bit(NFS4CLNT_RECALL_ANY_LAYOUT_READ, &cps->clp->cl_state); From patchwork Wed Nov 15 18:55:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13457241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D817BC2BB3F for ; Wed, 15 Nov 2023 19:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjKOTCW (ORCPT ); Wed, 15 Nov 2023 14:02:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbjKOTCV (ORCPT ); Wed, 15 Nov 2023 14:02:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B9BAE5 for ; Wed, 15 Nov 2023 11:02:17 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1DA3C433CA for ; Wed, 15 Nov 2023 19:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700074937; bh=Oxl0F+p87/Zb7F7ROl2xmY/7M8/1Z0fxZEGCh8/KSVc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tbsd97z/IHKHj0EtAf0Lc2RDXWIrdalQs5ATrPlaH+lVv/+nRXwJ/GaqO1jSj8UUJ aE66cqRAngM2UFSL2YBTOwnrwy0srejpHJfCtjHZyqucG17beEZCZiXubGULDy1QMl yrJNaMUX4CAbuxmPYHJUfTOnkuENgNz6RP1AZi/88gFLtYQpppBMS9HtTHCSkAIKv4 uwEVIx6BTyjgayK8MBaedfKRtJyU2jt/vS5TDDWvapwxWCKaL/D1xKgL9rzYlNYbn+ nim9U0NZogfAPE8MYFDSzxvFaN/uPrD+Fon3EQb5dwwqtsg9beIwYu0F9JqmqeiZDY LLOBEVE34vvtA== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 3/3] NFSv4.1/pnfs: Ensure we handle the error NFS4ERR_RETURNCONFLICT Date: Wed, 15 Nov 2023 13:55:29 -0500 Message-ID: <20231115185529.303842-3-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231115185529.303842-2-trondmy@kernel.org> References: <20231115185529.303842-1-trondmy@kernel.org> <20231115185529.303842-2-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Once the client has processed the CB_LAYOUTRECALL, but has not yet successfully returned the layout, the server is supposed to switch to returning NFS4ERR_RETURNCONFLICT. This patch ensures that we handle that return value correctly. Fixes: 183d9e7b112a ("pnfs: rework LAYOUTGET retry handling") Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index e7e80c67d82b..7e3053339d6a 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -170,6 +170,7 @@ static int nfs4_map_errors(int err) case -NFS4ERR_RESOURCE: case -NFS4ERR_LAYOUTTRYLATER: case -NFS4ERR_RECALLCONFLICT: + case -NFS4ERR_RETURNCONFLICT: return -EREMOTEIO; case -NFS4ERR_WRONGSEC: case -NFS4ERR_WRONG_CRED: @@ -558,6 +559,7 @@ static int nfs4_do_handle_exception(struct nfs_server *server, case -NFS4ERR_GRACE: case -NFS4ERR_LAYOUTTRYLATER: case -NFS4ERR_RECALLCONFLICT: + case -NFS4ERR_RETURNCONFLICT: exception->delay = 1; return 0; @@ -9691,6 +9693,7 @@ nfs4_layoutget_handle_exception(struct rpc_task *task, status = -EBUSY; break; case -NFS4ERR_RECALLCONFLICT: + case -NFS4ERR_RETURNCONFLICT: status = -ERECALLCONFLICT; break; case -NFS4ERR_DELEG_REVOKED: