<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/fs/btrfs, branch v3.3-rc2</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs</title>
<updated>2012-01-29T01:00:19+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-01-29T01:00:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=67d2433ee7aa631bc3ab14c2af6bbc1d44d13a00'/>
<id>67d2433ee7aa631bc3ab14c2af6bbc1d44d13a00</id>
<content type='text'>
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  Btrfs: fix reservations in btrfs_page_mkwrite
  Btrfs: advance window_start if we're using a bitmap
  btrfs: mask out gfp flags in releasepage
  Btrfs: fix enospc error caused by wrong checks of the chunk
  Btrfs: do not defrag a file partially
  Btrfs: fix warning for 32-bit build of fs/btrfs/check-integrity.c
  Btrfs: use cluster-&gt;window_start when allocating from a cluster bitmap
  Btrfs: Check for NULL page in extent_range_uptodate
  btrfs: Fix busyloops in transaction waiting code
  Btrfs: make sure a bitmap has enough bytes
  Btrfs: fix uninit warning in backref.c
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  Btrfs: fix reservations in btrfs_page_mkwrite
  Btrfs: advance window_start if we're using a bitmap
  btrfs: mask out gfp flags in releasepage
  Btrfs: fix enospc error caused by wrong checks of the chunk
  Btrfs: do not defrag a file partially
  Btrfs: fix warning for 32-bit build of fs/btrfs/check-integrity.c
  Btrfs: use cluster-&gt;window_start when allocating from a cluster bitmap
  Btrfs: Check for NULL page in extent_range_uptodate
  btrfs: Fix busyloops in transaction waiting code
  Btrfs: make sure a bitmap has enough bytes
  Btrfs: fix uninit warning in backref.c
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: fix reservations in btrfs_page_mkwrite</title>
<updated>2012-01-27T15:44:44+00:00</updated>
<author>
<name>Chris Mason</name>
<email>chris.mason@oracle.com</email>
</author>
<published>2012-01-25T18:47:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9998eb703490589c3e8f1bf09b15203156776edb'/>
<id>9998eb703490589c3e8f1bf09b15203156776edb</id>
<content type='text'>
Josef fixed btrfs_page_mkwrite to properly release reserved
extents if there was an error.  But if we fail to get a reservation
and we fail to dirty the inode (for ENOSPC reasons), we'll end up
trying to release a reservation we never had.

This makes sure we only release if we were able to reserve.

Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Josef fixed btrfs_page_mkwrite to properly release reserved
extents if there was an error.  But if we fail to get a reservation
and we fail to dirty the inode (for ENOSPC reasons), we'll end up
trying to release a reservation we never had.

This makes sure we only release if we were able to reserve.

Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: advance window_start if we're using a bitmap</title>
<updated>2012-01-26T20:01:12+00:00</updated>
<author>
<name>Josef Bacik</name>
<email>josef@redhat.com</email>
</author>
<published>2012-01-26T20:01:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9b23062840e7c685ef0a0b561285d6e3a3b6811b'/>
<id>9b23062840e7c685ef0a0b561285d6e3a3b6811b</id>
<content type='text'>
If we span a long area in a bitmap we could end up taking a lot of time
searching to the next free area if we're searching from the original
window_start, so advance window_start in order to make sure we don't do any
superficial searching.  Thanks,

Signed-off-by: Josef Bacik &lt;josef@redhat.com&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we span a long area in a bitmap we could end up taking a lot of time
searching to the next free area if we're searching from the original
window_start, so advance window_start in order to make sure we don't do any
superficial searching.  Thanks,

