]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
Btrfs: abort the transaction if the commit fails
authorJosef Bacik <josef@redhat.com>
Thu, 31 May 2012 19:52:43 +0000 (15:52 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 15 Jun 2012 01:29:13 +0000 (21:29 -0400)
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>
fs/btrfs/transaction.c

index 59e0203bfb9526e3ebbe360bd1ceba8ae4e4e6bd..b72b068183ec6bb334a1cb9088ffa02d7eb13029 100644 (file)
@@ -100,6 +100,10 @@ loop:
                kmem_cache_free(btrfs_transaction_cachep, cur_trans);
                cur_trans = fs_info->running_transaction;
                goto loop;
+       } else if (root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) {
+               spin_unlock(&root->fs_info->trans_lock);
+               kmem_cache_free(btrfs_transaction_cachep, cur_trans);
+               return -EROFS;
        }
 
        atomic_set(&cur_trans->num_writers, 1);
@@ -1213,12 +1217,14 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
 
 
 static void cleanup_transaction(struct btrfs_trans_handle *trans,
-                               struct btrfs_root *root)
+                               struct btrfs_root *root, int err)
 {
        struct btrfs_transaction *cur_trans = trans->transaction;
 
        WARN_ON(trans->use_count > 1);
 
+       btrfs_abort_transaction(trans, root, err);
+
        spin_lock(&root->fs_info->trans_lock);
        list_del_init(&cur_trans->list);
        if (cur_trans == root->fs_info->running_transaction) {
@@ -1530,7 +1536,7 @@ cleanup_transaction:
 //     WARN_ON(1);
        if (current->journal_info == trans)
                current->journal_info = NULL;
-       cleanup_transaction(trans, root);
+       cleanup_transaction(trans, root, ret);
 
        return ret;
 }