btrfs: Fix possible off-by-one in btrfs_search_path_in_tree
[pandora-kernel.git] / fs / btrfs / transaction.c
index 81376d9..292e847 100644 (file)
@@ -460,7 +460,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
        struct btrfs_fs_info *info = root->fs_info;
        int count = 0;
 
-       if (--trans->use_count) {
+       if (trans->use_count > 1) {
+               trans->use_count--;
                trans->block_rsv = trans->orig_rsv;
                return 0;
        }
@@ -494,17 +495,10 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
        }
 
        if (lock && cur_trans->blocked && !cur_trans->in_commit) {
-               if (throttle) {
-                       /*
-                        * We may race with somebody else here so end up having
-                        * to call end_transaction on ourselves again, so inc
-                        * our use_count.
-                        */
-                       trans->use_count++;
+               if (throttle)
                        return btrfs_commit_transaction(trans, root);
-               } else {
+               else
                        wake_up_process(info->transaction_kthread);
-               }
        }
 
        WARN_ON(cur_trans != info->running_transaction);