]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
btrfs: pass root to various extent ref mod functions
authorJosef Bacik <josef@toxicpanda.com>
Fri, 29 Sep 2017 19:43:49 +0000 (15:43 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 30 Oct 2017 11:28:00 +0000 (12:28 +0100)
We need the actual root for the ref verifier tool to work, so change
these functions to pass the root around instead.  This will be used in
a subsequent patch.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/relocation.c
fs/btrfs/tree-log.c

index 19b9c5131745a175a72711245e3c348e5bb8789a..531e0a8645b08a1554b495c0852cc7e53e528770 100644 (file)
@@ -192,7 +192,7 @@ struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root)
  * tree until you end up with a lock on the root.  A locked buffer
  * is returned, with a reference held.
  */
-static struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root)
+struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root)
 {
        struct extent_buffer *eb;
 
index 75947c6c04c3c220dd67fb32d50b5652d5668b1d..2fcc3c30d471fd95aee3e8e4e942f27d016e6fde 100644 (file)
@@ -2637,7 +2637,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
                           struct extent_buffer *buf,
                           u64 parent, int last_ref);
 int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
-                                    u64 root_objectid, u64 owner,
+                                    struct btrfs_root *root, u64 owner,
                                     u64 offset, u64 ram_bytes,
                                     struct btrfs_key *ins);
 int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
@@ -2656,7 +2656,7 @@ int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
                                u64 bytenr, u64 num_bytes, u64 flags,
                                int level, int is_data);
 int btrfs_free_extent(struct btrfs_trans_handle *trans,
-                     struct btrfs_fs_info *fs_info,
+                     struct btrfs_root *root,
                      u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
                      u64 owner, u64 offset);
 
@@ -2668,7 +2668,7 @@ void btrfs_prepare_extent_commit(struct btrfs_fs_info *fs_info);
 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
                               struct btrfs_fs_info *fs_info);
 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
-                        struct btrfs_fs_info *fs_info,
+                        struct btrfs_root *root,
                         u64 bytenr, u64 num_bytes, u64 parent,
                         u64 root_objectid, u64 owner, u64 offset);
 
@@ -2807,6 +2807,7 @@ void btrfs_set_item_key_safe(struct btrfs_fs_info *fs_info,
                             const struct btrfs_key *new_key);
 struct extent_buffer *btrfs_root_node(struct btrfs_root *root);
 struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root);
+struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root);
 int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path,
                        struct btrfs_key *key, int lowest_level,
                        u64 min_trans);
index 624aa6841bf2cbdfc4efbb8bcc95bf2e81024eb1..a9787c3c0f7e7ad80de0557afe5a5b7268b7a849 100644 (file)
@@ -2177,10 +2177,11 @@ int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr,
 
 /* Can return -ENOMEM */
 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
-                        struct btrfs_fs_info *fs_info,
+                        struct btrfs_root *root,
                         u64 bytenr, u64 num_bytes, u64 parent,
                         u64 root_objectid, u64 owner, u64 offset)
 {
+       struct btrfs_fs_info *fs_info = root->fs_info;
        int old_ref_mod, new_ref_mod;
        int ret;
 
@@ -3339,7 +3340,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
        int level;
        int ret = 0;
        int (*process_func)(struct btrfs_trans_handle *,
-                           struct btrfs_fs_info *,
+                           struct btrfs_root *,
                            u64, u64, u64, u64, u64, u64);
 
 
@@ -3379,7 +3380,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
 
                        num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi);
                        key.offset -= btrfs_file_extent_offset(buf, fi);
