[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260115143826.17725-1-jiashengjiangcool@gmail.com>
Date: Thu, 15 Jan 2026 14:38:26 +0000
From: Jiasheng Jiang <jiashengjiangcool@...il.com>
To: Chris Mason <clm@...com>,
David Sterba <dsterba@...e.com>,
linux-btrfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Jiasheng Jiang <jiashengjiangcool@...il.com>
Subject: [PATCH] btrfs: remove unnecessary RCU protection in clear_incompat_bg_bits
The function clear_incompat_bg_bits() currently uses
list_for_each_entry_rcu() to iterate over the fs_info->space_info list.
However, inside the loop, it calls down_read(&sinfo->groups_sem).
Since down_read() is a blocking operation that can sleep, calling it
inside an implied RCU read-side critical section is illegal and can
trigger "scheduling while atomic" errors or lockdep warnings.
As established in commit 728049050012 ("btrfs: kill the RCU protection
for fs_info->space_info"), the space_info list is initialized upon mount
and destroyed during unmount. It does not change during the runtime of
the filesystem, making RCU protection unnecessary.
Fix this by switching to the standard list_for_each_entry() iterator,
which safely allows blocking operations like semaphore acquisition within
the loop.
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@...il.com>
---
fs/btrfs/block-group.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 08b14449fabe..d2cb26f130eb 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1011,7 +1011,7 @@ static void clear_incompat_bg_bits(struct btrfs_fs_info *fs_info, u64 flags)
struct list_head *head = &fs_info->space_info;
struct btrfs_space_info *sinfo;
- list_for_each_entry_rcu(sinfo, head, list) {
+ list_for_each_entry(sinfo, head, list) {
down_read(&sinfo->groups_sem);
if (!list_empty(&sinfo->block_groups[BTRFS_RAID_RAID5]))
found_raid56 = true;
--
2.25.1
Powered by blists - more mailing lists