summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2025-01-24 14:19:38 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-01 18:37:53 +0100
commit307f68e49ddafa89f8d0c3fdbdb396cb01ee8373 (patch)
treeff792b11cf35d9f2712c92af34fc8ce5a8e3ac97 /mm
parentfc90bbcc08da47a4635455b4e946717d5c26258b (diff)
downloadlinux-307f68e49ddafa89f8d0c3fdbdb396cb01ee8373.tar.gz
linux-307f68e49ddafa89f8d0c3fdbdb396cb01ee8373.tar.bz2
linux-307f68e49ddafa89f8d0c3fdbdb396cb01ee8373.zip
libfs: Add simple_offset_empty()
[ Upstream commit ecba88a3b32d733d41e27973e25b2bc580f64281 ] For simple filesystems that use directory offset mapping, rely strictly on the directory offset map to tell when a directory has no children. After this patch is applied, the emptiness test holds only the RCU read lock when the directory being tested has no children. In addition, this adds another layer of confirmation that simple_offset_add/remove() are working as expected. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Link: https://lore.kernel.org/r/170820143463.6328.7872919188371286951.stgit@91.116.238.104.host.secureserver.net Signed-off-by: Christian Brauner <brauner@kernel.org> Stable-dep-of: 5a1a25be995e ("libfs: Add simple_offset_rename() API") Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/shmem.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index db7dd45c9181..aaf679976f3b 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_empty(dentry))
+ if (!simple_offset_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_empty(new_dentry))
+ if (!simple_offset_empty(new_dentry))
return -ENOTEMPTY;
if (flags & RENAME_WHITEOUT) {