<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/fs/btrfs/disk-io.c, branch v4.4.16</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Btrfs: fix deadlock running delayed iputs at transaction commit time</title>
<updated>2016-03-09T23:34:49+00:00</updated>
<author>
<name>Filipe Manana</name>
<email>fdmanana@suse.com</email>
</author>
<published>2016-01-15T11:05:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2232d6dc0017502b02157000afea6815a6810c2a'/>
<id>2232d6dc0017502b02157000afea6815a6810c2a</id>
<content type='text'>
commit c2d6cb1636d235257086f939a8194ef0bf93af6e upstream.

While running a stress test I ran into a deadlock when running the delayed
iputs at transaction time, which produced the following report and trace:

[  886.399989] =============================================
[  886.400871] [ INFO: possible recursive locking detected ]
[  886.401663] 4.4.0-rc6-btrfs-next-18+ #1 Not tainted
[  886.402384] ---------------------------------------------
[  886.403182] fio/8277 is trying to acquire lock:
[  886.403568]  (&amp;fs_info-&gt;delayed_iput_sem){++++..}, at: [&lt;ffffffffa0538823&gt;] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.403568]
[  886.403568] but task is already holding lock:
[  886.403568]  (&amp;fs_info-&gt;delayed_iput_sem){++++..}, at: [&lt;ffffffffa0538823&gt;] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.403568]
[  886.403568] other info that might help us debug this:
[  886.403568]  Possible unsafe locking scenario:
[  886.403568]
[  886.403568]        CPU0
[  886.403568]        ----
[  886.403568]   lock(&amp;fs_info-&gt;delayed_iput_sem);
[  886.403568]   lock(&amp;fs_info-&gt;delayed_iput_sem);
[  886.403568]
[  886.403568]  *** DEADLOCK ***
[  886.403568]
[  886.403568]  May be due to missing lock nesting notation
[  886.403568]
[  886.403568] 3 locks held by fio/8277:
[  886.403568]  #0:  (sb_writers#11){.+.+.+}, at: [&lt;ffffffff81174c4c&gt;] __sb_start_write+0x5f/0xb0
[  886.403568]  #1:  (&amp;sb-&gt;s_type-&gt;i_mutex_key#15){+.+.+.}, at: [&lt;ffffffffa054620d&gt;] btrfs_file_write_iter+0x73/0x408 [btrfs]
[  886.403568]  #2:  (&amp;fs_info-&gt;delayed_iput_sem){++++..}, at: [&lt;ffffffffa0538823&gt;] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.403568]
[  886.403568] stack backtrace:
[  886.403568] CPU: 6 PID: 8277 Comm: fio Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[  886.403568] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS by qemu-project.org 04/01/2014
[  886.403568]  0000000000000000 ffff88009f80f770 ffffffff8125d4fd ffffffff82af1fc0
[  886.403568]  ffff88009f80f830 ffffffff8108e5f9 0000000200000000 ffff88009fd92290
[  886.403568]  0000000000000000 ffffffff82af1fc0 ffffffff829cfb01 00042b216d008804
[  886.403568] Call Trace:
[  886.403568]  [&lt;ffffffff8125d4fd&gt;] dump_stack+0x4e/0x79
[  886.403568]  [&lt;ffffffff8108e5f9&gt;] __lock_acquire+0xd42/0xf0b
[  886.403568]  [&lt;ffffffff810c22db&gt;] ? __module_address+0xdf/0x108
[  886.403568]  [&lt;ffffffff8108eb77&gt;] lock_acquire+0x10d/0x194
[  886.403568]  [&lt;ffffffff8108eb77&gt;] ? lock_acquire+0x10d/0x194
[  886.403568]  [&lt;ffffffffa0538823&gt;] ? btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.489542]  [&lt;ffffffff8148556b&gt;] down_read+0x3e/0x4d
[  886.489542]  [&lt;ffffffffa0538823&gt;] ? btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.489542]  [&lt;ffffffffa0538823&gt;] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.489542]  [&lt;ffffffffa0533953&gt;] btrfs_commit_transaction+0x8f5/0x96e [btrfs]
[  886.489542]  [&lt;ffffffffa0521d7a&gt;] flush_space+0x435/0x44a [btrfs]
[  886.489542]  [&lt;ffffffffa052218b&gt;] ? reserve_metadata_bytes+0x26a/0x384 [btrfs]
[  886.489542]  [&lt;ffffffffa05221ae&gt;] reserve_metadata_bytes+0x28d/0x384 [btrfs]
[  886.489542]  [&lt;ffffffffa052256c&gt;] ? btrfs_block_rsv_refill+0x58/0x96 [btrfs]
[  886.489542]  [&lt;ffffffffa0522584&gt;] btrfs_block_rsv_refill+0x70/0x96 [btrfs]
[  886.489542]  [&lt;ffffffffa053d747&gt;] btrfs_evict_inode+0x394/0x55a [btrfs]
[  886.489542]  [&lt;ffffffff81188e31&gt;] evict+0xa7/0x15c
[  886.489542]  [&lt;ffffffff81189878&gt;] iput+0x1d3/0x266
[  886.489542]  [&lt;ffffffffa053887c&gt;] btrfs_run_delayed_iputs+0x8f/0xbf [btrfs]
[  886.489542]  [&lt;ffffffffa0533953&gt;] btrfs_commit_transaction+0x8f5/0x96e [btrfs]
[  886.489542]  [&lt;ffffffff81085096&gt;] ? signal_pending_state+0x31/0x31
[  886.489542]  [&lt;ffffffffa0521191&gt;] btrfs_alloc_data_chunk_ondemand+0x1d7/0x288 [btrfs]
[  886.489542]  [&lt;ffffffffa0521282&gt;] btrfs_check_data_free_space+0x40/0x59 [btrfs]
[  886.489542]  [&lt;ffffffffa05228f5&gt;] btrfs_delalloc_reserve_space+0x1e/0x4e [btrfs]
[  886.489542]  [&lt;ffffffffa053620a&gt;] btrfs_direct_IO+0x10c/0x27e [btrfs]
[  886.489542]  [&lt;ffffffff8111d9a1&gt;] generic_file_direct_write+0xb3/0x128
[  886.489542]  [&lt;ffffffffa05463c3&gt;] btrfs_file_write_iter+0x229/0x408 [btrfs]
[  886.489542]  [&lt;ffffffff8108ae38&gt;] ? __lock_is_held+0x38/0x50
[  886.489542]  [&lt;ffffffff8117279e&gt;] __vfs_write+0x7c/0xa5
[  886.489542]  [&lt;ffffffff81172cda&gt;] vfs_write+0xa0/0xe4
[  886.489542]  [&lt;ffffffff811734cc&gt;] SyS_write+0x50/0x7e
[  886.489542]  [&lt;ffffffff814872d7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6f
[ 1081.852335] INFO: task fio:8244 blocked for more than 120 seconds.
[ 1081.854348]       Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[ 1081.857560] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1081.863227] fio        D ffff880213f9bb28     0  8244   8240 0x00000000
[ 1081.868719]  ffff880213f9bb28 00ffffff810fc6b0 ffffffff0000000a ffff88023ed55240
[ 1081.872499]  ffff880206b5d400 ffff880213f9c000 ffff88020a4d5318 ffff880206b5d400
[ 1081.876834]  ffffffff00000001 ffff880206b5d400 ffff880213f9bb40 ffffffff81482ba4
[ 1081.880782] Call Trace:
[ 1081.881793]  [&lt;ffffffff81482ba4&gt;] schedule+0x7f/0x97
[ 1081.883340]  [&lt;ffffffff81485eb5&gt;] rwsem_down_write_failed+0x2d5/0x325
[ 1081.895525]  [&lt;ffffffff8108d48d&gt;] ? trace_hardirqs_on_caller+0x16/0x1ab
[ 1081.897419]  [&lt;ffffffff81269723&gt;] call_rwsem_down_write_failed+0x13/0x20
[ 1081.899251]  [&lt;ffffffff81269723&gt;] ? call_rwsem_down_write_failed+0x13/0x20
[ 1081.901063]  [&lt;ffffffff81089fae&gt;] ? __down_write_nested.isra.0+0x1f/0x21
[ 1081.902365]  [&lt;ffffffff814855bd&gt;] down_write+0x43/0x57
[ 1081.903846]  [&lt;ffffffffa05211b0&gt;] ? btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1081.906078]  [&lt;ffffffffa05211b0&gt;] btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1081.908846]  [&lt;ffffffff8108d461&gt;] ? mark_held_locks+0x56/0x6c
[ 1081.910409]  [&lt;ffffffffa0521282&gt;] btrfs_check_data_free_space+0x40/0x59 [btrfs]
[ 1081.912482]  [&lt;ffffffffa05228f5&gt;] btrfs_delalloc_reserve_space+0x1e/0x4e [btrfs]
[ 1081.914597]  [&lt;ffffffffa053620a&gt;] btrfs_direct_IO+0x10c/0x27e [btrfs]
[ 1081.919037]  [&lt;ffffffff8111d9a1&gt;] generic_file_direct_write+0xb3/0x128
[ 1081.920754]  [&lt;ffffffffa05463c3&gt;] btrfs_file_write_iter+0x229/0x408 [btrfs]
[ 1081.922496]  [&lt;ffffffff8108ae38&gt;] ? __lock_is_held+0x38/0x50
[ 1081.923922]  [&lt;ffffffff8117279e&gt;] __vfs_write+0x7c/0xa5
[ 1081.925275]  [&lt;ffffffff81172cda&gt;] vfs_write+0xa0/0xe4
[ 1081.926584]  [&lt;ffffffff811734cc&gt;] SyS_write+0x50/0x7e
[ 1081.927968]  [&lt;ffffffff814872d7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6f
[ 1081.985293] INFO: lockdep is turned off.
[ 1081.986132] INFO: task fio:8249 blocked for more than 120 seconds.
[ 1081.987434]       Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[ 1081.988534] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1081.990147] fio        D ffff880218febbb8     0  8249   8240 0x00000000
[ 1081.991626]  ffff880218febbb8 00ffffff81486b8e ffff88020000000b ffff88023ed75240
[ 1081.993258]  ffff8802120a9a00 ffff880218fec000 ffff88020a4d5318 ffff8802120a9a00
[ 1081.994850]  ffffffff00000001 ffff8802120a9a00 ffff880218febbd0 ffffffff81482ba4
[ 1081.996485] Call Trace:
[ 1081.997037]  [&lt;ffffffff81482ba4&gt;] schedule+0x7f/0x97
[ 1081.998017]  [&lt;ffffffff81485eb5&gt;] rwsem_down_write_failed+0x2d5/0x325
[ 1081.999241]  [&lt;ffffffff810852a5&gt;] ? finish_wait+0x6d/0x76
[ 1082.000306]  [&lt;ffffffff81269723&gt;] call_rwsem_down_write_failed+0x13/0x20
[ 1082.001533]  [&lt;ffffffff81269723&gt;] ? call_rwsem_down_write_failed+0x13/0x20
[ 1082.002776]  [&lt;ffffffff81089fae&gt;] ? __down_write_nested.isra.0+0x1f/0x21
[ 1082.003995]  [&lt;ffffffff814855bd&gt;] down_write+0x43/0x57
[ 1082.005000]  [&lt;ffffffffa05211b0&gt;] ? btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1082.007403]  [&lt;ffffffffa05211b0&gt;] btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1082.008988]  [&lt;ffffffffa0545064&gt;] btrfs_fallocate+0x7c1/0xc2f [btrfs]
[ 1082.010193]  [&lt;ffffffff8108a1ba&gt;] ? percpu_down_read+0x4e/0x77
[ 1082.011280]  [&lt;ffffffff81174c4c&gt;] ? __sb_start_write+0x5f/0xb0
[ 1082.012265]  [&lt;ffffffff81174c4c&gt;] ? __sb_start_write+0x5f/0xb0
[ 1082.013021]  [&lt;ffffffff811712e4&gt;] vfs_fallocate+0x170/0x1ff
[ 1082.013738]  [&lt;ffffffff81181ebb&gt;] ioctl_preallocate+0x89/0x9b
[ 1082.014778]  [&lt;ffffffff811822d7&gt;] do_vfs_ioctl+0x40a/0x4ea
[ 1082.015778]  [&lt;ffffffff81176ea7&gt;] ? SYSC_newfstat+0x25/0x2e
[ 1082.016806]  [&lt;ffffffff8118b4de&gt;] ? __fget_light+0x4d/0x71
[ 1082.017789]  [&lt;ffffffff8118240e&gt;] SyS_ioctl+0x57/0x79
[ 1082.018706]  [&lt;ffffffff814872d7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6f

This happens because we can recursively acquire the semaphore
fs_info-&gt;delayed_iput_sem when attempting to allocate space to satisfy
a file write request as shown in the first trace above - when committing
a transaction we acquire (down_read) the semaphore before running the
delayed iputs, and when running a delayed iput() we can end up calling
an inode's eviction handler, which in turn commits another transaction
and attempts to acquire (down_read) again the semaphore to run more
delayed iput operations.
This results in a deadlock because if a task acquires multiple times a
semaphore it should invoke down_read_nested() with a different lockdep
class for each level of recursion.

Fix this by simplifying the implementation and use a mutex instead that
is acquired by the cleaner kthread before it runs the delayed iputs
instead of always acquiring a semaphore before delayed references are
run from anywhere.

Fixes: d7c151717a1e (btrfs: Fix NO_SPACE bug caused by delayed-iput)
Signed-off-by: Filipe Manana &lt;fdmanana@suse.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit c2d6cb1636d235257086f939a8194ef0bf93af6e upstream.

While running a stress test I ran into a deadlock when running the delayed
iputs at transaction time, which produced the following report and trace:

[  886.399989] =============================================
[  886.400871] [ INFO: possible recursive locking detected ]
[  886.401663] 4.4.0-rc6-btrfs-next-18+ #1 Not tainted
[  886.402384] ---------------------------------------------
[  886.403182] fio/8277 is trying to acquire lock:
[  886.403568]  (&amp;fs_info-&gt;delayed_iput_sem){++++..}, at: [&lt;ffffffffa0538823&gt;] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.403568]
[  886.403568] but task is already holding lock:
[  886.403568]  (&amp;fs_info-&gt;delayed_iput_sem){++++..}, at: [&lt;ffffffffa0538823&gt;] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.403568]
[  886.403568] other info that might help us debug this:
[  886.403568]  Possible unsafe locking scenario:
[  886.403568]
[  886.403568]        CPU0
[  886.403568]        ----
[  886.403568]   lock(&amp;fs_info-&gt;delayed_iput_sem);
[  886.403568]   lock(&amp;fs_info-&gt;delayed_iput_sem);
[  886.403568]
[  886.403568]  *** DEADLOCK ***
[  886.403568]
[  886.403568]  May be due to missing lock nesting notation
[  886.403568]
[  886.403568] 3 locks held by fio/8277:
[  886.403568]  #0:  (sb_writers#11){.+.+.+}, at: [&lt;ffffffff81174c4c&gt;] __sb_start_write+0x5f/0xb0
[  886.403568]  #1:  (&amp;sb-&gt;s_type-&gt;i_mutex_key#15){+.+.+.}, at: [&lt;ffffffffa054620d&gt;] btrfs_file_write_iter+0x73/0x408 [btrfs]
[  886.403568]  #2:  (&amp;fs_info-&gt;delayed_iput_sem){++++..}, at: [&lt;ffffffffa0538823&gt;] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.403568]
[  886.403568] stack backtrace:
[  886.403568] CPU: 6 PID: 8277 Comm: fio Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[  886.403568] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS by qemu-project.org 04/01/2014
[  886.403568]  0000000000000000 ffff88009f80f770 ffffffff8125d4fd ffffffff82af1fc0
[  886.403568]  ffff88009f80f830 ffffffff8108e5f9 0000000200000000 ffff88009fd92290
[  886.403568]  0000000000000000 ffffffff82af1fc0 ffffffff829cfb01 00042b216d008804
[  886.403568] Call Trace:
[  886.403568]  [&lt;ffffffff8125d4fd&gt;] dump_stack+0x4e/0x79
[  886.403568]  [&lt;ffffffff8108e5f9&gt;] __lock_acquire+0xd42/0xf0b
[  886.403568]  [&lt;ffffffff810c22db&gt;] ? __module_address+0xdf/0x108
[  886.403568]  [&lt;ffffffff8108eb77&gt;] lock_acquire+0x10d/0x194
[  886.403568]  [&lt;ffffffff8108eb77&gt;] ? lock_acquire+0x10d/0x194
[  886.403568]  [&lt;ffffffffa0538823&gt;] ? btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.489542]  [&lt;ffffffff8148556b&gt;] down_read+0x3e/0x4d
[  886.489542]  [&lt;ffffffffa0538823&gt;] ? btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.489542]  [&lt;ffffffffa0538823&gt;] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[  886.489542]  [&lt;ffffffffa0533953&gt;] btrfs_commit_transaction+0x8f5/0x96e [btrfs]
[  886.489542]  [&lt;ffffffffa0521d7a&gt;] flush_space+0x435/0x44a [btrfs]
[  886.489542]  [&lt;ffffffffa052218b&gt;] ? reserve_metadata_bytes+0x26a/0x384 [btrfs]
[  886.489542]  [&lt;ffffffffa05221ae&gt;] reserve_metadata_bytes+0x28d/0x384 [btrfs]
[  886.489542]  [&lt;ffffffffa052256c&gt;] ? btrfs_block_rsv_refill+0x58/0x96 [btrfs]
[  886.489542]  [&lt;ffffffffa0522584&gt;] btrfs_block_rsv_refill+0x70/0x96 [btrfs]
[  886.489542]  [&lt;ffffffffa053d747&gt;] btrfs_evict_inode+0x394/0x55a [btrfs]
[  886.489542]  [&lt;ffffffff81188e31&gt;] evict+0xa7/0x15c
[  886.489542]  [&lt;ffffffff81189878&gt;] iput+0x1d3/0x266
[  886.489542]  [&lt;ffffffffa053887c&gt;] btrfs_run_delayed_iputs+0x8f/0xbf [btrfs]
[  886.489542]  [&lt;ffffffffa0533953&gt;] btrfs_commit_transaction+0x8f5/0x96e [btrfs]
[  886.489542]  [&lt;ffffffff81085096&gt;] ? signal_pending_state+0x31/0x31
[  886.489542]  [&lt;ffffffffa0521191&gt;] btrfs_alloc_data_chunk_ondemand+0x1d7/0x288 [btrfs]
[  886.489542]  [&lt;ffffffffa0521282&gt;] btrfs_check_data_free_space+0x40/0x59 [btrfs]
[  886.489542]  [&lt;ffffffffa05228f5&gt;] btrfs_delalloc_reserve_space+0x1e/0x4e [btrfs]
[  886.489542]  [&lt;ffffffffa053620a&gt;] btrfs_direct_IO+0x10c/0x27e [btrfs]
[  886.489542]  [&lt;ffffffff8111d9a1&gt;] generic_file_direct_write+0xb3/0x128
[  886.489542]  [&lt;ffffffffa05463c3&gt;] btrfs_file_write_iter+0x229/0x408 [btrfs]
[  886.489542]  [&lt;ffffffff8108ae38&gt;] ? __lock_is_held+0x38/0x50
[  886.489542]  [&lt;ffffffff8117279e&gt;] __vfs_write+0x7c/0xa5
[  886.489542]  [&lt;ffffffff81172cda&gt;] vfs_write+0xa0/0xe4
[  886.489542]  [&lt;ffffffff811734cc&gt;] SyS_write+0x50/0x7e
[  886.489542]  [&lt;ffffffff814872d7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6f
[ 1081.852335] INFO: task fio:8244 blocked for more than 120 seconds.
[ 1081.854348]       Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[ 1081.857560] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1081.863227] fio        D ffff880213f9bb28     0  8244   8240 0x00000000
[ 1081.868719]  ffff880213f9bb28 00ffffff810fc6b0 ffffffff0000000a ffff88023ed55240
[ 1081.872499]  ffff880206b5d400 ffff880213f9c000 ffff88020a4d5318 ffff880206b5d400
[ 1081.876834]  ffffffff00000001 ffff880206b5d400 ffff880213f9bb40 ffffffff81482ba4
[ 1081.880782] Call Trace:
[ 1081.881793]  [&lt;ffffffff81482ba4&gt;] schedule+0x7f/0x97
[ 1081.883340]  [&lt;ffffffff81485eb5&gt;] rwsem_down_write_failed+0x2d5/0x325
[ 1081.895525]  [&lt;ffffffff8108d48d&gt;] ? trace_hardirqs_on_caller+0x16/0x1ab
[ 1081.897419]  [&lt;ffffffff81269723&gt;] call_rwsem_down_write_failed+0x13/0x20
[ 1081.899251]  [&lt;ffffffff81269723&gt;] ? call_rwsem_down_write_failed+0x13/0x20
[ 1081.901063]  [&lt;ffffffff81089fae&gt;] ? __down_write_nested.isra.0+0x1f/0x21
[ 1081.902365]  [&lt;ffffffff814855bd&gt;] down_write+0x43/0x57
[ 1081.903846]  [&lt;ffffffffa05211b0&gt;] ? btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1081.906078]  [&lt;ffffffffa05211b0&gt;] btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1081.908846]  [&lt;ffffffff8108d461&gt;] ? mark_held_locks+0x56/0x6c
[ 1081.910409]  [&lt;ffffffffa0521282&gt;] btrfs_check_data_free_space+0x40/0x59 [btrfs]
[ 1081.912482]  [&lt;ffffffffa05228f5&gt;] btrfs_delalloc_reserve_space+0x1e/0x4e [btrfs]
[ 1081.914597]  [&lt;ffffffffa053620a&gt;] btrfs_direct_IO+0x10c/0x27e [btrfs]
[ 1081.919037]  [&lt;ffffffff8111d9a1&gt;] generic_file_direct_write+0xb3/0x128
[ 1081.920754]  [&lt;ffffffffa05463c3&gt;] btrfs_file_write_iter+0x229/0x408 [btrfs]
[ 1081.922496]  [&lt;ffffffff8108ae38&gt;] ? __lock_is_held+0x38/0x50
[ 1081.923922]  [&lt;ffffffff8117279e&gt;] __vfs_write+0x7c/0xa5
[ 1081.925275]  [&lt;ffffffff81172cda&gt;] vfs_write+0xa0/0xe4
[ 1081.926584]  [&lt;ffffffff811734cc&gt;] SyS_write+0x50/0x7e
[ 1081.927968]  [&lt;ffffffff814872d7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6f
[ 1081.985293] INFO: lockdep is turned off.
[ 1081.986132] INFO: task fio:8249 blocked for more than 120 seconds.
[ 1081.987434]       Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[ 1081.988534] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1081.990147] fio        D ffff880218febbb8     0  8249   8240 0x00000000
[ 1081.991626]  ffff880218febbb8 00ffffff81486b8e ffff88020000000b ffff88023ed75240
[ 1081.993258]  ffff8802120a9a00 ffff880218fec000 ffff88020a4d5318 ffff8802120a9a00
[ 1081.994850]  ffffffff00000001 ffff8802120a9a00 ffff880218febbd0 ffffffff81482ba4
[ 1081.996485] Call Trace:
[ 1081.997037]  [&lt;ffffffff81482ba4&gt;] schedule+0x7f/0x97
[ 1081.998017]  [&lt;ffffffff81485eb5&gt;] rwsem_down_write_failed+0x2d5/0x325
[ 1081.999241]  [&lt;ffffffff810852a5&gt;] ? finish_wait+0x6d/0x76
[ 1082.000306]  [&lt;ffffffff81269723&gt;] call_rwsem_down_write_failed+0x13/0x20
[ 1082.001533]  [&lt;ffffffff81269723&gt;] ? call_rwsem_down_write_failed+0x13/0x20
[ 1082.002776]  [&lt;ffffffff81089fae&gt;] ? __down_write_nested.isra.0+0x1f/0x21
[ 1082.003995]  [&lt;ffffffff814855bd&gt;] down_write+0x43/0x57
[ 1082.005000]  [&lt;ffffffffa05211b0&gt;] ? btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1082.007403]  [&lt;ffffffffa05211b0&gt;] btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1082.008988]  [&lt;ffffffffa0545064&gt;] btrfs_fallocate+0x7c1/0xc2f [btrfs]
[ 1082.010193]  [&lt;ffffffff8108a1ba&gt;] ? percpu_down_read+0x4e/0x77
[ 1082.011280]  [&lt;ffffffff81174c4c&gt;] ? __sb_start_write+0x5f/0xb0
[ 1082.012265]  [&lt;ffffffff81174c4c&gt;] ? __sb_start_write+0x5f/0xb0
[ 1082.013021]  [&lt;ffffffff811712e4&gt;] vfs_fallocate+0x170/0x1ff
[ 1082.013738]  [&lt;ffffffff81181ebb&gt;] ioctl_preallocate+0x89/0x9b
[ 1082.014778]  [&lt;ffffffff811822d7&gt;] do_vfs_ioctl+0x40a/0x4ea
[ 1082.015778]  [&lt;ffffffff81176ea7&gt;] ? SYSC_newfstat+0x25/0x2e
[ 1082.016806]  [&lt;ffffffff8118b4de&gt;] ? __fget_light+0x4d/0x71
[ 1082.017789]  [&lt;ffffffff8118240e&gt;] SyS_ioctl+0x57/0x79
[ 1082.018706]  [&lt;ffffffff814872d7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6f

This happens because we can recursively acquire the semaphore
fs_info-&gt;delayed_iput_sem when attempting to allocate space to satisfy
a file write request as shown in the first trace above - when committing
a transaction we acquire (down_read) the semaphore before running the
delayed iputs, and when running a delayed iput() we can end up calling
an inode's eviction handler, which in turn commits another transaction
and attempts to acquire (down_read) again the semaphore to run more
delayed iput operations.
This results in a deadlock because if a task acquires multiple times a
semaphore it should invoke down_read_nested() with a different lockdep
class for each level of recursion.

Fix this by simplifying the implementation and use a mutex instead that
is acquired by the cleaner kthread before it runs the delayed iputs
instead of always acquiring a semaphore before delayed references are
run from anywhere.

Fixes: d7c151717a1e (btrfs: Fix NO_SPACE bug caused by delayed-iput)
Signed-off-by: Filipe Manana &lt;fdmanana@suse.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: Initialize btrfs_root-&gt;highest_objectid when loading tree root and subvolume roots</title>
<updated>2016-03-03T23:07:12+00:00</updated>
<author>
<name>Chandan Rajendra</name>
<email>chandan@linux.vnet.ibm.com</email>
</author>
<published>2016-01-07T13:26:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8102f96ea48daf86a5f55c07699e926d8f9dee1f'/>
<id>8102f96ea48daf86a5f55c07699e926d8f9dee1f</id>
<content type='text'>
commit f32e48e925964c4f8ab917850788a87e1cef3bad upstream.

The following call trace is seen when btrfs/031 test is executed in a loop,

[  158.661848] ------------[ cut here ]------------
[  158.662634] WARNING: CPU: 2 PID: 890 at /home/chandan/repos/linux/fs/btrfs/ioctl.c:558 create_subvol+0x3d1/0x6ea()
[  158.664102] BTRFS: Transaction aborted (error -2)
[  158.664774] Modules linked in:
[  158.665266] CPU: 2 PID: 890 Comm: btrfs Not tainted 4.4.0-rc6-g511711a #2
[  158.666251] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
[  158.667392]  ffffffff81c0a6b0 ffff8806c7c4f8e8 ffffffff81431fc8 ffff8806c7c4f930
[  158.668515]  ffff8806c7c4f920 ffffffff81051aa1 ffff880c85aff000 ffff8800bb44d000
[  158.669647]  ffff8808863b5c98 0000000000000000 00000000fffffffe ffff8806c7c4f980
[  158.670769] Call Trace:
[  158.671153]  [&lt;ffffffff81431fc8&gt;] dump_stack+0x44/0x5c
[  158.671884]  [&lt;ffffffff81051aa1&gt;] warn_slowpath_common+0x81/0xc0
[  158.672769]  [&lt;ffffffff81051b27&gt;] warn_slowpath_fmt+0x47/0x50
[  158.673620]  [&lt;ffffffff813bc98d&gt;] create_subvol+0x3d1/0x6ea
[  158.674440]  [&lt;ffffffff813777c9&gt;] btrfs_mksubvol.isra.30+0x369/0x520
[  158.675376]  [&lt;ffffffff8108a4aa&gt;] ? percpu_down_read+0x1a/0x50
[  158.676235]  [&lt;ffffffff81377a81&gt;] btrfs_ioctl_snap_create_transid+0x101/0x180
[  158.677268]  [&lt;ffffffff81377b52&gt;] btrfs_ioctl_snap_create+0x52/0x70
[  158.678183]  [&lt;ffffffff8137afb4&gt;] btrfs_ioctl+0x474/0x2f90
[  158.678975]  [&lt;ffffffff81144b8e&gt;] ? vma_merge+0xee/0x300
[  158.679751]  [&lt;ffffffff8115be31&gt;] ? alloc_pages_vma+0x91/0x170
[  158.680599]  [&lt;ffffffff81123f62&gt;] ? lru_cache_add_active_or_unevictable+0x22/0x70
[  158.681686]  [&lt;ffffffff813d99cf&gt;] ? selinux_file_ioctl+0xff/0x1d0
[  158.682581]  [&lt;ffffffff8117b791&gt;] do_vfs_ioctl+0x2c1/0x490
[  158.683399]  [&lt;ffffffff813d3cde&gt;] ? security_file_ioctl+0x3e/0x60
[  158.684297]  [&lt;ffffffff8117b9d4&gt;] SyS_ioctl+0x74/0x80
[  158.685051]  [&lt;ffffffff819b2bd7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6a
[  158.685958] ---[ end trace 4b63312de5a2cb76 ]---
[  158.686647] BTRFS: error (device loop0) in create_subvol:558: errno=-2 No such entry
[  158.709508] BTRFS info (device loop0): forced readonly
[  158.737113] BTRFS info (device loop0): disk space caching is enabled
[  158.738096] BTRFS error (device loop0): Remounting read-write after error is not allowed
[  158.851303] BTRFS error (device loop0): cleaner transaction attach returned -30

This occurs because,

Mount filesystem
Create subvol with ID 257
Unmount filesystem
Mount filesystem
Delete subvol with ID 257
  btrfs_drop_snapshot()
    Add root corresponding to subvol 257 into
    btrfs_transaction-&gt;dropped_roots list
Create new subvol (i.e. create_subvol())
  257 is returned as the next free objectid
  btrfs_read_fs_root_no_name()
    Finds the btrfs_root instance corresponding to the old subvol with ID 257
    in btrfs_fs_info-&gt;fs_roots_radix.
    Returns error since btrfs_root_item-&gt;refs has the value of 0.

To fix the issue the commit initializes tree root's and subvolume root's
highest_objectid when loading the roots from disk.

Signed-off-by: Chandan Rajendra &lt;chandan@linux.vnet.ibm.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit f32e48e925964c4f8ab917850788a87e1cef3bad upstream.

The following call trace is seen when btrfs/031 test is executed in a loop,

[  158.661848] ------------[ cut here ]------------
[  158.662634] WARNING: CPU: 2 PID: 890 at /home/chandan/repos/linux/fs/btrfs/ioctl.c:558 create_subvol+0x3d1/0x6ea()
[  158.664102] BTRFS: Transaction aborted (error -2)
[  158.664774] Modules linked in:
[  158.665266] CPU: 2 PID: 890 Comm: btrfs Not tainted 4.4.0-rc6-g511711a #2
[  158.666251] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
[  158.667392]  ffffffff81c0a6b0 ffff8806c7c4f8e8 ffffffff81431fc8 ffff8806c7c4f930
[  158.668515]  ffff8806c7c4f920 ffffffff81051aa1 ffff880c85aff000 ffff8800bb44d000
[  158.669647]  ffff8808863b5c98 0000000000000000 00000000fffffffe ffff8806c7c4f980
[  158.670769] Call Trace:
[  158.671153]  [&lt;ffffffff81431fc8&gt;] dump_stack+0x44/0x5c
[  158.671884]  [&lt;ffffffff81051aa1&gt;] warn_slowpath_common+0x81/0xc0
[  158.672769]  [&lt;ffffffff81051b27&gt;] warn_slowpath_fmt+0x47/0x50
[  158.673620]  [&lt;ffffffff813bc98d&gt;] create_subvol+0x3d1/0x6ea
[  158.674440]  [&lt;ffffffff813777c9&gt;] btrfs_mksubvol.isra.30+0x369/0x520
[  158.675376]  [&lt;ffffffff8108a4aa&gt;] ? percpu_down_read+0x1a/0x50
[  158.676235]  [&lt;ffffffff81377a81&gt;] btrfs_ioctl_snap_create_transid+0x101/0x180
[  158.677268]  [&lt;ffffffff81377b52&gt;] btrfs_ioctl_snap_create+0x52/0x70
[  158.678183]  [&lt;ffffffff8137afb4&gt;] btrfs_ioctl+0x474/0x2f90
[  158.678975]  [&lt;ffffffff81144b8e&gt;] ? vma_merge+0xee/0x300
[  158.679751]  [&lt;ffffffff8115be31&gt;] ? alloc_pages_vma+0x91/0x170
[  158.680599]  [&lt;ffffffff81123f62&gt;] ? lru_cache_add_active_or_unevictable+0x22/0x70
[  158.681686]  [&lt;ffffffff813d99cf&gt;] ? selinux_file_ioctl+0xff/0x1d0
[  158.682581]  [&lt;ffffffff8117b791&gt;] do_vfs_ioctl+0x2c1/0x490
[  158.683399]  [&lt;ffffffff813d3cde&gt;] ? security_file_ioctl+0x3e/0x60
[  158.684297]  [&lt;ffffffff8117b9d4&gt;] SyS_ioctl+0x74/0x80
[  158.685051]  [&lt;ffffffff819b2bd7&gt;] entry_SYSCALL_64_fastpath+0x12/0x6a
[  158.685958] ---[ end trace 4b63312de5a2cb76 ]---
[  158.686647] BTRFS: error (device loop0) in create_subvol:558: errno=-2 No such entry
[  158.709508] BTRFS info (device loop0): forced readonly
[  158.737113] BTRFS info (device loop0): disk space caching is enabled
[  158.738096] BTRFS error (device loop0): Remounting read-write after error is not allowed
[  158.851303] BTRFS error (device loop0): cleaner transaction attach returned -30

This occurs because,

Mount filesystem
Create subvol with ID 257
Unmount filesystem
Mount filesystem
Delete subvol with ID 257
  btrfs_drop_snapshot()
    Add root corresponding to subvol 257 into
    btrfs_transaction-&gt;dropped_roots list
Create new subvol (i.e. create_subvol())
  257 is returned as the next free objectid
  btrfs_read_fs_root_no_name()
    Finds the btrfs_root instance corresponding to the old subvol with ID 257
    in btrfs_fs_info-&gt;fs_roots_radix.
    Returns error since btrfs_root_item-&gt;refs has the value of 0.

To fix the issue the commit initializes tree root's and subvolume root's
highest_objectid when loading the roots from disk.

Signed-off-by: Chandan Rajendra &lt;chandan@linux.vnet.ibm.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: add missing brelse when superblock checksum fails</title>
<updated>2016-03-03T23:07:11+00:00</updated>
<author>
<name>Anand Jain</name>
<email>anand.jain@oracle.com</email>
</author>
<published>2015-10-07T09:23:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=98d41a063d6584acc62ba1429ae074eac5d9d127'/>
<id>98d41a063d6584acc62ba1429ae074eac5d9d127</id>
<content type='text'>
commit b2acdddfad13c38a1e8b927d83c3cf321f63601a upstream.

Looks like oversight, call brelse() when checksum fails. Further down the
code, in the non error path, we do call brelse() and so we don't see
brelse() in the goto error paths.

Signed-off-by: Anand Jain &lt;anand.jain@oracle.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit b2acdddfad13c38a1e8b927d83c3cf321f63601a upstream.

Looks like oversight, call brelse() when checksum fails. Further down the
code, in the non error path, we do call brelse() and so we don't see
brelse() in the goto error paths.

Signed-off-by: Anand Jain &lt;anand.jain@oracle.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "btrfs: clear PF_NOFREEZE in cleaner_kthread()"</title>
<updated>2016-02-25T20:01:15+00:00</updated>
<author>
<name>David Sterba</name>
<email>dsterba@suse.com</email>
</author>
<published>2016-01-25T10:02:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=dfd2961ab6eda6c39aa9d7ddc5e6fb754b16a750'/>
<id>dfd2961ab6eda6c39aa9d7ddc5e6fb754b16a750</id>
<content type='text'>
commit 80ad623edd2d0ccb47d85357ee31c97e6c684e82 upstream.

This reverts commit 696249132158014d594896df3a81390616069c5c. The
cleaner thread can block freezing when there's a snapshot cleaning in
progress and the other threads get suspended first. From the logs
provided by Martin we're waiting for reading extent pages:

kernel: PM: Syncing filesystems ... done.
kernel: Freezing user space processes ... (elapsed 0.015 seconds) done.
kernel: Freezing remaining freezable tasks ...
kernel: Freezing of tasks failed after 20.003 seconds (1 tasks refusing to freeze, wq_busy=0):
kernel: btrfs-cleaner   D ffff88033dd13bc0     0   152      2 0x00000000
kernel: ffff88032ebc2e00 ffff88032e750000 ffff88032e74fa50 7fffffffffffffff
kernel: ffffffff814a58df 0000000000000002 ffffea000934d580 ffffffff814a5451
kernel: 7fffffffffffffff ffffffff814a6e8f 0000000000000000 0000000000000020
kernel: Call Trace:
kernel: [&lt;ffffffff814a58df&gt;] ? bit_wait+0x2c/0x2c
kernel: [&lt;ffffffff814a5451&gt;] ? schedule+0x6f/0x7c
kernel: [&lt;ffffffff814a6e8f&gt;] ? schedule_timeout+0x2f/0xd8
kernel: [&lt;ffffffff81076f94&gt;] ? timekeeping_get_ns+0xa/0x2e
kernel: [&lt;ffffffff81077603&gt;] ? ktime_get+0x36/0x44
kernel: [&lt;ffffffff814a4f6c&gt;] ? io_schedule_timeout+0x94/0xf2
kernel: [&lt;ffffffff814a4f6c&gt;] ? io_schedule_timeout+0x94/0xf2
kernel: [&lt;ffffffff814a590b&gt;] ? bit_wait_io+0x2c/0x30
kernel: [&lt;ffffffff814a5694&gt;] ? __wait_on_bit+0x41/0x73
kernel: [&lt;ffffffff8109eba8&gt;] ? wait_on_page_bit+0x6d/0x72
kernel: [&lt;ffffffff8105d718&gt;] ? autoremove_wake_function+0x2a/0x2a
kernel: [&lt;ffffffff811a02d7&gt;] ? read_extent_buffer_pages+0x1bd/0x203
kernel: [&lt;ffffffff8117d9e9&gt;] ? free_root_pointers+0x4c/0x4c
kernel: [&lt;ffffffff8117e831&gt;] ? btree_read_extent_buffer_pages.constprop.57+0x5a/0xe9
kernel: [&lt;ffffffff8117f4f3&gt;] ? read_tree_block+0x2d/0x45
kernel: [&lt;ffffffff8116782a&gt;] ? read_block_for_search.isra.34+0x22a/0x26b
kernel: [&lt;ffffffff811656c3&gt;] ? btrfs_set_path_blocking+0x1e/0x4a
kernel: [&lt;ffffffff8116919b&gt;] ? btrfs_search_slot+0x648/0x736
kernel: [&lt;ffffffff81170559&gt;] ? btrfs_lookup_extent_info+0xb7/0x2c7
kernel: [&lt;ffffffff81170ee5&gt;] ? walk_down_proc+0x9c/0x1ae
kernel: [&lt;ffffffff81171c9d&gt;] ? walk_down_tree+0x40/0xa4
kernel: [&lt;ffffffff8117375f&gt;] ? btrfs_drop_snapshot+0x2da/0x664
kernel: [&lt;ffffffff8104ff21&gt;] ? finish_task_switch+0x126/0x167
kernel: [&lt;ffffffff811850f8&gt;] ? btrfs_clean_one_deleted_snapshot+0xa6/0xb0
kernel: [&lt;ffffffff8117eaba&gt;] ? cleaner_kthread+0x13e/0x17b
kernel: [&lt;ffffffff8117e97c&gt;] ? btrfs_item_end+0x33/0x33
kernel: [&lt;ffffffff8104d256&gt;] ? kthread+0x95/0x9d
kernel: [&lt;ffffffff8104d1c1&gt;] ? kthread_parkme+0x16/0x16
kernel: [&lt;ffffffff814a7b5f&gt;] ? ret_from_fork+0x3f/0x70
kernel: [&lt;ffffffff8104d1c1&gt;] ? kthread_parkme+0x16/0x16

As this affects a released kernel (4.4) we need a minimal fix for
stable kernels.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=108361
Reported-by: Martin Ziegler &lt;ziegler@uni-freiburg.de&gt;
CC: Jiri Kosina &lt;jkosina@suse.cz&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 80ad623edd2d0ccb47d85357ee31c97e6c684e82 upstream.

This reverts commit 696249132158014d594896df3a81390616069c5c. The
cleaner thread can block freezing when there's a snapshot cleaning in
progress and the other threads get suspended first. From the logs
provided by Martin we're waiting for reading extent pages:

kernel: PM: Syncing filesystems ... done.
kernel: Freezing user space processes ... (elapsed 0.015 seconds) done.
kernel: Freezing remaining freezable tasks ...
kernel: Freezing of tasks failed after 20.003 seconds (1 tasks refusing to freeze, wq_busy=0):
kernel: btrfs-cleaner   D ffff88033dd13bc0     0   152      2 0x00000000
kernel: ffff88032ebc2e00 ffff88032e750000 ffff88032e74fa50 7fffffffffffffff
kernel: ffffffff814a58df 0000000000000002 ffffea000934d580 ffffffff814a5451
kernel: 7fffffffffffffff ffffffff814a6e8f 0000000000000000 0000000000000020
kernel: Call Trace:
kernel: [&lt;ffffffff814a58df&gt;] ? bit_wait+0x2c/0x2c
kernel: [&lt;ffffffff814a5451&gt;] ? schedule+0x6f/0x7c
kernel: [&lt;ffffffff814a6e8f&gt;] ? schedule_timeout+0x2f/0xd8
kernel: [&lt;ffffffff81076f94&gt;] ? timekeeping_get_ns+0xa/0x2e
kernel: [&lt;ffffffff81077603&gt;] ? ktime_get+0x36/0x44
kernel: [&lt;ffffffff814a4f6c&gt;] ? io_schedule_timeout+0x94/0xf2
kernel: [&lt;ffffffff814a4f6c&gt;] ? io_schedule_timeout+0x94/0xf2
kernel: [&lt;ffffffff814a590b&gt;] ? bit_wait_io+0x2c/0x30
kernel: [&lt;ffffffff814a5694&gt;] ? __wait_on_bit+0x41/0x73
kernel: [&lt;ffffffff8109eba8&gt;] ? wait_on_page_bit+0x6d/0x72
kernel: [&lt;ffffffff8105d718&gt;] ? autoremove_wake_function+0x2a/0x2a
kernel: [&lt;ffffffff811a02d7&gt;] ? read_extent_buffer_pages+0x1bd/0x203
kernel: [&lt;ffffffff8117d9e9&gt;] ? free_root_pointers+0x4c/0x4c
kernel: [&lt;ffffffff8117e831&gt;] ? btree_read_extent_buffer_pages.constprop.57+0x5a/0xe9
kernel: [&lt;ffffffff8117f4f3&gt;] ? read_tree_block+0x2d/0x45
kernel: [&lt;ffffffff8116782a&gt;] ? read_block_for_search.isra.34+0x22a/0x26b
kernel: [&lt;ffffffff811656c3&gt;] ? btrfs_set_path_blocking+0x1e/0x4a
kernel: [&lt;ffffffff8116919b&gt;] ? btrfs_search_slot+0x648/0x736
kernel: [&lt;ffffffff81170559&gt;] ? btrfs_lookup_extent_info+0xb7/0x2c7
kernel: [&lt;ffffffff81170ee5&gt;] ? walk_down_proc+0x9c/0x1ae
kernel: [&lt;ffffffff81171c9d&gt;] ? walk_down_tree+0x40/0xa4
kernel: [&lt;ffffffff8117375f&gt;] ? btrfs_drop_snapshot+0x2da/0x664
kernel: [&lt;ffffffff8104ff21&gt;] ? finish_task_switch+0x126/0x167
kernel: [&lt;ffffffff811850f8&gt;] ? btrfs_clean_one_deleted_snapshot+0xa6/0xb0
kernel: [&lt;ffffffff8117eaba&gt;] ? cleaner_kthread+0x13e/0x17b
kernel: [&lt;ffffffff8117e97c&gt;] ? btrfs_item_end+0x33/0x33
kernel: [&lt;ffffffff8104d256&gt;] ? kthread+0x95/0x9d
kernel: [&lt;ffffffff8104d1c1&gt;] ? kthread_parkme+0x16/0x16
kernel: [&lt;ffffffff814a7b5f&gt;] ? ret_from_fork+0x3f/0x70
kernel: [&lt;ffffffff8104d1c1&gt;] ? kthread_parkme+0x16/0x16

As this affects a released kernel (4.4) we need a minimal fix for
stable kernels.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=108361
Reported-by: Martin Ziegler &lt;ziegler@uni-freiburg.de&gt;
CC: Jiri Kosina &lt;jkosina@suse.cz&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs</title>
<updated>2015-11-14T00:30:29+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2015-11-14T00:30:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e75cdf9898132f521df98a3ce1c280a2f85d360a'/>
<id>e75cdf9898132f521df98a3ce1c280a2f85d360a</id>
<content type='text'>
Pull btrfs fixes and cleanups from Chris Mason:
 "Some of this got cherry-picked from a github repo this week, but I
  verified the patches.

  We have three small scrub cleanups and a collection of fixes"

* 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  btrfs: Use fs_info directly in btrfs_delete_unused_bgs
  btrfs: Fix lost-data-profile caused by balance bg
  btrfs: Fix lost-data-profile caused by auto removing bg
  btrfs: Remove len argument from scrub_find_csum
  btrfs: Reduce unnecessary arguments in scrub_recheck_block
  btrfs: Use scrub_checksum_data and scrub_checksum_tree_block for scrub_recheck_block_checksum
  btrfs: Reset sblock-&gt;xxx_error stats before calling scrub_recheck_block_checksum
  btrfs: scrub: setup all fields for sblock_to_check
  btrfs: scrub: set error stats when tree block spanning stripes
  Btrfs: fix race when listing an inode's xattrs
  Btrfs: fix race leading to BUG_ON when running delalloc for nodatacow
  Btrfs: fix race leading to incorrect item deletion when dropping extents
  Btrfs: fix sleeping inside atomic context in qgroup rescan worker
  Btrfs: fix race waiting for qgroup rescan worker
  btrfs: qgroup: exit the rescan worker during umount
  Btrfs: fix extent accounting for partial direct IO writes
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull btrfs fixes and cleanups from Chris Mason:
 "Some of this got cherry-picked from a github repo this week, but I
  verified the patches.

  We have three small scrub cleanups and a collection of fixes"

* 'for-linus-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  btrfs: Use fs_info directly in btrfs_delete_unused_bgs
  btrfs: Fix lost-data-profile caused by balance bg
  btrfs: Fix lost-data-profile caused by auto removing bg
  btrfs: Remove len argument from scrub_find_csum
  btrfs: Reduce unnecessary arguments in scrub_recheck_block
  btrfs: Use scrub_checksum_data and scrub_checksum_tree_block for scrub_recheck_block_checksum
  btrfs: Reset sblock-&gt;xxx_error stats before calling scrub_recheck_block_checksum
  btrfs: scrub: setup all fields for sblock_to_check
  btrfs: scrub: set error stats when tree block spanning stripes
  Btrfs: fix race when listing an inode's xattrs
  Btrfs: fix race leading to BUG_ON when running delalloc for nodatacow
  Btrfs: fix race leading to incorrect item deletion when dropping extents
  Btrfs: fix sleeping inside atomic context in qgroup rescan worker
  Btrfs: fix race waiting for qgroup rescan worker
  btrfs: qgroup: exit the rescan worker during umount
  Btrfs: fix extent accounting for partial direct IO writes
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'akpm' (patches from Andrew)</title>
<updated>2015-11-07T22:32:45+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2015-11-07T22:32:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ad804a0b2a769a0eed29015c53fe395449c09d13'/>
<id>ad804a0b2a769a0eed29015c53fe395449c09d13</id>
<content type='text'>
Merge second patch-bomb from Andrew Morton:

 - most of the rest of MM

 - procfs

 - lib/ updates

 - printk updates

 - bitops infrastructure tweaks

 - checkpatch updates

 - nilfs2 update

 - signals

 - various other misc bits: coredump, seqfile, kexec, pidns, zlib, ipc,
   dma-debug, dma-mapping, ...

* emailed patches from Andrew Morton &lt;akpm@linux-foundation.org&gt;: (102 commits)
  ipc,msg: drop dst nil validation in copy_msg
  include/linux/zutil.h: fix usage example of zlib_adler32()
  panic: release stale console lock to always get the logbuf printed out
  dma-debug: check nents in dma_sync_sg*
  dma-mapping: tidy up dma_parms default handling
  pidns: fix set/getpriority and ioprio_set/get in PRIO_USER mode
  kexec: use file name as the output message prefix
  fs, seqfile: always allow oom killer
  seq_file: reuse string_escape_str()
  fs/seq_file: use seq_* helpers in seq_hex_dump()
  coredump: change zap_threads() and zap_process() to use for_each_thread()
  coredump: ensure all coredumping tasks have SIGNAL_GROUP_COREDUMP
  signal: remove jffs2_garbage_collect_thread()-&gt;allow_signal(SIGCONT)
  signal: introduce kernel_signal_stop() to fix jffs2_garbage_collect_thread()
  signal: turn dequeue_signal_lock() into kernel_dequeue_signal()
  signals: kill block_all_signals() and unblock_all_signals()
  nilfs2: fix gcc uninitialized-variable warnings in powerpc build
  nilfs2: fix gcc unused-but-set-variable warnings
  MAINTAINERS: nilfs2: add header file for tracing
  nilfs2: add tracepoints for analyzing reading and writing metadata files
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Merge second patch-bomb from Andrew Morton:

 - most of the rest of MM

 - procfs

 - lib/ updates

 - printk updates

 - bitops infrastructure tweaks

 - checkpatch updates

 - nilfs2 update

 - signals

 - various other misc bits: coredump, seqfile, kexec, pidns, zlib, ipc,
   dma-debug, dma-mapping, ...

* emailed patches from Andrew Morton &lt;akpm@linux-foundation.org&gt;: (102 commits)
  ipc,msg: drop dst nil validation in copy_msg
  include/linux/zutil.h: fix usage example of zlib_adler32()
  panic: release stale console lock to always get the logbuf printed out
  dma-debug: check nents in dma_sync_sg*
  dma-mapping: tidy up dma_parms default handling
  pidns: fix set/getpriority and ioprio_set/get in PRIO_USER mode
  kexec: use file name as the output message prefix
  fs, seqfile: always allow oom killer
  seq_file: reuse string_escape_str()
  fs/seq_file: use seq_* helpers in seq_hex_dump()
  coredump: change zap_threads() and zap_process() to use for_each_thread()
  coredump: ensure all coredumping tasks have SIGNAL_GROUP_COREDUMP
  signal: remove jffs2_garbage_collect_thread()-&gt;allow_signal(SIGCONT)
  signal: introduce kernel_signal_stop() to fix jffs2_garbage_collect_thread()
  signal: turn dequeue_signal_lock() into kernel_dequeue_signal()
  signals: kill block_all_signals() and unblock_all_signals()
  nilfs2: fix gcc uninitialized-variable warnings in powerpc build
  nilfs2: fix gcc unused-but-set-variable warnings
  MAINTAINERS: nilfs2: add header file for tracing
  nilfs2: add tracepoints for analyzing reading and writing metadata files
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd</title>
<updated>2015-11-07T01:50:42+00:00</updated>
<author>
<name>Mel Gorman</name>
<email>mgorman@techsingularity.net</email>
</author>
<published>2015-11-07T00:28:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d0164adc89f6bb374d304ffcc375c6d2652fe67d'/>
<id>d0164adc89f6bb374d304ffcc375c6d2652fe67d</id>
<content type='text'>
__GFP_WAIT has been used to identify atomic context in callers that hold
spinlocks or are in interrupts.  They are expected to be high priority and
have access one of two watermarks lower than "min" which can be referred
to as the "atomic reserve".  __GFP_HIGH users get access to the first
lower watermark and can be called the "high priority reserve".

Over time, callers had a requirement to not block when fallback options
were available.  Some have abused __GFP_WAIT leading to a situation where
an optimisitic allocation with a fallback option can access atomic
reserves.

This patch uses __GFP_ATOMIC to identify callers that are truely atomic,
cannot sleep and have no alternative.  High priority users continue to use
__GFP_HIGH.  __GFP_DIRECT_RECLAIM identifies callers that can sleep and
are willing to enter direct reclaim.  __GFP_KSWAPD_RECLAIM to identify
callers that want to wake kswapd for background reclaim.  __GFP_WAIT is
redefined as a caller that is willing to enter direct reclaim and wake
kswapd for background reclaim.

This patch then converts a number of sites

o __GFP_ATOMIC is used by callers that are high priority and have memory
  pools for those requests. GFP_ATOMIC uses this flag.

o Callers that have a limited mempool to guarantee forward progress clear
  __GFP_DIRECT_RECLAIM but keep __GFP_KSWAPD_RECLAIM. bio allocations fall
  into this category where kswapd will still be woken but atomic reserves
  are not used as there is a one-entry mempool to guarantee progress.

o Callers that are checking if they are non-blocking should use the
  helper gfpflags_allow_blocking() where possible. This is because
  checking for __GFP_WAIT as was done historically now can trigger false
  positives. Some exceptions like dm-crypt.c exist where the code intent
  is clearer if __GFP_DIRECT_RECLAIM is used instead of the helper due to
  flag manipulations.

o Callers that built their own GFP flags instead of starting with GFP_KERNEL
  and friends now also need to specify __GFP_KSWAPD_RECLAIM.

The first key hazard to watch out for is callers that removed __GFP_WAIT
and was depending on access to atomic reserves for inconspicuous reasons.
In some cases it may be appropriate for them to use __GFP_HIGH.

The second key hazard is callers that assembled their own combination of
GFP flags instead of starting with something like GFP_KERNEL.  They may
now wish to specify __GFP_KSWAPD_RECLAIM.  It's almost certainly harmless
if it's missed in most cases as other activity will wake kswapd.

Signed-off-by: Mel Gorman &lt;mgorman@techsingularity.net&gt;
Acked-by: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Acked-by: Michal Hocko &lt;mhocko@suse.com&gt;
Acked-by: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Rik van Riel &lt;riel@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
__GFP_WAIT has been used to identify atomic context in callers that hold
spinlocks or are in interrupts.  They are expected to be high priority and
have access one of two watermarks lower than "min" which can be referred
to as the "atomic reserve".  __GFP_HIGH users get access to the first
lower watermark and can be called the "high priority reserve".

Over time, callers had a requirement to not block when fallback options
were available.  Some have abused __GFP_WAIT leading to a situation where
an optimisitic allocation with a fallback option can access atomic
reserves.

This patch uses __GFP_ATOMIC to identify callers that are truely atomic,
cannot sleep and have no alternative.  High priority users continue to use
__GFP_HIGH.  __GFP_DIRECT_RECLAIM identifies callers that can sleep and
are willing to enter direct reclaim.  __GFP_KSWAPD_RECLAIM to identify
callers that want to wake kswapd for background reclaim.  __GFP_WAIT is
redefined as a caller that is willing to enter direct reclaim and wake
kswapd for background reclaim.

This patch then converts a number of sites

o __GFP_ATOMIC is used by callers that are high priority and have memory
  pools for those requests. GFP_ATOMIC uses this flag.

o Callers that have a limited mempool to guarantee forward progress clear
  __GFP_DIRECT_RECLAIM but keep __GFP_KSWAPD_RECLAIM. bio allocations fall
  into this category where kswapd will still be woken but atomic reserves
  are not used as there is a one-entry mempool to guarantee progress.

o Callers that are checking if they are non-blocking should use the
  helper gfpflags_allow_blocking() where possible. This is because
  checking for __GFP_WAIT as was done historically now can trigger false
  positives. Some exceptions like dm-crypt.c exist where the code intent
  is clearer if __GFP_DIRECT_RECLAIM is used instead of the helper due to
  flag manipulations.

o Callers that built their own GFP flags instead of starting with GFP_KERNEL
  and friends now also need to specify __GFP_KSWAPD_RECLAIM.

The first key hazard to watch out for is callers that removed __GFP_WAIT
and was depending on access to atomic reserves for inconspicuous reasons.
In some cases it may be appropriate for them to use __GFP_HIGH.

The second key hazard is callers that assembled their own combination of
GFP flags instead of starting with something like GFP_KERNEL.  They may
now wish to specify __GFP_KSWAPD_RECLAIM.  It's almost certainly harmless
if it's missed in most cases as other activity will wake kswapd.

Signed-off-by: Mel Gorman &lt;mgorman@techsingularity.net&gt;
Acked-by: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Acked-by: Michal Hocko &lt;mhocko@suse.com&gt;
Acked-by: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Rik van Riel &lt;riel@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>btrfs: qgroup: exit the rescan worker during umount</title>
<updated>2015-11-05T10:32:20+00:00</updated>
<author>
<name>Justin Maggard</name>
<email>jmaggard10@gmail.com</email>
</author>
<published>2015-11-04T23:56:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7343dd61fd1b57c40cc06a5b5b5386df7f73c3ac'/>
<id>7343dd61fd1b57c40cc06a5b5b5386df7f73c3ac</id>
<content type='text'>
I was hitting a consistent NULL pointer dereference during shutdown that
showed the trace running through end_workqueue_bio().  I traced it back to
the endio_meta_workers workqueue being poked after it had already been
destroyed.

Eventually I found that the root cause was a qgroup rescan that was still
in progress while we were stopping all the btrfs workers.

Currently we explicitly pause balance and scrub operations in
close_ctree(), but we do nothing to stop the qgroup rescan.  We should
probably be doing the same for qgroup rescan, but that's a much larger
change.  This small change is good enough to allow me to unmount without
crashing.

Signed-off-by: Justin Maggard &lt;jmaggard@netgear.com&gt;
Reviewed-by: Filipe Manana &lt;fdmanana@suse.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I was hitting a consistent NULL pointer dereference during shutdown that
showed the trace running through end_workqueue_bio().  I traced it back to
the endio_meta_workers workqueue being poked after it had already been
destroyed.

Eventually I found that the root cause was a qgroup rescan that was still
in progress while we were stopping all the btrfs workers.

Currently we explicitly pause balance and scrub operations in
close_ctree(), but we do nothing to stop the qgroup rescan.  We should
probably be doing the same for qgroup rescan, but that's a much larger
change.  This small change is good enough to allow me to unmount without
crashing.

Signed-off-by: Justin Maggard &lt;jmaggard@netgear.com&gt;
Reviewed-by: Filipe Manana &lt;fdmanana@suse.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>btrfs: clear PF_NOFREEZE in cleaner_kthread()</title>
<updated>2015-10-27T02:42:30+00:00</updated>
<author>
<name>Jiri Kosina</name>
<email>jkosina@suse.cz</email>
</author>
<published>2015-10-26T06:06:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=696249132158014d594896df3a81390616069c5c'/>
<id>696249132158014d594896df3a81390616069c5c</id>
<content type='text'>
cleaner_kthread() kthread calls try_to_freeze() at the beginning of every
cleanup attempt. This operation can't ever succeed though, as the kthread
hasn't marked itself as freezable.

Before (hopefully eventually) kthread freezing gets converted to fileystem
freezing, we'd rather mark cleaner_kthread() freezable (as my
understanding is that it can generate filesystem I/O during suspend).

Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
cleaner_kthread() kthread calls try_to_freeze() at the beginning of every
cleanup attempt. This operation can't ever succeed though, as the kthread
hasn't marked itself as freezable.

Before (hopefully eventually) kthread freezing gets converted to fileystem
freezing, we'd rather mark cleaner_kthread() freezable (as my
understanding is that it can generate filesystem I/O during suspend).

Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'allocator-fixes' into for-linus-4.4</title>
<updated>2015-10-22T02:00:38+00:00</updated>
<author>
<name>Chris Mason</name>
<email>clm@fb.com</email>
</author>
<published>2015-10-22T02:00:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a9e6d153563d2ed69c6cd7fb4fa5ce4ca7c712eb'/>
<id>a9e6d153563d2ed69c6cd7fb4fa5ce4ca7c712eb</id>
<content type='text'>
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
