• Hisashi Hifumi's avatar
    VFS: fix dio write returning EIO when try_to_release_page fails · 6ccfa806
    Hisashi Hifumi authored
    Dio write returns EIO when try_to_release_page fails because bh is
    still referenced.
    
    The patch
    
        commit 3f31fddf
        Author: Mingming Cao <cmm@us.ibm.com>
        Date:   Fri Jul 25 01:46:22 2008 -0700
    
            jbd: fix race between free buffer and commit transaction
    
    was merged into 2.6.27-rc1, but I noticed that this patch is not enough
    to fix the race.
    
    I did fsstress test heavily to 2.6.27-rc1, and found that dio write still
    sometimes got EIO through this test.
    
    The patch above fixed race between freeing buffer(dio) and committing
    transaction(jbd) but I discovered that there is another race, freeing
    buffer(dio) and ext3/4_ordered_writepage.
    
    : background_writeout()
         ->write_cache_pages()
           ->ext3_ordered_writepage()
         	   walk_page_buffers() -> take a bh ref
     	   block_write_full_page() -> unlock_page
    		: <- end_page_writeback
                    : <- race! (dio write->try_to_release_page fails)
       ...
    6ccfa806
truncate.c 12.9 KB