<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/fs/btrfs/extent-tree.c, branch v3.17-rc2</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: qgroup: account shared subtrees during snapshot delete</title>
<updated>2014-08-15T14:43:14+00:00</updated>
<author>
<name>Mark Fasheh</name>
<email>mfasheh@suse.de</email>
</author>
<published>2014-07-17T19:39:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1152651a081720ef6a8c76bb7da676e8c900ac30'/>
<id>1152651a081720ef6a8c76bb7da676e8c900ac30</id>
<content type='text'>
During its tree walk, btrfs_drop_snapshot() will skip any shared
subtrees it encounters. This is incorrect when we have qgroups
turned on as those subtrees need to have their contents
accounted. In particular, the case we're concerned with is when
removing our snapshot root leaves the subtree with only one root
reference.

In those cases we need to find the last remaining root and add
each extent in the subtree to the corresponding qgroup exclusive
counts.

This patch implements the shared subtree walk and a new qgroup
operation, BTRFS_QGROUP_OPER_SUB_SUBTREE. When an operation of
this type is encountered during qgroup accounting, we search for
any root references to that extent and in the case that we find
only one reference left, we go ahead and do the math on it's
exclusive counts.

Signed-off-by: Mark Fasheh &lt;mfasheh@suse.de&gt;
Reviewed-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>
During its tree walk, btrfs_drop_snapshot() will skip any shared
subtrees it encounters. This is incorrect when we have qgroups
turned on as those subtrees need to have their contents
accounted. In particular, the case we're concerned with is when
removing our snapshot root leaves the subtree with only one root
reference.

In those cases we need to find the last remaining root and add
each extent in the subtree to the corresponding qgroup exclusive
counts.

This patch implements the shared subtree walk and a new qgroup
operation, BTRFS_QGROUP_OPER_SUB_SUBTREE. When an operation of
this type is encountered during qgroup accounting, we search for
any root references to that extent and in the case that we find
only one reference left, we go ahead and do the math on it's
exclusive counts.

Signed-off-by: Mark Fasheh &lt;mfasheh@suse.de&gt;
Reviewed-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: __btrfs_mod_ref should always use no_quota</title>
<updated>2014-08-15T14:43:11+00:00</updated>
<author>
<name>Josef Bacik</name>
<email>jbacik@fb.com</email>
</author>
<published>2014-07-02T17:54:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e339a6b097c515a31ce230d498c44ff2e89f1cf4'/>
<id>e339a6b097c515a31ce230d498c44ff2e89f1cf4</id>
<content type='text'>
Before I extended the no_quota arg to btrfs_dec/inc_ref because I didn't
understand how snapshot delete was using it and assumed that we needed the
quota operations there.  With Mark's work this has turned out to be not the
case, we _always_ need to use no_quota for btrfs_dec/inc_ref, so just drop the
argument and make __btrfs_mod_ref call it's process function with no_quota set
always.  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>
Before I extended the no_quota arg to btrfs_dec/inc_ref because I didn't
understand how snapshot delete was using it and assumed that we needed the
quota operations there.  With Mark's work this has turned out to be not the
case, we _always_ need to use no_quota for btrfs_dec/inc_ref, so just drop the
argument and make __btrfs_mod_ref call it's process function with no_quota set
always.  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 race of using total_bytes_pinned</title>
<updated>2014-07-03T14:04:15+00:00</updated>
<author>
<name>Liu Bo</name>
<email>bo.li.liu@oracle.com</email>
</author>
<published>2014-07-02T08:58:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d288db5dc0110c8e0732d099aaf7a05e2ea0e0c8'/>
<id>d288db5dc0110c8e0732d099aaf7a05e2ea0e0c8</id>
<content type='text'>
This percpu counter @total_bytes_pinned is introduced to skip unnecessary
operations of 'commit transaction', it accounts for those space we may free
but are stuck in delayed refs.

And we zero out @space_info-&gt;total_bytes_pinned every transaction period so
we have a better idea of how much space we'll actually free up by committing
this transaction.  However, we do the 'zero out' part a little earlier, before
we actually unpin space, so we end up returning ENOSPC when we actually have
free space that's just unpinned from committing transaction.

xfstests/generic/074 complained then.

This fixes it by actually accounting the percpu pinned number when 'unpin',
and since it's protected by space_info-&gt;lock, the race is gone now.

