Skip to content

Commit 365c531

Browse files
Josef Bacikmasoncl
authored andcommitted
Btrfs: don't commit the transaction in the async space flushing
We're triggering a huge number of commits from btrfs_async_reclaim_metadata_space. These aren't really requried, because everyone calling the async reclaim code is going to end up triggering a commit on their own. Signed-off-by: Chris Mason <[email protected]>
1 parent cb723e4 commit 365c531

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fs/btrfs/extent-tree.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4329,8 +4329,13 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_root *root,
43294329
static inline int need_do_async_reclaim(struct btrfs_space_info *space_info,
43304330
struct btrfs_fs_info *fs_info, u64 used)
43314331
{
4332-
return (used >= div_factor_fine(space_info->total_bytes, 98) &&
4333-
!btrfs_fs_closing(fs_info) &&
4332+
u64 thresh = div_factor_fine(space_info->total_bytes, 98);
4333+
4334+
/* If we're just plain full then async reclaim just slows us down. */
4335+
if (space_info->bytes_used >= thresh)
4336+
return 0;
4337+
4338+
return (used >= thresh && !btrfs_fs_closing(fs_info) &&
43344339
!test_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state));
43354340
}
43364341

@@ -4385,10 +4390,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
43854390
if (!btrfs_need_do_async_reclaim(space_info, fs_info,
43864391
flush_state))
43874392
return;
4388-
} while (flush_state <= COMMIT_TRANS);
4389-
4390-
if (btrfs_need_do_async_reclaim(space_info, fs_info, flush_state))
4391-
queue_work(system_unbound_wq, work);
4393+
} while (flush_state < COMMIT_TRANS);
43924394
}
43934395

43944396
void btrfs_init_async_reclaim_work(struct work_struct *work)

0 commit comments

Comments
 (0)