Bug 60524 - WARNING: at fs/btrfs/inode.c:4745 inode_tree_add while defragmenting
Summary: WARNING: at fs/btrfs/inode.c:4745 inode_tree_add while defragmenting
Status: RESOLVED CODE_FIX
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-05 21:45 UTC by Grzegorz Kowal
Modified: 2016-04-07 11:26 UTC (History)
3 users (show)

See Also:
Kernel Version: 3.9.9 + btrfs-next
Subsystem:
Regression: No
Bisected commit-id:


Attachments
syslog messages (49.82 KB, application/x-gzip)
2013-09-23 13:37 UTC, David Sterba
Details

Description Grzegorz Kowal 2013-07-05 21:45:12 UTC
While running defragmentation:

find /opt -type f -exec btrfs fi defrag {} \;

I've got some warnings:

 [  822.390399] ------------[ cut here ]------------
[  822.390418] WARNING: at fs/btrfs/inode.c:4745 inode_tree_add+0x164/0x170()
[  822.390423] Hardware name: U36JC
[  822.390426] Modules linked in: ipv6 bbswitch(O) rfcomm snd_hda_codec_realtek iwldvm mac80211 iwlwifi snd_hda_intel snd_hda_codec cfg80211 snd_hwdep snd_pcm coretemp btusb snd_page_alloc pcspkr kvm_intel kvm bluetooth microcode uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_core r8169 crc16 xhci_hcd videodev psmouse [last unloaded: nvidia]
[  822.390474] Pid: 5908, comm: btrfs-endio-wri Tainted: P       A   O 3.9.9-acrux #25
[  822.390478] Call Trace:
[  822.390491]  [<ffffffff8103ab3b>] ? warn_slowpath_common+0x7b/0xc0
[  822.390498]  [<ffffffff8124dfe4>] ? inode_tree_add+0x164/0x170
[  822.390505]  [<ffffffff812575e7>] ? btrfs_iget+0x147/0x550
[  822.390512]  [<ffffffff81257b01>] ? relink_extent_backref+0x111/0x830
[  822.390520]  [<ffffffff81258419>] ? btrfs_finish_ordered_io+0x1f9/0x9c0
[  822.390528]  [<ffffffff81279551>] ? worker_loop+0x151/0x550
[  822.390534]  [<ffffffff81279400>] ? btrfs_queue_worker+0x330/0x330
[  822.390543]  [<ffffffff8105dd33>] ? kthread+0xb3/0xc0
[  822.390550]  [<ffffffff81060000>] ? posix_cpu_nsleep_restart+0x30/0xa0
[  822.390556]  [<ffffffff8105dc80>] ? flush_kthread_worker+0xa0/0xa0
[  822.390567]  [<ffffffff815b4bec>] ? ret_from_fork+0x7c/0xb0
[  822.390574]  [<ffffffff8105dc80>] ? flush_kthread_worker+0xa0/0xa0
[  822.390578] ---[ end trace 287ea8332180a9d2 ]---
[  845.904032] btrfs: defrag_file cancelled

I've tested today's btrfs-next (commit ef343c54e55dc6cbb67fb68b915a5a5a1cae7a8e) and the same happens.

My mount options are

/dev/sda3 on / type btrfs (rw,noatime,nodiratime,compress=lzo,noacl,space_cache)
Comment 1 Josef Bacik 2013-07-09 00:45:00 UTC
Do you have snapshots or anything?  Did you use any special options when making the file system?  I've been running this command _a lot_ recently and I haven't seen this, so hopefully you are doing something different from me.
Comment 2 Grzegorz Kowal 2013-07-09 03:34:29 UTC
Yes, I use read only snapshots, but I didn't use any special options when I created the file system.  When I switched to kernel 3.9 I encountered the oops during defragmentation several times (__tree_mod_log_rewind bug reported in https://bugzilla.kernel.org/show_bug.cgi?id=56671), so I had to remove autodefrag option from my mount options.

Do you think that the oopses during defragmentation could leave the file system in an unusual state?
Comment 3 David Sterba 2013-09-23 13:36:00 UTC
I see this message with a 3.11 based kernel, there are lots of backref messages like the following one.

The system was freshly installed and running

