From: Anand Jain <Anand.Jain@oracle.com>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: [Report] corrupted root csum tree result in segfault.
Date: Tue, 26 Jun 2012 14:05:58 +0800 [thread overview]
Message-ID: <4FE95146.2030707@oracle.com> (raw)
# mkfs.btrfs /dev/sdd && btrfs-debug-tree -R /dev/sdd | egrep checksum
::
checksum tree key (CSUM_TREE ROOT_ITEM 0) 29376512 level 0
# btrfs-corrupt-block -l 29376512 /dev/sdd
mirror 1 logical 29376512 physical 37765120 device /dev/sdd
corrupting 29376512 copy 1
mirror 2 logical 29376512 physical 145113088 device /dev/sdd
corrupting 29376512 copy 2
# btrfsck /dev/sdd
Check tree block failed, want=29376512, have=0
Check tree block failed, want=29376512, have=0
Check tree block failed, want=29376512, have=0
Check tree block failed, want=29376512, have=0
Check tree block failed, want=29376512, have=0
read block failed check_tree_block
Couldn't setup csum tree
checking extents
Check tree block failed, want=29376512, have=0
Check tree block failed, want=29376512, have=0
Check tree block failed, want=29376512, have=0
Check tree block failed, want=29376512, have=0
Check tree block failed, want=29376512, have=0
read block failed check_tree_block <---- !!
Segmentation fault (core dumped) <--- !!
#
----------------
read_tree_block frees buf and returns NULL
----------------
struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
u32 blocksize, u64 parent_transid)
{
::
while (1) {
::
if (ignore) {
if (check_tree_block(root, eb))
printk("read block failed check_tree_block\n"); <----
else
printk("Csum didn't match\n");
break;
}
::
}
free_extent_buffer(eb);
return NULL;
}
----------------
we don't check if the buf is NULL and fails with
Segmentation faults in add_root_to_pending
---------------------
static int check_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *root, int repair)
{
::
buf = read_tree_block(root->fs_info->tree_root,
btrfs_root_bytenr(&ri),
btrfs_level_size(root,
btrfs_root_level(&ri)), 0); <--- buf is NULL
add_root_to_pending(buf, bits, bits_nr, &extent_cache,
&pending, &seen, &reada, &nodes,
&found_key);
free_extent_buffer(buf);
}
-----------------------
Seems like the simple fix is to redirect btrfsck user to use
--init-csum-tree when csum root is corrupted
thanks
Anand
next reply other threads:[~2012-06-26 6:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 6:05 Anand Jain [this message]
2012-07-03 4:04 ` [PATCH] Seg fault when csum-tree root is corrupted Anand jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FE95146.2030707@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.