From patchwork Mon Dec 16 14:21:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 13909828 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 258A5205E35; Mon, 16 Dec 2024 14:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359140; cv=none; b=UY8a32cbeBO98LcBz0hBJSjMLYN+b8bjgVqb/BzDy8/Zb+szkU5GWLBhqp+4uuHfLFZeCpTym388iIJUFwRPNaQsMZTrRVY4gPjyxp+flLMBlBv2jbrdVFcyVbFFa8W2r6ckTrQ3UWQR9puIHsIMPVMhMo0DzOiVrUTdtKVPNK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734359140; c=relaxed/simple; bh=Oa9jTFJpDS70NNm0uKE7MLck7hu3NZ80+BUyi2jnz04=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EJ18YsedDxn2il5+8e5hYDyAVQuGjpEpqduBh5kpEPG+2iXmA6b4l1QumtNB219hh94WQAPISvcjA67dROx7nQqtRWBmcEYIsGjq8ZQmaQvGonIRqbDscHXwdPpxj65uo7tj4SMi8GN1EiXms0CyxWdI0EME8L9Y8+I+af6JPuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4YBhzt2wFrz4f3lW3; Mon, 16 Dec 2024 22:25:14 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id D9B2A1A0194; Mon, 16 Dec 2024 22:25:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBHIoZXOGBnSTcXEw--.14700S7; Mon, 16 Dec 2024 22:25:34 +0800 (CST) From: Yang Erkun To: chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, okorniev@redhat.com, Dai.Ngo@oracle.com, tom@talpey.com, trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: yangerkun@huawei.com, yangerkun@huaweicloud.com, yi.zhang@huawei.com Subject: [RFC PATCH 3/5] nfsd: no need get cache ref when protected by rcu Date: Mon, 16 Dec 2024 22:21:54 +0800 Message-Id: <20241216142156.4133267-4-yangerkun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241216142156.4133267-1-yangerkun@huaweicloud.com> References: <20241216142156.4133267-1-yangerkun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBHIoZXOGBnSTcXEw--.14700S7 X-Coremail-Antispam: 1UD129KBjvdXoWrZFWxJF1DZFW3Zw48tw4ruFg_yoWDZFgE9a 18W3ZYgw45CFnxGw1akws8tryUua9F9r4jqr4rKFZxKry5trykKryqyrs5XrykuFsY9Fyf Cr1DCw1Fgw4a9jkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbkAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWwA2048vs2IY02 0Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7 AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE 2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0x vEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIev Ja73UjIFyTuYvjfUO_MaUUUUU X-CM-SenderInfo: 51dqwvhunx0q5kxd4v5lfo033gof0z/ From: Yang Erkun rcu_read_lock/rcu_read_unlock has already protect any ptr we will reference when we call e_show. No need get cache ref. Besides, exp_put may drop the last ref for cache_head, and the .put like expkey_put/svc_export_put will call dput, which may sleep, and this will break rcu protection. Fixes: ae74136b4bb6 ("SUNRPC: Allow cache lookups to use RCU protection rather than the r/w spinlock") Signed-off-by: Yang Erkun --- fs/nfsd/export.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 56002d9ef66b..1c795dc5a74b 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -1427,15 +1427,9 @@ static int e_show(struct seq_file *m, void *p) return 0; } - if (!cache_get_rcu(&exp->h)) + if (cache_check(cd, &exp->h, NULL)) return 0; - if (cache_check(cd, &exp->h, NULL)) { - cache_put(&exp->h, cd); - return 0; - } - - exp_put(exp); return svc_export_show(m, cd, cp); }