Signed-off-by: Liu Bo &lt;bo.li.liu@oracle.com&gt;
Reviewed-by: Miao Xie &lt;miaox@cn.fujitsu.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>
This percpu counter @total_bytes_pinned is introduced to skip unnecessary
operations of 'commit transaction', it accounts for those space we may free
but are stuck in delayed refs.

And we zero out @space_info-&gt;total_bytes_pinned every transaction period so
we have a better idea of how much space we'll actually free up by committing
this transaction.  However, we do the 'zero out' part a little earlier, before
we actually unpin space, so we end up returning ENOSPC when we actually have
free space that's just unpinned from committing transaction.

xfstests/generic/074 complained then.

This fixes it by actually accounting the percpu pinned number when 'unpin',
and since it's protected by space_info-&gt;lock, the race is gone now.

Signed-off-by: Liu Bo &lt;bo.li.liu@oracle.com&gt;
Reviewed-by: Miao Xie &lt;miaox@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: fix broken free space cache after the system crashed</title>
<updated>2014-06-19T21:20:54+00:00</updated>
<author>
<name>Miao Xie</name>
<email>miaox@cn.fujitsu.com</email>
</author>
<published>2014-06-19T02:42:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e570fd27f2c5d7eac3876bccf99e9838d7f911a3'/>
<id>e570fd27f2c5d7eac3876bccf99e9838d7f911a3</id>
<content type='text'>
When we mounted the filesystem after the crash, we got the following
message:
  BTRFS error (device xxx): block group xxxx has wrong amount of free space
  BTRFS error (device xxx): failed to load free space cache for block group xxx

It is because we didn't update the metadata of the allocated space (in extent
tree) until the file data was written into the disk. During this time, there was
no information about the allocated spaces in either the extent tree nor the
free space cache. when we wrote out the free space cache at this time (commit
transaction), those spaces were lost. In fact, only the free space that is
used to store the file data had this problem, the others didn't because
the metadata of them is updated in the same transaction context.

There are many methods which can fix the above problem
- track the allocated space, and write it out when we write out the free
  space cache
- account the size of the allocated space that is used to store the file
  data, if the size is not zero, don't write out the free space cache.

The first one is complex and may make the performance drop down.
This patch chose the second method, we use a per-block-group variant to
account the size of that allocated space. Besides that, we also introduce
a per-block-group read-write semaphore to avoid the race between
the allocation and the free space cache write out.

Signed-off-by: Miao Xie &lt;miaox@cn.fujitsu.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 we mounted the filesystem after the crash, we got the following
message:
  BTRFS error (device xxx): block group xxxx has wrong amount of free space
  BTRFS error (device xxx): failed to load free space cache for block group xxx

It is because we didn't update the metadata of the allocated space (in extent
tree) until the file data was written into the disk. During this time, there was
no information about the allocated spaces in either the extent tree nor the
free space cache. when we wrote out the free space cache at this time (commit
transaction), those spaces were lost. In fact, only the free space that is
used to store the file data had this problem, the others didn't because
the metadata of them is updated in the same transaction context.

There are many methods which can fix the above problem
- track the allocated space, and write it out when we write out the free
  space cache
- account the size of the allocated space that is used to store the file
  data, if the size is not zero, don't write out the free space cache.

The first one is complex and may make the performance drop down.
This patch chose the second method, we use a per-block-group variant to
account the size of that allocated space. Besides that, we also introduce
a per-block-group read-write semaphore to avoid the race between
the allocation and the free space cache write out.

Signed-off-by: Miao Xie &lt;miaox@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>btrfs: allocate raid type kobjects dynamically</title>
<updated>2014-06-10T00:21:01+00:00</updated>
<author>
<name>Jeff Mahoney</name>
<email>jeffm@suse.com</email>
</author>
<published>2014-05-27T16:59:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c1895442be01c58449e3bf9272f22062a670e08f'/>
<id>c1895442be01c58449e3bf9272f22062a670e08f</id>
<content type='text'>
We are currently allocating space_info objects in an array when we
allocate space_info. When a user does something like:

# btrfs balance start -mconvert=raid1 -dconvert=raid1 /mnt
# btrfs balance start -mconvert=single -dconvert=single /mnt -f
# btrfs balance start -mconvert=raid1 -dconvert=raid1 /

We can end up with memory corruption since the kobject hasn't
been reinitialized properly and the name pointer was left set.

The rationale behind allocating them statically was to avoid
creating a separate kobject container that just contained the
raid type. It used the index in the array to determine the index.

