<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/fs/btrfs/backref.c, branch v3.14</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>Btrfs: fix memory leaks on walking backrefs failure</title>
<updated>2014-01-29T15:06:26+00:00</updated>
<author>
<name>Wang Shilong</name>
<email>wangsl.fnst@cn.fujitsu.com</email>
</author>
<published>2014-01-28T11:13:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=f05c474688762f186b16a26366755b6ef0bfed0c'/>
<id>f05c474688762f186b16a26366755b6ef0bfed0c</id>
<content type='text'>
When walking backrefs, we may iterate every inode's extent
and add/merge them into ulist, and the caller will free memory
from ulist.

However, if we fail to allocate inode's extents element
memory or ulist_add() fail to allocate memory, we won't
add allocated memory into ulist, and the caller won't
free some allocated memory thus memory leaks happen.

Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When walking backrefs, we may iterate every inode's extent
and add/merge them into ulist, and the caller will free memory
from ulist.

However, if we fail to allocate inode's extents element
memory or ulist_add() fail to allocate memory, we won't
add allocated memory into ulist, and the caller won't
free some allocated memory thus memory leaks happen.

Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: add a reschedule point in btrfs_find_all_roots()</title>
<updated>2014-01-29T15:06:25+00:00</updated>
<author>
<name>Wang Shilong</name>
<email>wangsl.fnst@cn.fujitsu.com</email>
</author>
<published>2014-01-26T14:32:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=bca1a290033d20981e11f81ae4207e4d0fa5b1e6'/>
<id>bca1a290033d20981e11f81ae4207e4d0fa5b1e6</id>
<content type='text'>
I can easily trigger the following warnings when enabling quota
in my virtual machine(running Opensuse), Steps are firstly creating
a subvolume full of fragment extents, and then create many snapshots
(500 in my test case).

[ 2362.808459] BUG: soft lockup - CPU#0 stuck for 22s! [btrfs-qgroup-re:1970]

[ 2362.809023] task: e4af8450 ti: e371c000 task.ti: e371c000
[ 2362.809026] EIP: 0060:[&lt;fa38f4ae&gt;] EFLAGS: 00000246 CPU: 0
[ 2362.809049] EIP is at __merge_refs+0x5e/0x100 [btrfs]
[ 2362.809051] EAX: 00000000 EBX: cfadbcf0 ECX: 00000000 EDX: cfadbcb0
[ 2362.809052] ESI: dd8d3370 EDI: e371dde0 EBP: e371dd6c ESP: e371dd5c
[ 2362.809054]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[ 2362.809055] CR0: 80050033 CR2: ac454d50 CR3: 009a9000 CR4: 001407d0
[ 2362.809099] Stack:
[ 2362.809100]  00000001 e371dde0 dfcc6890 f29f8000 e371de28 fa39016d 00000011 00000001
[ 2362.809105]  99bfc000 00000000 93928000 00000000 00000001 00000050 e371dda8 00000001
[ 2362.809109]  f3a31000 f3413000 00000001 e371ddb8 000040a8 00000202 00000000 00000023
[ 2362.809113] Call Trace:
[ 2362.809136]  [&lt;fa39016d&gt;] find_parent_nodes+0x34d/0x1280 [btrfs]
[ 2362.809156]  [&lt;fa391172&gt;] btrfs_find_all_roots+0xb2/0x110 [btrfs]
[ 2362.809174]  [&lt;fa3934a8&gt;] btrfs_qgroup_rescan_worker+0x358/0x7a0 [btrfs]
[ 2362.809180]  [&lt;c024d0ce&gt;] ? lock_timer_base.isra.39+0x1e/0x40
[ 2362.809199]  [&lt;fa3648df&gt;] worker_loop+0xff/0x470 [btrfs]
[ 2362.809204]  [&lt;c027a88a&gt;] ? __wake_up_locked+0x1a/0x20
[ 2362.809221]  [&lt;fa3647e0&gt;] ? btrfs_queue_worker+0x2b0/0x2b0 [btrfs]
[ 2362.809225]  [&lt;c025ebbc&gt;] kthread+0x9c/0xb0
[ 2362.809229]  [&lt;c06b487b&gt;] ret_from_kernel_thread+0x1b/0x30
[ 2362.809233]  [&lt;c025eb20&gt;] ? kthread_create_on_node+0x110/0x110

By adding a reschedule point at the end of btrfs_find_all_roots(), i no longer
hit these warnings.

Cc: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.cz&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I can easily trigger the following warnings when enabling quota
in my virtual machine(running Opensuse), Steps are firstly creating
a subvolume full of fragment extents, and then create many snapshots
(500 in my test case).

[ 2362.808459] BUG: soft lockup - CPU#0 stuck for 22s! [btrfs-qgroup-re:1970]