Signed-off-by: Josef Bacik &lt;josef@redhat.com&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>btrfs: mask out gfp flags in releasepage</title>
<updated>2012-01-26T20:01:12+00:00</updated>
<author>
<name>David Sterba</name>
<email>dsterba@suse.cz</email>
</author>
<published>2012-01-26T20:01:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=0c4e538bccc106872d31b1514570b4dac95fb7f2'/>
<id>0c4e538bccc106872d31b1514570b4dac95fb7f2</id>
<content type='text'>
btree_releasepage is a callback and can be passed unknown gfp flags and then
they may end up in kmem_cache_alloc called from alloc_extent_state, slab
allocator will BUG_ON when there is HIGHMEM or DMA32 flag set.

This may happen when btrfs is mounted from a loop device, which masks out
__GFP_IO flag. The check in try_release_extent_state

3399                 if ((mask &amp; GFP_NOFS) == GFP_NOFS)
3400                         mask = GFP_NOFS;

will not work and passes unfiltered flags further resulting in crash at
mm/slab.c:2963

 [&lt;000000000024ae4c&gt;] cache_alloc_refill+0x3b4/0x5c8
 [&lt;000000000024c810&gt;] kmem_cache_alloc+0x204/0x294
 [&lt;00000000001fd3c2&gt;] mempool_alloc+0x52/0x170
 [&lt;000003c000ced0b0&gt;] alloc_extent_state+0x40/0xd4 [btrfs]
 [&lt;000003c000cee5ae&gt;] __clear_extent_bit+0x38a/0x4cc [btrfs]
 [&lt;000003c000cee78c&gt;] try_release_extent_state+0x9c/0xd4 [btrfs]
 [&lt;000003c000cc4c66&gt;] btree_releasepage+0x7e/0xd0 [btrfs]
 [&lt;0000000000210d84&gt;] shrink_page_list+0x6a0/0x724
 [&lt;0000000000211394&gt;] shrink_inactive_list+0x230/0x578
 [&lt;0000000000211bb8&gt;] shrink_list+0x6c/0x120
 [&lt;0000000000211e4e&gt;] shrink_zone+0x1e2/0x228
 [&lt;0000000000211f24&gt;] shrink_zones+0x90/0x254
 [&lt;0000000000213410&gt;] do_try_to_free_pages+0xac/0x420
 [&lt;0000000000213ae0&gt;] try_to_free_pages+0x13c/0x1b0
 [&lt;0000000000204e6c&gt;] __alloc_pages_nodemask+0x5b4/0x9a8
 [&lt;00000000001fb04a&gt;] grab_cache_page_write_begin+0x7e/0xe8

Signed-off-by: David Sterba &lt;dsterba@suse.cz&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
btree_releasepage is a callback and can be passed unknown gfp flags and then
they may end up in kmem_cache_alloc called from alloc_extent_state, slab
allocator will BUG_ON when there is HIGHMEM or DMA32 flag set.

This may happen when btrfs is mounted from a loop device, which masks out
__GFP_IO flag. The check in try_release_extent_state

3399                 if ((mask &amp; GFP_NOFS) == GFP_NOFS)
3400                         mask = GFP_NOFS;

will not work and passes unfiltered flags further resulting in crash at
mm/slab.c:2963

 [&lt;000000000024ae4c&gt;] cache_alloc_refill+0x3b4/0x5c8
 [&lt;000000000024c810&gt;] kmem_cache_alloc+0x204/0x294
 [&lt;00000000001fd3c2&gt;] mempool_alloc+0x52/0x170
 [&lt;000003c000ced0b0&gt;] alloc_extent_state+0x40/0xd4 [btrfs]
 [&lt;000003c000cee5ae&gt;] __clear_extent_bit+0x38a/0x4cc [btrfs]
 [&lt;000003c000cee78c&gt;] try_release_extent_state+0x9c/0xd4 [btrfs]
 [&lt;000003c000cc4c66&gt;] btree_releasepage+0x7e/0xd0 [btrfs]
 [&lt;0000000000210d84&gt;] shrink_page_list+0x6a0/0x724
 [&lt;0000000000211394&gt;] shrink_inactive_list+0x230/0x578
 [&lt;0000000000211bb8&gt;] shrink_list+0x6c/0x120
 [&lt;0000000000211e4e&gt;] shrink_zone+0x1e2/0x228
 [&lt;0000000000211f24&gt;] shrink_zones+0x90/0x254
 [&lt;0000000000213410&gt;] do_try_to_free_pages+0xac/0x420
 [&lt;0000000000213ae0&gt;] try_to_free_pages+0x13c/0x1b0
 [&lt;0000000000204e6c&gt;] __alloc_pages_nodemask+0x5b4/0x9a8
 [&lt;00000000001fb04a&gt;] grab_cache_page_write_begin+0x7e/0xe8

Signed-off-by: David Sterba &lt;dsterba@suse.cz&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: fix enospc error caused by wrong checks of the chunk</title>
<updated>2012-01-26T20:01:12+00:00</updated>
<author>
<name>Miao Xie</name>
<email>miaox@cn.fujitsu.com</email>
</author>
<published>2012-01-26T20:01:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9e622d6bea0202e9fe267955362c01918562c09b'/>
<id>9e622d6bea0202e9fe267955362c01918562c09b</id>
<content type='text'>
When we did sysbench test for inline files, enospc error happened easily though
there was lots of free disk space which could be allocated for new chunks.

Reproduce steps:
 # mkfs.btrfs -b $((2 * 1024 * 1024 * 1024)) &lt;test partition&gt;
 # mount &lt;test partition&gt; /mnt
 # ulimit -n 102400
 # cd /mnt
 # sysbench --num-threads=1 --test=fileio --file-num=81920 \
 &gt; --file-total-size=80M --file-block-size=1K --file-io-mode=sync \
 &gt; --file-test-mode=seqwr prepare
 # sysbench --num-threads=1 --test=fileio --file-num=81920 \
 &gt; --file-total-size=80M --file-block-size=1K --file-io-mode=sync \
 &gt; --file-test-mode=seqwr run
 &lt;soon later, BUG_ON() was triggered by enospc error&gt;

The reason of this bug is:
Now, we can reserve space which is larger than the free space in the chunks if
we have enough free disk space which can be used for new chunks. By this way,
the space allocator should allocate a new chunk by force if there is no free
space in the free space cache. But there are two wrong checks which break this
operation.

One is
	if (ret == -ENOSPC &amp;&amp; num_bytes &gt; min_alloc_size)
in btrfs_reserve_extent(), it is wrong, we should try to allocate a new chunk
even we fail to allocate free space by minimum allocable size.

The other is
	if (space_info-&gt;force_alloc)
		force = space_info-&gt;force_alloc;
in do_chunk_alloc(). It makes the allocator ignore CHUNK_ALLOC_FORCE If someone
sets -&gt;force_alloc to CHUNK_ALLOC_LIMITED, and makes the enospc error happen.

Fix these two wrong checks. Especially the second one, we fix it by changing
the value of CHUNK_ALLOC_LIMITED and CHUNK_ALLOC_FORCE, and make
CHUNK_ALLOC_FORCE greater than CHUNK_ALLOC_LIMITED since CHUNK_ALLOC_FORCE has
higher priority. And if the value which is passed in by the caller is greater
than -&gt;force_alloc, use the passed value.

Signed-off-by: Miao Xie &lt;miaox@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When we did sysbench test for inline files, enospc error happened easily though
there was lots of free disk space which could be allocated for new chunks.

Reproduce steps:
 # mkfs.btrfs -b $((2 * 1024 * 1024 * 1024)) &lt;test partition&gt;
 # mount &lt;test partition&gt; /mnt
 # ulimit -n 102400
 # cd /mnt
 # sysbench --num-threads=1 --test=fileio --file-num=81920 \
 &gt; --file-total-size=80M --file-block-size=1K --file-io-mode=sync \
 &gt; --file-test-mode=seqwr prepare
 # sysbench --num-threads=1 --test=fileio --file-num=81920 \
 &gt; --file-total-size=80M --file-block-size=1K --file-io-mode=sync \
 &gt; --file-test-mode=seqwr run
 &lt;soon later, BUG_ON() was triggered by enospc error&gt;

The reason of this bug is:
Now, we can reserve space which is larger than the free space in the chunks if
we have enough free disk space which can be used for new chunks. By this way,
the space allocator should allocate a new chunk by force if there is no free
space in the free space cache. But there are two wrong checks which break this
operation.

One is
	if (ret == -ENOSPC &amp;&amp; num_bytes &gt; min_alloc_size)
in btrfs_reserve_extent(), it is wrong, we should try to allocate a new chunk
even we fail to allocate free space by minimum allocable size.

The other is
	if (space_info-&gt;force_alloc)
		force = space_info-&gt;force_alloc;
in do_chunk_alloc(). It makes the allocator ignore CHUNK_ALLOC_FORCE If someone
sets -&gt;force_alloc to CHUNK_ALLOC_LIMITED, and makes the enospc error happen.

Fix these two wrong checks. Especially the second one, we fix it by changing
the value of CHUNK_ALLOC_LIMITED and CHUNK_ALLOC_FORCE, and make
CHUNK_ALLOC_FORCE greater than CHUNK_ALLOC_LIMITED since CHUNK_ALLOC_FORCE has
higher priority. And if the value which is passed in by the caller is greater
than -&gt;force_alloc, use the passed value.

Signed-off-by: Miao Xie &lt;miaox@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: do not defrag a file partially</title>
<updated>2012-01-26T20:01:12+00:00</updated>
<author>
<name>Liu Bo</name>
<email>liubo2009@cn.fujitsu.com</email>
</author>
<published>2012-01-26T20:01:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=7ec31b548a17f773ab6289e795ed3a6820e8b56e'/>
<id>7ec31b548a17f773ab6289e795ed3a6820e8b56e</id>
<content type='text'>
xfstests 218 complains that btrfs defrags a file partially:
 After: 1
 Write backwards sync, but contiguous - should defrag to 1 extent
 Before: 10
-After: 1
+After: 2

To fix this, we need to set max_to_defrag count properly.

Signed-off-by: Liu Bo &lt;liubo2009@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
xfstests 218 complains that btrfs defrags a file partially:
 After: 1
 Write backwards sync, but contiguous - should defrag to 1 extent
 Before: 10
-After: 1
+After: 2

To fix this, we need to set max_to_defrag count properly.

Signed-off-by: Liu Bo &lt;liubo2009@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: fix warning for 32-bit build of fs/btrfs/check-integrity.c</title>
<updated>2012-01-26T20:01:11+00:00</updated>
<author>
<name>Stefan Behrens</name>
<email>sbehrens@giantdisaster.de</email>
</author>
<published>2012-01-26T20:01:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=0b485143d835c019cddc45f46e4b3873dcc9aa4e'/>
<id>0b485143d835c019cddc45f46e4b3873dcc9aa4e</id>
<content type='text'>
There have been 4 warnings on 32-bit build, they are herewith fixed.

Signed-off-by: Stefan Behrens &lt;sbehrens@giantdisaster.de&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There have been 4 warnings on 32-bit build, they are herewith fixed.

Signed-off-by: Stefan Behrens &lt;sbehrens@giantdisaster.de&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: use cluster-&gt;window_start when allocating from a cluster bitmap</title>
<updated>2012-01-26T20:01:11+00:00</updated>
<author>
<name>Josef Bacik</name>
<email>josef@redhat.com</email>
</author>
<published>2012-01-26T20:01:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=0b4a9d248f88e6773312f262e8185f23863d984a'/>
<id>0b4a9d248f88e6773312f262e8185f23863d984a</id>
<content type='text'>
We specifically set window_start in the cluster struct to indicate where the
cluster starts in a bitmap, but we've been using min_start to indicate where
we're searching from.  This is usually the start of the blockgroup, so
essentially means we're constantly searching from the start of any bitmap we
find, which completely negates all the trouble we go to in order to setup a
cluster.  So start using window_start to make sure we actually use the area we
found.  Thanks,

