<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/jbd2/transaction.c, branch linux-3.14.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.14.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.14.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2016-02-17T20:34:36Z</updated>
<entry>
<title>jbd2: Fix unreclaimed pages after truncate in data=journal mode</title>
<updated>2016-02-17T20:34:36Z</updated>
<author>
<name>Jan Kara</name>
</author>
<published>2015-11-24T20:34:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0d7e2f0dd4d158136d10e7bec6e62c4c49d06d3c'/>
<id>urn:sha1:0d7e2f0dd4d158136d10e7bec6e62c4c49d06d3c</id>
<content type='text'>
commit bc23f0c8d7ccd8d924c4e70ce311288cb3e61ea8 upstream.

Ted and Namjae have reported that truncated pages don't get timely
reclaimed after being truncated in data=journal mode. The following test
triggers the issue easily:

for (i = 0; i &lt; 1000; i++) {
	pwrite(fd, buf, 1024*1024, 0);
	fsync(fd);
	fsync(fd);
	ftruncate(fd, 0);
}

The reason is that journal_unmap_buffer() finds that truncated buffers
are not journalled (jh-&gt;b_transaction == NULL), they are part of
checkpoint list of a transaction (jh-&gt;b_cp_transaction != NULL) and have
been already written out (!buffer_dirty(bh)). We clean such buffers but
we leave them in the checkpoint list. Since checkpoint transaction holds
a reference to the journal head, these buffers cannot be released until
the checkpoint transaction is cleaned up. And at that point we don't
call release_buffer_page() anymore so pages detached from mapping are
lingering in the system waiting for reclaim to find them and free them.

Fix the problem by removing buffers from transaction checkpoint lists
when journal_unmap_buffer() finds out they don't have to be there
anymore.

Reported-and-tested-by: Namjae Jeon &lt;namjae.jeon@samsung.com&gt;
Fixes: de1b794130b130e77ffa975bb58cb843744f9ae5
Signed-off-by: Jan Kara &lt;jack@suse.cz&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: fix NULL pointer dereference when journal restart fails</title>
<updated>2015-06-06T15:19:35Z</updated>
<author>
<name>Lukas Czerner</name>
</author>
<published>2015-05-14T22:55:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1e217f7207a18add4440166fa818d65b53f5422a'/>
<id>urn:sha1:1e217f7207a18add4440166fa818d65b53f5422a</id>
<content type='text'>
commit 9d506594069355d1fb2de3f9104667312ff08ed3 upstream.

Currently when journal restart fails, we'll have the h_transaction of
the handle set to NULL to indicate that the handle has been effectively
aborted. We handle this situation quietly in the jbd2_journal_stop() and just
free the handle and exit because everything else has been done before we
attempted (and failed) to restart the journal.

Unfortunately there are a number of problems with that approach
introduced with commit

41a5b913197c "jbd2: invalidate handle if jbd2_journal_restart()
fails"

First of all in ext4 jbd2_journal_stop() will be called through
__ext4_journal_stop() where we would try to get a hold of the superblock
by dereferencing h_transaction which in this case would lead to NULL
pointer dereference and crash.

In addition we're going to free the handle regardless of the refcount
which is bad as well, because others up the call chain will still
reference the handle so we might potentially reference already freed
memory.

Moreover it's expected that we'll get aborted handle as well as detached
handle in some of the journalling function as the error propagates up
the stack, so it's unnecessary to call WARN_ON every time we get
detached handle.

And finally we might leak some memory by forgetting to free reserved
handle in jbd2_journal_stop() in the case where handle was detached from
the transaction (h_transaction is NULL).

Fix the NULL pointer dereference in __ext4_journal_stop() by just
calling jbd2_journal_stop() quietly as suggested by Jan Kara. Also fix
the potential memory leak in jbd2_journal_stop() and use proper
handle refcounting before we attempt to free it to avoid use-after-free
issues.

And finally remove all WARN_ON(!transaction) from the code so that we do
not get random traces when something goes wrong because when journal
restart fails we will get to some of those functions.