[ 2362.809023] task: e4af8450 ti: e371c000 task.ti: e371c000
[ 2362.809026] EIP: 0060:[&lt;fa38f4ae&gt;] EFLAGS: 00000246 CPU: 0
[ 2362.809049] EIP is at __merge_refs+0x5e/0x100 [btrfs]
[ 2362.809051] EAX: 00000000 EBX: cfadbcf0 ECX: 00000000 EDX: cfadbcb0
[ 2362.809052] ESI: dd8d3370 EDI: e371dde0 EBP: e371dd6c ESP: e371dd5c
[ 2362.809054]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[ 2362.809055] CR0: 80050033 CR2: ac454d50 CR3: 009a9000 CR4: 001407d0
[ 2362.809099] Stack:
[ 2362.809100]  00000001 e371dde0 dfcc6890 f29f8000 e371de28 fa39016d 00000011 00000001
[ 2362.809105]  99bfc000 00000000 93928000 00000000 00000001 00000050 e371dda8 00000001
[ 2362.809109]  f3a31000 f3413000 00000001 e371ddb8 000040a8 00000202 00000000 00000023
[ 2362.809113] Call Trace:
[ 2362.809136]  [&lt;fa39016d&gt;] find_parent_nodes+0x34d/0x1280 [btrfs]
[ 2362.809156]  [&lt;fa391172&gt;] btrfs_find_all_roots+0xb2/0x110 [btrfs]
[ 2362.809174]  [&lt;fa3934a8&gt;] btrfs_qgroup_rescan_worker+0x358/0x7a0 [btrfs]
[ 2362.809180]  [&lt;c024d0ce&gt;] ? lock_timer_base.isra.39+0x1e/0x40
[ 2362.809199]  [&lt;fa3648df&gt;] worker_loop+0xff/0x470 [btrfs]
[ 2362.809204]  [&lt;c027a88a&gt;] ? __wake_up_locked+0x1a/0x20
[ 2362.809221]  [&lt;fa3647e0&gt;] ? btrfs_queue_worker+0x2b0/0x2b0 [btrfs]
[ 2362.809225]  [&lt;c025ebbc&gt;] kthread+0x9c/0xb0
[ 2362.809229]  [&lt;c06b487b&gt;] ret_from_kernel_thread+0x1b/0x30
[ 2362.809233]  [&lt;c025eb20&gt;] ? kthread_create_on_node+0x110/0x110

By adding a reschedule point at the end of btrfs_find_all_roots(), i no longer
hit these warnings.

Cc: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.cz&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: fix to catch all errors when resolving indirect ref</title>
<updated>2014-01-29T15:06:23+00:00</updated>
<author>
<name>Wang Shilong</name>
<email>wangsl.fnst@cn.fujitsu.com</email>
</author>
<published>2014-01-23T05:47:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=95def2ede1a9dd12b164932eaf5fefb67aefc41c'/>
<id>95def2ede1a9dd12b164932eaf5fefb67aefc41c</id>
<content type='text'>
We can only tolerate ENOENT here, for other errors, we should
return directly.

Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We can only tolerate ENOENT here, for other errors, we should
return directly.

Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: fix protection between walking backrefs and root deletion</title>
<updated>2014-01-29T15:06:23+00:00</updated>
<author>
<name>Wang Shilong</name>
<email>wangsl.fnst@cn.fujitsu.com</email>
</author>
<published>2014-01-23T05:47:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=538f72cdf03cad1c21c551ea542c8ce7d9fa2d81'/>
<id>538f72cdf03cad1c21c551ea542c8ce7d9fa2d81</id>
<content type='text'>
There is a race condition between resolving indirect ref and root deletion,
and we should gurantee that root can not be destroyed to avoid accessing
broken tree here.

Here we fix it by holding @subvol_srcu, and we will release it as soon
as we have held root node lock.

Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There is a race condition between resolving indirect ref and root deletion,
and we should gurantee that root can not be destroyed to avoid accessing
broken tree here.

