Home Home > GIT Browse > SLE15
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-01-22 14:59:50 +0800
committerQu Wenruo <wqu@suse.com>2019-01-22 14:59:50 +0800
commit7c01025f649745370a81410f607d9a5397912f4c (patch)
treec161b69e680cfb7319e65cee0e6c2a764c5b449e
parentca68b03780fd48708e440269f871ce05e188d0f2 (diff)
btrfs: qgroup: Fix root item corruption when multiple same
source snapshots are created with quota enabled (bsc#1122324).
-rw-r--r--patches.fixes/0001-btrfs-qgroup-Fix-root-item-corruption-when-multiple-.patch62
-rw-r--r--series.conf1
2 files changed, 63 insertions, 0 deletions
diff --git a/patches.fixes/0001-btrfs-qgroup-Fix-root-item-corruption-when-multiple-.patch b/patches.fixes/0001-btrfs-qgroup-Fix-root-item-corruption-when-multiple-.patch
new file mode 100644
index 0000000000..c7e2ec7b02
--- /dev/null
+++ b/patches.fixes/0001-btrfs-qgroup-Fix-root-item-corruption-when-multiple-.patch
@@ -0,0 +1,62 @@
+From 4d31778aa2fa342f5f92ca4025b293a1729161d1 Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Tue, 19 Dec 2017 15:44:54 +0800
+Subject: [PATCH] btrfs: qgroup: Fix root item corruption when multiple same
+ source snapshots are created with quota enabled
+Git-commit: 4d31778aa2fa342f5f92ca4025b293a1729161d1
+Patch-mainline: v4.17-rc1
+References: bsc#1122324
+
+When multiple pending snapshots referring to the same source subvolume
+are executed, enabled quota will cause root item corruption, where root
+items are using old bytenr (no backref in extent tree).
+
+This can be triggered by fstests btrfs/152.
+
+The cause is when source subvolume is still dirty, extra commit
+(simplied transaction commit) of qgroup_account_snapshot() can skip
+dirty roots not recorded in current transaction, making root item of
+source subvolume not updated.
+
+Fix it by forcing recording source subvolume in current transaction
+before qgroup sub-transaction commit.
+
+Reported-by: Justin Maggard <jmaggard@netgear.com>
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: Filipe Manana <fdmanana@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/transaction.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
+index 665438542b96..17978fd731f6 100644
+--- a/fs/btrfs/transaction.c
++++ b/fs/btrfs/transaction.c
+@@ -319,7 +319,7 @@ static int record_root_in_trans(struct btrfs_trans_handle *trans,
+ if ((test_bit(BTRFS_ROOT_REF_COWS, &root->state) &&
+ root->last_trans < trans->transid) || force) {
+ WARN_ON(root == fs_info->extent_root);
+- WARN_ON(root->commit_root != root->node);
++ WARN_ON(!force && root->commit_root != root->node);
+
+ /*
+ * see below for IN_TRANS_SETUP usage rules
+@@ -1371,6 +1371,14 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
+ if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))
+ return 0;
+
++ /*
++ * Ensure dirty @src will be commited. Or, after comming
++ * commit_fs_roots() and switch_commit_roots(), any dirty but not
++ * recorded root will never be updated again, causing an outdated root
++ * item.
++ */
++ record_root_in_trans(trans, src, 1);
++
+ /*
+ * We are going to commit transaction, see btrfs_commit_transaction()
+ * comment for reason locking tree_log_mutex
+--
+2.20.1
+
diff --git a/series.conf b/series.conf
index 6c9a369289..b4a9145991 100644
--- a/series.conf
+++ b/series.conf
@@ -14705,6 +14705,7 @@
patches.fixes/xfs-catch-inode-allocation-state-mismatch-corruption.patch
patches.suse/btrfs-do-not-check-inode-s-runtime-flags-under-root-orphan_lock.patch
patches.suse/0014-btrfs-tree-checker-Replace-root-parameter-with-fs_in.patch
+ patches.fixes/0001-btrfs-qgroup-Fix-root-item-corruption-when-multiple-.patch
patches.suse/btrfs-handle-error-from-btrfs_uuid_tree_rem-call-in-btrfs_ioctl_set_received_subvol.patch
patches.suse/btrfs-fix-lockdep-splat-in-btrfs_alloc_subvolume_writers.patch
patches.suse/btrfs-remove-dead-create_space_info-calls.patch