Ultimately, though, this wastes more memory than it saves in all
but the most complex scenarios and introduces kobject lifetime
questions.

This patch allocates the kobjects dynamically instead. Note that
we also remove the kobject_get/put of the parent kobject since
kobject_add and kobject_del do that internally.

Signed-off-by: Jeff Mahoney &lt;jeffm@suse.com&gt;
Reported-by: David Sterba &lt;dsterba@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>
We are currently allocating space_info objects in an array when we
allocate space_info. When a user does something like:

# btrfs balance start -mconvert=raid1 -dconvert=raid1 /mnt
# btrfs balance start -mconvert=single -dconvert=single /mnt -f
# btrfs balance start -mconvert=raid1 -dconvert=raid1 /

We can end up with memory corruption since the kobject hasn't
been reinitialized properly and the name pointer was left set.

The rationale behind allocating them statically was to avoid
creating a separate kobject container that just contained the
raid type. It used the index in the array to determine the index.

Ultimately, though, this wastes more memory than it saves in all
but the most complex scenarios and introduces kobject lifetime
questions.

This patch allocates the kobjects dynamically instead. Note that
we also remove the kobject_get/put of the parent kobject since
kobject_add and kobject_del do that internally.

Signed-off-by: Jeff Mahoney &lt;jeffm@suse.com&gt;
Reported-by: David Sterba &lt;dsterba@suse.cz&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: async delayed refs</title>
<updated>2014-06-10T00:20:58+00:00</updated>
<author>
<name>Chris Mason</name>
<email>clm@fb.com</email>
</author>
<published>2014-05-22T23:18:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a79b7d4b3e8118f265dcb4bdf9a572c392f02708'/>
<id>a79b7d4b3e8118f265dcb4bdf9a572c392f02708</id>
<content type='text'>
Delayed extent operations are triggered during transaction commits.
The goal is to queue up a healthly batch of changes to the extent
allocation tree and run through them in bulk.

This farms them off to async helper threads.  The goal is to have the
bulk of the delayed operations being done in the background, but this is
also important to limit our stack footprint.

Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Delayed extent operations are triggered during transaction commits.
The goal is to queue up a healthly batch of changes to the extent
allocation tree and run through them in bulk.

This farms them off to async helper threads.  The goal is to have the
bulk of the delayed operations being done in the background, but this is
also important to limit our stack footprint.

Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>btrfs: remove stale newlines from log messages</title>
<updated>2014-06-10T00:20:53+00:00</updated>
<author>
<name>David Sterba</name>
<email>dsterba@suse.cz</email>
</author>
<published>2014-05-15T14:48:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=351fd3532159441e810d458a5b681090ff8449fd'/>
<id>351fd3532159441e810d458a5b681090ff8449fd</id>
<content type='text'>
I've noticed an extra line after "use no compression", but search
revealed much more in messages of more critical levels and rare errors.

Signed-off-by: David Sterba &lt;dsterba@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>
I've noticed an extra line after "use no compression", but search
revealed much more in messages of more critical levels and rare errors.

Signed-off-by: David Sterba &lt;dsterba@suse.cz&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: add sanity tests for new qgroup accounting code</title>
<updated>2014-06-10T00:20:49+00:00</updated>
<author>
<name>Josef Bacik</name>
<email>jbacik@fb.com</email>
</author>
<published>2014-05-07T21:06:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=faa2dbf004e89e8f7ccd28fbe6f07c308417b8ae'/>
<id>faa2dbf004e89e8f7ccd28fbe6f07c308417b8ae</id>
<content type='text'>
This exercises the various parts of the new qgroup accounting code.  We do some
basic stuff and do some things with the shared refs to make sure all that code
works.  I had to add a bunch of infrastructure because I needed to be able to
insert items into a fake tree without having to do all the hard work myself,
hopefully this will be usefull in the future.  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>
This exercises the various parts of the new qgroup accounting code.  We do some
basic stuff and do some things with the shared refs to make sure all that code
works.  I had to add a bunch of infrastructure because I needed to be able to
insert items into a fake tree without having to do all the hard work myself,
hopefully this will be usefull in the future.  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: rework qgroup accounting</title>
<updated>2014-06-10T00:20:48+00:00</updated>
<author>
<name>Josef Bacik</name>
<email>jbacik@fb.com</email>
</author>
<published>2014-05-14T00:30:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fcebe4562dec83b3f8d3088d77584727b09130b2'/>
<id>fcebe4562dec83b3f8d3088d77584727b09130b2</id>
<content type='text'>
Currently qgroups account for space by intercepting delayed ref updates to fs
trees.  It does this by adding sequence numbers to delayed ref updates so that
it can figure out how the tree looked before the update so we can adjust the
counters properly.  The problem with this is that it does not allow delayed refs
to be merged, so if you say are defragging an extent with 5k snapshots pointing
to it we will thrash the delayed ref lock because we need to go back and
manually merge these things together.  Instead we want to process quota changes
when we know they are going to happen, like when we first allocate an extent, we
free a reference for an extent, we add new references etc.  This patch
accomplishes this by only adding qgroup operations for real ref changes.  We
only modify the sequence number when we need to lookup roots for bytenrs, this
reduces the amount of churn on the sequence number and allows us to merge
delayed refs as we add them most of the time.  This patch encompasses a bunch of
architectural changes