Here we fix it by holding @subvol_srcu, and we will release it as soon
as we have held root node lock.

Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: only process as many file extents as there are refs</title>
<updated>2014-01-28T21:20:28+00:00</updated>
<author>
<name>Josef Bacik</name>
<email>jbacik@fb.com</email>
</author>
<published>2014-01-24T19:05:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=7ef81ac86c8a44ab9f4e6e04e1f4c9ea53615b8a'/>
<id>7ef81ac86c8a44ab9f4e6e04e1f4c9ea53615b8a</id>
<content type='text'>
The backref walking code will search down to the key it is looking for and then
proceed to walk _all_ of the extents on the file until it hits the end.  This is
suboptimal with large files, we only need to look for as many extents as we have
references for that inode.  I have a testcase that creates a randomly written 4
gig file and before this patch it took 6min 30sec to do the initial send, with
this patch it takes 2min 30sec to do the intial send.  Thanks,

Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The backref walking code will search down to the key it is looking for and then
proceed to walk _all_ of the extents on the file until it hits the end.  This is
suboptimal with large files, we only need to look for as many extents as we have
references for that inode.  I have a testcase that creates a randomly written 4
gig file and before this patch it took 6min 30sec to do the initial send, with
this patch it takes 2min 30sec to do the intial send.  Thanks,

Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: fix extent_from_logical to deal with skinny metadata</title>
<updated>2014-01-28T21:20:27+00:00</updated>
<author>
<name>Josef Bacik</name>
<email>jbacik@fb.com</email>
</author>
<published>2014-01-23T21:03:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=580f0a678ebeba85d30b6a7f22ce32c472263c72'/>
<id>580f0a678ebeba85d30b6a7f22ce32c472263c72</id>
<content type='text'>
I don't think this is an issue and I've not seen it in practice but
extent_from_logical will fail to find a skinny extent because it uses
btrfs_previous_item and gives it the normal extent item type.  This is just not
a place to use btrfs_previous_item since we care about either normal extents or
skinny extents, so open code btrfs_previous_item to properly check.  This would
only affect metadata and the only place this is used for metadata is scrub and
I'm pretty sure it's just for printing stuff out, not actually doing any work so
hopefully it was never a problem other than a cosmetic one.  Thanks,

Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I don't think this is an issue and I've not seen it in practice but
extent_from_logical will fail to find a skinny extent because it uses
btrfs_previous_item and gives it the normal extent item type.  This is just not
a place to use btrfs_previous_item since we care about either normal extents or
skinny extents, so open code btrfs_previous_item to properly check.  This would
only affect metadata and the only place this is used for metadata is scrub and
I'm pretty sure it's just for printing stuff out, not actually doing any work so
hopefully it was never a problem other than a cosmetic one.  Thanks,

Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: attach delayed ref updates to delayed ref heads</title>
<updated>2014-01-28T21:20:25+00:00</updated>
<author>
<name>Josef Bacik</name>
<email>jbacik@fb.com</email>
</author>
<published>2014-01-23T14:21:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=d7df2c796d7eedd72a334dc89c65e1fec8171431'/>
<id>d7df2c796d7eedd72a334dc89c65e1fec8171431</id>
<content type='text'>
Currently we have two rb-trees, one for delayed ref heads and one for all of the
delayed refs, including the delayed ref heads.  When we process the delayed refs
we have to hold onto the delayed ref lock for all of the selecting and merging
and such, which results in quite a bit of lock contention.  This was solved by
having a waitqueue and only one flusher at a time, however this hurts if we get
a lot of delayed refs queued up.

So instead just have an rb tree for the delayed ref heads, and then attach the
delayed ref updates to an rb tree that is per delayed ref head.  Then we only
need to take the delayed ref lock when adding new delayed refs and when
selecting a delayed ref head to process, all the rest of the time we deal with a
per delayed ref head lock which will be much less contentious.

The locking rules for this get a little more complicated since we have to lock
up to 3 things to properly process delayed refs, but I will address that problem
later.  For now this passes all of xfstests and my overnight stress tests.
Thanks,

Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently we have two rb-trees, one for delayed ref heads and one for all of the
delayed refs, including the delayed ref heads.  When we process the delayed refs
we have to hold onto the delayed ref lock for all of the selecting and merging
and such, which results in quite a bit of lock contention.  This was solved by
having a waitqueue and only one flusher at a time, however this hurts if we get
a lot of delayed refs queued up.

So instead just have an rb tree for the delayed ref heads, and then attach the
delayed ref updates to an rb tree that is per delayed ref head.  Then we only
need to take the delayed ref lock when adding new delayed refs and when
selecting a delayed ref head to process, all the rest of the time we deal with a
per delayed ref head lock which will be much less contentious.

The locking rules for this get a little more complicated since we have to lock
up to 3 things to properly process delayed refs, but I will address that problem
later.  For now this passes all of xfstests and my overnight stress tests.
Thanks,

Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: fix deadlock when iterating inode refs and running delayed inodes</title>
<updated>2014-01-28T21:19:59+00:00</updated>
<author>
<name>Filipe David Borba Manana</name>
<email>fdmanana@gmail.com</email>
</author>
<published>2013-12-15T12:43:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=3fe81ce206f3805e0eb5d886aabbf91064655144'/>
<id>3fe81ce206f3805e0eb5d886aabbf91064655144</id>
<content type='text'>
While running btrfs/004 from xfstests, after 503 iterations, dmesg reported
a deadlock between tasks iterating inode refs and tasks running delayed inodes
(during a transaction commit).

It turns out that iterating inode refs implies doing one tree search and
release all nodes in the path except the leaf node, and then passing that
leaf node to btrfs_ref_to_path(), which in turn does another tree search
without releasing the lock on the leaf node it received as parameter.