Signed-off-by: Lukas Czerner &lt;lczerner@redhat.com&gt;
Signed-off-by: Theodore Ts'o &lt;tytso@mit.edu&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ext4: disable synchronous transaction batching if max_batch_time==0</title>
<updated>2014-07-17T23:21:05Z</updated>
<author>
<name>Eric Sandeen</name>
</author>
<published>2014-07-05T23:18:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e35d008f558a9b7609bd2f1befe7aa7e2e0a1b2a'/>
<id>urn:sha1:e35d008f558a9b7609bd2f1befe7aa7e2e0a1b2a</id>
<content type='text'>
commit 5dd214248f94d430d70e9230bda72f2654ac88a8 upstream.

The mount manpage says of the max_batch_time option,

	This optimization can be turned off entirely
	by setting max_batch_time to 0.

But the code doesn't do that.  So fix the code to do
that.

Signed-off-by: Eric Sandeen &lt;sandeen@redhat.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>jbd2: fix use after free in jbd2_journal_start_reserved()</title>
<updated>2014-02-18T01:33:01Z</updated>
<author>
<name>Dan Carpenter</name>
</author>
<published>2014-02-18T01:33:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=92e3b40537707001d17bbad800d150ab04e53bf4'/>
<id>urn:sha1:92e3b40537707001d17bbad800d150ab04e53bf4</id>
<content type='text'>
If start_this_handle() fails then it leads to a use after free of
"handle".

Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: "Theodore Ts'o" &lt;tytso@mit.edu&gt;
Cc: stable@vger.kernel.org

