Skip to content

Commit b8883b6

Browse files
SaltyKitkatkdave
authored andcommitted
btrfs: hold space_info->lock when clearing periodic reclaim ready
btrfs_set_periodic_reclaim_ready() requires space_info->lock to be held, as enforced by lockdep_assert_held(). However, btrfs_reclaim_sweep() was calling it after do_reclaim_sweep() returns, at which point space_info->lock is no longer held. Fix this by explicitly acquiring space_info->lock before clearing the periodic reclaim ready flag in btrfs_reclaim_sweep(). Reported-by: Chris Mason <clm@meta.com> Link: https://lore.kernel.org/linux-btrfs/20260208182556.891815-1-clm@meta.com/ Fixes: 19eff93 ("btrfs: fix periodic reclaim condition") Reviewed-by: Boris Burkov <boris@bur.io> Signed-off-by: Sun YangKai <sunk67188@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent b85cfdf commit b8883b6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

fs/btrfs/space-info.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2194,8 +2194,11 @@ void btrfs_reclaim_sweep(const struct btrfs_fs_info *fs_info)
21942194
if (!btrfs_should_periodic_reclaim(space_info))
21952195
continue;
21962196
for (raid = 0; raid < BTRFS_NR_RAID_TYPES; raid++) {
2197-
if (do_reclaim_sweep(space_info, raid))
2197+
if (do_reclaim_sweep(space_info, raid)) {
2198+
spin_lock(&space_info->lock);
21982199
btrfs_set_periodic_reclaim_ready(space_info, false);
2200+
spin_unlock(&space_info->lock);
2201+
}
21992202
}
22002203
}
22012204
}

0 commit comments

Comments
 (0)