This is a problem when other task wants to write to the btree as well and
ends up updating the leaf that is read locked - the writer task locks the
parent of the leaf and then blocks waiting for the leaf's lock to be
released - at the same time, the task executing btrfs_ref_to_path()
does a second tree search, without releasing the lock on the first leaf,
and wants to access a leaf (the same or another one) that is a child of
the same parent, resulting in a deadlock.

The trace reported by lockdep follows.

[84314.936373] INFO: task fsstress:11930 blocked for more than 120 seconds.
[84314.936381]       Tainted: G        W  O 3.12.0-fdm-btrfs-next-16+ #70
[84314.936383] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[84314.936386] fsstress        D ffff8806e1bf8000     0 11930  11926 0x00000000
[84314.936393]  ffff8804d6d89b78 0000000000000046 ffff8804d6d89b18 ffffffff810bd8bd
[84314.936399]  ffff8806e1bf8000 ffff8804d6d89fd8 ffff8804d6d89fd8 ffff8804d6d89fd8
[84314.936405]  ffff880806308000 ffff8806e1bf8000 ffff8804d6d89c08 ffff8804deb8f190
[84314.936410] Call Trace:
[84314.936421]  [&lt;ffffffff810bd8bd&gt;] ? trace_hardirqs_on+0xd/0x10
[84314.936428]  [&lt;ffffffff81774269&gt;] schedule+0x29/0x70
[84314.936451]  [&lt;ffffffffa0715bf5&gt;] btrfs_tree_lock+0x75/0x270 [btrfs]
[84314.936457]  [&lt;ffffffff810715c0&gt;] ? __init_waitqueue_head+0x60/0x60
[84314.936470]  [&lt;ffffffffa06ba231&gt;] btrfs_search_slot+0x7f1/0x930 [btrfs]
[84314.936489]  [&lt;ffffffffa0731c2a&gt;] ? __btrfs_run_delayed_items+0x13a/0x1e0 [btrfs]
[84314.936504]  [&lt;ffffffffa06d2e1f&gt;] btrfs_lookup_inode+0x2f/0xa0 [btrfs]
[84314.936510]  [&lt;ffffffff810bd6ef&gt;] ? trace_hardirqs_on_caller+0x1f/0x1e0
[84314.936528]  [&lt;ffffffffa073173c&gt;] __btrfs_update_delayed_inode+0x4c/0x1d0 [btrfs]
[84314.936543]  [&lt;ffffffffa0731c2a&gt;] ? __btrfs_run_delayed_items+0x13a/0x1e0 [btrfs]
[84314.936558]  [&lt;ffffffffa0731c2a&gt;] ? __btrfs_run_delayed_items+0x13a/0x1e0 [btrfs]
[84314.936573]  [&lt;ffffffffa0731c82&gt;] __btrfs_run_delayed_items+0x192/0x1e0 [btrfs]
[84314.936589]  [&lt;ffffffffa0731d03&gt;] btrfs_run_delayed_items+0x13/0x20 [btrfs]
[84314.936604]  [&lt;ffffffffa06dbcd4&gt;] btrfs_flush_all_pending_stuffs+0x24/0x80 [btrfs]
[84314.936620]  [&lt;ffffffffa06ddc13&gt;] btrfs_commit_transaction+0x223/0xa20 [btrfs]
[84314.936630]  [&lt;ffffffffa06ae5ae&gt;] btrfs_sync_fs+0x6e/0x110 [btrfs]
[84314.936635]  [&lt;ffffffff811d0b50&gt;] ? __sync_filesystem+0x60/0x60
[84314.936639]  [&lt;ffffffff811d0b50&gt;] ? __sync_filesystem+0x60/0x60
[84314.936643]  [&lt;ffffffff811d0b70&gt;] sync_fs_one_sb+0x20/0x30
[84314.936648]  [&lt;ffffffff811a3541&gt;] iterate_supers+0xf1/0x100
[84314.936652]  [&lt;ffffffff811d0c45&gt;] sys_sync+0x55/0x90
[84314.936658]  [&lt;ffffffff8177ef12&gt;] system_call_fastpath+0x16/0x1b
[84314.936660] INFO: lockdep is turned off.
[84314.936663] INFO: task btrfs:11955 blocked for more than 120 seconds.
[84314.936666]       Tainted: G        W  O 3.12.0-fdm-btrfs-next-16+ #70
[84314.936668] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[84314.936670] btrfs           D ffff880541729a88     0 11955  11608 0x00000000
[84314.936674]  ffff880541729a38 0000000000000046 ffff8805417299d8 ffffffff810bd8bd
[84314.936680]  ffff88075430c8a0 ffff880541729fd8 ffff880541729fd8 ffff880541729fd8
[84314.936685]  ffffffff81c104e0 ffff88075430c8a0 ffff8804de8b00b8 ffff8804de8b0000
[84314.936690] Call Trace:
[84314.936695]  [&lt;ffffffff810bd8bd&gt;] ? trace_hardirqs_on+0xd/0x10
[84314.936700]  [&lt;ffffffff81774269&gt;] schedule+0x29/0x70
[84314.936717]  [&lt;ffffffffa0715815&gt;] btrfs_tree_read_lock+0xd5/0x140 [btrfs]
[84314.936721]  [&lt;ffffffff810715c0&gt;] ? __init_waitqueue_head+0x60/0x60
[84314.936733]  [&lt;ffffffffa06ba201&gt;] btrfs_search_slot+0x7c1/0x930 [btrfs]
[84314.936746]  [&lt;ffffffffa06bd505&gt;] btrfs_find_item+0x55/0x160 [btrfs]
[84314.936763]  [&lt;ffffffffa06ff689&gt;] ? free_extent_buffer+0x49/0xc0 [btrfs]
[84314.936780]  [&lt;ffffffffa073c9ca&gt;] btrfs_ref_to_path+0xba/0x1e0 [btrfs]
[84314.936797]  [&lt;ffffffffa06f9719&gt;] ? release_extent_buffer+0xb9/0xe0 [btrfs]
[84314.936813]  [&lt;ffffffffa06ff689&gt;] ? free_extent_buffer+0x49/0xc0 [btrfs]
[84314.936830]  [&lt;ffffffffa073cb50&gt;] inode_to_path+0x60/0xd0 [btrfs]
[84314.936846]  [&lt;ffffffffa073d365&gt;] paths_from_inode+0x115/0x3c0 [btrfs]
[84314.936851]  [&lt;ffffffff8118dd44&gt;] ? kmem_cache_alloc_trace+0x114/0x200
[84314.936868]  [&lt;ffffffffa0714494&gt;] btrfs_ioctl+0xf14/0x2030 [btrfs]
[84314.936873]  [&lt;ffffffff817762db&gt;] ? _raw_spin_unlock+0x2b/0x50
[84314.936877]  [&lt;ffffffff8116598f&gt;] ? handle_mm_fault+0x34f/0xb00
[84314.936882]  [&lt;ffffffff81075563&gt;] ? up_read+0x23/0x40
[84314.936886]  [&lt;ffffffff8177a41c&gt;] ? __do_page_fault+0x20c/0x5a0
[84314.936892]  [&lt;ffffffff811b2946&gt;] do_vfs_ioctl+0x96/0x570
[84314.936896]  [&lt;ffffffff81776e23&gt;] ? error_sti+0x5/0x6
[84314.936901]  [&lt;ffffffff810b71e8&gt;] ? trace_hardirqs_off_caller+0x28/0xd0
[84314.936906]  [&lt;ffffffff81776a09&gt;] ? retint_swapgs+0xe/0x13
[84314.936910]  [&lt;ffffffff811b2eb1&gt;] SyS_ioctl+0x91/0xb0
[84314.936915]  [&lt;ffffffff813eecde&gt;] ? trace_hardirqs_on_thunk+0x3a/0x3f
[84314.936920]  [&lt;ffffffff8177ef12&gt;] system_call_fastpath+0x16/0x1b
[84314.936922] INFO: lockdep is turned off.
[84434.866873] INFO: task btrfs-transacti:11921 blocked for more than 120 seconds.
[84434.866881]       Tainted: G        W  O 3.12.0-fdm-btrfs-next-16+ #70
[84434.866883] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[84434.866886] btrfs-transacti D ffff880755b6a478     0 11921      2 0x00000000
[84434.866893]  ffff8800735b9ce8 0000000000000046 ffff8800735b9c88 ffffffff810bd8bd
[84434.866899]  ffff8805a1b848a0 ffff8800735b9fd8 ffff8800735b9fd8 ffff8800735b9fd8
[84434.866904]  ffffffff81c104e0 ffff8805a1b848a0 ffff880755b6a478 ffff8804cece78f0
[84434.866910] Call Trace:
[84434.866920]  [&lt;ffffffff810bd8bd&gt;] ? trace_hardirqs_on+0xd/0x10
[84434.866927]  [&lt;ffffffff81774269&gt;] schedule+0x29/0x70
[84434.866948]  [&lt;ffffffffa06dd2ef&gt;] wait_current_trans.isra.33+0xbf/0x120 [btrfs]
[84434.866954]  [&lt;ffffffff810715c0&gt;] ? __init_waitqueue_head+0x60/0x60
[84434.866970]  [&lt;ffffffffa06dec18&gt;] start_transaction+0x388/0x5a0 [btrfs]
[84434.866985]  [&lt;ffffffffa06db9b5&gt;] ? transaction_kthread+0xb5/0x280 [btrfs]
[84434.866999]  [&lt;ffffffffa06dee97&gt;] btrfs_attach_transaction+0x17/0x20 [btrfs]
[84434.867012]  [&lt;ffffffffa06dba9e&gt;] transaction_kthread+0x19e/0x280 [btrfs]
[84434.867026]  [&lt;ffffffffa06db900&gt;] ? open_ctree+0x2260/0x2260 [btrfs]
[84434.867030]  [&lt;ffffffff81070dad&gt;] kthread+0xed/0x100
[84434.867035]  [&lt;ffffffff81070cc0&gt;] ? flush_kthread_worker+0x190/0x190
[84434.867040]  [&lt;ffffffff8177ee6c&gt;] ret_from_fork+0x7c/0xb0
[84434.867044]  [&lt;ffffffff81070cc0&gt;] ? flush_kthread_worker+0x190/0x190

