Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp760928rdb; Fri, 26 Jan 2024 09:47:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmhxtPMotWuFEgt86w58ZL3tm5wGD6m3o8LJqF6lznVc1KerrYhP31k5jjlc8K1nNUS+lq X-Received: by 2002:a2e:7217:0:b0:2cd:f5b9:b306 with SMTP id n23-20020a2e7217000000b002cdf5b9b306mr64607ljc.115.1706291260092; Fri, 26 Jan 2024 09:47:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706291260; cv=pass; d=google.com; s=arc-20160816; b=dCv7WF1K3kfFDy2LTHtIUOHLTCgYdjZS9EzgVpAwXYluQkoPP/FDzgEqXv2Q+Nnskn NtfFCHR1ZY7HqNS2WmTm03HiSFtBEOFPd0oIXq1BqbQ5gccszZ1n00koU5YM0IZoVws5 hlYXJYWQd9f1eEXl/Y8TKh6dWxbNbxnKdrQwEAGgoUVxrOyO1K3qiAEDPtYnPUpnuX8m 0EwsC2H1vO0CJg6HGP+KdziaMBdIosEFBzwSOHGe60/YyvRwZ3ZXy3JtV3gObwW+zmZe WaKHgpuvHeBoIoIk146ku7nl7SfvMZJ9CrL6QpsxYob2t0+wYO8tDD4LZbtOef3hEpy1 s5lA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:to:from:subject:dkim-signature; bh=EnImfekdSkjxdEa4e7eUpH/wpiAHFj30wy+EXr/6Jpw=; fh=Mys3y4MwsHRytUQMpdfGBn3oGRYLcLloxNwkFYMYMmg=; b=WODEZuGzcn8Ur4xmWskWfhNXq84GoKq3pbBxmwYsK9Zty9cxXZWHZGdfGwStWgNvW5 XwaDP0sm5tutjDuZ492CkOI5pYnryUSDFfJkZvtdVkagL7xD05V8S9NCIs8AW+imohvV GQGov7dggskc0OUlwvswk6ZFC449zZ0bamv21/78+Oyp1pOUeR1S3+e0W1s2aBfB92Yj Yy2PL8jvlrBZTidgheEs4VMFok2RtBRWvLyGZla5kwojR1XPSbuxOmx5WL9RVZD0QgsI dhXaIl+b2UgIxsR+DGalIT08uRpYvu9O1HJH+132m5AfJiQlItNEwB/+azwABGeBURN4 3Svw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QdR5bvtt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x27-20020a50d61b000000b00558e8d1a7d1si860667edi.534.2024.01.26.09.47.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 09:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QdR5bvtt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D19111F2469C for ; Fri, 26 Jan 2024 17:47:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EEFE208C5; Fri, 26 Jan 2024 17:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QdR5bvtt" X-Original-To: linux-nfs@vger.kernel.org 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 59F29208BC for ; Fri, 26 Jan 2024 17:45:30 +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=1706291132; cv=none; b=U9FFeP9uAqznH4P9JnpolOxTwSnUF/w+TuBpOy5L4VP1HZYhgQFfGM/QMqVwPjb6aS6Xf8P9esv0bn+TWTi5mG+zkJOt1lErwjMWp507IdCe6ocjOfECHsi1VRMmRLpekMFHBfsDfDG7SktVdB05m33URotOjvQ1jB/gxlFRt+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706291132; c=relaxed/simple; bh=mF7dux60dMpAU6FPXOAtOEcVq3Hty/2INAqzdyqD1KY=; h=Subject:From:To:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jTC15DEnI+43/hN4oTqr0Qjqejumeo+LSPQ/ZABdqpdS0XzMus+hk0+STI0fJgFKHZNVj/wohUojqsMtQ7Oye0+vWAY/87XtDPzr5ENyL6p4dFt+RYiS6cKnBeoz8dx5PKoe0tf9hopGSMr+BBuwICNpk6Yma2I8r7U344MHsxk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QdR5bvtt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD07DC43399 for ; Fri, 26 Jan 2024 17:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706291130; bh=mF7dux60dMpAU6FPXOAtOEcVq3Hty/2INAqzdyqD1KY=; h=Subject:From:To:Date:In-Reply-To:References:From; b=QdR5bvttXdOSh7PMZPNmjBejDYl1VJBHOTo0ov2M2EC7jt12qBCo9Wp1gRBaoQGKs 98kC3O/O/wYDUqGoCb6f8UMZ5rBT4h28V8BtTjQqRUfCjGDrKTP2WDYKnVwsM1KgyY 1xqhS18Jugb004qDaNedFYJe6qbzI/9TGuRUFYYZXrvKxl7QI+1imiyP4KoljR5zGl BmSlGPG+6Xp9+KAkHjb0VMOGArkimF6pDQ4GEoSSCf4LWutD6YsNUKlf6IwEUZyz2H b3dtxU4UmUmem2w9OnApGkz936NT9aJ8qoRoeAMQS+TT2iXGFCSvCtV1LOqRQbwjgP ujRhv0dBuREUQ== Subject: [PATCH 2 03/14] NFSD: Reschedule CB operations when backchannel rpc_clnt is shut down From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Fri, 26 Jan 2024 12:45:29 -0500 Message-ID: <170629112969.20612.8526400738389878628.stgit@manet.1015granger.net> In-Reply-To: <170629091560.20612.563908774748586696.stgit@manet.1015granger.net> References: <170629091560.20612.563908774748586696.stgit@manet.1015granger.net> User-Agent: StGit/1.5 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit From: Chuck Lever As part of managing a client disconnect, NFSD closes down and replaces the backchannel rpc_clnt. If a callback operation is pending when the backchannel rpc_clnt is shut down, currently nfsd4_run_cb_work() just discards that callback. But there are multiple cases to deal with here: o The client's lease is getting destroyed. Throw the CB away. o The client disconnected. It might be forcing a retransmit of CB operations, or it could have disconnected for other reasons. Reschedule the CB so it is retransmitted when the client reconnects. Since callback operations can now be rescheduled, ensure that cb_ops->prepare can be called only once by moving the cb_ops->prepare paragraph down to just before the rpc_call_async() call. Fixes: 2bbfed98a4d8 ("nfsd: Fix races between nfsd4_cb_release() and nfsd4_shutdown_callback()") Signed-off-by: Chuck Lever --- fs/nfsd/nfs4callback.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 1ed2512b3648..389d05985c52 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -890,6 +890,13 @@ static bool nfsd4_queue_cb(struct nfsd4_callback *cb) return queue_delayed_work(callback_wq, &cb->cb_work, 0); } +static void nfsd4_queue_cb_delayed(struct nfsd4_callback *cb, + unsigned long msecs) +{ + queue_delayed_work(callback_wq, &cb->cb_work, + msecs_to_jiffies(msecs)); +} + static void nfsd41_cb_inflight_begin(struct nfs4_client *clp) { atomic_inc(&clp->cl_cb_inflight); @@ -1375,20 +1382,21 @@ nfsd4_run_cb_work(struct work_struct *work) struct rpc_clnt *clnt; int flags; - if (cb->cb_need_restart) { - cb->cb_need_restart = false; - } else { - if (cb->cb_ops && cb->cb_ops->prepare) - cb->cb_ops->prepare(cb); - } - if (clp->cl_flags & NFSD4_CLIENT_CB_FLAG_MASK) nfsd4_process_cb_update(cb); clnt = clp->cl_cb_client; if (!clnt) { - /* Callback channel broken, or client killed; give up: */ - nfsd41_destroy_cb(cb); + if (test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags)) + nfsd41_destroy_cb(cb); + else { + /* + * XXX: Ideally, we could wait for the client to + * reconnect, but I haven't figured out how + * to do that yet. + */ + nfsd4_queue_cb_delayed(cb, 25); + } return; } @@ -1401,6 +1409,12 @@ nfsd4_run_cb_work(struct work_struct *work) return; } + if (cb->cb_need_restart) { + cb->cb_need_restart = false; + } else { + if (cb->cb_ops && cb->cb_ops->prepare) + cb->cb_ops->prepare(cb); + } cb->cb_msg.rpc_cred = clp->cl_cb_cred; flags = clp->cl_minorversion ? RPC_TASK_NOCONNECT : RPC_TASK_SOFTCONN; rpc_call_async(clnt, &cb->cb_msg, RPC_TASK_SOFT | flags,