Bug 196217 - btrfs check: cmds-check.c:5488: check_owner_ref: BUG_ON `rec->is_root` triggered, value 1
Summary: btrfs check: cmds-check.c:5488: check_owner_ref: BUG_ON `rec->is_root` trigge...
Status: RESOLVED PATCH_ALREADY_AVAILABLE
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 high
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-29 09:24 UTC by lakshmipathi
Modified: 2017-07-03 04:15 UTC (History)
2 users (show)

See Also:
Kernel Version: 4.9.0-040900-generic
Tree: Mainline
Regression: No


Attachments

Description lakshmipathi 2017-06-29 09:24:31 UTC
[This bug may be addressed by Liu patch(https://patchwork.kernel.org/patch/9815611/) but needs verification. ]

Step 1) Use --no-datasum option with btrfs-convert
# ./btrfs-convert --no-datasum tests/t1
create btrfs filesystem:
	blocksize: 4096
	nodesize:  16384
	features:  extref, skinny-metadata (default)
creating ext2 image file
creating btrfs metadatacopy inodes [o] [         0/        12]
conversion complete

Step 2) run btrfs check on newly converted image. It crashes like:
# ./btrfs check tests/t1               
Checking filesystem on tests/t1
UUID: e0b0e0bc-fb64-4139-8ff9-66438e0c3291
checking extents
cmds-check.c:5488: check_owner_ref: BUG_ON `rec->is_root` triggered, value 1
./btrfs[0x44c7b3]
./btrfs[0x459d94]
./btrfs[0x45ace2]
./btrfs[0x45b8ea]
./btrfs(cmd_check+0x19d7)[0x460250]
./btrfs(main+0x15d)[0x40abf3]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f48df01f830]
./btrfs(_start+0x29)[0x40a6c9]
Aborted (core dumped)

# ./btrfs --version
btrfs-progs v4.11-dirty

backtrace:
gdb) bt
#0  0x00007f3c03bd4418 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007f3c03bd601a in __GI_abort () at abort.c:89
#2  0x0000000000459d99 in bugon_trace (val=<optimized out>, line=5488, func=<synthetic pointer>, filename=0x4882d5 "cmds-check.c", 
    assertion=0x488780 "rec->is_root") at kerncompat.h:115
#3  check_owner_ref (buf=0x828a30, rec=0x836080, root=0x82cf20) at cmds-check.c:5488
#4  check_block (flags=<optimized out>, buf=0x828a30, extent_cache=0x7ffd96ee4d20, root=0x82cf20) at cmds-check.c:5884
#5  run_next_block (root=root@entry=0x82cf20, bits=bits@entry=0x831620, bits_nr=bits_nr@entry=1024, last=last@entry=0x7ffd96ee4ae8, 
    pending=pending@entry=0x7ffd96ee4d40, seen=seen@entry=0x7ffd96ee4d30, reada=0x7ffd96ee4d50, nodes=0x7ffd96ee4d60, 
    extent_cache=0x7ffd96ee4d20, chunk_cache=0x7ffd96ee4d10, dev_cache=0x7ffd96ee4d00, block_group_cache=0x7ffd96ee4e10, 
    dev_extent_cache=0x7ffd96ee4e30, ri=0x835720) at cmds-check.c:7733
#6  0x000000000045ace2 in deal_root_from_list (list=list@entry=0x7ffd96ee4d90, root=root@entry=0x82cf20, bits=bits@entry=0x831620, 
    bits_nr=bits_nr@entry=1024, pending=pending@entry=0x7ffd96ee4d40, seen=seen@entry=0x7ffd96ee4d30, reada=0x7ffd96ee4d50, 
    nodes=0x7ffd96ee4d60, extent_cache=0x7ffd96ee4d20, chunk_cache=0x7ffd96ee4d10, dev_cache=0x7ffd96ee4d00, 
    block_group_cache=0x7ffd96ee4e10, dev_extent_cache=0x7ffd96ee4e30) at cmds-check.c:9797
