jbd: fix fsync() tid wraparound bug
authorTed Ts'o <tytso@mit.edu>
Sat, 30 Apr 2011 17:17:11 +0000 (13:17 -0400)
committerSteve Conklin <sconklin@canonical.com>
Fri, 15 Jul 2011 17:20:54 +0000 (12:20 -0500)
commitfe9642e86ec861ed77f631609abc749d1209d23f
treea14a42dd649fe23fa33e98caae348b0d25b3f8c8
parentba12d84a956ff4dd6dc5077b3d1a14b143d6f060
jbd: fix fsync() tid wraparound bug

BugLink: http://bugs.launchpad.net/bugs/793702

commit d9b01934d56a96d9f4ae2d6204d4ea78a36f5f36 upstream.

If an application program does not make any changes to the indirect
blocks or extent tree, i_datasync_tid will not get updated.  If there
are enough commits (i.e., 2**31) such that tid_geq()'s calculations
wrap, and there isn't a currently active transaction at the time of
the fdatasync() call, this can end up triggering a BUG_ON in
fs/jbd/commit.c:

J_ASSERT(journal->j_running_transaction != NULL);

It's pretty rare that this can happen, since it requires the use of
fdatasync() plus *very* frequent and excessive use of fsync().  But
with the right workload, it can.

We fix this by replacing the use of tid_geq() with an equality test,
since there's only one valid transaction id that is valid for us to
start: namely, the currently running transaction (if it exists).

Reported-by: Martin_Zielinski@McAfee.com
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
fs/jbd/journal.c