btrfs: rename the option to nospace_cache
[pandora-kernel.git] / fs / btrfs / transaction.c
index 29bef63..6a0574e 100644 (file)
@@ -55,6 +55,7 @@ static noinline int join_transaction(struct btrfs_root *root, int nofail)
        struct btrfs_transaction *cur_trans;
 
        spin_lock(&root->fs_info->trans_lock);
+loop:
        if (root->fs_info->trans_no_join) {
                if (!nofail) {
                        spin_unlock(&root->fs_info->trans_lock);
@@ -75,16 +76,18 @@ static noinline int join_transaction(struct btrfs_root *root, int nofail)
        cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, GFP_NOFS);
        if (!cur_trans)
                return -ENOMEM;
+
        spin_lock(&root->fs_info->trans_lock);
        if (root->fs_info->running_transaction) {
+               /*
+                * someone started a transaction after we unlocked.  Make sure
+                * to redo the trans_no_join checks above
+                */
                kmem_cache_free(btrfs_transaction_cachep, cur_trans);
                cur_trans = root->fs_info->running_transaction;
-               atomic_inc(&cur_trans->use_count);
-               atomic_inc(&cur_trans->num_writers);
-               cur_trans->num_joined++;
-               spin_unlock(&root->fs_info->trans_lock);
-               return 0;
+               goto loop;
        }
+
        atomic_set(&cur_trans->num_writers, 1);
        cur_trans->num_joined = 0;
        init_waitqueue_head(&cur_trans->writer_wait);
@@ -634,7 +637,12 @@ int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,
 
        ret = btrfs_write_marked_extents(root, dirty_pages, mark);
        ret2 = btrfs_wait_marked_extents(root, dirty_pages, mark);
-       return ret || ret2;
+
+       if (ret)
+               return ret;
+       if (ret2)
+               return ret2;
+       return 0;
 }
 
 int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
@@ -874,8 +882,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        btrfs_reloc_pre_snapshot(trans, pending, &to_reserve);
 
        if (to_reserve > 0) {
-               ret = btrfs_block_rsv_add(root, &pending->block_rsv,
-                                         to_reserve);
+               ret = btrfs_block_rsv_add_noflush(root, &pending->block_rsv,
+                                                 to_reserve);
                if (ret) {
                        pending->error = ret;
                        goto fail;
@@ -991,7 +999,7 @@ static void update_super_roots(struct btrfs_root *root)
        struct btrfs_root_item *root_item;
        struct btrfs_super_block *super;
 
-       super = &root->fs_info->super_copy;
+       super = root->fs_info->super_copy;
 
        root_item = &root->fs_info->chunk_root->root_item;
        super->chunk_root = root_item->bytenr;
@@ -1301,12 +1309,12 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
        update_super_roots(root);
 
        if (!root->fs_info->log_root_recovering) {
-               btrfs_set_super_log_root(&root->fs_info->super_copy, 0);
-               btrfs_set_super_log_root_level(&root->fs_info->super_copy, 0);
+               btrfs_set_super_log_root(root->fs_info->super_copy, 0);
+               btrfs_set_super_log_root_level(root->fs_info->super_copy, 0);
        }
 
-       memcpy(&root->fs_info->super_for_commit, &root->fs_info->super_copy,
-              sizeof(root->fs_info->super_copy));
+       memcpy(root->fs_info->super_for_commit, root->fs_info->super_copy,
+              sizeof(*root->fs_info->super_copy));
 
        trans->transaction->blocked = 0;
        spin_lock(&root->fs_info->trans_lock);