Whamcloud - gitweb
LU-17486 ldiskfs: fix race in ext4_destroy_inode
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 31 Jan 2024 05:16:12 +0000 (08:16 +0300)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 19 Jun 2024 05:37:55 +0000 (05:37 +0000)
ext4_i_callback() can race with the access to i_reserved_data_blocks
in ext4_destroy_inode() when used with preemption-enabled kernel.

Lustre-change: https://review.whamcloud.com/53868
Lustre-commit: 4b51f1df05c4219cd8f910ac8ad58e8de946bb56

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I69c6bcfbb24e6c07d28ebcd2bdd9d9e6f06ec8d1
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55428
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
ldiskfs/kernel_patches/patches/rhel8/ext4-race-in-ext4-destroy-inode.patch [new file with mode: 0644]
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.8.series

diff --git a/ldiskfs/kernel_patches/patches/rhel8/ext4-race-in-ext4-destroy-inode.patch b/ldiskfs/kernel_patches/patches/rhel8/ext4-race-in-ext4-destroy-inode.patch
new file mode 100644 (file)
index 0000000..3ce9fcd
--- /dev/null
@@ -0,0 +1,20 @@
+Index: linux-4.18.0-32.el8.x86_64/fs/ext4/ext4.h
+===================================================================
+--- linux-4.18.0-32.el8.x86_64.orig/fs/ext4/super.c
++++ linux-4.18.0-32.el8.x86_64/fs/ext4/super.c
+@@ -1186,13 +1186,14 @@ static void ext4_destroy_inode(struct in
+                               true);
+               dump_stack();
+       }
+-      call_rcu(&inode->i_rcu, ext4_i_callback);
+       if (EXT4_I(inode)->i_reserved_data_blocks)
+               ext4_msg(inode->i_sb, KERN_ERR,
+                        "Inode %lu (%p): i_reserved_data_blocks (%u) not cleared!",
+                        inode->i_ino, EXT4_I(inode),
+                        EXT4_I(inode)->i_reserved_data_blocks);
++
++      call_rcu(&inode->i_rcu, ext4_i_callback);
+ }
+ static void init_once(void *foo)
index 92e48d4..b25ca59 100644 (file)
@@ -41,3 +41,4 @@ rhel8/ext4-limit-per-inode-preallocation-list.patch
 rhel8/ext4-mballoc-improve.patch
 rhel8/ext4-mballoc-for-hybrid.patch
 rhel8/ext4-mballoc-dense.patch
+rhel8/ext4-race-in-ext4-destroy-inode.patch