]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: zoned: simplify btrfs_check_meta_write_pointer
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 7 Dec 2021 14:28:35 +0000 (06:28 -0800)
committerDavid Sterba <dsterba@suse.com>
Fri, 7 Jan 2022 13:18:25 +0000 (14:18 +0100)
btrfs_check_meta_write_pointer() will always be called with a NULL
'cache_ret' argument.

As there's no need to check if we have a valid block_group passed in
remove these checks.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zoned.c

index 5ef430f02fd243e090239c86c581a5147355bf04..767ff6cffeae266b17305968122e927cdaa8ffb6 100644 (file)
@@ -1637,29 +1637,19 @@ bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
        if (!btrfs_is_zoned(fs_info))
                return true;
 
-       cache = *cache_ret;
+       cache = btrfs_lookup_block_group(fs_info, eb->start);
+       if (!cache)
+               return true;
 
-       if (cache && (eb->start < cache->start ||
-                     cache->start + cache->length <= eb->start)) {
+       if (cache->meta_write_pointer != eb->start) {
                btrfs_put_block_group(cache);
                cache = NULL;
-               *cache_ret = NULL;
+               ret = false;
+       } else {
+               cache->meta_write_pointer = eb->start + eb->len;
        }
 
-       if (!cache)
-               cache = btrfs_lookup_block_group(fs_info, eb->start);
-
-       if (cache) {
-               if (cache->meta_write_pointer != eb->start) {
-                       btrfs_put_block_group(cache);
-                       cache = NULL;
-                       ret = false;
-               } else {
-                       cache->meta_write_pointer = eb->start + eb->len;
-               }
-
-               *cache_ret = cache;
-       }
+       *cache_ret = cache;
 
        return ret;
 }