Signed-off-by: Filipe David Borba Manana &lt;fdmanana@gmail.com&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While running btrfs/004 from xfstests, after 503 iterations, dmesg reported
a deadlock between tasks iterating inode refs and tasks running delayed inodes
(during a transaction commit).

It turns out that iterating inode refs implies doing one tree search and
release all nodes in the path except the leaf node, and then passing that
leaf node to btrfs_ref_to_path(), which in turn does another tree search
without releasing the lock on the leaf node it received as parameter.

This is a problem when other task wants to write to the btree as well and
ends up updating the leaf that is read locked - the writer task locks the
parent of the leaf and then blocks waiting for the leaf's lock to be
released - at the same time, the task executing btrfs_ref_to_path()
does a second tree search, without releasing the lock on the first leaf,
and wants to access a leaf (the same or another one) that is a child of
the same parent, resulting in a deadlock.

The trace reported by lockdep follows.

[84314.936373] INFO: task fsstress:11930 blocked for more than 120 seconds.
[84314.936381]       Tainted: G        W  O 3.12.0-fdm-btrfs-next-16+ #70
[84314.936383] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[84314.936386] fsstress        D ffff8806e1bf8000     0 11930  11926 0x00000000
[84314.936393]  ffff8804d6d89b78 0000000000000046 ffff8804d6d89b18 ffffffff810bd8bd
[84314.936399]  ffff8806e1bf8000 ffff8804d6d89fd8 ffff8804d6d89fd8 ffff8804d6d89fd8
[84314.936405]  ffff880806308000 ffff8806e1bf8000 ffff8804d6d89c08 ffff8804deb8f190
[84314.936410] Call Trace:
[84314.936421]  [&lt;ffffffff810bd8bd&gt;] ? trace_hardirqs_on+0xd/0x10
[84314.936428]  [&lt;ffffffff81774269&gt;] schedule+0x29/0x70
[84314.936451]  [&lt;ffffffffa0715bf5&gt;] btrfs_tree_lock+0x75/0x270 [btrfs]
[84314.936457]  [&lt;ffffffff810715c0&gt;] ? __init_waitqueue_head+0x60/0x60
[84314.936470]  [&lt;ffffffffa06ba231&gt;] btrfs_search_slot+0x7f1/0x930 [btrfs]
[84314.936489]  [&lt;ffffffffa0731c2a&gt;] ? __btrfs_run_delayed_items+0x13a/0x1e0 [btrfs]
[84314.936504]  [&lt;ffffffffa06d2e1f&gt;] btrfs_lookup_inode+0x2f/0xa0 [btrfs]
[84314.936510]  [&lt;ffffffff810bd6ef&gt;] ? trace_hardirqs_on_caller+0x1f/0x1e0
[84314.936528]  [&lt;ffffffffa073173c&gt;] __btrfs_update_delayed_inode+0x4c/0x1d0 [btrfs]
[84314.936543]  [&lt;ffffffffa0731c2a&gt;] ? __btrfs_run_delayed_items+0x13a/0x1e0 [btrfs]
[84314.936558]  [&lt;ffffffffa0731c2a&gt;] ? __btrfs_run_delayed_items+0x13a/0x1e0 [btrfs]
[84314.936573]  [&lt;ffffffffa0731c82&gt;] __btrfs_run_delayed_items+0x192/0x1e0 [btrfs]
[84314.936589]  [&lt;ffffffffa0731d03&gt;] btrfs_run_delayed_items+0x13/0x20 [btrfs]
[84314.936604]  [&lt;ffffffffa06dbcd4&gt;] btrfs_flush_all_pending_stuffs+0x24/0x80 [btrfs]
[84314.936620]  [&lt;ffffffffa06ddc13&gt;] btrfs_commit_transaction+0x223/0xa20 [btrfs]
[84314.936630]  [&lt;ffffffffa06ae5ae&gt;] btrfs_sync_fs+0x6e/0x110 [btrfs]
[84314.936635]  [&lt;ffffffff811d0b50&gt;] ? __sync_filesystem+0x60/0x60
[84314.936639]  [&lt;ffffffff811d0b50&gt;] ? __sync_filesystem+0x60/0x60
[84314.936643]  [&lt;ffffffff811d0b70&gt;] sync_fs_one_sb+0x20/0x30
[84314.936648]  [&lt;ffffffff811a3541&gt;] iterate_supers+0xf1/0x100
[84314.936652]  [&lt;ffffffff811d0c45&gt;] sys_sync+0x55/0x90
[84314.936658]  [&lt;ffffffff8177ef12&gt;] system_call_fastpath+0x16/0x1b
[84314.936660] INFO: lockdep is turned off.
[84314.936663] INFO: task btrfs:11955 blocked for more than 120 seconds.
[84314.936666]       Tainted: G        W  O 3.12.0-fdm-btrfs-next-16+ #70
[84314.936668] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[84314.936670] btrfs           D ffff880541729a88     0 11955  11608 0x00000000
[84314.936674]  ffff880541729a38 0000000000000046 ffff8805417299d8 ffffffff810bd8bd
[84314.936680]  ffff88075430c8a0 ffff880541729fd8 ffff880541729fd8 ffff880541729fd8
[84314.936685]  ffffffff81c104e0 ffff88075430c8a0 ffff8804de8b00b8 ffff8804de8b0000
[84314.936690] Call Trace:
[84314.936695]  [&lt;ffffffff810bd8bd&gt;] ? trace_hardirqs_on+0xd/0x10
[84314.936700]  [&lt;ffffffff81774269&gt;] schedule+0x29/0x70
[84314.936717]  [&lt;ffffffffa0715815&gt;] btrfs_tree_read_lock+0xd5/0x140 [btrfs]
[84314.936721]  [&lt;ffffffff810715c0&gt;] ? __init_waitqueue_head+0x60/0x60
[84314.936733]  [&lt;ffffffffa06ba201&gt;] btrfs_search_slot+0x7c1/0x930 [btrfs]
[84314.936746]  [&lt;ffffffffa06bd505&gt;] btrfs_find_item+0x55/0x160 [btrfs]
[84314.936763]  [&lt;ffffffffa06ff689&gt;] ? free_extent_buffer+0x49/0xc0 [btrfs]
[84314.936780]  [&lt;ffffffffa073c9ca&gt;] btrfs_ref_to_path+0xba/0x1e0 [btrfs]
[84314.936797]  [&lt;ffffffffa06f9719&gt;] ? release_extent_buffer+0xb9/0xe0 [btrfs]
[84314.936813]  [&lt;ffffffffa06ff689&gt;] ? free_extent_buffer+0x49/0xc0 [btrfs]
[84314.936830]  [&lt;ffffffffa073cb50&gt;] inode_to_path+0x60/0xd0 [btrfs]
[84314.936846]  [&lt;ffffffffa073d365&gt;] paths_from_inode+0x115/0x3c0 [btrfs]
[84314.936851]  [&lt;ffffffff8118dd44&gt;] ? kmem_cache_alloc_trace+0x114/0x200
[84314.936868]  [&lt;ffffffffa0714494&gt;] btrfs_ioctl+0xf14/0x2030 [btrfs]
[84314.936873]  [&lt;ffffffff817762db&gt;] ? _raw_spin_unlock+0x2b/0x50
[84314.936877]  [&lt;ffffffff8116598f&gt;] ? handle_mm_fault+0x34f/0xb00
[84314.936882]  [&lt;ffffffff81075563&gt;] ? up_read+0x23/0x40
[84314.936886]  [&lt;ffffffff8177a41c&gt;] ? __do_page_fault+0x20c/0x5a0
[84314.936892]  [&lt;ffffffff811b2946&gt;] do_vfs_ioctl+0x96/0x570
[84314.936896]  [&lt;ffffffff81776e23&gt;] ? error_sti+0x5/0x6
[84314.936901]  [&lt;ffffffff810b71e8&gt;] ? trace_hardirqs_off_caller+0x28/0xd0
[84314.936906]  [&lt;ffffffff81776a09&gt;] ? retint_swapgs+0xe/0x13
[84314.936910]  [&lt;ffffffff811b2eb1&gt;] SyS_ioctl+0x91/0xb0
[84314.936915]  [&lt;ffffffff813eecde&gt;] ? trace_hardirqs_on_thunk+0x3a/0x3f
[84314.936920]  [&lt;ffffffff8177ef12&gt;] system_call_fastpath+0x16/0x1b
[84314.936922] INFO: lockdep is turned off.
[84434.866873] INFO: task btrfs-transacti:11921 blocked for more than 120 seconds.
[84434.866881]       Tainted: G        W  O 3.12.0-fdm-btrfs-next-16+ #70
[84434.866883] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[84434.866886] btrfs-transacti D ffff880755b6a478     0 11921      2 0x00000000
[84434.866893]  ffff8800735b9ce8 0000000000000046 ffff8800735b9c88 ffffffff810bd8bd
[84434.866899]  ffff8805a1b848a0 ffff8800735b9fd8 ffff8800735b9fd8 ffff8800735b9fd8
[84434.866904]  ffffffff81c104e0 ffff8805a1b848a0 ffff880755b6a478 ffff8804cece78f0
[84434.866910] Call Trace:
[84434.866920]  [&lt;ffffffff810bd8bd&gt;] ? trace_hardirqs_on+0xd/0x10
[84434.866927]  [&lt;ffffffff81774269&gt;] schedule+0x29/0x70
[84434.866948]  [&lt;ffffffffa06dd2ef&gt;] wait_current_trans.isra.33+0xbf/0x120 [btrfs]
[84434.866954]  [&lt;ffffffff810715c0&gt;] ? __init_waitqueue_head+0x60/0x60
[84434.866970]  [&lt;ffffffffa06dec18&gt;] start_transaction+0x388/0x5a0 [btrfs]
[84434.866985]  [&lt;ffffffffa06db9b5&gt;] ? transaction_kthread+0xb5/0x280 [btrfs]
[84434.866999]  [&lt;ffffffffa06dee97&gt;] btrfs_attach_transaction+0x17/0x20 [btrfs]
[84434.867012]  [&lt;ffffffffa06dba9e&gt;] transaction_kthread+0x19e/0x280 [btrfs]
[84434.867026]  [&lt;ffffffffa06db900&gt;] ? open_ctree+0x2260/0x2260 [btrfs]
[84434.867030]  [&lt;ffffffff81070dad&gt;] kthread+0xed/0x100
[84434.867035]  [&lt;ffffffff81070cc0&gt;] ? flush_kthread_worker+0x190/0x190
[84434.867040]  [&lt;ffffffff8177ee6c&gt;] ret_from_fork+0x7c/0xb0
[84434.867044]  [&lt;ffffffff81070cc0&gt;] ? flush_kthread_worker+0x190/0x190

