jbd2: fix race between jbd2_journal_try_to_free_buffers() and jbd2 commit transaction
authorMingming Cao <cmm@us.ibm.com>
Mon, 14 Jul 2008 01:06:39 +0000 (21:06 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 14 Jul 2008 01:06:39 +0000 (21:06 -0400)
commit530576bbf379fc45cfb34f246257d8526db44567
treed4a89bf6f2736816e1b43abfdafcf2d61bbd19ef
parent772cb7c83ba256a11c7bf99a11bef3858d23767c
jbd2: fix race between jbd2_journal_try_to_free_buffers() and jbd2 commit transaction

journal_try_to_free_buffers() could race with jbd commit transaction
when the later is holding the buffer reference while waiting for the
data buffer to flush to disk. If the caller of
journal_try_to_free_buffers() request tries hard to release the buffers,
it will treat the failure as error and return back to the caller. We
have seen the directo IO failed due to this race.  Some of the caller of
releasepage() also expecting the buffer to be dropped when passed with
GFP_KERNEL mask to the releasepage()->journal_try_to_free_buffers().

With this patch, if the caller is passing the GFP_KERNEL to indicating
this call could wait, in case of try_to_free_buffers() failed, let's
waiting for journal_commit_transaction() to finish commit the current
committing transaction , then try to free those buffers again with
journal locked.

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Reviewed-by: Badari Pulavarty <pbadari@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/jbd2/transaction.c