From patchwork Fri Dec 20 15:33:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13916888 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 98BE0E7718B for ; Fri, 20 Dec 2024 15:33:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CC4B6B0083; Fri, 20 Dec 2024 10:33:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 32D606B0088; Fri, 20 Dec 2024 10:33:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17FAB6B0089; Fri, 20 Dec 2024 10:33:23 -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 F02C66B0083 for ; Fri, 20 Dec 2024 10:33:22 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A0B93160B0E for ; Fri, 20 Dec 2024 15:33:22 +0000 (UTC) X-FDA: 82915730310.21.A73CCF7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id C63B1140002 for ; Fri, 20 Dec 2024 15:32:54 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=F3exKZ2T; spf=pass (imf26.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=1734708774; 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=EvGnTa8al1EYy5YKK16KcjK1WmCT04bBJ6JnFuu97WQ=; b=qANeWQXAjcTOmuFL2sM3Q1mgs0ZGVFwl0x03cJaBDUgEqF94Xt51lO7Siphxh4P26RvMsJ LNGLxoOu3dLyopde+MZAjkO2VyVUllDhT4j3qmvAjeJdrxoSooUl9fFQ9xR0rxp8bHZ4ra r2Hhy0gGidYRUVhg39toDZAS1MS0pe0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=F3exKZ2T; spf=pass (imf26.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734708774; a=rsa-sha256; cv=none; b=agLBLWWutsZEBZ/YbvO8+dLg2f6zx3hMnzKRfrI8smJEWi+j1+iA6vsjnMQGGnqN0gknK0 EbqjECpW37arN0YzQOvBwLps0qE7E1+xC/QxmXx/MC9y97pCwzJEftBZN/m03J/H6V36og w4frf+FcmasgjqzwjZIOHBC/7p+dBOs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 24BDA5C65A3; Fri, 20 Dec 2024 15:32:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBC47C4CEDC; Fri, 20 Dec 2024 15:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734708799; bh=ZyCXpRT455r2S07+QOUD9SLmwrfNZHhbqdLqERRMUuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F3exKZ2T5TgdU+zC58sBpE4t5ZjksAHSgtcv+GepWfxEqTmJyAJFq7FrwKp2iubcV NT6tJPsTRr06rcD6138Ya+4zZNhbLXJawNOtTiO5xXvQk5GVtY/HPLONeKs+QVkdug kxGsdY5zU8XA6Tzut1cA3LYOWYlT7H55zz+OBqA9QfqPJvgS6ziryU6gY5n4QXAHhV J7xMHac3Nn+/JSYu4zevHf5pSeXqYcLmzz7dpIUPC/8JWkRxAofdZkqLIyRhGrnt0z 1iHnTsuS3kGJXivaJ3EuItrypzffShYARESNujqmZV3+LaTaWr+z61Kzs5TVSMI5Z7 hfO4MHZ5gOmGA== From: cel@kernel.org To: Hugh Dickins , Christian Brauner , Al Viro Cc: , , yukuai3@huawei.com, yangerkun@huaweicloud.com, Chuck Lever Subject: [PATCH v6 2/5] Revert "libfs: Add simple_offset_empty()" Date: Fri, 20 Dec 2024 10:33:11 -0500 Message-ID: <20241220153314.5237-3-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241220153314.5237-1-cel@kernel.org> References: <20241220153314.5237-1-cel@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C63B1140002 X-Rspamd-Server: rspam12 X-Stat-Signature: giye17fx4n7tkgr5ya3finb64emrwrea X-Rspam-User: X-HE-Tag: 1734708774-70806 X-HE-Meta: U2FsdGVkX18QMIPEmS8qIPn5r7EXSEUZO8jUxDA4/TqUPhVFMP9P+bNvkJ0nI+J3CiX4inLaq/UX/97/B+CWHz8q81VpbKICFvZkR+Xt9E75Dv6nFAGMbYJs51+zl5Z7toFRR+E1Z6BIoiZTbMIK2rFrmmHOxpGu3ATV1o07fOIQ6fK7EGeFj6vxoi+2n/2kTWt2e7p8tBanropCRlRpq56gPMetuUQKFS4vEXnC6gY+WgtlRKw7iNm9TrY9mNYvIJdVjgmHzcul7PhFWuKjjOpfa5r3Nw2OShIdEnSJD1iwEfYZO7SdqQXjg/1iyuaHreqaq7JfCqWv1/q1pbYhlCzjgT5jw5EHYqFPiW/wq5d+nIcUqoSwS+5pRlYD3aER3ySMFCCEoj4h2a8E4yJMllR2t0kH4y1gDIAN3etscRpEuVLjSNx15HTHswXpO/LrezIlZjyPThCGIl6gFXx/9KwzrgYROzVPI9n1AAOZuCuU33cnk/Bc2CuS1/fkJM4Vq4+4KkNa31kX2UYVPkHbgdLtAmJuS9RI0AmMbxAwJK9szr7AlMMLYmzADo7zLnLnRCmtLgdHALzk4Om3b9PhY46M4gWfaj4b2UBiZk+35pET5mUDQ5hBmOTotBtgPhqu8seqKsO3AOo5FgCmEM+MGp0GXFm0n9T8nHcleUxMpMdQ54MjgdB+yy/FFNwYQHVd09lG97pcl1uYkcLEG0d4XKZmgpL9NWRCZO5s6Kfw37Rd2pS3XgtX/1i1adXUFAvVLIxoS98K/yUU6VZWKBRVFxSoqUkcK/Q3PH3p1lm0tz5KCpNaI8QbYdp95ANSXRzk4nbd+aS5PEXePa0lFGZgXjECqlBKGWn0GP+VJFVdd87LOShEZUCeIFg4/IJ43RAxA6ZGGYyX/67cScoV1tyV5gasSzqxkcMWah80A/ikKSy1trTPcjVV+umc2ZkxWS2ISqZY1rcgFw4UmxB+WVF /I43ZPmy LEE6i5Wn6gSpOCdpNhsfNVFzcsOer3Ds8uw/oDWAwaKBYeyIwdVPkfxCBfrn1lRf6gYBIaXV2TK7IMgj6DPoShbSj7Vnx2uk6R1Vzt675P0sEd968hHi1xLi/u3VdwqAnJuDQ3bqQELKmg5/FMPb6Crrj7/7QXOVypPREGUv2hIG0MYxCmgVVikbJFVBdmgOL1b6z695k9TEOIzBuaIAVS43GvhovfAQSIJDPGlygMcQjADGQcXAH4hweh4iF9v5gMgDRG9zCMCko8vLfxRo1joYkgw== 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 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) {