while true; do
        echo 3 > /proc/sys/vm/drop_caches
        find / -xdev -type f -exec md5sum '{}' +
        find / -xdev -type f -exec btrfs fi defrag -clzo '{}' \;
        btrfs fi balance start /
        btrfs scrub start -Bd /
done

[ 1336.674400] ------------[ cut here ]------------
[ 1336.674439] WARNING: CPU: 0 PID: 3802 at /home/abuild/rpmbuild/BUILD/kernel-desktop-3.11.1/linux-3.11/fs/btrfs/inode.c:2206 record_one_backref+0x379/0x420 [btrfs]()
[ 1336.674486] CPU: 0 PID: 3802 Comm: btrfs-endio-wri Tainted: G        W    3.11.1-1.g1383321-desktop #1
[ 1336.674489] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[ 1336.674492]  0000000000000009 ffffffff815a9297 0000000000000000 ffffffff81050e02
[ 1336.674497]  ffff8800203a42e0 0000000000000001 ffff880079c33800 0000000000014c0b
[ 1336.674502]  ffff88003037b920 ffffffffa01638f9 00000000005c0000 0000000000000135
[ 1336.674507] Call Trace:
[ 1336.674538]  [<ffffffff81004988>] dump_trace+0x88/0x310
[ 1336.674546]  [<ffffffff81004ce0>] show_stack_log_lvl+0xd0/0x1d0
[ 1336.674553]  [<ffffffff8100612c>] show_stack+0x1c/0x50
[ 1336.674562]  [<ffffffff815a9297>] dump_stack+0x50/0x89
[ 1336.674571]  [<ffffffff81050e02>] warn_slowpath_common+0x72/0x90
[ 1336.674596]  [<ffffffffa01638f9>] record_one_backref+0x379/0x420 [btrfs]
[ 1336.674684]  [<ffffffffa01b8716>] iterate_extent_inodes+0x1c6/0x320 [btrfs]
[ 1336.674846]  [<ffffffffa01b88f4>] iterate_inodes_from_logical+0x84/0xa0 [btrfs]
[ 1336.675004]  [<ffffffffa01620db>] record_extent_backrefs+0x6b/0xe0 [btrfs]
[ 1336.675154]  [<ffffffffa016c560>] btrfs_finish_ordered_io+0x150/0x990 [btrfs]
[ 1336.675248]  [<ffffffffa018cae9>] worker_loop+0x149/0x550 [btrfs]
[ 1336.675351]  [<ffffffff81071b1f>] kthread+0xaf/0xc0
[ 1336.675359]  [<ffffffff815b6dfc>] ret_from_fork+0x7c/0xb0
[ 1336.675597] ---[ end trace 3960f2ebba1c6e7d ]---

and the inode_tree_add

[ 1452.616673] ------------[ cut here ]------------
[ 1452.616695] WARNING: CPU: 0 PID: 3848 at /home/abuild/rpmbuild/BUILD/kernel-desktop-3.11.1/linux-3.11/fs/btrfs/inode.c:4746 inode_tree_add+0x135/0x140 [btrfs]()
[ 1452.616719] CPU: 0 PID: 3848 Comm: btrfs-endio-wri Tainted: G        W    3.11.1-1.g1383321-desktop #1
[ 1452.616721] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[ 1452.616722]  0000000000000009 ffffffff815a9297 0000000000000000 ffffffff81050e02
[ 1452.616725]  ffff880009d40448 ffff880024aed4a8 ffff880024aed4b0 0000000000007f95
[ 1452.616727]  ffff88002ac108b8 ffffffffa0162285 ffff88002ac108b8 ffff880003f2d420
[ 1452.616729] Call Trace:
[ 1452.616772]  [<ffffffff81004988>] dump_trace+0x88/0x310
[ 1452.616772]  [<ffffffff81004ce0>] show_stack_log_lvl+0xd0/0x1d0
[ 1452.616788]  [<ffffffff8100612c>] show_stack+0x1c/0x50
[ 1452.616788]  [<ffffffff815a9297>] dump_stack+0x50/0x89
[ 1452.616788]  [<ffffffff81050e02>] warn_slowpath_common+0x72/0x90
[ 1452.616807]  [<ffffffffa0162285>] inode_tree_add+0x135/0x140 [btrfs]
[ 1452.616822]  [<ffffffffa016b3af>] btrfs_iget+0x11f/0x530 [btrfs]
[ 1452.616862]  [<ffffffffa016bd38>] relink_extent_backref+0xd8/0x7b0 [btrfs]
[ 1452.616922]  [<ffffffffa016c609>] btrfs_finish_ordered_io+0x1f9/0x990 [btrfs]
[ 1452.616963]  [<ffffffffa018cae9>] worker_loop+0x149/0x550 [btrfs]
[ 1452.617083]  [<ffffffff81071b1f>] kthread+0xaf/0xc0
[ 1452.617119]  [<ffffffff815b6dfc>] ret_from_fork+0x7c/0xb0
[ 1452.617119] ---[ end trace 3960f2ebba1c6e82 ]---
Comment 4 David Sterba 2013-09-23 13:37:30 UTC
Created attachment 109301 [details]
syslog messages
Comment 5 Grzegorz Kowal 2013-09-24 12:47:37 UTC
I am currently on kernel 3.10.12 (without btrfs-next patches) and the warning still shows up:

[57713.010355] ------------[ cut here ]------------
[57713.010371] WARNING: at fs/btrfs/inode.c:4864 inode_tree_add+0x164/0x170()
[57713.010373] Modules linked in: usb_storage ipv6 bbswitch(O) rfcomm xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack iptable_filter ip_tables x_tables uvcvideo videobuf2_vmalloc videobuf2_memops psmouse btusb coretemp pcspkr microcode snd_hda_codec_realtek iwldvm mac80211 videobuf2_core bluetooth videodev crc16 snd_hda_intel snd_hda_codec snd_hwdep iwlwifi cfg80211 snd_pcm snd_page_alloc xhci_hcd mei_me r8169 mei [last unloaded: nvidia]
[57713.010409] CPU: 1 PID: 18438 Comm: btrfs-endio-wri Tainted: P       AW  O 3.10.12-acrux #1
[57713.010411] Hardware name: ASUSTeK Computer Inc. U36JC/U36JC, BIOS U36JC.206 02/25/2011
[57713.010413]  ffffffff815ab2ba 0000000000000000 ffffffff8103a4cc ffff88000e1e0138
[57713.010416]  0000000000009c04 ffff880015339580 ffff88018a5e24a0 ffff88018a5e24a8
[57713.010419]  ffffffff81247ec4 ffff880015339580 ffff88024277c630 ffff88018a5e2000
[57713.010422] Call Trace:
[57713.010428]  [<ffffffff815ab2ba>] ? dump_stack+0xd/0x17
[57713.010432]  [<ffffffff8103a4cc>] ? warn_slowpath_common+0x6c/0xa0
[57713.010435]  [<ffffffff81247ec4>] ? inode_tree_add+0x164/0x170
[57713.010437]  [<ffffffff81251d97>] ? btrfs_iget+0x147/0x550
[57713.010439]  [<ffffffff812522c1>] ? relink_extent_backref+0x121/0x810
[57713.010444]  [<ffffffff815a8700>] ? __slab_free+0x13a/0x2a2
[57713.010447]  [<ffffffff81252ba9>] ? btrfs_finish_ordered_io+0x1f9/0x990
[57713.010451]  [<ffffffff812728e1>] ? worker_loop+0x151/0x530
[57713.010455]  [<ffffffff815af0ea>] ? schedule+0x60a/0xdf0
[57713.010458]  [<ffffffff81272790>] ? btrfs_queue_worker+0x330/0x330
[57713.010462]  [<ffffffff8105e7e3>] ? kthread+0xb3/0xc0
[57713.010464]  [<ffffffff8105e730>] ? flush_kthread_work+0x100/0x100
[57713.010467]  [<ffffffff815b132c>] ? ret_from_fork+0x7c/0xb0
[57713.010469]  [<ffffffff8105e730>] ? flush_kthread_work+0x100/0x100
[57713.010471] ---[ end trace ef8f28bab661051a ]---
Comment 6 [account disabled by administrator] 2016-04-07 03:58:17 UTC
I don't known if your still having issues with this but if your try adding this line before the return statement in the function, btrfs_iget_locked for the file fs/btrfs/inode.c:
inode->i_state |= I_WILL_FREE | I_FREEING
Comment 7 David Sterba 2016-04-07 11:26:15 UTC
This has been fixed long time ago, besides that such messing with I_ flags is dangerous.

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