btrfs: Rename __btrfs_free_reserved_extent to btrfs_pin_reserved_extent
authorNikolay Borisov <nborisov@suse.com>
Thu, 21 Nov 2019 12:03:31 +0000 (14:03 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 20 Jan 2020 15:40:51 +0000 (16:40 +0100)
__btrfs_free_reserved_extent now performs the actions of
btrfs_free_and_pin_reserved_extent. But this name is a bit of a
misnomer, since the extent is not really freed but just pinned. Reflect
this in the new name. No semantics changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/tree-log.c

index 54efb21c27272685c11dc70185ef0a48c5146dd1..ea49e4b52cd26a8602f6426cd940ac894cc53b34 100644 (file)
@@ -2449,8 +2449,8 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref);
 
 int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
                               u64 start, u64 len, int delalloc);
-int btrfs_free_and_pin_reserved_extent(struct btrfs_fs_info *fs_info,
-                                      u64 start, u64 len);
+int btrfs_pin_reserved_extent(struct btrfs_fs_info *fs_info, u64 start,
+                             u64 len);
 void btrfs_prepare_extent_commit(struct btrfs_fs_info *fs_info);
 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans);
 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
index 215dceaacaead18ca4a6c8f573a8dec9b8cf476b..2a7dff22c3b743c132bce492498d609c8a6f2674 100644 (file)
@@ -4165,12 +4165,10 @@ again:
        return ret;
 }
 
-static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
-                                       u64 start, u64 len,
-                                       int pin, int delalloc)
+int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
+                              u64 start, u64 len, int delalloc)
 {
        struct btrfs_block_group *cache;
-       int ret = 0;
 
        cache = btrfs_lookup_block_group(fs_info, start);
        if (!cache) {
@@ -4179,15 +4177,18 @@ static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
                return -ENOSPC;
        }
 
-       ret = pin_down_extent(cache, start, len, 1);
+       btrfs_add_free_space(cache, start, len);
+       btrfs_free_reserved_bytes(cache, len, delalloc);
+       trace_btrfs_reserved_extent_free(fs_info, start, len);
+
        btrfs_put_block_group(cache);
-       return ret;
+       return 0;
 }
 
-int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
-                              u64 start, u64 len, int delalloc)
+int btrfs_pin_reserved_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len)
 {
        struct btrfs_block_group *cache;
+       int ret = 0;
 
        cache = btrfs_lookup_block_group(fs_info, start);
        if (!cache) {
@@ -4195,18 +4196,9 @@ int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
                return -ENOSPC;
        }
 
-       btrfs_add_free_space(cache, start, len);
-       btrfs_free_reserved_bytes(cache, len, delalloc);
-       trace_btrfs_reserved_extent_free(fs_info, start, len);
-
+       ret = pin_down_extent(cache, start, len, 1);
        btrfs_put_block_group(cache);
-       return 0;
-}
-
-int btrfs_free_and_pin_reserved_extent(struct btrfs_fs_info *fs_info,
-                                      u64 start, u64 len)
-{
-       return __btrfs_free_reserved_extent(fs_info, start, len, 1, 0);
+       return ret;
 }
 
 static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
index 44480762003cd3697aae9dc0b547af770c5979c1..47f4c6eea8512967109051abc677072eafb46cf8 100644 (file)
@@ -2732,9 +2732,8 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
 
                                WARN_ON(root_owner !=
                                        BTRFS_TREE_LOG_OBJECTID);
-                               ret = btrfs_free_and_pin_reserved_extent(
-                                                       fs_info, bytenr,
-                                                       blocksize);
+                               ret = btrfs_pin_reserved_extent(fs_info,
+                                                       bytenr, blocksize);
                                if (ret) {
                                        free_extent_buffer(next);
                                        return ret;
@@ -2815,8 +2814,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
                                }
 
                                WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID);
-                               ret = btrfs_free_and_pin_reserved_extent(
-                                               fs_info,
+                               ret = btrfs_pin_reserved_extent(fs_info,
                                                path->nodes[*level]->start,
                                                path->nodes[*level]->len);
                                if (ret)
@@ -2898,8 +2896,8 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
 
                        WARN_ON(log->root_key.objectid !=
                                BTRFS_TREE_LOG_OBJECTID);
-                       ret = btrfs_free_and_pin_reserved_extent(fs_info,
-                                                       next->start, next->len);
+                       ret = btrfs_pin_reserved_extent(fs_info, next->start,
+                                                       next->len);
                        if (ret)
                                goto out;
                }