|
@@ -456,28 +456,31 @@ static noinline void wait_for_commit(struct btrfs_root *root,
|
|
int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
|
|
int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
|
|
{
|
|
{
|
|
struct btrfs_transaction *cur_trans = NULL, *t;
|
|
struct btrfs_transaction *cur_trans = NULL, *t;
|
|
- int ret;
|
|
|
|
|
|
+ int ret = 0;
|
|
|
|
|
|
- ret = 0;
|
|
|
|
if (transid) {
|
|
if (transid) {
|
|
if (transid <= root->fs_info->last_trans_committed)
|
|
if (transid <= root->fs_info->last_trans_committed)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
|
|
+ ret = -EINVAL;
|
|
/* find specified transaction */
|
|
/* find specified transaction */
|
|
spin_lock(&root->fs_info->trans_lock);
|
|
spin_lock(&root->fs_info->trans_lock);
|
|
list_for_each_entry(t, &root->fs_info->trans_list, list) {
|
|
list_for_each_entry(t, &root->fs_info->trans_list, list) {
|
|
if (t->transid == transid) {
|
|
if (t->transid == transid) {
|
|
cur_trans = t;
|
|
cur_trans = t;
|
|
atomic_inc(&cur_trans->use_count);
|
|
atomic_inc(&cur_trans->use_count);
|
|
|
|
+ ret = 0;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- if (t->transid > transid)
|
|
|
|
|
|
+ if (t->transid > transid) {
|
|
|
|
+ ret = 0;
|
|
break;
|
|
break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
spin_unlock(&root->fs_info->trans_lock);
|
|
spin_unlock(&root->fs_info->trans_lock);
|
|
- ret = -EINVAL;
|
|
|
|
|
|
+ /* The specified transaction doesn't exist */
|
|
if (!cur_trans)
|
|
if (!cur_trans)
|
|
- goto out; /* bad transid */
|
|
|
|
|
|
+ goto out;
|
|
} else {
|
|
} else {
|
|
/* find newest transaction that is committing | committed */
|
|
/* find newest transaction that is committing | committed */
|
|
spin_lock(&root->fs_info->trans_lock);
|
|
spin_lock(&root->fs_info->trans_lock);
|
|
@@ -497,9 +500,7 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
|
|
}
|
|
}
|
|
|
|
|
|
wait_for_commit(root, cur_trans);
|
|
wait_for_commit(root, cur_trans);
|
|
-
|
|
|
|
put_transaction(cur_trans);
|
|
put_transaction(cur_trans);
|
|
- ret = 0;
|
|
|
|
out:
|
|
out:
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|