btrfs: Remove fs_info from btrfs_alloc_logged_file_extent
[sfrench/cifs-2.6.git] / fs / btrfs / extent-tree.c
index 64346986f6f0b343144a507c309b515b1eee541a..c27215dc8b840538bd04b5e29cc516b54affa77c 100644 (file)
@@ -52,24 +52,21 @@ enum {
 };
 
 static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
-                              struct btrfs_fs_info *fs_info,
-                               struct btrfs_delayed_ref_node *node, u64 parent,
-                               u64 root_objectid, u64 owner_objectid,
-                               u64 owner_offset, int refs_to_drop,
-                               struct btrfs_delayed_extent_op *extra_op);
+                              struct btrfs_delayed_ref_node *node, u64 parent,
+                              u64 root_objectid, u64 owner_objectid,
+                              u64 owner_offset, int refs_to_drop,
+                              struct btrfs_delayed_extent_op *extra_op);
 static void __run_delayed_extent_op(struct btrfs_delayed_extent_op *extent_op,
                                    struct extent_buffer *leaf,
                                    struct btrfs_extent_item *ei);
 static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
-                                     struct btrfs_fs_info *fs_info,
                                      u64 parent, u64 root_objectid,
                                      u64 flags, u64 owner, u64 offset,
                                      struct btrfs_key *ins, int ref_mod);
 static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
                                     struct btrfs_delayed_ref_node *node,
                                     struct btrfs_delayed_extent_op *extent_op);
-static int do_chunk_alloc(struct btrfs_trans_handle *trans,
-                         struct btrfs_fs_info *fs_info, u64 flags,
+static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
                          int force);
 static int find_next_key(struct btrfs_path *path, int level,
                         struct btrfs_key *key);
@@ -220,9 +217,9 @@ static int add_excluded_extent(struct btrfs_fs_info *fs_info,
        return 0;
 }
 
-static void free_excluded_extents(struct btrfs_fs_info *fs_info,
-                                 struct btrfs_block_group_cache *cache)
+static void free_excluded_extents(struct btrfs_block_group_cache *cache)
 {
+       struct btrfs_fs_info *fs_info = cache->fs_info;
        u64 start, end;
 
        start = cache->key.objectid;
@@ -234,9 +231,9 @@ static void free_excluded_extents(struct btrfs_fs_info *fs_info,
                          start, end, EXTENT_UPTODATE);
 }
 