Signed-off-by: Josef Bacik &lt;josef@redhat.com&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We specifically set window_start in the cluster struct to indicate where the
cluster starts in a bitmap, but we've been using min_start to indicate where
we're searching from.  This is usually the start of the blockgroup, so
essentially means we're constantly searching from the start of any bitmap we
find, which completely negates all the trouble we go to in order to setup a
cluster.  So start using window_start to make sure we actually use the area we
found.  Thanks,

Signed-off-by: Josef Bacik &lt;josef@redhat.com&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Btrfs: Check for NULL page in extent_range_uptodate</title>
<updated>2012-01-26T20:01:11+00:00</updated>
<author>
<name>Mitch Harder</name>
<email>mitch.harder@sabayonlinux.org</email>
</author>
<published>2012-01-26T20:01:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=8bedd51b6121c4607784d75f852828d25d119c52'/>
<id>8bedd51b6121c4607784d75f852828d25d119c52</id>
<content type='text'>
A user has encountered a NULL pointer kernel oops in btrfs when
encountering media errors.  The problem has been identified
as an unhandled NULL pointer returned from find_get_page().
This modification simply checks for a NULL page, and returns
with an error if found (the extent_range_uptodate() function
returns 1 on errors).

After testing this patch, the user reported that the error with
the NULL pointer oops was solved.  However, there is still a
remaining problem with a thread becoming stuck in
wait_on_page_locked(page) in the read_extent_buffer_pages(...)
function in extent_io.c

       for (i = start_i; i &lt; num_pages; i++) {
               page = extent_buffer_page(eb, i);
               wait_on_page_locked(page);
               if (!PageUptodate(page))
                       ret = -EIO;
       }

This patch leaves the issue with the locked page yet to be resolved.

Signed-off-by: Mitch Harder &lt;mitch.harder@sabayonlinux.org&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A user has encountered a NULL pointer kernel oops in btrfs when
encountering media errors.  The problem has been identified
as an unhandled NULL pointer returned from find_get_page().
This modification simply checks for a NULL page, and returns
with an error if found (the extent_range_uptodate() function
returns 1 on errors).

After testing this patch, the user reported that the error with
the NULL pointer oops was solved.  However, there is still a
remaining problem with a thread becoming stuck in
wait_on_page_locked(page) in the read_extent_buffer_pages(...)
function in extent_io.c

       for (i = start_i; i &lt; num_pages; i++) {
               page = extent_buffer_page(eb, i);
               wait_on_page_locked(page);
               if (!PageUptodate(page))
                       ret = -EIO;
       }

This patch leaves the issue with the locked page yet to be resolved.

Signed-off-by: Mitch Harder &lt;mitch.harder@sabayonlinux.org&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>btrfs: Fix busyloops in transaction waiting code</title>
<updated>2012-01-26T20:01:11+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2012-01-26T20:01:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6dd70ce4eb7429c2ba6dd9fa46f78a0a2a254038'/>
<id>6dd70ce4eb7429c2ba6dd9fa46f78a0a2a254038</id>
<content type='text'>
wait_log_commit() and wait_for_writer() were using slightly different
conditions for deciding whether they should call schedule() and whether they
should continue in the wait loop. Thus it could happen that we busylooped when
the first condition was not true while the second one was. That is burning CPU
cycles needlessly and is deadly on UP machines...

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
wait_log_commit() and wait_for_writer() were using slightly different
conditions for deciding whether they should call schedule() and whether they
should continue in the wait loop. Thus it could happen that we busylooped when
the first condition was not true while the second one was. That is burning CPU
cycles needlessly and is deadly on UP machines...

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Chris Mason &lt;chris.mason@oracle.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
