aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2012-11-26 03:42:07 -0500
committerChris Mason <chris.mason@fusionio.com>2012-12-16 20:46:08 -0500
commit8cd2807f79b73ef2d8c1cb6b3732dc5758ac7212 (patch)
treecc743e41c7cb92d900abeb2727e7df7c48dff4e7 /fs/btrfs/transaction.c
parentff7c1d33551862c86f7737fe88edc3e499d291e6 (diff)
Btrfs: fix wrong return value of btrfs_wait_for_commit()
If the id of the existed transaction is more than the one we specified, it means the specified transaction was commited, so we should return 0, not EINVAL. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 8db401fa2f8f..e6509b92433b 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -456,28 +456,31 @@ static noinline void wait_for_commit(struct btrfs_root *root,
456int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid) 456int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
457{ 457{
458 struct btrfs_transaction *cur_trans = NULL, *t; 458 struct btrfs_transaction *cur_trans = NULL, *t;
459 int ret; 459 int ret = 0;
460 460
461 ret = 0;
462 if (transid) { 461 if (transid) {
463 if (transid <= root->fs_info->last_trans_committed) 462 if (transid <= root->fs_info->last_trans_committed)
464 goto out; 463 goto out;
465 464
465 ret = -EINVAL;
466 /* find specified transaction */ 466 /* find specified transaction */
467 spin_lock(&root->fs_info->trans_lock); 467 spin_lock(&root->fs_info->trans_lock);
468 list_for_each_entry(t, &root->fs_info->trans_list, list) { 468 list_for_each_entry(t, &root->fs_info->trans_list, list) {
469 if (t->transid == transid) { 469 if (t->transid == transid) {
470 cur_trans = t; 470 cur_trans = t;
471 atomic_inc(&cur_trans->use_count); 471 atomic_inc(&cur_trans->use_count);
472 ret = 0;
472 break; 473 break;
473 } 474 }
474 if (t->transid > transid) 475 if (t->transid > transid) {
476 ret = 0;
475 break; 477 break;
478 }
476 } 479 }
477 spin_unlock(&root->fs_info->trans_lock); 480 spin_unlock(&root->fs_info->trans_lock);
478 ret = -EINVAL; 481 /* The specified transaction doesn't exist */
479 if (!cur_trans) 482 if (!cur_trans)
480 goto out; /* bad transid */ 483 goto out;
481 } else { 484 } else {
482 /* find newest transaction that is committing | committed */ 485 /* find newest transaction that is committing | committed */
483 spin_lock(&root->fs_info->trans_lock); 486 spin_lock(&root->fs_info->trans_lock);
@@ -497,9 +500,7 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
497 } 500 }
498 501
499 wait_for_commit(root, cur_trans); 502 wait_for_commit(root, cur_trans);
500
501 put_transaction(cur_trans); 503 put_transaction(cur_trans);
502 ret = 0;
503out: 504out:
504 return ret; 505 return ret;
505} 506}