]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Btrfs: fix tree corruption after multi-thread snapshots and inode_cache flush
authorLiu Bo <liubo2009@cn.fujitsu.com>
Tue, 15 Nov 2011 01:48:06 +0000 (20:48 -0500)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:21:03 +0000 (21:21 -0500)
commit14acd470355a7399016d1359f7f588a1f8d0540b
tree0bf509ad36de5788098e621d46f47b3c65d512ac
parentbe04ca36c5e75d244aa8531c5adade2b05c6a997
Btrfs: fix tree corruption after multi-thread snapshots and inode_cache flush

The btrfs snapshotting code requires that once a root has been
snapshotted, we don't change it during a commit.

But there are two cases to lead to tree corruptions:

1) multi-thread snapshots can commit serveral snapshots in a transaction,
   and this may change the src root when processing the following pending
   snapshots, which lead to the former snapshots corruptions;

2) the free inode cache was changing the roots when it root the cache,
   which lead to corruptions.

This fixes things by making sure we force COW the block after we create a
snapshot during commiting a transaction, then any changes to the roots
will result in COW, and we get all the fs roots and snapshot roots to be
consistent.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit f1ebcc74d5b2159f44c96b479b6eb8afc7829095)
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/transaction.c