]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: always use trans->block_rsv for orphans
authorJosef Bacik <jbacik@fb.com>
Fri, 27 May 2016 17:01:08 +0000 (13:01 -0400)
committerDavid Sterba <dsterba@suse.com>
Thu, 7 Jul 2016 16:45:53 +0000 (18:45 +0200)
This is the case all the time anyway except for relocation which could be doing
a reloc root for a non ref counted root, in which case we'd end up with some
random block rsv rather than the one we have our reservation in.  If there isn't
enough space in the block rsv we are trying to steal from we'll BUG() because we
expect there to be space for the orphan to make its reservation.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index 7c644f8108168891280f696a13248703a13cfcdb..f3de211173adfec0b859761c1f6c178f6e75e7c3 100644 (file)
@@ -5744,7 +5744,13 @@ int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,
                                  struct inode *inode)
 {
        struct btrfs_root *root = BTRFS_I(inode)->root;
-       struct btrfs_block_rsv *src_rsv = get_block_rsv(trans, root);
+       /*
+        * We always use trans->block_rsv here as we will have reserved space
+        * for our orphan when starting the transaction, using get_block_rsv()
+        * here will sometimes make us choose the wrong block rsv as we could be
+        * doing a reloc inode for a non refcounted root.
+        */
+       struct btrfs_block_rsv *src_rsv = trans->block_rsv;
        struct btrfs_block_rsv *dst_rsv = root->orphan_block_rsv;
 
        /*