-static int exclude_super_stripes(struct btrfs_fs_info *fs_info,
-                                struct btrfs_block_group_cache *cache)
+static int exclude_super_stripes(struct btrfs_block_group_cache *cache)
 {
+       struct btrfs_fs_info *fs_info = cache->fs_info;
        u64 bytenr;
        u64 *logical;
        int stripe_len;
@@ -558,7 +555,7 @@ static noinline void caching_thread(struct btrfs_work *work)
        caching_ctl->progress = (u64)-1;
 
        up_read(&fs_info->commit_root_sem);
-       free_excluded_extents(fs_info, block_group);
+       free_excluded_extents(block_group);
        mutex_unlock(&caching_ctl->mutex);
 
        wake_up(&caching_ctl->wait);
@@ -666,7 +663,7 @@ static int cache_block_group(struct btrfs_block_group_cache *cache,
                wake_up(&caching_ctl->wait);
                if (ret == 1) {
                        put_caching_control(caching_ctl);
-                       free_excluded_extents(fs_info, cache);
+                       free_excluded_extents(cache);
                        return 0;
                }
        } else {
@@ -1216,13 +1213,12 @@ static int match_extent_data_ref(struct extent_buffer *leaf,
 }
 
 static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans,
-                                          struct btrfs_fs_info *fs_info,
                                           struct btrfs_path *path,
                                           u64 bytenr, u64 parent,
                                           u64 root_objectid,
                                           u64 owner, u64 offset)
 {
-       struct btrfs_root *root = fs_info->extent_root;
+       struct btrfs_root *root = trans->fs_info->extent_root;
        struct btrfs_key key;
        struct btrfs_extent_data_ref *ref;
        struct extent_buffer *leaf;
@@ -1487,12 +1483,11 @@ static noinline u32 extent_data_ref_count(struct btrfs_path *path,
 }
 
 static noinline int lookup_tree_block_ref(struct btrfs_trans_handle *trans,
-                                         struct btrfs_fs_info *fs_info,
                                          struct btrfs_path *path,
                                          u64 bytenr, u64 parent,
                                          u64 root_objectid)
 {
-       struct btrfs_root *root = fs_info->extent_root;
+       struct btrfs_root *root = trans->fs_info->extent_root;
        struct btrfs_key key;
        int ret;
 
@@ -1596,13 +1591,13 @@ static int find_next_key(struct btrfs_path *path, int level,
  */
 static noinline_for_stack
 int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
-                                struct btrfs_fs_info *fs_info,
                                 struct btrfs_path *path,
                                 struct btrfs_extent_inline_ref **ref_ret,
                                 u64 bytenr, u64 num_bytes,
                                 u64 parent, u64 root_objectid,
                                 u64 owner, u64 offset, int insert)
 {
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_root *root = fs_info->extent_root;
        struct btrfs_key key;
        struct extent_buffer *leaf;
@@ -1860,7 +1855,6 @@ void setup_inline_extent_backref(struct btrfs_fs_info *fs_info,
 }
 
 static int lookup_extent_backref(struct btrfs_trans_handle *trans,
-                                struct btrfs_fs_info *fs_info,
                                 struct btrfs_path *path,
                                 struct btrfs_extent_inline_ref **ref_ret,
                                 u64 bytenr, u64 num_bytes, u64 parent,
@@ -1868,9 +1862,9 @@ static int lookup_extent_backref(struct btrfs_trans_handle *trans,
 {
        int ret;
 
-       ret = lookup_inline_extent_backref(trans, fs_info, path, ref_ret,
-                                          bytenr, num_bytes, parent,
-                                          root_objectid, owner, offset, 0);
+       ret = lookup_inline_extent_backref(trans, path, ref_ret, bytenr,
+                                          num_bytes, parent, root_objectid,
+                                          owner, offset, 0);
        if (ret != -ENOENT)
                return ret;
 
@@ -1878,12 +1872,11 @@ static int lookup_extent_backref(struct btrfs_trans_handle *trans,
        *ref_ret = NULL;
 
        if (owner < BTRFS_FIRST_FREE_OBJECTID) {
-               ret = lookup_tree_block_ref(trans, fs_info, path, bytenr,
-                                           parent, root_objectid);
+               ret = lookup_tree_block_ref(trans, path, bytenr, parent,
+                                           root_objectid);
        } else {
-               ret = lookup_extent_data_ref(trans, fs_info, path, bytenr,
-                                            parent, root_objectid, owner,
-                                            offset);
+               ret = lookup_extent_data_ref(trans, path, bytenr, parent,
+                                            root_objectid, owner, offset);
        }
        return ret;
 }
@@ -1892,14 +1885,14 @@ static int lookup_extent_backref(struct btrfs_trans_handle *trans,
  * helper to update/remove inline back ref
  */
 static noinline_for_stack
-void update_inline_extent_backref(struct btrfs_fs_info *fs_info,
-                                 struct btrfs_path *path,
+void update_inline_extent_backref(struct btrfs_path *path,
                                  struct btrfs_extent_inline_ref *iref,
                                  int refs_to_mod,
                                  struct btrfs_delayed_extent_op *extent_op,
                                  int *last_ref)
 {
-       struct extent_buffer *leaf;
+       struct extent_buffer *leaf = path->nodes[0];
+       struct btrfs_fs_info *fs_info = leaf->fs_info;
        struct btrfs_extent_item *ei;
        struct btrfs_extent_data_ref *dref = NULL;
        struct btrfs_shared_data_ref *sref = NULL;
@@ -1910,7 +1903,6 @@ void update_inline_extent_backref(struct btrfs_fs_info *fs_info,
        int type;
        u64 refs;
 
-       leaf = path->nodes[0];
        ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
        refs = btrfs_extent_refs(leaf, ei);
        WARN_ON(refs_to_mod < 0 && refs + refs_to_mod <= 0);
@@ -1962,7 +1954,6 @@ void update_inline_extent_backref(struct btrfs_fs_info *fs_info,
 
 static noinline_for_stack
 int insert_inline_extent_backref(struct btrfs_trans_handle *trans,
-                                struct btrfs_fs_info *fs_info,
                                 struct btrfs_path *path,
                                 u64 bytenr, u64 num_bytes, u64 parent,
                                 u64 root_objectid, u64 owner,
@@ -1972,15 +1963,15 @@ int insert_inline_extent_backref(struct btrfs_trans_handle *trans,
        struct btrfs_extent_inline_ref *iref;
        int ret;
 
-       ret = lookup_inline_extent_backref(trans, fs_info, path, &iref,
-                                          bytenr, num_bytes, parent,
-                                          root_objectid, owner, offset, 1);
+       ret = lookup_inline_extent_backref(trans, path, &iref, bytenr,
+                                          num_bytes, parent, root_objectid,
+                                          owner, offset, 1);
        if (ret == 0) {
                BUG_ON(owner < BTRFS_FIRST_FREE_OBJECTID);
-               update_inline_extent_backref(fs_info, path, iref,
-                                            refs_to_add, extent_op, NULL);
+               update_inline_extent_backref(path, iref, refs_to_add,
+                                            extent_op, NULL);
        } else if (ret == -ENOENT) {
-               setup_inline_extent_backref(fs_info, path, iref, parent,
+               setup_inline_extent_backref(trans->fs_info, path, iref, parent,
                                            root_objectid, owner, offset,
                                            refs_to_add, extent_op);
                ret = 0;
@@ -2007,7 +1998,6 @@ static int insert_extent_backref(struct btrfs_trans_handle *trans,
 }
 
 static int remove_extent_backref(struct btrfs_trans_handle *trans,
-                                struct btrfs_fs_info *fs_info,
                                 struct btrfs_path *path,
                                 struct btrfs_extent_inline_ref *iref,
                                 int refs_to_drop, int is_data, int *last_ref)
@@ -2016,14 +2006,14 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans,
 
        BUG_ON(!is_data && refs_to_drop != 1);
        if (iref) {
-               update_inline_extent_backref(fs_info, path, iref,
-                                            -refs_to_drop, NULL, last_ref);
+               update_inline_extent_backref(path, iref, -refs_to_drop, NULL,
+                                            last_ref);
        } else if (is_data) {
                ret = remove_extent_data_ref(trans, path, refs_to_drop,
                                             last_ref);
        } else {
                *last_ref = 1;
-               ret = btrfs_del_item(trans, fs_info->extent_root, path);
+               ret = btrfs_del_item(trans, trans->fs_info->extent_root, path);
        }
        return ret;
 }
@@ -2181,13 +2171,13 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
                           owner, offset, BTRFS_ADD_DELAYED_REF);
 
        if (owner < BTRFS_FIRST_FREE_OBJECTID) {
-               ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr,
+               ret = btrfs_add_delayed_tree_ref(trans, bytenr,
                                                 num_bytes, parent,
                                                 root_objectid, (int)owner,
                                                 BTRFS_ADD_DELAYED_REF, NULL,
                                                 &old_ref_mod, &new_ref_mod);
        } else {
-               ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
+               ret = btrfs_add_delayed_data_ref(trans, bytenr,
                                                 num_bytes, parent,
                                                 root_objectid, owner, offset,
                                                 0, BTRFS_ADD_DELAYED_REF,
@@ -2238,7 +2228,6 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
  *
  */
 static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
-                                 struct btrfs_fs_info *fs_info,
                                  struct btrfs_delayed_ref_node *node,
                                  u64 parent, u64 root_objectid,
                                  u64 owner, u64 offset, int refs_to_add,
@@ -2260,10 +2249,9 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
        path->reada = READA_FORWARD;
        path->leave_spinning = 1;
        /* this will setup the path even if it fails to insert the back ref */
-       ret = insert_inline_extent_backref(trans, fs_info, path, bytenr,
-                                          num_bytes, parent, root_objectid,
-                                          owner, offset,
-                                          refs_to_add, extent_op);
+       ret = insert_inline_extent_backref(trans, path, bytenr, num_bytes,
+                                          parent, root_objectid, owner,
+                                          offset, refs_to_add, extent_op);
        if ((ret < 0 && ret != -EAGAIN) || !ret)
                goto out;
 
@@ -2296,7 +2284,6 @@ out:
 }
 
 static int run_delayed_data_ref(struct btrfs_trans_handle *trans,
-                               struct btrfs_fs_info *fs_info,
                                struct btrfs_delayed_ref_node *node,
                                struct btrfs_delayed_extent_op *extent_op,
                                int insert_reserved)
@@ -2313,7 +2300,7 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans,
        ins.type = BTRFS_EXTENT_ITEM_KEY;
 
        ref = btrfs_delayed_node_to_data_ref(node);
-       trace_run_delayed_data_ref(fs_info, node, ref, node->action);
+       trace_run_delayed_data_ref(trans->fs_info, node, ref, node->action);
 
        if (node->type == BTRFS_SHARED_DATA_REF_KEY)
                parent = ref->parent;
@@ -2322,17 +2309,16 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans,
        if (node->action == BTRFS_ADD_DELAYED_REF && insert_reserved) {
                if (extent_op)
                        flags |= extent_op->flags_to_set;
-               ret = alloc_reserved_file_extent(trans, fs_info,
-                                                parent, ref_root, flags,
-                                                ref->objectid, ref->offset,
-                                                &ins, node->ref_mod);
+               ret = alloc_reserved_file_extent(trans, parent, ref_root,
+                                                flags, ref->objectid,
+                                                ref->offset, &ins,
+                                                node->ref_mod);
        } else if (node->action == BTRFS_ADD_DELAYED_REF) {
-               ret = __btrfs_inc_extent_ref(trans, fs_info, node, parent,
-                                            ref_root, ref->objectid,
-                                            ref->offset, node->ref_mod,
-                                            extent_op);
+               ret = __btrfs_inc_extent_ref(trans, node, parent, ref_root,
+                                            ref->objectid, ref->offset,
+                                            node->ref_mod, extent_op);
        } else if (node->action == BTRFS_DROP_DELAYED_REF) {
-               ret = __btrfs_free_extent(trans, fs_info, node, parent,
+               ret = __btrfs_free_extent(trans, node, parent,
                                          ref_root, ref->objectid,
                                          ref->offset, node->ref_mod,
                                          extent_op);
@@ -2361,10 +2347,10 @@ static void __run_delayed_extent_op(struct btrfs_delayed_extent_op *extent_op,
 }
 
 static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
-                                struct btrfs_fs_info *fs_info,
                                 struct btrfs_delayed_ref_head *head,
                                 struct btrfs_delayed_extent_op *extent_op)
 {
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_key key;
        struct btrfs_path *path;
        struct btrfs_extent_item *ei;
@@ -2452,7 +2438,6 @@ out:
 }
 
 static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
-                               struct btrfs_fs_info *fs_info,
                                struct btrfs_delayed_ref_node *node,
                                struct btrfs_delayed_extent_op *extent_op,
                                int insert_reserved)
@@ -2463,14 +2448,14 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
        u64 ref_root = 0;
 
        ref = btrfs_delayed_node_to_tree_ref(node);
-       trace_run_delayed_tree_ref(fs_info, node, ref, node->action);
+       trace_run_delayed_tree_ref(trans->fs_info, node, ref, node->action);
 
        if (node->type == BTRFS_SHARED_BLOCK_REF_KEY)
                parent = ref->parent;
        ref_root = ref->root;
 
        if (node->ref_mod != 1) {
-               btrfs_err(fs_info,
+               btrfs_err(trans->fs_info,
        "btree block(%llu) has %d references rather than 1: action %d ref_root %llu parent %llu",
                          node->bytenr, node->ref_mod, node->action, ref_root,
                          parent);
@@ -2480,13 +2465,10 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
                BUG_ON(!extent_op || !extent_op->update_flags);
                ret = alloc_reserved_tree_block(trans, node, extent_op);
        } else if (node->action == BTRFS_ADD_DELAYED_REF) {
-               ret = __btrfs_inc_extent_ref(trans, fs_info, node,
-                                            parent, ref_root,
-                                            ref->level, 0, 1,
-                                            extent_op);
+               ret = __btrfs_inc_extent_ref(trans, node, parent, ref_root,
+                                            ref->level, 0, 1, extent_op);
        } else if (node->action == BTRFS_DROP_DELAYED_REF) {
-               ret = __btrfs_free_extent(trans, fs_info, node,
-                                         parent, ref_root,
+               ret = __btrfs_free_extent(trans, node, parent, ref_root,
                                          ref->level, 0, 1, extent_op);
        } else {
                BUG();
@@ -2496,7 +2478,6 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
 
 /* helper function to actually process a single delayed ref entry */
 static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
-                              struct btrfs_fs_info *fs_info,
                               struct btrfs_delayed_ref_node *node,
                               struct btrfs_delayed_extent_op *extent_op,
                               int insert_reserved)
@@ -2505,18 +2486,18 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
 
        if (trans->aborted) {
                if (insert_reserved)
-                       btrfs_pin_extent(fs_info, node->bytenr,
+                       btrfs_pin_extent(trans->fs_info, node->bytenr,
                                         node->num_bytes, 1);
                return 0;
        }
 
        if (node->type == BTRFS_TREE_BLOCK_REF_KEY ||
            node->type == BTRFS_SHARED_BLOCK_REF_KEY)
-               ret = run_delayed_tree_ref(trans, fs_info, node, extent_op,
+               ret = run_delayed_tree_ref(trans, node, extent_op,
                                           insert_reserved);
        else if (node->type == BTRFS_EXTENT_DATA_REF_KEY ||
                 node->type == BTRFS_SHARED_DATA_REF_KEY)
-               ret = run_delayed_data_ref(trans, fs_info, node, extent_op,
+               ret = run_delayed_data_ref(trans, node, extent_op,
                                           insert_reserved);
        else
                BUG();
@@ -2558,7 +2539,6 @@ static void unselect_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_ref
 }
 
 static int cleanup_extent_op(struct btrfs_trans_handle *trans,
-                            struct btrfs_fs_info *fs_info,
                             struct btrfs_delayed_ref_head *head)
 {
        struct btrfs_delayed_extent_op *extent_op = head->extent_op;
@@ -2572,21 +2552,22 @@ static int cleanup_extent_op(struct btrfs_trans_handle *trans,
                return 0;
        }
        spin_unlock(&head->lock);
-       ret = run_delayed_extent_op(trans, fs_info, head, extent_op);
+       ret = run_delayed_extent_op(trans, head, extent_op);
        btrfs_free_delayed_extent_op(extent_op);
        return ret ? ret : 1;
 }
 
 static int cleanup_ref_head(struct btrfs_trans_handle *trans,
-                           struct btrfs_fs_info *fs_info,
                            struct btrfs_delayed_ref_head *head)
 {
+
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_delayed_ref_root *delayed_refs;
        int ret;
 
        delayed_refs = &trans->transaction->delayed_refs;
 
-       ret = cleanup_extent_op(trans, fs_info, head);
+       ret = cleanup_extent_op(trans, head);
        if (ret < 0) {
                unselect_delayed_ref_head(delayed_refs, head);
                btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret);
@@ -2735,7 +2716,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
                 * up and move on to the next ref_head.
                 */
                if (!ref) {
-                       ret = cleanup_ref_head(trans, fs_info, locked_ref);
+                       ret = cleanup_ref_head(trans, locked_ref);
                        if (ret > 0 ) {
                                /* We dropped our lock, we need to loop. */
                                ret = 0;
@@ -2782,7 +2763,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
                locked_ref->extent_op = NULL;
                spin_unlock(&locked_ref->lock);
 
-               ret = run_one_delayed_ref(trans, fs_info, ref, extent_op,
+               ret = run_one_delayed_ref(trans, ref, extent_op,
                                          must_insert_reserved);
 
                btrfs_free_delayed_extent_op(extent_op);
@@ -4319,7 +4300,7 @@ again:
                        if (IS_ERR(trans))
                                return PTR_ERR(trans);
 
-                       ret = do_chunk_alloc(trans, fs_info, alloc_target,
+                       ret = do_chunk_alloc(trans, alloc_target,
                                             CHUNK_ALLOC_NO_FORCE);
                        btrfs_end_transaction(trans);
                        if (ret < 0) {
@@ -4541,9 +4522,9 @@ static u64 get_profile_num_devs(struct btrfs_fs_info *fs_info, u64 type)
  * for allocating a chunk, otherwise if it's false, reserve space necessary for
  * removing a chunk.
  */
-void check_system_chunk(struct btrfs_trans_handle *trans,
-                       struct btrfs_fs_info *fs_info, u64 type)
+void check_system_chunk(struct btrfs_trans_handle *trans, u64 type)
 {
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_space_info *info;
        u64 left;
        u64 thresh;
@@ -4582,7 +4563,7 @@ void check_system_chunk(struct btrfs_trans_handle *trans,
                 * the paths we visit in the chunk tree (they were already COWed
                 * or created in the current transaction for example).
                 */
-               ret = btrfs_alloc_chunk(trans, fs_info, flags);
+               ret = btrfs_alloc_chunk(trans, flags);
        }
 
        if (!ret) {
@@ -4603,9 +4584,10 @@ void check_system_chunk(struct btrfs_trans_handle *trans,
  *    - return 1 if it successfully allocates a chunk,
  *    - return errors including -ENOSPC otherwise.
  */
-static int do_chunk_alloc(struct btrfs_trans_handle *trans,
-                         struct btrfs_fs_info *fs_info, u64 flags, int force)
+static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
+                         int force)
 {
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_space_info *space_info;
        int wait_for_alloc = 0;
        int ret = 0;
@@ -4681,9 +4663,9 @@ again:
         * Check if we have enough space in SYSTEM chunk because we may need
         * to update devices.
         */
-       check_system_chunk(trans, fs_info, flags);
+       check_system_chunk(trans, flags);
 
-       ret = btrfs_alloc_chunk(trans, fs_info, flags);
+       ret = btrfs_alloc_chunk(trans, flags);
        trans->allocating_chunk = false;
 
        spin_lock(&space_info->lock);
@@ -5014,7 +4996,7 @@ static void flush_space(struct btrfs_fs_info *fs_info,
                        ret = PTR_ERR(trans);
                        break;
                }
-               ret = do_chunk_alloc(trans, fs_info,
+               ret = do_chunk_alloc(trans,
                                     btrfs_metadata_alloc_profile(fs_info),
                                     CHUNK_ALLOC_NO_FORCE);
                btrfs_end_transaction(trans);
@@ -6845,12 +6827,12 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans)
 }
 
 static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
-                               struct btrfs_fs_info *info,
-                               struct btrfs_delayed_ref_node *node, u64 parent,
-                               u64 root_objectid, u64 owner_objectid,
-                               u64 owner_offset, int refs_to_drop,
-                               struct btrfs_delayed_extent_op *extent_op)
+                              struct btrfs_delayed_ref_node *node, u64 parent,
+                              u64 root_objectid, u64 owner_objectid,
+                              u64 owner_offset, int refs_to_drop,
+                              struct btrfs_delayed_extent_op *extent_op)
 {
+       struct btrfs_fs_info *info = trans->fs_info;
        struct btrfs_key key;
        struct btrfs_path *path;
        struct btrfs_root *extent_root = info->extent_root;
@@ -6882,9 +6864,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
        if (is_data)
                skinny_metadata = false;
 
-       ret = lookup_extent_backref(trans, info, path, &iref,
-                                   bytenr, num_bytes, parent,
-                                   root_objectid, owner_objectid,
+       ret = lookup_extent_backref(trans, path, &iref, bytenr, num_bytes,
+                                   parent, root_objectid, owner_objectid,
                                    owner_offset);
        if (ret == 0) {
                extent_slot = path->slots[0];
@@ -6914,7 +6895,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 #endif
                if (!found_extent) {
                        BUG_ON(iref);
-                       ret = remove_extent_backref(trans, info, path, NULL,
+                       ret = remove_extent_backref(trans, path, NULL,
                                                    refs_to_drop,
                                                    is_data, &last_ref);
                        if (ret) {
@@ -7058,9 +7039,9 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
                        btrfs_mark_buffer_dirty(leaf);
                }
                if (found_extent) {
-                       ret = remove_extent_backref(trans, info, path,
-                                                   iref, refs_to_drop,
-                                                   is_data, &last_ref);
+                       ret = remove_extent_backref(trans, path, iref,
+                                                   refs_to_drop, is_data,
+                                                   &last_ref);
                        if (ret) {
                                btrfs_abort_transaction(trans, ret);
                                goto out;
@@ -7202,7 +7183,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
                                   root->root_key.objectid,
                                   btrfs_header_level(buf), 0,
                                   BTRFS_DROP_DELAYED_REF);
-               ret = btrfs_add_delayed_tree_ref(fs_info, trans, buf->start,
+               ret = btrfs_add_delayed_tree_ref(trans, buf->start,
                                                 buf->len, parent,
                                                 root->root_key.objectid,
                                                 btrfs_header_level(buf),
@@ -7281,13 +7262,13 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
                old_ref_mod = new_ref_mod = 0;
                ret = 0;
        } else if (owner < BTRFS_FIRST_FREE_OBJECTID) {
-               ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr,
+               ret = btrfs_add_delayed_tree_ref(trans, bytenr,
                                                 num_bytes, parent,
                                                 root_objectid, (int)owner,
                                                 BTRFS_DROP_DELAYED_REF, NULL,
                                                 &old_ref_mod, &new_ref_mod);
        } else {
-               ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr,
+               ret = btrfs_add_delayed_data_ref(trans, bytenr,
                                                 num_bytes, parent,
                                                 root_objectid, owner, offset,
                                                 0, BTRFS_DROP_DELAYED_REF,
@@ -7856,8 +7837,7 @@ loop:
                                goto out;
                        }
 
-                       ret = do_chunk_alloc(trans, fs_info, flags,
-                                            CHUNK_ALLOC_FORCE);
+                       ret = do_chunk_alloc(trans, flags, CHUNK_ALLOC_FORCE);
 
                        /*
                         * If we can't allocate a new chunk we've already looped
@@ -8083,11 +8063,11 @@ int btrfs_free_and_pin_reserved_extent(struct btrfs_fs_info *fs_info,
 }
 
 static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
-                                     struct btrfs_fs_info *fs_info,
                                      u64 parent, u64 root_objectid,
                                      u64 flags, u64 owner, u64 offset,
                                      struct btrfs_key *ins, int ref_mod)
 {
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        int ret;
        struct btrfs_extent_item *extent_item;
        struct btrfs_extent_inline_ref *iref;
@@ -8261,7 +8241,6 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
                                     u64 offset, u64 ram_bytes,
                                     struct btrfs_key *ins)
 {
-       struct btrfs_fs_info *fs_info = root->fs_info;
        int ret;
 
        BUG_ON(root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID);
@@ -8270,7 +8249,7 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
                           root->root_key.objectid, owner, offset,
                           BTRFS_ADD_DELAYED_EXTENT);
 
-       ret = btrfs_add_delayed_data_ref(fs_info, trans, ins->objectid,
+       ret = btrfs_add_delayed_data_ref(trans, ins->objectid,
                                         ins->offset, 0,
                                         root->root_key.objectid, owner,
                                         offset, ram_bytes,
@@ -8284,10 +8263,10 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
  * space cache bits as well
  */
 int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
-                                  struct btrfs_fs_info *fs_info,
                                   u64 root_objectid, u64 owner, u64 offset,
                                   struct btrfs_key *ins)
 {
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        int ret;
        struct btrfs_block_group_cache *block_group;
        struct btrfs_space_info *space_info;
@@ -8315,8 +8294,8 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
        spin_unlock(&block_group->lock);
        spin_unlock(&space_info->lock);
 
-       ret = alloc_reserved_file_extent(trans, fs_info, 0, root_objectid,
-                                        0, owner, offset, ins, 1);
+       ret = alloc_reserved_file_extent(trans, 0, root_objectid, 0, owner,
+                                        offset, ins, 1);
        btrfs_put_block_group(block_group);
        return ret;
 }
@@ -8497,7 +8476,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
                btrfs_ref_tree_mod(root, ins.objectid, ins.offset, parent,
                                   root_objectid, level, 0,
                                   BTRFS_ADD_DELAYED_EXTENT);
-               ret = btrfs_add_delayed_tree_ref(fs_info, trans, ins.objectid,
+               ret = btrfs_add_delayed_tree_ref(trans, ins.objectid,
                                                 ins.offset, parent,
                                                 root_objectid, level,
                                                 BTRFS_ADD_DELAYED_EXTENT,
@@ -9484,7 +9463,7 @@ again:
         */
        alloc_flags = update_block_group_flags(fs_info, cache->flags);
        if (alloc_flags != cache->flags) {
-               ret = do_chunk_alloc(trans, fs_info, alloc_flags,
+               ret = do_chunk_alloc(trans, alloc_flags,
                                     CHUNK_ALLOC_FORCE);
                /*
                 * ENOSPC is allowed here, we may have enough space
@@ -9501,8 +9480,7 @@ again:
        if (!ret)
                goto out;
        alloc_flags = get_alloc_profile(fs_info, cache->space_info->flags);
-       ret = do_chunk_alloc(trans, fs_info, alloc_flags,
-                            CHUNK_ALLOC_FORCE);
+       ret = do_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
        if (ret < 0)
                goto out;
        ret = inc_block_group_ro(cache, 0);
@@ -9510,7 +9488,7 @@ out:
        if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) {
                alloc_flags = update_block_group_flags(fs_info, cache->flags);
                mutex_lock(&fs_info->chunk_mutex);
-               check_system_chunk(trans, fs_info, alloc_flags);
+               check_system_chunk(trans, alloc_flags);
                mutex_unlock(&fs_info->chunk_mutex);
        }
        mutex_unlock(&fs_info->ro_block_group_mutex);
@@ -9524,7 +9502,7 @@ int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans,
 {
        u64 alloc_flags = get_alloc_profile(fs_info, type);
 
-       return do_chunk_alloc(trans, fs_info, alloc_flags, CHUNK_ALLOC_FORCE);
+       return do_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
 }
 
 /*
@@ -9877,7 +9855,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
                 */
                if (block_group->cached == BTRFS_CACHE_NO ||
                    block_group->cached == BTRFS_CACHE_ERROR)
-                       free_excluded_extents(info, block_group);
+                       free_excluded_extents(block_group);
 
                btrfs_remove_free_space_cache(block_group);
                ASSERT(block_group->cached != BTRFS_CACHE_STARTED);
@@ -10119,13 +10097,13 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
                 * info has super bytes accounted for, otherwise we'll think
                 * we have more space than we actually do.
                 */
-               ret = exclude_super_stripes(info, cache);
+               ret = exclude_super_stripes(cache);
                if (ret) {
                        /*
                         * We may have excluded something, so call this just in
                         * case.
                         */
-                       free_excluded_extents(info, cache);
+                       free_excluded_extents(cache);
                        btrfs_put_block_group(cache);
                        goto error;
                }
@@ -10140,14 +10118,14 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
                if (found_key.offset == btrfs_block_group_used(&cache->item)) {
                        cache->last_byte_to_unpin = (u64)-1;
                        cache->cached = BTRFS_CACHE_FINISHED;
-                       free_excluded_extents(info, cache);
+                       free_excluded_extents(cache);
                } else if (btrfs_block_group_used(&cache->item) == 0) {
                        cache->last_byte_to_unpin = (u64)-1;
                        cache->cached = BTRFS_CACHE_FINISHED;
                        add_new_free_space(cache, found_key.objectid,
                                           found_key.objectid +
                                           found_key.offset);
-                       free_excluded_extents(info, cache);
+                       free_excluded_extents(cache);
                }
 
                ret = btrfs_add_block_group_cache(info, cache);
@@ -10248,10 +10226,10 @@ next:
        trans->can_flush_pending_bgs = can_flush_pending_bgs;
 }
 
-int btrfs_make_block_group(struct btrfs_trans_handle *trans,
-                          struct btrfs_fs_info *fs_info, u64 bytes_used,
+int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
                           u64 type, u64 chunk_offset, u64 size)
 {
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_block_group_cache *cache;
        int ret;
 
@@ -10270,20 +10248,20 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
        cache->last_byte_to_unpin = (u64)-1;
        cache->cached = BTRFS_CACHE_FINISHED;
        cache->needs_free_space = 1;
-       ret = exclude_super_stripes(fs_info, cache);
+       ret = exclude_super_stripes(cache);
        if (ret) {
                /*
                 * We may have excluded something, so call this just in
                 * case.
                 */
-               free_excluded_extents(fs_info, cache);
+               free_excluded_extents(cache);
                btrfs_put_block_group(cache);
                return ret;
        }
 
        add_new_free_space(cache, chunk_offset, chunk_offset + size);
 
-       free_excluded_extents(fs_info, cache);
+       free_excluded_extents(cache);
 
 #ifdef CONFIG_BTRFS_DEBUG
        if (btrfs_should_fragment_free_space(cache)) {
@@ -10341,9 +10319,9 @@ static void clear_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags)
 }
 
 int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
-                            struct btrfs_fs_info *fs_info, u64 group_start,
-                            struct extent_map *em)
+                            u64 group_start, struct extent_map *em)
 {
+       struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_root *root = fs_info->extent_root;
        struct btrfs_path *path;
        struct btrfs_block_group_cache *block_group;
@@ -10367,7 +10345,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
         * Free the reserved super bytes from this block group before
         * remove it.
         */
-       free_excluded_extents(fs_info, block_group);
+       free_excluded_extents(block_group);
        btrfs_free_ref_tree_range(fs_info, block_group->key.objectid,
                                  block_group->key.offset);