<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/ext4/extents.c, branch linux-4.7.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.7.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.7.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2016-10-22T10:06:49Z</updated>
<entry>
<title>ext4: fix memory leak in ext4_insert_range()</title>
<updated>2016-10-22T10:06:49Z</updated>
<author>
<name>Fabian Frederick</name>
</author>
<published>2016-09-15T15:39:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=befb1bb64bbd3f5b9699661c28a1450b43aa2e33'/>
<id>urn:sha1:befb1bb64bbd3f5b9699661c28a1450b43aa2e33</id>
<content type='text'>
commit edf15aa180d7b98fe16bd3eda42f9dd0e60dee20 upstream.

Running xfstests generic/013 with kmemleak gives the following:

unreferenced object 0xffff8801d3d27de0 (size 96):
  comm "fsstress", pid 4941, jiffies 4294860168 (age 53.485s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff818eaaf3&gt;] kmemleak_alloc+0x23/0x40
    [&lt;ffffffff81179805&gt;] __kmalloc+0xf5/0x1d0
    [&lt;ffffffff8122ef5c&gt;] ext4_find_extent+0x1ec/0x2f0
    [&lt;ffffffff8123530c&gt;] ext4_insert_range+0x34c/0x4a0
    [&lt;ffffffff81235942&gt;] ext4_fallocate+0x4e2/0x8b0
    [&lt;ffffffff81181334&gt;] vfs_fallocate+0x134/0x210
    [&lt;ffffffff8118203f&gt;] SyS_fallocate+0x3f/0x60
    [&lt;ffffffff818efa9b&gt;] entry_SYSCALL_64_fastpath+0x13/0x8f
    [&lt;ffffffffffffffff&gt;] 0xffffffffffffffff

Problem seems mitigated by dropping refs and freeing path
when there's no path[depth].p_ext

Signed-off-by: Fabian Frederick &lt;fabf@skynet.be&gt;
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ext4: check for extents that wrap around</title>
<updated>2016-08-16T07:35:00Z</updated>
<author>
<name>Vegard Nossum</name>
</author>
<published>2016-06-30T15:53:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7fc7b085daded6124e1bab55f24c087358c340fd'/>
<id>urn:sha1:7fc7b085daded6124e1bab55f24c087358c340fd</id>
<content type='text'>
commit f70749ca42943faa4d4dcce46dfdcaadb1d0c4b6 upstream.

An extent with lblock = 4294967295 and len = 1 will pass the
ext4_valid_extent() test:

	ext4_lblk_t last = lblock + len - 1;

	if (len == 0 || lblock &gt; last)
		return 0;

since last = 4294967295 + 1 - 1 = 4294967295. This would later trigger
the BUG_ON(es-&gt;es_lblk + es-&gt;es_len &lt; es-&gt;es_lblk) in ext4_es_end().

