Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2942372lqt; Tue, 23 Apr 2024 06:28:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAQSMmTzqLMpkKeIWzdC8DURwixx3aMBFR7v8oVgW3J0DoeopDnnlrmuS/WOZnNqOjo2Hwbh2845hiqZfBSeQ7Bxcd3cMpRhArfCOXbg== X-Google-Smtp-Source: AGHT+IHnbLqZKB+9YcDe1uNeGk0rdQ6yqk8VRuq1YBvdF6RyfjgSwg+42GTl/gGSy1EJNOM8egoF X-Received: by 2002:a17:902:8c8f:b0:1e2:538:a063 with SMTP id t15-20020a1709028c8f00b001e20538a063mr13060848plo.33.1713878936749; Tue, 23 Apr 2024 06:28:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713878936; cv=pass; d=google.com; s=arc-20160816; b=vrdY5qg+PK6VrfBnmJuLRzeSfo0Aa758WI/qvroIu69X0eO2JeGJLYxTtEeE8x0lq2 5hJ5e7XoRxYavktdm9QIHUImHapumxf0mTV2IuwDBsNGXLvZ8Y7PHFdh/6jQ8m259CHI kyk3Qrr3PqYZ94IG0SnLzyxAxa5up+PXmpkiFe2BxU28ctxWyTvM386lqXMeBZaKyPHi JOyqqVBO1K8S+/3zK9YwQnj26asxnSlg4j8hA3q9jpJWn5EL124gr2izKHsTzzv72WDI zLsFrqhsYL97n0TiVatDfCxnGpY1new9ekJuMy17QpcEWwu128kxUFGGh7A+EYhs+QQ2 2SUg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lsGheym7FuhRMk/n+HVwj2q+jYS9tccVhVhQuL+88Kg=; fh=DMCDS8gUzVrNgxbf14gHb/h+T7HG77KdNqMH/8ibnkw=; b=nCbS9o5ryFGWosOV3QtrTqukZnUquELLnR/UtWB/9AVXc/xojGpSWEPnZjHcsnjlz4 dlzMDn2kH/kyAtUkCssVguoyw9PGyz3UGSHm9ppAWexOqSXJR+/rHwRte8OD7tneSSB6 ygcUrksbVSiokkW3ciXjuyivacSToSgHTi+qk1IiIIaPYQrlejlbU9r001dUklOcawwv Qy2leSrBsSx3uSMw/leZxn9l7W1nC/st1ss9pFCUIiujouw52HGM2Wqcr3n4/c8gCZcR T24Hd7weCxxJFCs/yjdqyIpYde740MRWeep6PbIhvGS60GgOPO3ibE2/92fRxM9EKtZi iyTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mpubW2hW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-2948-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2948-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 j4-20020a170902da8400b001e41c66599fsi9617210plx.478.2024.04.23.06.28.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 06:28:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2948-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=mpubW2hW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-2948-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2948-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 368DC28977D for ; Tue, 23 Apr 2024 13:26:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78592135A72; Tue, 23 Apr 2024 13:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mpubW2hW" 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 4EDEE135A61; Tue, 23 Apr 2024 13:26:01 +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=1713878762; cv=none; b=idVutmWyejwtCxtwlsAn16GsSQQ4tGPs99rLcMv2mHH6creId7NzfAXtNIZovAynSoh9TKWd1MF8njj6Y1bf3l8eWXSHQLz84rE1o8GGvMx6+9NLTNv4cN0mC9emSbRnfX/M7UUghaiJnP0MiJXGDiPPeCb7U8+4Nu8rUozpkZI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713878762; c=relaxed/simple; bh=iUOGaXIug4vVksYxq6UGEyNm1YHFXKBHVAIoC3dovGs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l2BW3bZJ6f+rM5V+BQAUBZxSsxpl5hTckL7ad00M26eLfDvwbpdRkiKZ5fpZGMo774RVtiZyJsoMjJEVQ/dsdHD7g42xft5LjH+8/JMLS7PuCzr++kQncrweYeZwluwtp4TWuMMNVX4gPDw+6qUIgIWJMi6nvHYxnW4YBpiNHWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mpubW2hW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CE5FC116B1; Tue, 23 Apr 2024 13:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713878761; bh=iUOGaXIug4vVksYxq6UGEyNm1YHFXKBHVAIoC3dovGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mpubW2hWMUv4A15ebPz2+bRWpD6pUqsHyNthHJ2Qrqk3gxmCq8OIf3B3gE+AFe7Zq Euc5jcPB+925yk3wJlGL+IC+ftvvczO38mRNROtuoM3a6kEDWwFbxOe0AW8od3rUt7 QxktaJNcX/PgNHThNGKNvhRaNssusoKh6xC6B25yGvX93FiwvcNCE37PimrZLLXrcy 4qPYpjrfYlztRwwMYluQ7CROgeFsBZZncq6TEamH2abZDq0GoQA50cjtzVl7q/C42H kRYltj45KJFyNgh+G+VH6Gc/h7CWEIf7QKQJXuiJOs69nXXlQBR9TyzlQhjzOAUo/P OR5HG5J+lcgAA== From: Lorenzo Bianconi To: linux-nfs@vger.kernel.org Cc: neilb@suse.de, lorenzo.bianconi@redhat.com, chuck.lever@oracle.com, netdev@vger.kernel.org, kuba@kernel.org, jlayton@kernel.org Subject: [PATCH v9 1/7] NFSD: move nfsd_mutex handling into nfsd_svc callers Date: Tue, 23 Apr 2024 15:25:38 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jeff Layton Currently nfsd_svc holds the nfsd_mutex over the whole function. For some of the later netlink patches though, we want to do some other things to the server before starting it. Move the mutex handling into the callers. Signed-off-by: Jeff Layton Signed-off-by: Lorenzo Bianconi --- fs/nfsd/nfsctl.c | 2 ++ fs/nfsd/nfssvc.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 340c5d61f199..2fe78b802f98 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -404,7 +404,9 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) if (newthreads < 0) return -EINVAL; trace_nfsd_ctl_threads(net, newthreads); + mutex_lock(&nfsd_mutex); rv = nfsd_svc(newthreads, net, file->f_cred); + mutex_unlock(&nfsd_mutex); if (rv < 0) return rv; } else diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index c0d17b92b249..ca193f7ff0e1 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -775,7 +775,8 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred) struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct svc_serv *serv; - mutex_lock(&nfsd_mutex); + lockdep_assert_held(&nfsd_mutex); + dprintk("nfsd: creating service\n"); nrservs = max(nrservs, 0); @@ -804,7 +805,6 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred) if (serv->sv_nrthreads == 0) nfsd_destroy_serv(net); out: - mutex_unlock(&nfsd_mutex); return error; } -- 2.44.0