Commit 9ce2f423 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: refactor priority_reclaim_metadata_space

With the eviction flushing stuff we'll want to allow for different
states, but still work basically the same way that
priority_reclaim_metadata_space works currently.  Refactor this to take
the flushing states and size as an argument so we can use the same logic
for limit flushing and eviction flushing.
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 03235279
...@@ -849,8 +849,10 @@ static const enum btrfs_flush_state priority_flush_states[] = { ...@@ -849,8 +849,10 @@ static const enum btrfs_flush_state priority_flush_states[] = {
}; };
static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info, static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info, struct btrfs_space_info *space_info,
struct reserve_ticket *ticket) struct reserve_ticket *ticket,
const enum btrfs_flush_state *states,
int states_nr)
{ {
u64 to_reclaim; u64 to_reclaim;
int flush_state; int flush_state;
...@@ -866,8 +868,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info, ...@@ -866,8 +868,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
flush_state = 0; flush_state = 0;
do { do {
flush_space(fs_info, space_info, to_reclaim, flush_space(fs_info, space_info, to_reclaim, states[flush_state]);
priority_flush_states[flush_state]);
flush_state++; flush_state++;
spin_lock(&space_info->lock); spin_lock(&space_info->lock);
if (ticket->bytes == 0) { if (ticket->bytes == 0) {
...@@ -875,7 +876,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info, ...@@ -875,7 +876,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
return; return;
} }
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
} while (flush_state < ARRAY_SIZE(priority_flush_states)); } while (flush_state < states_nr);
} }
static void wait_reserve_ticket(struct btrfs_fs_info *fs_info, static void wait_reserve_ticket(struct btrfs_fs_info *fs_info,
...@@ -924,7 +925,9 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info, ...@@ -924,7 +925,9 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info,
if (flush == BTRFS_RESERVE_FLUSH_ALL) if (flush == BTRFS_RESERVE_FLUSH_ALL)
wait_reserve_ticket(fs_info, space_info, ticket); wait_reserve_ticket(fs_info, space_info, ticket);
else else
priority_reclaim_metadata_space(fs_info, space_info, ticket); priority_reclaim_metadata_space(fs_info, space_info, ticket,
priority_flush_states,
ARRAY_SIZE(priority_flush_states));
spin_lock(&space_info->lock); spin_lock(&space_info->lock);
ret = ticket->error; ret = ticket->error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment