path: root/ctree.c
diff options
authorJosef Bacik <>2013-10-01 09:00:19 -0400
committerChris Mason <>2013-10-16 08:23:12 -0400
commitc64485544baa9ffc5fbedd5661a05bdee1b37598 (patch)
tree4461ef770a41b3056a0f0763d308d4f6a53e07b6 /ctree.c
parent2454473dd1647e83d6eba9852eeb08d331e9ea9a (diff)
Btrfs-progs: keep track of transid failures and fix them if possible
A user was reporting an issue with bad transid errors on his blocks. The thing is that btrfs-progs will ignore transid failures for things like restore and fsck so we can do a best effort to fix a users file system. So fsck can put together a coherent view of the file system with stale blocks. So if everything else is ok in the mind of fsck then we can recow these blocks to fix the generation and the user can get their file system back. Thanks, Signed-off-by: Josef Bacik <> Signed-off-by: David Sterba <> Signed-off-by: Chris Mason <>
Diffstat (limited to 'ctree.c')
1 files changed, 6 insertions, 1 deletions
diff --git a/ctree.c b/ctree.c
index b54554bc..fdb1bcbf 100644
--- a/ctree.c
+++ b/ctree.c
@@ -293,7 +293,8 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
write_extent_buffer(cow, root->fs_info->fsid,
btrfs_header_fsid(), BTRFS_FSID_SIZE);
- WARN_ON(btrfs_header_generation(buf) > trans->transid);
+ WARN_ON(!(buf->flags & EXTENT_BAD_TRANSID) &&
+ btrfs_header_generation(buf) > trans->transid);
update_ref_for_cow(trans, root, buf, cow);
@@ -317,6 +318,10 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
btrfs_free_extent(trans, root, buf->start, buf->len,
0, root->root_key.objectid, level, 1);
+ if (!list_empty(&buf->recow)) {
+ list_del_init(&buf->recow);
+ free_extent_buffer(buf);
+ }
*cow_ret = cow;