1) qgroup ref operations: instead of tracking qgroup operations through the
delayed refs we simply add new ref operations whenever we notice that we need to
when we've modified the refs themselves.

2) tree mod seq:  we no longer have this separation of major/minor counters.
this makes the sequence number stuff much more sane and we can remove some
locking that was needed to protect the counter.

3) delayed ref seq: we now read the tree mod seq number and use that as our
sequence.  This means each new delayed ref doesn't have it's own unique sequence
number, rather whenever we go to lookup backrefs we inc the sequence number so
we can make sure to keep any new operations from screwing up our world view at
that given point.  This allows us to merge delayed refs during runtime.

With all of these changes the delayed ref stuff is a little saner and the qgroup
accounting stuff no longer goes negative in some cases like it was before.
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 qgroups account for space by intercepting delayed ref updates to fs
trees.  It does this by adding sequence numbers to delayed ref updates so that
it can figure out how the tree looked before the update so we can adjust the
counters properly.  The problem with this is that it does not allow delayed refs
to be merged, so if you say are defragging an extent with 5k snapshots pointing
to it we will thrash the delayed ref lock because we need to go back and
manually merge these things together.  Instead we want to process quota changes
when we know they are going to happen, like when we first allocate an extent, we
free a reference for an extent, we add new references etc.  This patch
accomplishes this by only adding qgroup operations for real ref changes.  We
only modify the sequence number when we need to lookup roots for bytenrs, this
reduces the amount of churn on the sequence number and allows us to merge
delayed refs as we add them most of the time.  This patch encompasses a bunch of
architectural changes

1) qgroup ref operations: instead of tracking qgroup operations through the
delayed refs we simply add new ref operations whenever we notice that we need to
when we've modified the refs themselves.

2) tree mod seq:  we no longer have this separation of major/minor counters.
this makes the sequence number stuff much more sane and we can remove some
locking that was needed to protect the counter.

3) delayed ref seq: we now read the tree mod seq number and use that as our
sequence.  This means each new delayed ref doesn't have it's own unique sequence
number, rather whenever we go to lookup backrefs we inc the sequence number so
we can make sure to keep any new operations from screwing up our world view at
that given point.  This allows us to merge delayed refs during runtime.

With all of these changes the delayed ref stuff is a little saner and the qgroup
accounting stuff no longer goes negative in some cases like it was before.
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 joining same transaction handle more than twice</title>
<updated>2014-06-10T00:20:46+00:00</updated>
<author>
<name>Wang Shilong</name>
<email>wangsl.fnst@cn.fujitsu.com</email>
</author>
<published>2014-03-13T05:19:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f017f15f7c1893cb518ddae796f3a75c0c413a92'/>
<id>f017f15f7c1893cb518ddae796f3a75c0c413a92</id>
<content type='text'>
We hit something like the following function call flows:

|-&gt;run_delalloc_range()
 |-&gt;btrfs_join_transaction()
   |-&gt;cow_file_range()
     |-&gt;btrfs_join_transaction()
       |-&gt;find_free_extent()
         |-&gt;btrfs_join_transaction()

Trace infomation can be seen as:

[ 7411.127040] ------------[ cut here ]------------
[ 7411.127060] WARNING: CPU: 0 PID: 11557 at fs/btrfs/transaction.c:383 start_transaction+0x561/0x580 [btrfs]()
[ 7411.127079] CPU: 0 PID: 11557 Comm: kworker/u8:9 Tainted: G           O 3.13.0+ #4
[ 7411.127080] Hardware name: LENOVO QiTianM4350/ , BIOS F1KT52AUS 05/24/2013
[ 7411.127085] Workqueue: writeback bdi_writeback_workfn (flush-btrfs-5)
[ 7411.127092] Call Trace:
[ 7411.127097]  [&lt;ffffffff815b87b0&gt;] dump_stack+0x45/0x56
[ 7411.127101]  [&lt;ffffffff81051ffd&gt;] warn_slowpath_common+0x7d/0xa0
[ 7411.127102]  [&lt;ffffffff810520da&gt;] warn_slowpath_null+0x1a/0x20
[ 7411.127109]  [&lt;ffffffffa0444fb1&gt;] start_transaction+0x561/0x580 [btrfs]
[ 7411.127115]  [&lt;ffffffffa0445027&gt;] btrfs_join_transaction+0x17/0x20 [btrfs]
[ 7411.127120]  [&lt;ffffffffa0431c91&gt;] find_free_extent+0xa21/0xb50 [btrfs]
[ 7411.127126]  [&lt;ffffffffa0431f68&gt;] btrfs_reserve_extent+0xa8/0x1a0 [btrfs]
[ 7411.127131]  [&lt;ffffffffa04322ce&gt;] btrfs_alloc_free_block+0xee/0x440 [btrfs]
[ 7411.127137]  [&lt;ffffffffa043bd6e&gt;] ? btree_set_page_dirty+0xe/0x10 [btrfs]
[ 7411.127142]  [&lt;ffffffffa041da51&gt;] __btrfs_cow_block+0x121/0x530 [btrfs]
[ 7411.127146]  [&lt;ffffffffa041dfff&gt;] btrfs_cow_block+0x11f/0x1c0 [btrfs]
[ 7411.127151]  [&lt;ffffffffa0421b74&gt;] btrfs_search_slot+0x1d4/0x9c0 [btrfs]
[ 7411.127157]  [&lt;ffffffffa0438567&gt;] btrfs_lookup_file_extent+0x37/0x40 [btrfs]
[ 7411.127163]  [&lt;ffffffffa0456bfc&gt;] __btrfs_drop_extents+0x16c/0xd90 [btrfs]
[ 7411.127169]  [&lt;ffffffffa0444ae3&gt;] ? start_transaction+0x93/0x580 [btrfs]
[ 7411.127171]  [&lt;ffffffff811663e2&gt;] ? kmem_cache_alloc+0x132/0x140
[ 7411.127176]  [&lt;ffffffffa041cd9a&gt;] ? btrfs_alloc_path+0x1a/0x20 [btrfs]
[ 7411.127182]  [&lt;ffffffffa044aa61&gt;] cow_file_range_inline+0x181/0x2e0 [btrfs]
[ 7411.127187]  [&lt;ffffffffa044aead&gt;] cow_file_range+0x2ed/0x440 [btrfs]
[ 7411.127194]  [&lt;ffffffffa0464d7f&gt;] ? free_extent_buffer+0x4f/0xb0 [btrfs]
[ 7411.127200]  [&lt;ffffffffa044b38f&gt;] run_delalloc_nocow+0x38f/0xa60 [btrfs]
[ 7411.127207]  [&lt;ffffffffa0461600&gt;] ? test_range_bit+0x30/0x180 [btrfs]
[ 7411.127212]  [&lt;ffffffffa044bd48&gt;] run_delalloc_range+0x2e8/0x350 [btrfs]
[ 7411.127219]  [&lt;ffffffffa04618f9&gt;] ? find_lock_delalloc_range+0x1a9/0x1e0 [btrfs]
[ 7411.127222]  [&lt;ffffffff812a1e71&gt;] ? blk_queue_bio+0x2c1/0x330
[ 7411.127228]  [&lt;ffffffffa0462ad4&gt;] __extent_writepage+0x2f4/0x760 [btrfs]

Here we fix it by avoiding joining transaction again if we have held
a transaction handle when allocating chunk in find_free_extent().

Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.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 hit something like the following function call flows:

|-&gt;run_delalloc_range()
 |-&gt;btrfs_join_transaction()
   |-&gt;cow_file_range()
     |-&gt;btrfs_join_transaction()
       |-&gt;find_free_extent()
         |-&gt;btrfs_join_transaction()

Trace infomation can be seen as:

[ 7411.127040] ------------[ cut here ]------------
[ 7411.127060] WARNING: CPU: 0 PID: 11557 at fs/btrfs/transaction.c:383 start_transaction+0x561/0x580 [btrfs]()
[ 7411.127079] CPU: 0 PID: 11557 Comm: kworker/u8:9 Tainted: G           O 3.13.0+ #4
[ 7411.127080] Hardware name: LENOVO QiTianM4350/ , BIOS F1KT52AUS 05/24/2013
[ 7411.127085] Workqueue: writeback bdi_writeback_workfn (flush-btrfs-5)
[ 7411.127092] Call Trace:
[ 7411.127097]  [&lt;ffffffff815b87b0&gt;] dump_stack+0x45/0x56
[ 7411.127101]  [&lt;ffffffff81051ffd&gt;] warn_slowpath_common+0x7d/0xa0
[ 7411.127102]  [&lt;ffffffff810520da&gt;] warn_slowpath_null+0x1a/0x20
[ 7411.127109]  [&lt;ffffffffa0444fb1&gt;] start_transaction+0x561/0x580 [btrfs]
[ 7411.127115]  [&lt;ffffffffa0445027&gt;] btrfs_join_transaction+0x17/0x20 [btrfs]
[ 7411.127120]  [&lt;ffffffffa0431c91&gt;] find_free_extent+0xa21/0xb50 [btrfs]
[ 7411.127126]  [&lt;ffffffffa0431f68&gt;] btrfs_reserve_extent+0xa8/0x1a0 [btrfs]
[ 7411.127131]  [&lt;ffffffffa04322ce&gt;] btrfs_alloc_free_block+0xee/0x440 [btrfs]
[ 7411.127137]  [&lt;ffffffffa043bd6e&gt;] ? btree_set_page_dirty+0xe/0x10 [btrfs]
[ 7411.127142]  [&lt;ffffffffa041da51&gt;] __btrfs_cow_block+0x121/0x530 [btrfs]
[ 7411.127146]  [&lt;ffffffffa041dfff&gt;] btrfs_cow_block+0x11f/0x1c0 [btrfs]
[ 7411.127151]  [&lt;ffffffffa0421b74&gt;] btrfs_search_slot+0x1d4/0x9c0 [btrfs]
[ 7411.127157]  [&lt;ffffffffa0438567&gt;] btrfs_lookup_file_extent+0x37/0x40 [btrfs]
[ 7411.127163]  [&lt;ffffffffa0456bfc&gt;] __btrfs_drop_extents+0x16c/0xd90 [btrfs]
[ 7411.127169]  [&lt;ffffffffa0444ae3&gt;] ? start_transaction+0x93/0x580 [btrfs]
[ 7411.127171]  [&lt;ffffffff811663e2&gt;] ? kmem_cache_alloc+0x132/0x140
[ 7411.127176]  [&lt;ffffffffa041cd9a&gt;] ? btrfs_alloc_path+0x1a/0x20 [btrfs]
[ 7411.127182]  [&lt;ffffffffa044aa61&gt;] cow_file_range_inline+0x181/0x2e0 [btrfs]
[ 7411.127187]  [&lt;ffffffffa044aead&gt;] cow_file_range+0x2ed/0x440 [btrfs]
[ 7411.127194]  [&lt;ffffffffa0464d7f&gt;] ? free_extent_buffer+0x4f/0xb0 [btrfs]
[ 7411.127200]  [&lt;ffffffffa044b38f&gt;] run_delalloc_nocow+0x38f/0xa60 [btrfs]
[ 7411.127207]  [&lt;ffffffffa0461600&gt;] ? test_range_bit+0x30/0x180 [btrfs]
[ 7411.127212]  [&lt;ffffffffa044bd48&gt;] run_delalloc_range+0x2e8/0x350 [btrfs]
[ 7411.127219]  [&lt;ffffffffa04618f9&gt;] ? find_lock_delalloc_range+0x1a9/0x1e0 [btrfs]
[ 7411.127222]  [&lt;ffffffff812a1e71&gt;] ? blk_queue_bio+0x2c1/0x330
[ 7411.127228]  [&lt;ffffffffa0462ad4&gt;] __extent_writepage+0x2f4/0x760 [btrfs]

Here we fix it by avoiding joining transaction again if we have held
a transaction handle when allocating chunk in find_free_extent().

Signed-off-by: Wang Shilong &lt;wangsl.fnst@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