</content>
</entry>
<entry>
<title>jbd2: rename obsoleted msg JBD-&gt;JBD2</title>
<updated>2013-12-09T02:14:59Z</updated>
<author>
<name>Dmitry Monakhov</name>
</author>
<published>2013-12-09T02:14:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a67c848a8b9aa9e471f9eaadd2cb29cc527462cf'/>
<id>urn:sha1:a67c848a8b9aa9e471f9eaadd2cb29cc527462cf</id>
<content type='text'>
Rename performed via: perl -pi -e 's/JBD:/JBD2:/g' fs/jbd2/*.c

Signed-off-by: Dmitry Monakhov &lt;dmonakhov@openvz.org&gt;
Signed-off-by: "Theodore Ts'o" &lt;tytso@mit.edu&gt;
Reviewed-by: Carlos Maiolino &lt;cmaiolino@redhat.com&gt;
</content>
</entry>
<entry>
<title>jbd2: revise KERN_EMERG error messages</title>
<updated>2013-12-09T02:13:59Z</updated>
<author>
<name>Jan Kara</name>
</author>
<published>2013-12-09T02:13:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=75685071cd5b26d64fd2577330387aeab019ac97'/>
<id>urn:sha1:75685071cd5b26d64fd2577330387aeab019ac97</id>
<content type='text'>
Some of KERN_EMERG printk messages do not really deserve this log
level and the one in log_wait_commit() is even rather useless (the
journal has been previously aborted and *that* is where we should have
been complaining). So make some messages just KERN_ERR and remove the
useless message.

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>jbd2: don't BUG but return ENOSPC if a handle runs out of space</title>
<updated>2013-12-09T02:12:59Z</updated>
<author>
<name>Theodore Ts'o</name>
</author>
<published>2013-12-09T02:12:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f6c07cad081ba222d63623d913aafba5586c1d2c'/>
<id>urn:sha1:f6c07cad081ba222d63623d913aafba5586c1d2c</id>
<content type='text'>
If a handle runs out of space, we currently stop the kernel with a BUG
in jbd2_journal_dirty_metadata().  This makes it hard to figure out
what might be going on.  So return an error of ENOSPC, so we can let
the file system layer figure out what is going on, to make it more
likely we can get useful debugging information).  This should make it
easier to debug problems such as the one which was reported by:

    https://bugzilla.kernel.org/show_bug.cgi?id=44731

The only two callers of this function are ext4_handle_dirty_metadata()
and ocfs2_journal_dirty().  The ocfs2 function will trigger a
BUG_ON(), which means there will be no change in behavior.  The ext4
function will call ext4_error_inode() which will print the useful
debugging information and then handle the situation using ext4's error
handling mechanisms (i.e., which might mean halting the kernel or
remounting the file system read-only).

Also, since both file systems already call WARN_ON(), drop the WARN_ON
from jbd2_journal_dirty_metadata() to avoid two stack traces from
being displayed.

Signed-off-by: "Theodore Ts'o" &lt;tytso@mit.edu&gt;
Cc: ocfs2-devel@oss.oracle.com
Acked-by: Joel Becker &lt;jlbec@evilplan.org&gt;
</content>
</entry>
<entry>
<title>jbd2: invalidate handle if jbd2_journal_restart() fails</title>
<updated>2013-07-01T12:12:41Z</updated>
<author>
<name>Theodore Ts'o</name>
</author>
<published>2013-07-01T12:12:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=41a5b913197c3a25fddef1735dc9b3d1fdc57428'/>
<id>urn:sha1:41a5b913197c3a25fddef1735dc9b3d1fdc57428</id>
<content type='text'>
If jbd2_journal_restart() fails the handle will have been disconnected
from the current transaction.  In this situation, the handle must not
be used for for any jbd2 function other than jbd2_journal_stop().
Enforce this with by treating a handle which has a NULL transaction
pointer as an aborted handle, and issue a kernel warning if
jbd2_journal_extent(), jbd2_journal_get_write_access(),
jbd2_journal_dirty_metadata(), etc. is called with an invalid handle.

This commit also fixes a bug where jbd2_journal_stop() would trip over
a kernel jbd2 assertion check when trying to free an invalid handle.

Also move the responsibility of setting current-&gt;journal_info to
start_this_handle(), simplifying the three users of this function.

Signed-off-by: "Theodore Ts'o" &lt;tytso@mit.edu&gt;
Reported-by: Younger Liu &lt;younger.liu@huawei.com&gt;
Cc: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>jbd2: fix theoretical race in jbd2__journal_restart</title>
<updated>2013-07-01T12:12:40Z</updated>
<author>
<name>Theodore Ts'o</name>
</author>
<published>2013-07-01T12:12:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=39c04153fda8c32e85b51c96eb5511a326ad7609'/>
<id>urn:sha1:39c04153fda8c32e85b51c96eb5511a326ad7609</id>
<content type='text'>
Once we decrement transaction-&gt;t_updates, if this is the last handle
holding the transaction from closing, and once we release the
t_handle_lock spinlock, it's possible for the transaction to commit
and be released.  In practice with normal kernels, this probably won't
happen, since the commit happens in a separate kernel thread and it's
unlikely this could all happen within the space of a few CPU cycles.

On the other hand, with a real-time kernel, this could potentially
happen, so save the tid found in transaction-&gt;t_tid before we release
t_handle_lock.  It would require an insane configuration, such as one
where the jbd2 thread was set to a very high real-time priority,
perhaps because a high priority real-time thread is trying to read or
write to a file system.  But some people who use real-time kernels
have been known to do insane things, including controlling
laser-wielding industrial robots.  :-)

Signed-off-by: "Theodore Ts'o" &lt;tytso@mit.edu&gt;
Cc: stable@vger.kernel.org

</content>
</entry>
<entry>
<title>jbd2: optimize jbd2_journal_force_commit</title>
<updated>2013-06-13T02:24:07Z</updated>
<author>
<name>Dmitry Monakhov</name>
</author>
<published>2013-06-13T02:24:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9ff864462477206bc23b405a6ae506e92fb6dc9c'/>
<id>urn:sha1:9ff864462477206bc23b405a6ae506e92fb6dc9c</id>
<content type='text'>
Current implementation of jbd2_journal_force_commit() is suboptimal because
result in empty and useless commits. But callers just want to force and wait
any unfinished commits. We already have jbd2_journal_force_commit_nested()
which does exactly what we want, except we are guaranteed that we do not hold
journal transaction open.

Signed-off-by: Dmitry Monakhov &lt;dmonakhov@openvz.org&gt;
Signed-off-by: "Theodore Ts'o" &lt;tytso@mit.edu&gt;
</content>
</entry>
</feed>
