]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Btrfs: release trans metadata bytes before flushing delayed refs
authorJosef Bacik <josef@redhat.com>
Fri, 14 Oct 2011 18:40:17 +0000 (14:40 -0400)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:20:33 +0000 (21:20 -0500)
We started setting trans->block_rsv = NULL to allow the delayed refs flushing
stuff to use the right block_rsv and then just made
btrfs_trans_release_metadata() unconditionally use the trans block rsv.  The
problem with this is we need to reserve some space in the transaction and then
migrate it to the global block rsv, so we need to be able to free that out
properly.  So instead just move btrfs_trans_release_metadata() before the
delayed ref flushing and use trans->block_rsv for the freeing.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
(cherry picked from commit b24e03db0df3e9164c9649db12fecc8c2d81b0d1)

fs/btrfs/extent-tree.c
fs/btrfs/transaction.c

index fedbf86d1ec183242cac51cea7e9690e60be8c98..b41483db05ef7c616d882f2a6633fc6d785d92d8 100644 (file)
@@ -3909,13 +3909,10 @@ static void release_global_block_rsv(struct btrfs_fs_info *fs_info)
 void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
                                  struct btrfs_root *root)
 {
-       struct btrfs_block_rsv *block_rsv;
-
        if (!trans->bytes_reserved)
                return;
 
-       block_rsv = &root->fs_info->trans_block_rsv;
-       btrfs_block_rsv_release(root, block_rsv, trans->bytes_reserved);
+       btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved);
        trans->bytes_reserved = 0;
 }
 
index 1e1a4816ccb0aaaf688c6c5f4b5ba642385dd69c..d064fa0a4a078e306c9987d4319f2878ffbbda2c 100644 (file)
@@ -462,6 +462,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
                return 0;
        }
 
+       btrfs_trans_release_metadata(trans, root);
        trans->block_rsv = NULL;
        while (count < 4) {
                unsigned long cur = trans->delayed_ref_updates;
@@ -483,8 +484,6 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
                count++;
        }
 
-       btrfs_trans_release_metadata(trans, root);
-
        if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) &&
            should_end_transaction(trans, root)) {
                trans->transaction->blocked = 1;
@@ -1128,6 +1127,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
 
        btrfs_run_ordered_operations(root, 0);
 
+       btrfs_trans_release_metadata(trans, root);
        trans->block_rsv = NULL;
 
        /* make a pass through all the delayed refs we have so far
@@ -1136,8 +1136,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
        ret = btrfs_run_delayed_refs(trans, root, 0);
        BUG_ON(ret);
 
-       btrfs_trans_release_metadata(trans, root);
-
        cur_trans = trans->transaction;
        /*
         * set the flushing flag so procs in this transaction have to