From patchwork Fri Jan 24 19:19:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13949890 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 08D29C02181 for ; Fri, 24 Jan 2025 19:20:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E29EE28009C; Fri, 24 Jan 2025 14:20:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DD9A4280065; Fri, 24 Jan 2025 14:20:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDD5528009C; Fri, 24 Jan 2025 14:20:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9F3F7280065 for ; Fri, 24 Jan 2025 14:20:03 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4E5CF141739 for ; Fri, 24 Jan 2025 19:20:03 +0000 (UTC) X-FDA: 83043310686.12.3E4CF7D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id A85EC10000E for ; Fri, 24 Jan 2025 19:20:01 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q306l4ws; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737746401; a=rsa-sha256; cv=none; b=mKr2samOqISzG6Fvgn/Kjwhs7FgsTnTB8LAIINj4b3stpMW8BvKS9QqaXS5Tknt9ZIFg0D kO7U4EiciR5FlpNgrwfbtQJxw0dKuSClxsiXI5gn2LQkovvEuDhRAn/66RaqJEFpzhfrlL 5SuP+x4zoiRKR8OOZxEqBmhZrsudu4I= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q306l4ws; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737746401; 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=BWSo0jNo15W5sZXDUrOELyAn1gO7K0iZELRReJKqbnU=; b=u40YynCtAS4f7fmlyaZc3Y/axPEOW1oyv9/SGJoFrDss0N/yHqbVZBv2ZNPnrE4erdq5pY YFZphiFwxmvXOWwn5ygPDhxr6YAeynauqDWwix/dPCt2Np2M6UiZDStjQX0sfRiLOW0qcB eJJUf2ylwGywgU7xeMTSV8brBZL8RvA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B2B905C6195; Fri, 24 Jan 2025 19:19:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1325C4CEE3; Fri, 24 Jan 2025 19:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737746400; bh=7i8ieMEYnSbXE7wG5048yyfg5P+RPVEiCcn7OJpp8XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q306l4wsGt82CKQzJvzhCo3HcT3FOVHMDa4ucpXOi/awls8OhBeRzHF/cvjCiN/es TpjuBhJs8QKINqg3tPofapF/U7S59qv64UiRwDNps4Rn+6oEbcAONf+scmmvYG4mNe nEfrbvG9XNRWRWNLjoXHoBtXHpu3kAhE8RFN1bOacH8yxGWMfvwNggTrD4lUdBPv7R k31E1KBrrisj3Vo0UfhlGhwQ+3t7EgN9Z674QXx6Ss2S9DM6gYboYkLaS+pHszU2ih mNVa3Qn5iyQh7toBcbBlE15mLKn9yoHQ0DU2Z4aNaTrgOz0Ur0D6WmjFylrTUOtK9n 4BS4b24PehbQQ== From: cel@kernel.org To: Hugh Dickins , Andrew Morten , Christian Brauner , Al Viro , Greg Kroah-Hartman , Sasha Levin Cc: , , , yukuai3@huawei.com, yangerkun@huawei.com, Chuck Lever Subject: [RFC PATCH v6.6 08/10] Revert "libfs: Add simple_offset_empty()" Date: Fri, 24 Jan 2025 14:19:43 -0500 Message-ID: <20250124191946.22308-9-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250124191946.22308-1-cel@kernel.org> References: <20250124191946.22308-1-cel@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A85EC10000E X-Stat-Signature: w3iirxfsdgfpahe48b7sgng5t34zm9gc X-HE-Tag: 1737746401-3359 X-HE-Meta: U2FsdGVkX19YU8toJPmr7MvqeDOrhxzSymMWoW8Iw5MWJFssI9ytQJWT8b0gAK5oXwdbw6f60NRfMNYsaVA7RxQUA0JEGfWrIlKOP4zBrphb0dfEI9DjrDqFacskufZ63r0Bw6pdveLrX0woqoLY2UNhI9CmLsM6YdDxulf1TyZw/KEKMrxabx1Hf9Pa1OGLtnNWflIRt0GOXS1zX0aYP5OMxuNX65Tgr5tJNUSNSFwbKx5hPp6S5FTEBqNmfTRZFabWku+oPwYuAKWclVyQp3o3omy5fqBcDuDPemeZCXAvbn/dptDjPQ9fLGuyxzsDqcx46fHilEOS8IzA9E0+cFEmkP1lqxmHiU2CG2SQe5eqsRtVu2w4QlY9DJO1Payp/Am5SlwF7d4QqKpqZAUF1udo857DuqGuAzRvt8gi6eRQdPm3H7tH8Mx3rhwOBzY+HF76gIsKjnbLtv9nemjEKRriPM9eDgEIaqRHFWKpN5Dx4LbJoD5NwSuhBLJxtn0ZuSoEqk5puYVdLRAcwX4PtFDxnF8Tdzfw0mrmciLdpOFrPop774i0Bj2lAtUG5f2Eem47pr1eLjkBHnx++MmezbSIZywwFP71boHvzhEmqJ78wIB1dFpIT1OSDWE5sr/wc/ZP8Sq4KesPHrD8lL62RghyJrVbgh15lMuhXfQChNtdZwaHse8N4rLg5Eg3iIxKym/HKSKuZpFBlsbxwjwWH0E+Cx+PyNKRREp5/rKpprff9Ea/RIC6rQEJYoQARvBvwkX7xGMyvTKq6XMRRhQ500rEt8c+lXVeeSJcD5/HG4FUS3JizJtPVwkp79DB2KzIUgvsBwDYI/rHGdwey1H4DhmBmd3epMj4SsY6mpzRjA6Fh/J7om2TIL4ifnzk9LSR0lltiavam6RE/XGOtM1pTQTxwtiNnvvOSTtf5roUqYct1ucAVOcnvPdU4hvao0Wpz21w9UBehx2HoWlciY2 ngyMTiVj 0N5B7Ziyw9ODponJ7baasNq4y40ZvbtOFgXwIHonpPdtVGzgppj4dXNp3AnjlAPQwk+WhKN92vF9Dcf/NopD2ktNGHQy3AJPxq4wm4Y+IsEcX/gNlvfh6WG1bZ8E9Cl1B76m1dB6kiodStt2XPQNFDenhAzYHPYuG/uW7965Kdu7l5Vs/niPnnpvMU7/ptoMze2z09M/1pnehQClHonpbxeQXgLgE2TDcIiPrLAJz/2sgO3eGClIOFhiHW2Zv3sE/VfX69B/mn1g3p6v1V6GBVaNiLA4YDdSC8L82D3kR19ANnKkJWD473MMVfF8a1leXQgpfx/M40/Smz98= 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 [ Upstream commit d7bde4f27ceef3dc6d72010a20d4da23db835a32 ] simple_empty() and simple_offset_empty() perform the same task. The latter's use as a canary to find bugs has not found any new issues. A subsequent patch will remove the use of the mtree for iterating directory contents, so revert back to using a similar mechanism for determining whether a directory is indeed empty. Only one such mechanism is ever needed. Signed-off-by: Chuck Lever Link: https://lore.kernel.org/r/20241228175522.1854234-3-cel@kernel.org Reviewed-by: Yang Erkun Signed-off-by: Christian Brauner [ cel: adjusted to apply to origin/linux-6.6.y ] Signed-off-by: Chuck Lever --- fs/libfs.c | 32 -------------------------------- include/linux/fs.h | 1 - mm/shmem.c | 4 ++-- 3 files changed, 2 insertions(+), 35 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 200bcfc2ac34..082bacf0b9e6 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -324,38 +324,6 @@ void simple_offset_remove(struct offset_ctx *octx, struct dentry *dentry) offset_set(dentry, 0); } -/** - * simple_offset_empty - Check if a dentry can be unlinked - * @dentry: dentry to be tested - * - * Returns 0 if @dentry is a non-empty directory; otherwise returns 1. - */ -int simple_offset_empty(struct dentry *dentry) -{ - struct inode *inode = d_inode(dentry); - struct offset_ctx *octx; - struct dentry *child; - unsigned long index; - int ret = 1; - - if (!inode || !S_ISDIR(inode->i_mode)) - return ret; - - index = DIR_OFFSET_MIN; - octx = inode->i_op->get_offset_ctx(inode); - xa_for_each(&octx->xa, index, child) { - spin_lock(&child->d_lock); - if (simple_positive(child)) { - spin_unlock(&child->d_lock); - ret = 0; - break; - } - spin_unlock(&child->d_lock); - } - - return ret; -} - /** * simple_offset_rename - handle directory offsets for rename * @old_dir: parent directory of source entry diff --git a/include/linux/fs.h b/include/linux/fs.h index e4d139fcaad0..e47596d354ff 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3197,7 +3197,6 @@ struct offset_ctx { void simple_offset_init(struct offset_ctx *octx); int simple_offset_add(struct offset_ctx *octx, struct dentry *dentry); void simple_offset_remove(struct offset_ctx *octx, struct dentry *dentry); -int simple_offset_empty(struct dentry *dentry); int simple_offset_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); int simple_offset_rename_exchange(struct inode *old_dir, diff --git a/mm/shmem.c b/mm/shmem.c index ab2b0e87b051..283fb62084d4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3368,7 +3368,7 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry) static int shmem_rmdir(struct inode *dir, struct dentry *dentry) { - if (!simple_offset_empty(dentry)) + if (!simple_empty(dentry)) return -ENOTEMPTY; drop_nlink(d_inode(dentry)); @@ -3425,7 +3425,7 @@ static int shmem_rename2(struct mnt_idmap *idmap, return simple_offset_rename_exchange(old_dir, old_dentry, new_dir, new_dentry); - if (!simple_offset_empty(new_dentry)) + if (!simple_empty(new_dentry)) return -ENOTEMPTY; if (flags & RENAME_WHITEOUT) {