From patchwork Wed Nov 27 15:28:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13887144 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3B0ED6ACE9 for ; Wed, 27 Nov 2024 15:28:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F5FE6B0088; Wed, 27 Nov 2024 10:28:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 37E486B0089; Wed, 27 Nov 2024 10:28:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D2566B008C; Wed, 27 Nov 2024 10:28:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F0D686B0088 for ; Wed, 27 Nov 2024 10:28:23 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A9975418F0 for ; Wed, 27 Nov 2024 15:28:23 +0000 (UTC) X-FDA: 82832256318.30.A82F732 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id 27EBB40007 for ; Wed, 27 Nov 2024 15:28:13 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uzrIQLw4; spf=pass (imf27.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732721299; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XmcVEnMjwO3f2OOD9E6Y0+hH6fL+F7ARSgj9E9galIU=; b=xXAKkNvBYu4ebOkIpBwlKdLaJg2iFfR2DDtCHcjAwyvorg/YEPrXbrVnEmjMq1LB6IqfKH mztVTCjs/S/+plrD2skma1ZshJoZUIsRtZB33bK4TlErSWhlaN3ZUXSGQkSwq1pcd6fnFK qk6fzO6X5XpVsgifWrKbMmPumIF8C94= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732721299; a=rsa-sha256; cv=none; b=7HhJhVS0CIHDZ29b1TKNdWN/T+w0FLddnQrtMbom1YImV0R02WhMg0/aLVY5fDIENOdGQH 0GWms+Q8otZlxe1Q7O4D5av8JUgt/gEyzRLaHSsLKta+DR3o5lxNuxs2PTeT0bA3EY/Gvh vlNFA5poKVzVKP3Y9wvzBqYIxvWf86I= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uzrIQLw4; spf=pass (imf27.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 015F55C313E; Wed, 27 Nov 2024 15:27:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49030C4CED2; Wed, 27 Nov 2024 15:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732721301; bh=aJTYjqVoUaXrqckTrck4WCU2AgH83lVUIj4TdCwyW2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uzrIQLw4Jw7yzpy6ZXPe3lXaRaa6goSV9ivXdsUM8ksj/HydQlqJ4WWkEW9MZGjVR CRD7v+S9HNCXHNrp+a7juwjqJsekk1Obmyr5Cyzkj+KTZdBnCF1e2gExkRo0BOVWEL bONFucLAdSkZqFjbtHRnET8KdeZObE4OQR6y19wYXVqAD8zeYxroq3WdLeFDdbRxji Ma0fzQcfCDBgZ9xqaBtb+Co2HcLC6ddaEpir81jYH6hHGhjAsD0+UFvM5N5H8fI1MW le88zehs5l7qVf4fAV15yWU+OoLIs8rNVNBBlyFnUQPxVtY9RLvCKOlxtJpJJd3uox uF/pVBAOV68Wg== From: cel@kernel.org To: Hugh Dickens , Christian Brauner , Al Viro Cc: , , yukuai3@huawei.com, yangerkun@huaweicloud.com, Chuck Lever Subject: [RFC PATCH v3 2/5] libfs: Remove unnecessary locking from simple_offset_empty() Date: Wed, 27 Nov 2024 10:28:12 -0500 Message-ID: <20241127152815.151781-3-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241127152815.151781-1-cel@kernel.org> References: <20241127152815.151781-1-cel@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 27EBB40007 X-Stat-Signature: n7sasw4n8i7pfkdtfnuddhaucs9wuwob X-Rspam-User: X-HE-Tag: 1732721293-99681 X-HE-Meta: U2FsdGVkX18azC7A+NQgqPE0LGgC3jTCb1NOuSrRwMw6UtVMX4H3x2nh/4vXUAOmj7BxhOSmEbfpQCDcNcBO0K8t9bU8vc8VfRqUi4KWV9ZmSZ9RUO+UyWHX1y6nsoRaZUHRKScoFRSq8XO4qCe205NwXAi8oyPw9XexGGdtEETIZ+/kP389Z1Su/gGpwZ6/a2wWDMUWnHAlBN79yhbxyV+4C9nvBJZ3tetrWRJL1gUV9VoiK80OUYVMGsTuZl89UwDpmpRD2hVyLKl3PCiI/fP2VS6C64B86DCa0rs9z98t93IQWxwMjj4ykSOrvVQaZYx8ecjlWgffYgd1qzVG1DZfbdD8wfPrXU0OThfijXsxvH2vEdgFsf5Z4p2FctmSmonpyouWIdjvkczIC44BxPnQSbiM5WcYkS+wKj6lAfvWyu5GXXJX49xdUSPcE7aSI5nSxa93gmiVrjmk7c8v8HgMylXxFMuv1aHW+voQ+NyvctxjJoUD+On/+FP4AAugoiRtL7Sltg/Krlc9W8cc8Malq6T/5ZyJEgpflnAotDleWlQRQdCD4vlCDpDG8sQhzkxxQMExcHNKlMNQ3fRr9W5k31n/X6R/JHAO1mdoFt95hz4NGETBAngUrFd4GVqAJV1XNBCWxEuqpdJ5OUeFed0k1vr9QsveOgIDiEG7nWiR0w+sK+6/887kBFNFxPOTR9DEJ4iXLiJbLENSM3guwdiHjhaIe2SWR5Mn0cQivjsnFH2H4moedRiCsXoIKXgSRi+RA87W7OH4vufXtkpezlqJlTO/q+E00tsoZtY3c2+bK9T8Ape2aS/6cJjsa0JoDqa74bDuyog9mO3LVbTj81wO4iTYivQzokPxHhC4yQWtwzCTZe2I3Uj4rJeLpriphkoVewmg7DxMbY0LF4hqakoSblLcMmccZ2OnYmQstRAAxsaAFgjXzdWoU1wEdIKsRoi3lHiW59/XZIvNPoD k84VF4fN Yl84Q8Vo2l7B547msG1nrrdslnR65jkfAlpJrUlEkktYn1tHrzdJci721klDeew184iaPecFPIVN4LgqP6caNLvsjhxew3xggT9AXY/N5z3vXwOL1IoKHmD11GFjayyolYoA6mf7eU9zdmevzvc1TJUfiBQLvrBeMfGFdtypaaLW3LfWGmfM0WbeXUruovU5956b/B83PRkekKL0yKfhSrgueW+HLo1CB0eoPzaXpDkXZzETxj5RLDlYu/4sM8k23cDp0DJCuTZHkZrMbb+OJrax19Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Chuck Lever I hit the DEBUG_LOCKS_WARN_ON() in hlock_class() several times during testing. This indicates that simple_offset_empty() is attempting to lock a negative dentry. That warning is of course silent on a kernel that is built without lock debugging. The simple_positive() check can be done without holding the child's d_lock. Fixes: ecba88a3b32d ("libfs: Add simple_offset_empty()") Signed-off-by: Chuck Lever --- fs/libfs.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index bf67954b525b..f686336489a3 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -347,13 +347,10 @@ int simple_offset_empty(struct dentry *dentry) index = DIR_OFFSET_MIN; octx = inode->i_op->get_offset_ctx(inode); mt_for_each(&octx->mt, child, index, LONG_MAX) { - spin_lock(&child->d_lock); if (simple_positive(child)) { - spin_unlock(&child->d_lock); ret = 0; break; } - spin_unlock(&child->d_lock); } return ret;