From patchwork Sat Dec 28 17:55:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13922480 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 C7A9DE77188 for ; Sat, 28 Dec 2024 17:55:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C6966B0085; Sat, 28 Dec 2024 12:55:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5762E6B0088; Sat, 28 Dec 2024 12:55:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43D4A6B0089; Sat, 28 Dec 2024 12:55:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2AC5C6B0088 for ; Sat, 28 Dec 2024 12:55:33 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D0C321C7E8B for ; Sat, 28 Dec 2024 17:55:32 +0000 (UTC) X-FDA: 82945119600.28.C4F3734 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf22.hostedemail.com (Postfix) with ESMTP id 34E56C0006 for ; Sat, 28 Dec 2024 17:54:45 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QkZyB+e+; spf=pass (imf22.hostedemail.com: domain of cel@kernel.org designates 147.75.193.91 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=1735408501; 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=lbnYaR4UZV6QkJ0pgjBsR9slp6cAjdYj0RwFEqEJK7E=; b=bxrBtfDwu1EtSAabN8lzrCT4+qkM0r6EMwDgiHxVpLVzaJCWyxmSzt5oO9q/RdU4Upa/lS n/Mk4pm67VUi9jO/Tw0XnO6vgvugXWtOXH/TvV79GsNKwq5ZIrzIEjg4+ifIfGVq6uDO0v eUy7GnbvvVWOa3YTREYUZe9DXDsRVKI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QkZyB+e+; spf=pass (imf22.hostedemail.com: domain of cel@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735408501; a=rsa-sha256; cv=none; b=ILT9VeEo2fB4drMmKgS/gy3tgxlM9kMcl/rNU+P/y9ETHQdk0C/TAMoLiBZmI/VN+zVtHH 8soHoJHCAl4GgmYWpDKnXaom7AHy8PSF1HPfG8nb7b3jeROZTVNLJmx+wY5Ssx2/n/qVkb jHlG4uvlWmLmMCOd03F5urayUcmAuq8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id C5E06A406D8; Sat, 28 Dec 2024 17:53:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5054DC4CED4; Sat, 28 Dec 2024 17:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735408530; bh=WTZSoNUmlpCr3xI8k1Ogjd81zfFoaOgkluDOdOMlomc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QkZyB+e+oXkkoiHfk2e90Exd3floAYt11DNoTBTvESvt94QQxkC2Teg8+ggq+xFly hh6n3Io4qJeO2eJVX5/oiBoIaxWwI02BBTFu5hPJ9BIyXL5O7WhzGYEuAG5/7DjY3g 00G1EdCX5yStiA+UmPqSLYUoZhviIviS79CEIjDM8eXfWkIhl3QZuys+KfLNEKduK5 r7pXgWrri3WFqa68vMdNuqQyRDNbj/P1mL2CpqIKBpOR9iVmY2GyKq6LW/KawYnc2q x9NRV17i8nJIEKHRy990w/ibPDPP0H73lUGAZxny5q4qBC7LIs3xDnfBu4mt7EJs9o UaUDHrVVugSsg== From: cel@kernel.org To: Hugh Dickins , Christian Brauner , Al Viro Cc: , , yukuai3@huawei.com, yangerkun@huaweicloud.com, Liam.Howlett@oracle.com, Chuck Lever Subject: [PATCH v7 2/5] Revert "libfs: Add simple_offset_empty()" Date: Sat, 28 Dec 2024 12:55:18 -0500 Message-ID: <20241228175522.1854234-3-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241228175522.1854234-1-cel@kernel.org> References: <20241228175522.1854234-1-cel@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: sknn5axfupt9sxc6mayd1f3dhxemm9ig X-Rspamd-Queue-Id: 34E56C0006 X-Rspam-User: X-HE-Tag: 1735408485-908467 X-HE-Meta: U2FsdGVkX1/XC7sNW9FiBCYNCxSNtu7g4jz0u+89CskxjxfSf3p5YagbhD+8S3troIsS6Vgji+8fy9m9IO6lqrQ5sgnTXUlJGLPdr5DpIYf9jebjLKyEzPc7UGq//rSQufjPVp2ei++Een7cuUbR2cNq2RQa27qfX4LqmvbGzruW6vYVJUbkkQS/VbsCH/80cga+blWTrpoFh14bqQuPJh5FwKqTj/r+OXpHShHIzDyZwIJRjQoG04eU1uQlGo0Mounwwk8ocUCfolDgnR+QSOHLYLlwFVOKXPDxQsjCigt6QkUBMf95baAbPLOjBK8GxVwcd28fsVZQTL057/xIM9zHKsfZC4D3PoaHX4mGFQN4QJPQEJEG+DXUVqRu/xky9liQxvJyOC5vVoOemyEo1238mwf52VucdAyCCrIAlDQsjCsFHK/ExbCiZXA2KUeVBnv0gg5My8G98dDU/chav+ZBgHyBBXmd1ChxWpa1V/vTv2oGSi/PP6UE/Yuv8Lgf/2a5DQXMS36xH5LCCYzAa3QAdxolFFvs3EwxFAY2M70dg0puMomeXnjUY8OlmChrzdZHNY20gVmLhruUdy5xVCBwMAyP+RintQ8hfivA6ydhX67dAAhCTNlAhtY7Apyxjx53Z2ZOZsPVu8wJ6lNPiH5cDy7A8rsFEmoKx/oJtswfHYCEQfw1tPKgc+zWg6B/oUnTpupbiVPUlikDhK+as2svljvKd0F5tT/DzeGCkIDeIqObXT0lgkT1VlyPkAJecunBIN6q1B436Huui1JLKTjboRlaCbmL1MF6sLD9HLDjr0OpErNXj+6ChznaGkZXKMX5kxBprQnaIPvqtRv0FSTAg70qFlMmePhvefLbfh8Vfh8lpHNGDLv/82FI5wd5wKdK7CKuJ+h6PcSO8RWp03Zf4AS3cGghZxDydeLLWnJfaAUk0kbZK5nFw12s3tSbhGSasy+bY5WWPQed7hX hgIIlWg3 hUoIsshKLma+2gfsgLFcf4Fp36U+bXbcTKk+B9nlGwn1C0DNrFFXKUwisA7hHMPNkD9GWpVfsaTCBEtGIOQPsWhMgZBhzJdUFIZWOQkwS+uSc/mZ6yYy40lnjIz98vw/13Wo0xx6siA7hwC1RXmVhwxV40DK7IIRzYWJOGNCN06Uj9kuJ5fPbSRHd155v1HC6MhJ9ZxJI1FWzRHZ1U/gKvy7Rxhh2y3pL1AU2Ph1r71YLCbFK5V7RCvVFh+IvfqzSAQ8h/avYRqHMUfGGDbiFF1orSg== 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 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 --- 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 3da58a92f48f..8380d9314ebd 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -329,38 +329,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); - 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; -} - /** * 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 7e29433c5ecc..f7efc6866ebc 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3468,7 +3468,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 f6fb053ac50d..fe5613a5ae20 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3820,7 +3820,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)); @@ -3877,7 +3877,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) {