Home Home > GIT Browse > SLE15-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2019-08-16 16:50:02 +0100
committerFilipe Manana <fdmanana@suse.com>2019-08-16 16:50:02 +0100
commit38ff7a409cc7bac20ed19084147a9bfe3e8072a3 (patch)
tree760e954baa879e28aeb4c42782878202b32cc237
parentfaef505033124f75e5d24dab4a32c594370ad68a (diff)
Btrfs: fix race leading to fs corruption after transaction abort
(bsc#1145937). suse-commit: fc04aaf77625e365937c728afc3db574dcd8668f
-rw-r--r--fs/btrfs/transaction.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 5ce9180030e6..0d0f5b4b819f 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2064,6 +2064,16 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
}
} else {
spin_unlock(&fs_info->trans_lock);
+ /*
+ * The previous transaction was aborted and was already removed
+ * from the list of transactions at fs_info->trans_list. So we
+ * abort to prevent writing a new superblock that reflects a
+ * corrupt state (pointing to trees with unwritten nodes/leafs).
+ */
+ if (test_bit(BTRFS_FS_STATE_TRANS_ABORTED, &fs_info->fs_state)) {
+ ret = -EROFS;
+ goto cleanup_transaction;
+ }
}
extwriter_counter_dec(cur_trans, trans->type);