Signed-off-by: Filipe David Borba Manana &lt;fdmanana@gmail.com&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fb.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>btrfs: bootstrap generic btrfs_find_item interface</title>
<updated>2014-01-28T21:19:36+00:00</updated>
<author>
<name>Kelley Nielsen</name>
<email>kelleynnn@gmail.com</email>
</author>
<published>2013-11-05T03:33:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e33d5c3d6d61518c7f115af6d11d3dffa230d31f'/>
<id>e33d5c3d6d61518c7f115af6d11d3dffa230d31f</id>
<content type='text'>
There are many btrfs functions that manually search the tree for an
item. They all reimplement the same mechanism and differ in the
conditions that they use to find the item. __inode_info() is one such
example. Zach Brown proposed creating a new interface to take the place
of these functions.

This patch is the first step to creating the interface. A new function,
btrfs_find_item, has been added to ctree.c and prototyped in ctree.h.
It is identical to __inode_info, except that the order of the parameters
has been rearranged to more closely those of similar functions elsewhere
in the code (now, root and path come first, then the objectid, offset
and type, and the key to be filled in last). __inode_info's callers have
been set to call this new function instead, and __inode_info itself has
been removed.

Signed-off-by: Kelley Nielsen &lt;kelleynnn@gmail.com&gt;
Suggested-by: Zach Brown &lt;zab@redhat.com&gt;
Reviewed-by: Josh Triplett &lt;josh@joshtriplett.org&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fusionio.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are many btrfs functions that manually search the tree for an
item. They all reimplement the same mechanism and differ in the
conditions that they use to find the item. __inode_info() is one such
example. Zach Brown proposed creating a new interface to take the place
of these functions.