#7  0x000000000045b8ea in check_chunks_and_extents (root=root@entry=0x82cf20) at cmds-check.c:9964
#8  0x0000000000460250 in cmd_check (argc=<optimized out>, argv=<optimized out>) at cmds-check.c:13025
#9  0x000000000040abf3 in main (argc=2, argv=0x7ffd96ee5760) at btrfs.c:302
(gdb) f 3
#3  check_owner_ref (buf=0x828a30, rec=0x836080, root=0x82cf20) at cmds-check.c:5488
5488		BUG_ON(rec->is_root);
(gdb) p rec->is_root
$1 = 1
(gdb) f 4
#4  check_block (flags=<optimized out>, buf=0x828a30, extent_cache=0x7ffd96ee4d20, root=0x82cf20) at cmds-check.c:5884
5884				ret = check_owner_ref(root, rec, buf);
(gdb) p root
$2 = (struct btrfs_root *) 0x82cf20
(gdb) p *root
$3 = {node = 0x82d180, commit_root = 0x0, root_item = {inode = {generation = 1, transid = 0, size = 3, nbytes = 16384, block_group = 0, 
      nlink = 1, uid = 0, gid = 0, mode = 16877, rdev = 0, flags = 0, sequence = 0, reserved = {0, 0, 0, 0}, atime = {sec = 0, nsec = 0}, 
      ctime = {sec = 0, nsec = 0}, mtime = {sec = 0, nsec = 0}, otime = {sec = 0, nsec = 0}}, generation = 5, root_dirid = 256, 
    bytenr = 67190784, byte_limit = 0, bytes_used = 16384, last_snapshot = 0, flags = 0, refs = 1, drop_progress = {objectid = 0, 
      type = 0 '\000', offset = 0}, drop_level = 0 '\000', level = 0 '\000', generation_v2 = 5, uuid = '\000' <repeats 15 times>, 
    parent_uuid = '\000' <repeats 15 times>, received_uuid = '\000' <repeats 15 times>, ctransid = 0, otransid = 0, stransid = 0, 
    rtransid = 0, ctime = {sec = 0, nsec = 0}, otime = {sec = 0, nsec = 0}, stime = {sec = 0, nsec = 0}, rtime = {sec = 0, nsec = 0}, 
    reserved = {0, 0, 0, 0, 0, 0, 0, 0}}, root_key = {objectid = 5, type = 132 '\204', offset = 0}, fs_info = 0x8163a0, objectid = 5, 
  last_trans = 0, sectorsize = 4096, nodesize = 16384, leafsize = 16384, stripesize = 4096, ref_cows = 1, track_dirty = 0, type = 0, 
  last_inode_alloc = 0, orphan_data_extents = {next = 0x82d138, prev = 0x82d138}, dirty_list = {next = 0x82d148, prev = 0x82d148}, rb_node = {
    __rb_parent_color = 1, rb_right = 0x0, rb_left = 0x0}}
(gdb) p *rec 
$4 = {backrefs = {next = 0x835920, prev = 0x835aa0}, dups = {next = 0x836090, prev = 0x836090}, list = {next = 0x8360a0, prev = 0x8360a0}, 
  cache = {rb_node = {__rb_parent_color = 1, rb_right = 0x8369d0, rb_left = 0x836320}, objectid = 0, start = 67239936, size = 16384}, 
  parent_key = {objectid = 0, type = 0 '\000', offset = 0}, start = 67239936, max_size = 16384, nr = 16384, refs = 1, extent_item_refs = 1, 
  generation = 1, parent_generation = 0, info_objectid = 1048576, num_duplicates = 0, info_level = 0 '\000', flag_block_full_backref = 0, 
  found_rec = 1, content_checked = 1, owner_ref_checked = 0, is_root = 1, metadata = 1, bad_full_backref = 0, crossing_stripes = 0, 
  wrong_chunk_type = 0}
Comment 1 lakshmipathi 2017-07-02 12:17:02 UTC
(In reply to lakshmipathi from comment #0)
> [This bug may be addressed by Liu
> patch(https://patchwork.kernel.org/patch/9815611/) but needs verification. ]
> 

Tested with above patch. Even now below steps crashes.


mkfs.ext4 tests/t1 #repeat  for ext2 and ext3
mount tests/t1 /data
cp -r *.c /data
umount /data
./btrfs-convert --no-datasum tests/t1
./btrfs check tests/t1
<you will  get the crash>
Comment 2 lakshmipathi 2017-07-03 04:15:12 UTC
Works with v4.11.1. Its not a valid issue.

Note You need to log in before you can comment on or make changes to this bug.