We can simplify it by removing the - 1 altogether and changing the test
to use lblock + len &lt;= lblock, since now if len = 0, then lblock + 0 ==
lblock and it fails, and if len &gt; 0 then lblock + len &gt; lblock in order
to pass (i.e. it doesn't overflow).

Fixes: 5946d0893 ("ext4: check for overlapping extents in ext4_valid_extent_entries()")
Fixes: 2f974865f ("ext4: check for zero length extent explicitly")
Cc: Eryu Guan &lt;guaneryu@gmail.com&gt;
Signed-off-by: Phil Turnbull &lt;phil.turnbull@oracle.com&gt;
Signed-off-by: Vegard Nossum &lt;vegard.nossum@oracle.com&gt;
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ext4: verify extent header depth</title>
<updated>2016-08-16T07:34:57Z</updated>
<author>
<name>Vegard Nossum</name>
</author>
<published>2016-07-15T04:22:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3f66cf7a98699128acf210d6f671b3c60b9555f9'/>
<id>urn:sha1:3f66cf7a98699128acf210d6f671b3c60b9555f9</id>
<content type='text'>
commit 7bc9491645118c9461bd21099c31755ff6783593 upstream.

Although the extent tree depth of 5 should enough be for the worst
case of 2*32 extents of length 1, the extent tree code does not
currently to merge nodes which are less than half-full with a sibling
node, or to shrink the tree depth if possible.  So it's possible, at
least in theory, for the tree depth to be greater than 5.  However,
even in the worst case, a tree depth of 32 is highly unlikely, and if
the file system is maliciously corrupted, an insanely large eh_depth
can cause memory allocation failures that will trigger kernel warnings
(here, eh_depth = 65280):

    JBD2: ext4.exe wants too many credits credits:195849 rsv_credits:0 max:256
    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 50 at fs/jbd2/transaction.c:293 start_this_handle+0x569/0x580
    CPU: 0 PID: 50 Comm: ext4.exe Not tainted 4.7.0-rc5+ #508
    Stack:
     604a8947 625badd8 0002fd09 00000000
     60078643 00000000 62623910 601bf9bc
     62623970 6002fc84 626239b0 900000125
    Call Trace:
     [&lt;6001c2dc&gt;] show_stack+0xdc/0x1a0
     [&lt;601bf9bc&gt;] dump_stack+0x2a/0x2e
     [&lt;6002fc84&gt;] __warn+0x114/0x140
     [&lt;6002fdff&gt;] warn_slowpath_null+0x1f/0x30
     [&lt;60165829&gt;] start_this_handle+0x569/0x580
     [&lt;60165d4e&gt;] jbd2__journal_start+0x11e/0x220
     [&lt;60146690&gt;] __ext4_journal_start_sb+0x60/0xa0
     [&lt;60120a81&gt;] ext4_truncate+0x131/0x3a0
     [&lt;60123677&gt;] ext4_setattr+0x757/0x840
     [&lt;600d5d0f&gt;] notify_change+0x16f/0x2a0
     [&lt;600b2b16&gt;] do_truncate+0x76/0xc0
     [&lt;600c3e56&gt;] path_openat+0x806/0x1300
     [&lt;600c55c9&gt;] do_filp_open+0x89/0xf0
     [&lt;600b4074&gt;] do_sys_open+0x134/0x1e0
     [&lt;600b4140&gt;] SyS_open+0x20/0x30
     [&lt;6001ea68&gt;] handle_syscall+0x88/0x90
     [&lt;600295fd&gt;] userspace+0x3fd/0x500
     [&lt;6001ac55&gt;] fork_handler+0x85/0x90

    ---[ end trace 08b0b88b6387a244 ]---

[ Commit message modified and the extent tree depath check changed
from 5 to 32 -- tytso ]

Cc: Darrick J. Wong &lt;darrick.wong@oracle.com&gt;
Signed-off-by: Vegard Nossum &lt;vegard.nossum@oracle.com&gt;
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ext4: remove unmeetable inconsisteny check from ext4_find_extent()</title>
<updated>2016-05-06T02:43:04Z</updated>
<author>
<name>Nicolai Stange</name>
</author>
<published>2016-05-06T02:43:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=816cd71b0c723a7296d14aadb8ff1ba42f6181d2'/>
<id>urn:sha1:816cd71b0c723a7296d14aadb8ff1ba42f6181d2</id>
<content type='text'>
ext4_find_extent(), stripped down to the parts relevant to this patch,
reads as

  ppos = 0;
  i = depth;
  while (i) {
    --i;
    ++ppos;
    if (unlikely(ppos &gt; depth)) {
      ...
      ret = -EFSCORRUPTED;
      goto err;
    }
  }

Due to the loop's bounds, the condition ppos &gt; depth can never be met.

Remove this dead code.

Signed-off-by: Nicolai Stange &lt;nicstange@gmail.com&gt;
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
</content>
</entry>
<entry>
<title>ext4: remove trailing \n from ext4_warning/ext4_error calls</title>
<updated>2016-04-27T05:11:21Z</updated>
<author>
<name>Jakub Wilk</name>
</author>
<published>2016-04-27T05:11:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8d2ae1cbe8a984d7a755755fb53955de2f60a2f9'/>
<id>urn:sha1:8d2ae1cbe8a984d7a755755fb53955de2f60a2f9</id>
<content type='text'>
Messages passed to ext4_warning() or ext4_error() don't need trailing
newlines, because these function add the newlines themselves.

Signed-off-by: Jakub Wilk &lt;jwilk@jwilk.net&gt;
</content>
</entry>
<entry>
<title>ext4: fix jbd2 handle extension in ext4_ext_truncate_extend_restart()</title>
<updated>2016-04-26T03:13:17Z</updated>
<author>
<name>Theodore Ts'o</name>
</author>
<published>2016-04-26T03:13:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7b8081912d75df1d910d6969f0a374b66ef242bf'/>
<id>urn:sha1:7b8081912d75df1d910d6969f0a374b66ef242bf</id>
<content type='text'>
The function jbd2_journal_extend() takes as its argument the number of
new credits to be added to the handle.  We weren't taking into account
the currently unused handle credits; worse, we would try to extend the
handle by N credits when it had N credits available.

In the case where jbd2_journal_extend() fails because the transaction
is too large, when jbd2_journal_restart() gets called, the N credits
owned by the handle gets returned to the transaction, and the
transaction commit is asynchronously requested, and then
start_this_handle() will be able to successfully attach the handle to
the current transaction since the required credits are now available.

This is mostly harmless, but since ext4_ext_truncate_extend_restart()
returns EAGAIN, the truncate machinery will once again try to call
ext4_ext_truncate_extend_restart(), which will do the above sequence
over and over again until the transaction has committed.

This was found while I was debugging a lockup in caused by running
xfstests generic/074 in the data=journal case.  I'm still not sure why
we ended up looping forever, which suggests there may still be another
bug hiding in the transaction accounting machinery, but this commit
prevents us from looping in the first place.

Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
</content>
</entry>
<entry>
<title>ext4: fix misspellings in comments.</title>
<updated>2016-03-10T04:49:05Z</updated>
<author>
<name>Adam Buchbinder</name>
</author>
<published>2016-03-10T04:49:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b8a07463c8c5fd7c609590c7cd9eda897a1b6cd6'/>
<id>urn:sha1:b8a07463c8c5fd7c609590c7cd9eda897a1b6cd6</id>
<content type='text'>
Signed-off-by: Adam Buchbinder &lt;adam.buchbinder@gmail.com&gt;
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
</content>
</entry>
<entry>
<title>ext4: return hole from ext4_map_blocks()</title>
<updated>2016-03-10T03:54:00Z</updated>
<author>
<name>Jan Kara</name>
</author>
<published>2016-03-10T03:54:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=facab4d9711e7aa3532cb82643803e8f1b9518e8'/>
<id>urn:sha1:facab4d9711e7aa3532cb82643803e8f1b9518e8</id>
<content type='text'>
Currently, ext4_map_blocks() just returns 0 when it finds a hole and
allocation is not requested. However we have all the information
available to tell how large the hole actually is and there are callers
of ext4_map_blocks() which would save some block-by-block hole iteration
if they knew this information. So fill in struct ext4_map_blocks even
for holes with the information we have. We keep returning 0 for holes to
maintain backward compatibility of the function.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
</content>
</entry>
<entry>
<title>ext4: factor out determining of hole size</title>
<updated>2016-03-10T03:46:57Z</updated>
<author>
<name>Jan Kara</name>
</author>
<published>2016-03-10T03:46:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=140a52508a68387e22486659ff9eaa89a24f6e40'/>
<id>urn:sha1:140a52508a68387e22486659ff9eaa89a24f6e40</id>
<content type='text'>
ext4_ext_put_gap_in_cache() determines hole size in the extent tree,
then trims this with possible delayed allocated blocks, and inserts the
result into the extent status tree. Factor out determination of the size
of the hole in the extent tree as we will need this information in
ext4_ext_map_blocks() as well.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
</content>
</entry>
<entry>
<title>ext4: simplify io_end handling for AIO DIO</title>
<updated>2016-03-09T04:36:46Z</updated>
<author>
<name>Jan Kara</name>
</author>
<published>2016-03-09T04:36:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=109811c20fb8ec46e2ed01750214a32a9163d164'/>
<id>urn:sha1:109811c20fb8ec46e2ed01750214a32a9163d164</id>
<content type='text'>
When mapping blocks for direct IO, we allocate io_end structure before
mapping blocks and store pointer to it in the inode. This creates a
requirement that any AIO DIO using io_end must be protected by i_mutex.
This created problems in the past with dioread_nolock mode which was
corrupting io_end pointers. Also io_end is allocated unnecessarily in
case where we don't need to convert any extents (which is a common case
for example when overwriting file).

We fix the problem by allocating io_end only once we return unwritten
extent from block mapping function for AIO DIO (so we can save some
pointless io_end allocations) and we pass pointer to it in bh-&gt;b_private
which generic DIO code later passes to our end IO callback. That way we
remove any need for global pointer to io_end structure and thus fix the
races.

The downside of this change is that the checking for unwritten IO in
flight in ext4_extents_can_be_merged() is more racy since we now
increment i_unwritten / set EXT4_STATE_DIO_UNWRITTEN only after dropping
i_data_sem. However the check has been racy already before because
ext4_writepages() already increment i_unwritten after dropping
i_data_sem and reserved blocks save us from hitting ENOSPC in the worst
case.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
</feed>
