• Mingming Cao's avatar
    jbd: fix race between free buffer and commit transaction · 3f31fddf
    Mingming Cao authored
    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_WAIT and __GFP_FS 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.
    
    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: default avatarMingming Cao <cmm@us.ibm.com>
    Reviewed-by: default avatarBadari Pulavarty <pbadari@us.ibm.com>
    Acked-by: default avatarJan Kara <jack@suse.cz>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    3f31fddf
filemap.c 68.2 KB