diff options
author | Filipe Manana <fdmanana@suse.com> | 2015-03-23 14:07:40 +0000 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-03-26 17:56:24 -0700 |
commit | dcc82f4783ad91d4ab654f89f37ae9291cdc846a (patch) | |
tree | 314961b1a50008eba2da794b2ee7ccd9829d1739 /fs/btrfs/xattr.c | |
parent | 2f2ff0ee5e4303e727cfd7abd4133d1a8ee68394 (diff) | |
download | lwn-dcc82f4783ad91d4ab654f89f37ae9291cdc846a.tar.gz lwn-dcc82f4783ad91d4ab654f89f37ae9291cdc846a.zip |
Btrfs: fix log tree corruption when fs mounted with -o discard
While committing a transaction we free the log roots before we write the
new super block. Freeing the log roots implies marking the disk location
of every node/leaf (metadata extent) as pinned before the new super block
is written. This is to prevent the disk location of log metadata extents
from being reused before the new super block is written, otherwise we
would have a corrupted log tree if before the new super block is written
a crash/reboot happens and the location of any log tree metadata extent
ended up being reused and rewritten.
Even though we pinned the log tree's metadata extents, we were issuing a
discard against them if the fs was mounted with the -o discard option,
resulting in corruption of the log tree if a crash/reboot happened before
writing the new super block - the next time the fs was mounted, during
the log replay process we would find nodes/leafs of the log btree with
a content full of zeroes, causing the process to fail and require the
use of the tool btrfs-zero-log to wipeout the log tree (and all data
previously fsynced becoming lost forever).
Fix this by not doing a discard when pinning an extent. The discard will
be done later when it's safe (after the new super block is committed) at
extent-tree.c:btrfs_finish_extent_commit().
Fixes: e688b7252f78 (Btrfs: fix extent pinning bugs in the tree log)
CC: <stable@vger.kernel.org>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/xattr.c')
0 files changed, 0 insertions, 0 deletions