OSDN Git Service

btrfs: move mapping of block for discard to its caller
authorDavid Sterba <dsterba@suse.com>
Thu, 2 Aug 2018 22:36:29 +0000 (00:36 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2020 16:01:44 +0000 (17:01 +0100)
There's a simple forwarded call based on the operation that would better
fit the caller btrfs_map_block that's until now a trivial wrapper.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index b978794..c93cafe 100644 (file)
@@ -5878,10 +5878,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
        struct btrfs_io_geometry geom;
 
        ASSERT(bbio_ret);
-
-       if (op == BTRFS_MAP_DISCARD)
-               return __btrfs_map_block_for_discard(fs_info, logical,
-                                                    length, bbio_ret);
+       ASSERT(op != BTRFS_MAP_DISCARD);
 
        ret = btrfs_get_io_geometry(fs_info, op, logical, *length, &geom);
        if (ret < 0)
@@ -6111,6 +6108,10 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
                      u64 logical, u64 *length,
                      struct btrfs_bio **bbio_ret, int mirror_num)
 {
+       if (op == BTRFS_MAP_DISCARD)
+               return __btrfs_map_block_for_discard(fs_info, logical,
+                                                    length, bbio_ret);
+
        return __btrfs_map_block(fs_info, op, logical, length, bbio_ret,
                                 mirror_num, 0);
 }