Commit bf6d7d49 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Remove invalid null checks from btrfs_cleanup_dirty_bgs

list_first_entry is essentially a wrapper over cotnainer_of. The latter
can never return null even if it's working on inconsistent list since it
will either crash or return some offset in the wrong struct.
Additionally, for the dirty_bgs list the iteration is done under
dirty_bgs_lock which ensures consistency of the list.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 8f2ceaa7
...@@ -4327,11 +4327,6 @@ void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *cur_trans, ...@@ -4327,11 +4327,6 @@ void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *cur_trans,
cache = list_first_entry(&cur_trans->dirty_bgs, cache = list_first_entry(&cur_trans->dirty_bgs,
struct btrfs_block_group_cache, struct btrfs_block_group_cache,
dirty_list); dirty_list);
if (!cache) {
btrfs_err(fs_info, "orphan block group dirty_bgs list");
spin_unlock(&cur_trans->dirty_bgs_lock);
return;
}
if (!list_empty(&cache->io_list)) { if (!list_empty(&cache->io_list)) {
spin_unlock(&cur_trans->dirty_bgs_lock); spin_unlock(&cur_trans->dirty_bgs_lock);
...@@ -4355,10 +4350,6 @@ void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *cur_trans, ...@@ -4355,10 +4350,6 @@ void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *cur_trans,
cache = list_first_entry(&cur_trans->io_bgs, cache = list_first_entry(&cur_trans->io_bgs,
struct btrfs_block_group_cache, struct btrfs_block_group_cache,
io_list); io_list);
if (!cache) {
btrfs_err(fs_info, "orphan block group on io_bgs list");
return;
}
list_del_init(&cache->io_list); list_del_init(&cache->io_list);
spin_lock(&cache->lock); spin_lock(&cache->lock);
......
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