Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4062191rwb; Mon, 31 Jul 2023 00:02:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlH7soZeCzEkqfjvaFVqwrDZLEdi0MMMdRDut4iRljgDHmr6JAJMtv50r/E2TGQ75Q07gu9o X-Received: by 2002:a17:907:e8b:b0:988:d841:7f90 with SMTP id ho11-20020a1709070e8b00b00988d8417f90mr6070316ejc.27.1690786966020; Mon, 31 Jul 2023 00:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690786966; cv=none; d=google.com; s=arc-20160816; b=jrVlyoTHI5MDUONwE1awffeJ8BUJzW5YdfNeipcPPCq4BAlUo3M0LFC4SwaZgz/OCC Fokl4QSIbK9ReDtN42HXJmdzoxR6PQjmDBylIg4Ij41A/xCXpzUW14hxzbXj9GIeqrVg V50kFgdYVfi5ZIVGNh2HfsrSqX/hchiVk2vfjUxwLnQnZnmc1tVlkxWhiJ90TNnJT1/P shhf3vmA03K6S/hZJcQ7g9dCpib/A2HE9bGu4NIcMaRHimvD5mvnprgvhLzsm6UiD7BB xthx2XDKFmxLOHtqktw0fJFVNPUfUHkxDhCNEJp+bPwTQ6kf2F8M+2XzwHUvFuTHE6lz srTw== 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:cc:to:from :dkim-signature:dkim-signature; bh=aUoIN+bi6OHz8LNJYb3xb9EMGlBqAwyg+UUoyZPhaCw=; fh=BG1K0WrNCDl2IiSLnDtgJLHPQBaNsmsTJjqgDAImPg0=; b=ES2KiiHWuQDEKXWhLfhipfHalROvcZ/x5ON3xuroZOF1ADhp/ChhzVKO+zvvU6Qz4x YHj1dhv7E2PmBg0jH1QMJEN+OEEYoH/3xZGPXXys16IONYzIa18RRsQ4IhlWOdAc8JDF fJggbFp+BrcmxOQNRD1Lo3zfscC892ENDk16g0AOT3Y8qPZ5/jq4Wmnn8aKqfgdlAd1H 6Ws68mQUIoVSAd1XzZApBS3bW9u0q843RfI2LJxO7oF+Vd1o3PtKFFMNFyk3gMhG3hFK cwvgCVhT5sG2DDjmUY/qpX7Iwl237TeguJKhJ0NUYJja4LMVhOiZ5loC6VcUk9TPTjjl uNBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=oXGeaw6E; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q24-20020a17090622d800b00997bd42d213si6605195eja.165.2023.07.31.00.02.18; Mon, 31 Jul 2023 00:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=oXGeaw6E; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbjGaGwE (ORCPT + 99 others); Mon, 31 Jul 2023 02:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230289AbjGaGvw (ORCPT ); Mon, 31 Jul 2023 02:51:52 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3117510EC for ; Sun, 30 Jul 2023 23:51:40 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E5B501F460; Mon, 31 Jul 2023 06:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690786298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aUoIN+bi6OHz8LNJYb3xb9EMGlBqAwyg+UUoyZPhaCw=; b=oXGeaw6ERXDHFuNCqUSJh7NHr0RrL/bqW278uYzQzb/yq7pNQSmC6kTTB+877nMaOWqnIG uwoCNlw31WPBU/GWw12szWeIr9qmsdF076btcPywqtyVMukEJPL7K2Y2MvcReB3tYB+BnM 2vBMEvp81dvimE2TMMTNXp5StkmgLRs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690786298; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aUoIN+bi6OHz8LNJYb3xb9EMGlBqAwyg+UUoyZPhaCw=; b=gN4PApoi3/6zMowT9mPY/zZQf2NOdNCnwWuD+vvMPcSevdiZDWDdFm0qwS+E42040I2rR4 Yyrd1sCydMEwGbDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A4F4B1322C; Mon, 31 Jul 2023 06:51:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Fi3XFflZx2SzbwAAMHmgww (envelope-from ); Mon, 31 Jul 2023 06:51:37 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org Subject: [PATCH 04/12] nfsd: Simplify code around svc_exit_thread() call in nfsd() Date: Mon, 31 Jul 2023 16:48:31 +1000 Message-Id: <20230731064839.7729-5-neilb@suse.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230731064839.7729-1-neilb@suse.de> References: <20230731064839.7729-1-neilb@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-nfs@vger.kernel.org Previously a thread could exit asynchronously (due to a signal) so some care was needed to hold nfsd_mutex over the last svc_put() call. Now a thread can only exit when svc_set_num_thread() is called, and this is always called under nfsd_mutex. So no care is needed. Not only is it the mutex held when a thread exits now, but the svc refcount is elevated, so the svc_put() in svc_exit_thread() will never be a final put, so the mutex isn't even needed at this point in the code. Signed-off-by: NeilBrown --- fs/nfsd/nfssvc.c | 23 ----------------------- include/linux/sunrpc/svc.h | 13 ------------- 2 files changed, 36 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 82e272707d2f..33a80725e14e 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -982,31 +982,8 @@ nfsd(void *vrqstp) atomic_dec(&nfsdstats.th_cnt); out: - /* Take an extra ref so that the svc_put in svc_exit_thread() - * doesn't call svc_destroy() - */ - svc_get(nn->nfsd_serv); - /* Release the thread */ svc_exit_thread(rqstp); - - /* We need to drop a ref, but may not drop the last reference - * without holding nfsd_mutex, and we cannot wait for nfsd_mutex as that - * could deadlock with nfsd_shutdown_threads() waiting for us. - * So three options are: - * - drop a non-final reference, - * - get the mutex without waiting - * - sleep briefly andd try the above again - */ - while (!svc_put_not_last(nn->nfsd_serv)) { - if (mutex_trylock(&nfsd_mutex)) { - nfsd_put(net); - mutex_unlock(&nfsd_mutex); - break; - } - msleep(20); - } - return 0; } diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 110f4560be38..db3de4ea33f9 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -125,19 +125,6 @@ static inline void svc_put(struct svc_serv *serv) kref_put(&serv->sv_refcnt, svc_destroy); } -/** - * svc_put_not_last - decrement non-final reference count on SUNRPC serv - * @serv: the svc_serv to have count decremented - * - * Returns: %true is refcount was decremented. - * - * If the refcount is 1, it is not decremented and instead failure is reported. - */ -static inline bool svc_put_not_last(struct svc_serv *serv) -{ - return refcount_dec_not_one(&serv->sv_refcnt.refcount); -} - /* * Maximum payload size supported by a kernel RPC server. * This is use to determine the max number of pages nfsd is -- 2.40.1