Skip to content
  • Jan Kara's avatar
    ext3: Fix deadlock in data=journal mode when fs is frozen · 166418cc
    Jan Kara authored
    
    
    When ext3 is used in data=journal mode, syncing filesystem makes sure
    all the data is committed in the journal but the data doesn't have to be
    checkpointed. ext3_freeze() then takes care of checkpointing all the
    data so all buffer heads are clean but pages can still have dangling
    dirty bits. So when flusher thread comes later when filesystem is
    frozen, it tries to write back dirty pages, ext3_journalled_writepage()
    tries to start a transaction and hangs waiting for frozen fs causing a
    deadlock because a holder of s_umount semaphore may be waiting for
    flusher thread to complete.
    
    The fix is luckily relatively easy. We don't have to start a transaction
    in ext3_journalled_writepage() when a page is just dirty (and doesn't
    have PageChecked set) because in that case all buffers should be already
    mapped (mapping must happen before writing a buffer to the journal) and
    it is enough to write them out. This optimization also solves the deadlock
    because block_write_full_page() will just find out there's no buffer to
    write and do nothing.
    
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    166418cc