-                       ret = process_func(trans, fs_info, bytenr, num_bytes,
+                       ret = process_func(trans, root, bytenr, num_bytes,
                                           parent, ref_root, key.objectid,
                                           key.offset);
                        if (ret)
@@ -3387,7 +3388,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
                } else {
                        bytenr = btrfs_node_blockptr(buf, i);
                        num_bytes = fs_info->nodesize;
-                       ret = process_func(trans, fs_info, bytenr, num_bytes,
+                       ret = process_func(trans, root, bytenr, num_bytes,
                                           parent, ref_root, level - 1, 0);
                        if (ret)
                                goto fail;
@@ -7331,17 +7332,17 @@ out:
 
 /* Can return -ENOMEM */
 int btrfs_free_extent(struct btrfs_trans_handle *trans,
-                     struct btrfs_fs_info *fs_info,
+                     struct btrfs_root *root,
                      u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
                      u64 owner, u64 offset)
 {
+       struct btrfs_fs_info *fs_info = root->fs_info;
        int old_ref_mod, new_ref_mod;
        int ret;
 
        if (btrfs_is_testing(fs_info))
                return 0;
 
-
        /*
         * tree log blocks never actually go into the extent allocation
         * tree, just update pinning info and exit early.
@@ -8308,17 +8309,18 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 }
 
 int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
-                                    u64 root_objectid, u64 owner,
+                                    struct btrfs_root *root, u64 owner,
                                     u64 offset, u64 ram_bytes,
                                     struct btrfs_key *ins)
 {
-       struct btrfs_fs_info *fs_info = trans->fs_info;
+       struct btrfs_fs_info *fs_info = root->fs_info;
        int ret;
 
-       BUG_ON(root_objectid == BTRFS_TREE_LOG_OBJECTID);
+       BUG_ON(root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID);
 
        ret = btrfs_add_delayed_data_ref(fs_info, trans, ins->objectid,
-                                        ins->offset, 0, root_objectid, owner,
+                                        ins->offset, 0,
+                                        root->root_key.objectid, owner,
                                         offset, ram_bytes,
                                         BTRFS_ADD_DELAYED_EXTENT, NULL, NULL);
        return ret;
@@ -8896,7 +8898,7 @@ skip:
                                             ret);
                        }
                }
-               ret = btrfs_free_extent(trans, fs_info, bytenr, blocksize,
+               ret = btrfs_free_extent(trans, root, bytenr, blocksize,
                                        parent, root->root_key.objectid,
                                        level - 1, 0);
                if (ret)
index 79945053c7e756759fb8e747d5da0a07588278cb..d3c1725f03e41bd9fb219a0263350f21bcade4f3 100644 (file)
@@ -856,7 +856,7 @@ next_slot:
                        btrfs_mark_buffer_dirty(leaf);
 
                        if (update_refs && disk_bytenr > 0) {
-                               ret = btrfs_inc_extent_ref(trans, fs_info,
+                               ret = btrfs_inc_extent_ref(trans, root,
                                                disk_bytenr, num_bytes, 0,
                                                root->root_key.objectid,
                                                new_key.objectid,
@@ -940,7 +940,7 @@ delete_extent_item:
                                extent_end = ALIGN(extent_end,
                                                   fs_info->sectorsize);
                        } else if (update_refs && disk_bytenr > 0) {
-                               ret = btrfs_free_extent(trans, fs_info,
+                               ret = btrfs_free_extent(trans, root,
                                                disk_bytenr, num_bytes, 0,
                                                root->root_key.objectid,
                                                key.objectid, key.offset -
@@ -1234,7 +1234,7 @@ again:
                                                extent_end - split);
                btrfs_mark_buffer_dirty(leaf);
 
-               ret = btrfs_inc_extent_ref(trans, fs_info, bytenr, num_bytes,
+               ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes,
                                           0, root->root_key.objectid,
                                           ino, orig_offset);
                if (ret) {
@@ -1268,7 +1268,7 @@ again:
                extent_end = other_end;
                del_slot = path->slots[0] + 1;
                del_nr++;
-               ret = btrfs_free_extent(trans, fs_info, bytenr, num_bytes,
+               ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
                                        0, root->root_key.objectid,
                                        ino, orig_offset);
                if (ret) {
@@ -1288,7 +1288,7 @@ again:
                key.offset = other_start;
                del_slot = path->slots[0];
                del_nr++;
-               ret = btrfs_free_extent(trans, fs_info, bytenr, num_bytes,
+               ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
                                        0, root->root_key.objectid,
                                        ino, orig_offset);
                if (ret) {
index 4ddb299af4728c452335f2a2ac3d93bcc86fba98..a11f87fa79d089dfc19de08ecaf2af62f432e567 100644 (file)
@@ -2218,8 +2218,9 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
        if (ret < 0)
                goto out;
        qg_released = ret;
-       ret = btrfs_alloc_reserved_file_extent(trans, root->root_key.objectid,
-                       btrfs_ino(BTRFS_I(inode)), file_pos, qg_released, &ins);
+       ret = btrfs_alloc_reserved_file_extent(trans, root,
+                                              btrfs_ino(BTRFS_I(inode)),
+                                              file_pos, qg_released, &ins);
 out:
        btrfs_free_path(path);
 
@@ -2671,7 +2672,7 @@ again:
        inode_add_bytes(inode, len);
        btrfs_release_path(path);
 
-       ret = btrfs_inc_extent_ref(trans, fs_info, new->bytenr,
+       ret = btrfs_inc_extent_ref(trans, root, new->bytenr,
                        new->disk_len, 0,
                        backref->root_id, backref->inum,
                        new->file_pos); /* start - extent_offset */
@@ -4665,7 +4666,7 @@ delete:
                     root == fs_info->tree_root)) {
                        btrfs_set_path_blocking(path);
                        bytes_deleted += extent_num_bytes;
-                       ret = btrfs_free_extent(trans, fs_info, extent_start,
+                       ret = btrfs_free_extent(trans, root, extent_start,
                                                extent_num_bytes, 0,
                                                btrfs_header_owner(leaf),
                                                ino, extent_offset);
index f969c034d7b383feab46e987e49c22eb30a3b022..847d318756d4747f4bfdc67b573f2f21c53c5be8 100644 (file)
@@ -3694,7 +3694,7 @@ process_slot:
                                if (disko) {
                                        inode_add_bytes(inode, datal);
                                        ret = btrfs_inc_extent_ref(trans,
-                                                       fs_info,
+                                                       root,
                                                        disko, diskl, 0,
                                                        root->root_key.objectid,
                                                        btrfs_ino(BTRFS_I(inode)),
index 9841faef08ea72d0b50aa3ad3c881bd27bd7fc76..7d506a3e46dd82cd913c7b9d8d571bbb40aaea75 100644 (file)
@@ -1742,7 +1742,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
                dirty = 1;
 
                key.offset -= btrfs_file_extent_offset(leaf, fi);
-               ret = btrfs_inc_extent_ref(trans, fs_info, new_bytenr,
+               ret = btrfs_inc_extent_ref(trans, root, new_bytenr,
                                           num_bytes, parent,
                                           btrfs_header_owner(leaf),
                                           key.objectid, key.offset);
@@ -1751,7 +1751,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
                        break;
                }
 
-               ret = btrfs_free_extent(trans, fs_info, bytenr, num_bytes,
+               ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
                                        parent, btrfs_header_owner(leaf),
                                        key.objectid, key.offset);
                if (ret) {
@@ -1952,21 +1952,21 @@ again:
                                              path->slots[level], old_ptr_gen);
                btrfs_mark_buffer_dirty(path->nodes[level]);
 
-               ret = btrfs_inc_extent_ref(trans, fs_info, old_bytenr,
+               ret = btrfs_inc_extent_ref(trans, src, old_bytenr,
                                        blocksize, path->nodes[level]->start,
                                        src->root_key.objectid, level - 1, 0);
                BUG_ON(ret);
-               ret = btrfs_inc_extent_ref(trans, fs_info, new_bytenr,
+               ret = btrfs_inc_extent_ref(trans, dest, new_bytenr,
                                        blocksize, 0, dest->root_key.objectid,
                                        level - 1, 0);
                BUG_ON(ret);
 
-               ret = btrfs_free_extent(trans, fs_info, new_bytenr, blocksize,
+               ret = btrfs_free_extent(trans, src, new_bytenr, blocksize,
                                        path->nodes[level]->start,
                                        src->root_key.objectid, level - 1, 0);
                BUG_ON(ret);
 
-               ret = btrfs_free_extent(trans, fs_info, old_bytenr, blocksize,
+               ret = btrfs_free_extent(trans, dest, old_bytenr, blocksize,
                                        0, dest->root_key.objectid, level - 1,
                                        0);
                BUG_ON(ret);
@@ -2808,7 +2808,7 @@ static int do_relocation(struct btrfs_trans_handle *trans,
                                                      trans->transid);
                        btrfs_mark_buffer_dirty(upper->eb);
 
-                       ret = btrfs_inc_extent_ref(trans, root->fs_info,
+                       ret = btrfs_inc_extent_ref(trans, root,
                                                node->eb->start, blocksize,
                                                upper->eb->start,
                                                btrfs_header_owner(upper->eb),
index 1036ac7313a7d6c76a319437bd66a8536600bd0c..aa7c71cff575a5a3e1d73b8194239936cc509877 100644 (file)
@@ -717,7 +717,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
                        ret = btrfs_lookup_data_extent(fs_info, ins.objectid,
                                                ins.offset);
                        if (ret == 0) {
-                               ret = btrfs_inc_extent_ref(trans, fs_info,
+                               ret = btrfs_inc_extent_ref(trans, root,
                                                ins.objectid, ins.offset,
                                                0, root->root_key.objectid,
                                                key->objectid, offset);