From patchwork Sun Dec 15 18:58:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13908873 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 331B3E7717F for ; Sun, 15 Dec 2024 18:58:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D4C56B0085; Sun, 15 Dec 2024 13:58:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 635066B0088; Sun, 15 Dec 2024 13:58:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AD0C6B0089; Sun, 15 Dec 2024 13:58:25 -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 2D4436B0085 for ; Sun, 15 Dec 2024 13:58:25 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CD779A3C8D for ; Sun, 15 Dec 2024 18:58:24 +0000 (UTC) X-FDA: 82898103204.21.793922E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id D0BB3140010 for ; Sun, 15 Dec 2024 18:58:03 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RWfkeu17; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.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=1734289090; 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=smC4UxGETgvC/ylD53lkuwmBZ7b2vnbUI16yw6ptyRg=; b=xh2yZ6XkcApmTzsRnB3j0+mk3JvGproYiuXSW5AkA9wZY9+smPPzqgsT93kJnqeha2haaq 6v4PhHr4Pt+IDcXOmdppSNmdKRkHaXcM1YbZiCkkvfkXEzkmOfsoji60mTFF9zeBxTsY5k dnjGgGERkilSVbUUz79tr4ChFKpkld4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734289090; a=rsa-sha256; cv=none; b=cGhxfziZ0A4gyqIdU5FbQFbfcuo5qiIpRm4fBmBJYppSRxYNL9vZhO0u/t+ghRzABcXyA4 B4wE1So+1Z2a9IJvMsA5xfUrxU/5hJQluGk3g0UY2K7PpOWVkmlkJT9StI50ovG/PhcqVo m3gON5ApCpq+j3JdYk4kTxIKrW3bvBc= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RWfkeu17; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3BA475C5B7E; Sun, 15 Dec 2024 18:57:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C8ABC4CEE2; Sun, 15 Dec 2024 18:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734289102; bh=8uJ2Pr2s2e4IY7lhSwlQ1U0qNB24Hr3dfGxCSwH7i3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RWfkeu17XsQ+VEfxJGvSI1fYGGkfbSlT2wtA6f7qr/YCmDZmIILW5Y7tthYzlzTjj +f739dSbqQXnNixYLSpa/VJWdd/z4Lw4NmTKq4c2rPSur2mK8Qd6WJqcbN7dMoua6l 3hIXUCg94IHunYxZwUmbgaheKN9dkL/Jpxz1FYF6ldyB6gKg4P2V7DUGIEuaTvu67g U+tprO9LReZW8Jz6fxc8s64cDP6lP7UrykVNSQdV3C//s4wPhLBxsvCi9uEcQBzBco JM0GEkPZSaToe/PoMuv7e7WSQ6seR1DI8J4lLITiGagTpCgTvjRQhUQ6VwZYtod69Y JgEZLwf+wpBSg== From: cel@kernel.org To: Hugh Dickins , Christian Brauner , Al Viro Cc: , , yukuai3@huawei.com, yangerkun@huaweicloud.com, Chuck Lever Subject: [PATCH v5 2/5] Revert "libfs: Add simple_offset_empty()" Date: Sun, 15 Dec 2024 13:58:13 -0500 Message-ID: <20241215185816.1826975-3-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241215185816.1826975-1-cel@kernel.org> References: <20241215185816.1826975-1-cel@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 953958bm7t5rhw9xhnzknnjyda3zr3nx X-Rspamd-Queue-Id: D0BB3140010 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734289083-202241 X-HE-Meta: U2FsdGVkX1+90IunZ8Zsh7nIzBCA0lYDT7WqMMDe7i3orIyRJKY5430a1N4HZqkiVqgvk308sIvgNcQ/yPRnh+pYeA4VUceLo6WHyoKob80TiSCWu1wO9xOW+otN4ZtMHwgunScEeGidsajTPj4f2lErtm3hkcjtWqS7nmzaj0oUuqai/IDhq5FW5PMZavyArH776SzaoOm/zdj828uCkz8IoM0lEvoyJ6CrqfGgwenF/9ai2M52otX7n+utLDRYcTSXvxOGwHvK1o1uLMJDqtDmhjbVAVl56i8JJgd51Zqy2Nv6UOeKIDybdxdiEk79hXwfN/hU5SNZ4dCdN2h4K4lh0AFukeBDigFm+e02mcDGDxqIQ3at4P7MhxKuMlwVkcKU4eZhpA9B9ygWA792aDcjjg8H+UdsqKvTFXhEsPMWtk1mKCCQ6SiYgmgYLkQcSmKOK9p3mvpD0cgoUwqGwobKsJ1d6LihKbzC7pTBpQGEvx743d4f8JxntyVJRKvpAn31MWnkdpb+pVbbZ/Tq9gZBDzkhuLQsNoXocGln/s0U+xOXLEse+bFyUnM6RZeH/CgonnBMTbGcv9rngrnC04Cy+OKx61L0Fbw4nyOO6LosOfrewwkkG5IAZRoau38vxU6ORqx5f2XO85rpH5T23orR5ys1U7KdIGDDpTGH/1Ld96vJBGgSbr3Ib++2CPR7/1E0m1T5XAwDr1NCJYviCznuT+HAIq9CvD3uIFrhKBXWbGM0qnXukJKPBvsDQhATOzLAnhBiHUDITFHVzDIAoOLLUYGaehRRSMCK7vtUqNDEoT37gNs0PyQXg8U3gHBgaauHsk6MS3UKSKkFja8U5l0YEaS52BQzCHPf8X0Sl7aFl3GMx5h5IJ06Quvxtxi7OBeFDLGEyFbVb+D2Vp742fTL3XP+t5675BRTtdVnu3pxXG8Ai1WXvsrk1rajXmKCSId6Xi8pJ9QcXIZEtAW KPrI/EH9 SieXU800LM3MBQ5uU1uGPLehBcmKzsAWCSm1Jifi7N9FeD1NHyp7ls5Jtk2WwmA6bwzKF33jcqviZexXUbce9UVpB4RIej6xzr+vIqwhJBDevRizqrRpStffdTiE0o4PAtEBaHnpLogMN/+YUgvj1C3T8g8nTh0LkR6dugojCs7lIBG9kLbEQTBrbXReGu9NrCgcA+0J8jxqyapqze2icfcoPGCOf25nq7D43QLIxhkXAvNC4nLwYnL2mZZT2hJIuNYSv9WVbI6YUkIy8vv69zN+IWg== 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 f6d04c69f195..9bcc97ffae48 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -331,38 +331,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 ccb9629a0f70..274c2666f457 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3818,7 +3818,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)); @@ -3875,7 +3875,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) {