]> git.karo-electronics.de Git - karo-tx-linux.git/commit
jbd: fix fsync() tid wraparound bug
authorTed Ts'o <tytso@mit.edu>
Sat, 30 Apr 2011 17:17:11 +0000 (13:17 -0400)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Thu, 17 May 2012 15:20:28 +0000 (11:20 -0400)
commitbc4e172f975f34f77998b4bfc6bf4e864eea00e4
treeaf7f9456dd76ea2d450f610a20e17ef56e7f125d
parentc019be4b3fb7e9681be89ee18243049abf50859b
jbd: fix fsync() tid wraparound bug

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: Paul Gortmaker <paul.gortmaker@windriver.com>
fs/jbd/journal.c