Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp69523rdb; Thu, 25 Jan 2024 08:28:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpTDZyrqBpuP38JKtvyLecCkneeBnSfLufumKIdQZgM+c1UIMBGF4zajsd9Y3kV/dahr7A X-Received: by 2002:a17:903:2291:b0:1d6:f0e3:d2a8 with SMTP id b17-20020a170903229100b001d6f0e3d2a8mr1241820plh.77.1706200137049; Thu, 25 Jan 2024 08:28:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706200137; cv=pass; d=google.com; s=arc-20160816; b=t7nlgOnzx2nUfxv7X1hve/qIWHVbgPWIYq9TmPigch1g8sufaaP/r6fiLfPdlsgDam Z6gzdi+35PzFgOeACVk8rtzdibZEtGGXYBDW5kbaR1idelBibjioPTQcVgDyLxcEUJEG CaxztwwmudZ3UaTRUu5EEY0Ek5DKSYvZyphxFTGLDj6ix5K5VHr6JhGAg32PGMl0Et3g thA4UAnjdX+r69YekpFviFNEhkOp1V2dW+F7Bl4DTeWX/LBNJX+nkZ7Jm9pFSJNH8xXP TVZGqgubKjVDExps7gx/EcbfJjV+ERPIFyfWPvej/FYOM+i9XxrzpdYDp7SvpVJa6veR uzUw== 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=4LyJdxgUvCqZ3MTKGac/7qlx7yt/TEPPLbRjQMZaeOc=; fh=Mys3y4MwsHRytUQMpdfGBn3oGRYLcLloxNwkFYMYMmg=; b=DL0HPwnVZWvMheAGGGJPagUs7dXzRgkgr1mzR9LEd+kM4f6VinpQ5Q90lSXEvJukST o4dNJ76TkmpL3DdK+R3FCiFN3fRzj2i0McvOHOkT1HQ/E2A3+u5LJEirQWDUrdcrUW7A eW/5JzQrYn6dScWbIvc5ZF/zoMHPDiLKcZPeUP/F1Zm+/npy5CSNkSi2Ze/MPNUyNO3a 2gPeELb+Mf90WQLoPxFLfBOLJ00TcKxcw9bCXaPdm5B0FG2hutwtflGrEOULtYNl5CYD eaHm/FOSzfKXUelxBwsvUmLGlSSDNybjbkTNwk8h1JRAKc/g3OVNpEIR+4SpVLhXNNtf Gw7Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JAPt+91f; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1388-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1388-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i13-20020a17090332cd00b001d7599ded36si6991438plr.31.2024.01.25.08.28.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 08:28:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1388-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JAPt+91f; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-1388-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1388-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 61C54297C3D for ; Thu, 25 Jan 2024 16:28:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 546C57762A; Thu, 25 Jan 2024 16:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JAPt+91f" 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 30D9673177 for ; Thu, 25 Jan 2024 16:28:53 +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=1706200134; cv=none; b=mnO9I7gnL1AYMAYZt4+5yYYbU62cRJureddVefo44CzhXE4bspFAlwSjY5HJRwX4joI38EMqguw7MTPuS83iHAndTEcOZBGC9DKYOCFBbwE0U4g26XcrIwHlH2F5aqI2PrxrFe5csJZ/luay1n/VlRNB3MoxZmZEre8vKmIqqLg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706200134; c=relaxed/simple; bh=ZirEQrrH2B9FdI5tnbQePr1bsGZg3ZHsZpBpGBgGRbA=; h=Subject:From:To:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XstthNJ89aS6vXfn7pdWMemgtAhznasvVWofSwxJY2R4Uo+7y1pyhYcqpxIATJRS1Y6rEw1tT+88i2EBqIR6sERrgI9Mg5jAOTLINrayJTHGiHLrSDJ3wjQf8Y+EeeW2K20+SDiBPMX9Dv3jCDwShFXu3PUbrvUR318H29hUuDk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JAPt+91f; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86370C433C7 for ; Thu, 25 Jan 2024 16:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706200133; bh=ZirEQrrH2B9FdI5tnbQePr1bsGZg3ZHsZpBpGBgGRbA=; h=Subject:From:To:Date:In-Reply-To:References:From; b=JAPt+91fi4pBOPlg9sM30YIdzdHn1D6m1HuOssoxG6sYFPZyCe7pw8UKq6nUSWj1/ mqqyYpky6G2mtDMYnYA5C/qZA/ZXXBaUYS+BbAWNcL66K2DaTI7rrIwZvjX0/584uy eW7DcYGVG34zXLLfAilMGngacNk9dSiEmTXnx7xS8fgOj/HQlFFJw7LEyYujAeApS6 JLZWyTENagGW7dw/UhmikKDI+Y3HXFPirxxaI6diZsqVIZblGw8fpz4MZmg+BssaId tBLyl01VK/n5U3BuIeF4VI4Tww7rFve/1z52G9wrT7x6bFq90TUUbBLBUjksZRgr/P Le0qur6WE26dA== Subject: [PATCH RFC 02/13] NFSD: Reschedule CB operations when backchannel rpc_clnt is shut down From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Thu, 25 Jan 2024 11:28:52 -0500 Message-ID: <170620013252.2833.10156142379669175540.stgit@manet.1015granger.net> In-Reply-To: <170619984210.2833.7173004255003914651.stgit@manet.1015granger.net> References: <170619984210.2833.7173004255003914651.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 | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 43b0a34a5d5b..b2844abcb51f 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -1375,20 +1375,22 @@ 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 would wait for the client to + * reconnect, but I haven't figured out how + * to do that yet. + */ + msleep(30); + nfsd4_queue_cb(cb); + } return; } @@ -1401,6 +1403,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,