Commit 50c31eaa authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: simplify block group traversal in btrfs_put_block_group_cache

We're breaking out and re-searching for the next block group while
evicting any of the block group cache inodes.  This is not needed, the
block groups aren't disappearing here, we can simply loop through the
block groups like normal and iput any inode that we find.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
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 9283b9e0
...@@ -3950,36 +3950,24 @@ void btrfs_reserve_chunk_metadata(struct btrfs_trans_handle *trans, ...@@ -3950,36 +3950,24 @@ void btrfs_reserve_chunk_metadata(struct btrfs_trans_handle *trans,
void btrfs_put_block_group_cache(struct btrfs_fs_info *info) void btrfs_put_block_group_cache(struct btrfs_fs_info *info)
{ {
struct btrfs_block_group *block_group; struct btrfs_block_group *block_group;
u64 last = 0;
while (1) { block_group = btrfs_lookup_first_block_group(info, 0);
struct inode *inode; while (block_group) {
btrfs_wait_block_group_cache_done(block_group);
block_group = btrfs_lookup_first_block_group(info, last); spin_lock(&block_group->lock);
while (block_group) { if (test_and_clear_bit(BLOCK_GROUP_FLAG_IREF,
btrfs_wait_block_group_cache_done(block_group); &block_group->runtime_flags)) {
spin_lock(&block_group->lock); struct inode *inode = block_group->inode;
if (test_bit(BLOCK_GROUP_FLAG_IREF,
&block_group->runtime_flags)) block_group->inode = NULL;
break;
spin_unlock(&block_group->lock); spin_unlock(&block_group->lock);
block_group = btrfs_next_block_group(block_group);
}
if (!block_group) {
if (last == 0)
break;
last = 0;
continue;
}
inode = block_group->inode; ASSERT(block_group->io_ctl.inode == NULL);
clear_bit(BLOCK_GROUP_FLAG_IREF, &block_group->runtime_flags); iput(inode);
block_group->inode = NULL; } else {
spin_unlock(&block_group->lock); spin_unlock(&block_group->lock);
ASSERT(block_group->io_ctl.inode == NULL); }
iput(inode); block_group = btrfs_next_block_group(block_group);
last = block_group->start + block_group->length;
btrfs_put_block_group(block_group);
} }
} }
......
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