diff options
author | Josef Bacik <josef@redhat.com> | 2012-05-31 15:52:43 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2012-06-14 21:29:13 -0400 |
commit | 7b8b92af58db347de64a237861fcf13374b34a9c (patch) | |
tree | 09b7c7cc0eb37d8e6d98127e2fef2b679a998059 /fs/btrfs | |
parent | d7096fc3ef8360f30f228344bc564d4f97d8a158 (diff) |
Btrfs: abort the transaction if the commit fails
If a transaction commit fails we don't abort it so we don't set an error on
the file system. This patch fixes that by actually calling the abort stuff
and then adding a check for a fs error in the transaction start stuff to
make sure it is caught properly. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/transaction.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 59e0203bfb95..b72b068183ec 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -100,6 +100,10 @@ loop: | |||
100 | kmem_cache_free(btrfs_transaction_cachep, cur_trans); | 100 | kmem_cache_free(btrfs_transaction_cachep, cur_trans); |
101 | cur_trans = fs_info->running_transaction; | 101 | cur_trans = fs_info->running_transaction; |
102 | goto loop; | 102 | goto loop; |
103 | } else if (root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { | ||
104 | spin_unlock(&root->fs_info->trans_lock); | ||
105 | kmem_cache_free(btrfs_transaction_cachep, cur_trans); | ||
106 | return -EROFS; | ||
103 | } | 107 | } |
104 | 108 | ||
105 | atomic_set(&cur_trans->num_writers, 1); | 109 | atomic_set(&cur_trans->num_writers, 1); |
@@ -1213,12 +1217,14 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, | |||
1213 | 1217 | ||
1214 | 1218 | ||
1215 | static void cleanup_transaction(struct btrfs_trans_handle *trans, | 1219 | static void cleanup_transaction(struct btrfs_trans_handle *trans, |
1216 | struct btrfs_root *root) | 1220 | struct btrfs_root *root, int err) |
1217 | { | 1221 | { |
1218 | struct btrfs_transaction *cur_trans = trans->transaction; | 1222 | struct btrfs_transaction *cur_trans = trans->transaction; |
1219 | 1223 | ||
1220 | WARN_ON(trans->use_count > 1); | 1224 | WARN_ON(trans->use_count > 1); |
1221 | 1225 | ||
1226 | btrfs_abort_transaction(trans, root, err); | ||
1227 | |||
1222 | spin_lock(&root->fs_info->trans_lock); | 1228 | spin_lock(&root->fs_info->trans_lock); |
1223 | list_del_init(&cur_trans->list); | 1229 | list_del_init(&cur_trans->list); |
1224 | if (cur_trans == root->fs_info->running_transaction) { | 1230 | if (cur_trans == root->fs_info->running_transaction) { |
@@ -1530,7 +1536,7 @@ cleanup_transaction: | |||
1530 | // WARN_ON(1); | 1536 | // WARN_ON(1); |
1531 | if (current->journal_info == trans) | 1537 | if (current->journal_info == trans) |
1532 | current->journal_info = NULL; | 1538 | current->journal_info = NULL; |
1533 | cleanup_transaction(trans, root); | 1539 | cleanup_transaction(trans, root, ret); |
1534 | 1540 | ||
1535 | return ret; | 1541 | return ret; |
1536 | } | 1542 | } |