Skip to content

Commit 9cc0b83

Browse files
morbidrsakdave
authored andcommitted
btrfs: don't block if we can't acquire the reclaim lock
If we can't acquire the reclaim_bgs_lock on block group reclaim, we block until it is free. This can potentially stall for a long time. While reclaim of block groups is necessary for a good user experience on a zoned file system, there still is no need to block as it is best effort only, just like when we're deleting unused block groups. CC: [email protected] # 5.13 Signed-off-by: Johannes Thumshirn <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent abb99cf commit 9cc0b83

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/btrfs/block-group.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,15 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
14981498
if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE))
14991499
return;
15001500

1501-
mutex_lock(&fs_info->reclaim_bgs_lock);
1501+
/*
1502+
* Long running balances can keep us blocked here for eternity, so
1503+
* simply skip reclaim if we're unable to get the mutex.
1504+
*/
1505+
if (!mutex_trylock(&fs_info->reclaim_bgs_lock)) {
1506+
btrfs_exclop_finish(fs_info);
1507+
return;
1508+
}
1509+
15021510
spin_lock(&fs_info->unused_bgs_lock);
15031511
while (!list_empty(&fs_info->reclaim_bgs)) {
15041512
u64 zone_unusable;

0 commit comments

Comments
 (0)