Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3469462pxv; Mon, 26 Jul 2021 05:03:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmOLzKVdN26085CdK0OPEGIvBN1zSFCsrSInfDGskL3WIT0BaEjtOvmYtyaNHIC3dMbmkU X-Received: by 2002:a17:906:24d8:: with SMTP id f24mr3264246ejb.2.1627300982829; Mon, 26 Jul 2021 05:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627300982; cv=none; d=google.com; s=arc-20160816; b=iIhPrxG4psh8nBycKON0EfsisM6bi3dWGWyyrbRTfmK+iYk+V475EziYxl8j4DckKK KaddTifurj/b3C7LqKriugBwHczAA8EIvIEJXgwFvhcIQP776eT0AiZAln/147cuo3lR MK2p5g2kaffr/tSSNBLJObsvDbrQY+1j8faO5NBxDvV+SznfhH/TKrXk4SzV/m5p6l3S 3IEM3v57cHtlwzVc1kVDNdlYi3hUA6kobygRySrqNPloUrBOMPZ347dDWAzLW4PlYbqe JVgUvEGsTWzmJ1wued/YKtFb/x85w8AAvzy0Eili9c3cTc8jI5wroF1iWb+RUgve7ss/ Xp5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=dSod8fG0sm3S8kBrvuWs9iJcj3fTwHvFqyP1qzzoIWU=; b=MZjCyFjQj7baRGuPozOK3M4WLzTmcy1rrbSsBbQe1MDVYdEAD8NPKAfEqzoX4wbGR+ mIE0RUraX6W5fj7bYLQS4ElX8HQreW60hxn0WFzr46r7u0NVZ6DGiw33Yw9/k22y8FRK h+rnVzpjK7I4WAI/GqO202wyxCJk0voV2wXJJxFdDJ2yuztCM+e97vR+6YANI4wL6Z9q UkekPQn7nCQLKXmxDZFQE/1Y/xCf363rgSR+uLhYwsWznHC6G7+wLQt06y8bItviydO4 hzWQDmoHV5Jqt8L1fhnTrLTM3vkkRbUpChblSc+/kCP1/H+3U5YrcNZjyAXAKpJ3rhk2 DUHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnu9H6IH; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eg19si33035096edb.391.2021.07.26.05.02.39; Mon, 26 Jul 2021 05:03:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnu9H6IH; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233821AbhGZLS6 (ORCPT + 99 others); Mon, 26 Jul 2021 07:18:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:37522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233824AbhGZLS4 (ORCPT ); Mon, 26 Jul 2021 07:18:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B7BA60F4F for ; Mon, 26 Jul 2021 11:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627300765; bh=0poQSGhZAIj00Xj+7V3yRetui+9NrotTiv9dLx9yQEg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gnu9H6IHxUIs96xdPWmnW4kMYY0gQmXGWN2OuXlWSddePQQa64VPVvNP1dz7grXHC RppT1EuLMfg2QuG/hL/xEkvZuM5p23F9NApdy859M5+CEsNZBGiyDYbxPnUj5DLije XYW9wYPXwt3YKOU7iETwuHvRAkvIuG0hqqjqEZ4Vt3G4W04eyvyX797dOEenZlUBIv pSo3c8jsHdqF04wo7NfTit8LO1JvynV3WwSl04pI7G1p+U4kw5fpCADhKN8PuasRYk yFwgM801D32kgsHeZjT5gYYe2Kf8+T3Dt7QsLsyfk+t8y5ohZCA+4eIWu24hM3sTY3 nmVFNg4XJ+KyA== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 2/2] SUNRPC: Clean up scheduling of autoclose Date: Mon, 26 Jul 2021 07:59:24 -0400 Message-Id: <20210726115924.8576-2-trondmy@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210726115924.8576-1-trondmy@kernel.org> References: <20210726115924.8576-1-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Consolidate duplicated code in xprt_force_disconnect() and xprt_conditional_disconnect(). Signed-off-by: Trond Myklebust --- net/sunrpc/xprt.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index bddd354a0076..aae5a328b15b 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -760,6 +760,20 @@ void xprt_disconnect_done(struct rpc_xprt *xprt) } EXPORT_SYMBOL_GPL(xprt_disconnect_done); +/** + * xprt_schedule_autoclose_locked - Try to schedule an autoclose RPC call + * @xprt: transport to disconnect + */ +static void xprt_schedule_autoclose_locked(struct rpc_xprt *xprt) +{ + set_bit(XPRT_CLOSE_WAIT, &xprt->state); + if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) + queue_work(xprtiod_workqueue, &xprt->task_cleanup); + else if (xprt->snd_task && !test_bit(XPRT_SND_IS_COOKIE, &xprt->state)) + rpc_wake_up_queued_task_set_status(&xprt->pending, + xprt->snd_task, -ENOTCONN); +} + /** * xprt_force_disconnect - force a transport to disconnect * @xprt: transport to disconnect @@ -771,13 +785,7 @@ void xprt_force_disconnect(struct rpc_xprt *xprt) /* Don't race with the test_bit() in xprt_clear_locked() */ spin_lock(&xprt->transport_lock); - set_bit(XPRT_CLOSE_WAIT, &xprt->state); - /* Try to schedule an autoclose RPC call */ - if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) - queue_work(xprtiod_workqueue, &xprt->task_cleanup); - else if (xprt->snd_task && !test_bit(XPRT_SND_IS_COOKIE, &xprt->state)) - rpc_wake_up_queued_task_set_status(&xprt->pending, - xprt->snd_task, -ENOTCONN); + xprt_schedule_autoclose_locked(xprt); spin_unlock(&xprt->transport_lock); } EXPORT_SYMBOL_GPL(xprt_force_disconnect); @@ -817,11 +825,7 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie) goto out; if (test_bit(XPRT_CLOSING, &xprt->state)) goto out; - set_bit(XPRT_CLOSE_WAIT, &xprt->state); - /* Try to schedule an autoclose RPC call */ - if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) - queue_work(xprtiod_workqueue, &xprt->task_cleanup); - xprt_wake_pending_tasks(xprt, -EAGAIN); + xprt_schedule_autoclose_locked(xprt); out: spin_unlock(&xprt->transport_lock); } -- 2.31.1