This patch is the first step to creating the interface. A new function,
btrfs_find_item, has been added to ctree.c and prototyped in ctree.h.
It is identical to __inode_info, except that the order of the parameters
has been rearranged to more closely those of similar functions elsewhere
in the code (now, root and path come first, then the objectid, offset
and type, and the key to be filled in last). __inode_info's callers have
been set to call this new function instead, and __inode_info itself has
been removed.

Signed-off-by: Kelley Nielsen &lt;kelleynnn@gmail.com&gt;
Suggested-by: Zach Brown &lt;zab@redhat.com&gt;
Reviewed-by: Josh Triplett &lt;josh@joshtriplett.org&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fusionio.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>btrfs: replace path-&gt;slots[0] with otherwise unused variable 'slot'</title>
<updated>2014-01-28T21:19:35+00:00</updated>
<author>
<name>Valentina Giusti</name>
<email>valentina.giusti@microon.de</email>
</author>
<published>2013-11-04T21:34:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e94acd86d48d61a5d919d807ed1efa0d8c1cd5ae'/>
<id>e94acd86d48d61a5d919d807ed1efa0d8c1cd5ae</id>
<content type='text'>
Signed-off-by: Valentina Giusti &lt;valentina.giusti@microon.de&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fusionio.com&gt;
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: Valentina Giusti &lt;valentina.giusti@microon.de&gt;
Signed-off-by: Josef Bacik &lt;jbacik@fusionio.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
