Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2116209ioo; Mon, 23 May 2022 10:24:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuYXRDJb3TX/FXwF9rD2fmYDzMBK8bPvQJVAOIVh67qb0u1b3zPkAmkjayI+E2wsAkJ6bg X-Received: by 2002:a17:903:310a:b0:162:3809:a002 with SMTP id w10-20020a170903310a00b001623809a002mr1727698plc.5.1653326647426; Mon, 23 May 2022 10:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653326647; cv=none; d=google.com; s=arc-20160816; b=nN1ZWGfK7bXKfJICWVwwgjDMyPUivArN8TnjmnBkku/Z408ObQyICU/RmBNUdtjGpe 2Oy4kENbcyWcU9EdkordlryU5hRIP4LEFq9HKCowjBjuUvb5puZeZcHOmcBKLZlaIG+m C2nH0+qd0xmTttA+sZr7olf9qyD9chohq/hXOp43/df/j7UF/HplHc5sDWw+/ezDrCGN eGEMf1N+1ahEzEWIz63h3WCzvP6M5Y8+FnvefQ7n6DyrPORYi3+fGKi4xUbSz1gKWYwh Xk03XyDJ5/wy33hbRB/65Ua8fA+8Lqrf0nj2Xt/il6SnWPAJlMp8HHwLL6yCrpuV0S2O e6fg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tONO/tXBovsN23dCtapvkSxYGj/Z7oUyZaGPv/yXJ9Q=; b=yo/VQzJI2kPlGqCLdg97/Ec+QPXCmbaBotfcO3hn2Nno5g2m52PHH2FtibOYAq5mdb CVBxPUaiWt76ENq3Tj012K9W1B9M+7ZqmjPQ1u3R1EEF+ppXKBHrMZcdmYfM+B81ZcG6 Q5fhwH1CTKdrXwU8nOCDd/8M64nTl9erVY5QxPbahXG8VarqhOvqaMprySt26MJNfkBb zF7GP7GRcW7G5TXYXXs4byvhC2OG7k5fRtK9txpYHSMPL3zoExadPaY7x+aX8HEr6erF GX+D+LRYCCvxB8Y5jwolv1K4kLNcCQxLYGb2IT44MjjX18+DM8ZKsg2Kn3tYhghDbLUk +/ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=01FWANk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ot4-20020a17090b3b4400b001e02e0b20e6si8768480pjb.75.2022.05.23.10.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:24:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=01FWANk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27B87819BF; Mon, 23 May 2022 10:23:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240522AbiEWRSR (ORCPT + 99 others); Mon, 23 May 2022 13:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240142AbiEWRP0 (ORCPT ); Mon, 23 May 2022 13:15:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DF3211A03; Mon, 23 May 2022 10:12:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4E340614E5; Mon, 23 May 2022 17:12:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35BB8C385A9; Mon, 23 May 2022 17:12:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325959; bh=lIwMAvvut7ndMdEen037betf53Ozq/OmMdPtw0ev+Jg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=01FWANk4q/ewHhX4GVQ21cpxh/aGwhFTmR3F+q8Uup4Iv9yaBfDwNnvkIIjUmoeWa wzb993GJVgBlFej8AbMuYmeS9qmcgyV0FsIQt/om/YAdnBGFkfyk4IjGbHuyRyIH6m GUbDCYErkmgdE+skEVwEPWltd3sR6FzF6+MWBj3Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Trond Myklebust , Anna Schumaker , Meena Shanmugam Subject: [PATCH 5.4 22/68] SUNRPC: Clean up scheduling of autoclose Date: Mon, 23 May 2022 19:04:49 +0200 Message-Id: <20220523165806.308236890@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165802.500642349@linuxfoundation.org> References: <20220523165802.500642349@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Meena Shanmugam From: Trond Myklebust commit e26d9972720e2484f44cdd94ca4e31cc372ed2ed upstream. Consolidate duplicated code in xprt_force_disconnect() and xprt_conditional_disconnect(). Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Meena Shanmugam Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/xprt.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -717,21 +717,29 @@ void xprt_disconnect_done(struct rpc_xpr EXPORT_SYMBOL_GPL(xprt_disconnect_done); /** - * xprt_force_disconnect - force a transport to disconnect + * xprt_schedule_autoclose_locked - Try to schedule an autoclose RPC call * @xprt: transport to disconnect - * */ -void xprt_force_disconnect(struct rpc_xprt *xprt) +static void xprt_schedule_autoclose_locked(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_force_disconnect - force a transport to disconnect + * @xprt: transport to disconnect + * + */ +void xprt_force_disconnect(struct rpc_xprt *xprt) +{ + /* Don't race with the test_bit() in xprt_clear_locked() */ + spin_lock(&xprt->transport_lock); + xprt_schedule_autoclose_locked(xprt); spin_unlock(&xprt->transport_lock); } EXPORT_SYMBOL_GPL(xprt_force_disconnect); @@ -771,11 +779,7 @@ void xprt_conditional_disconnect(struct 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); }