ext3: Fix deadlock in data=journal mode when fs is frozen
authorJan Kara <jack@suse.cz>
Wed, 21 May 2014 21:46:51 +0000 (23:46 +0200)
committerJan Kara <jack@suse.cz>
Thu, 22 May 2014 15:26:11 +0000 (17:26 +0200)
commit166418ccefc3cec0e8de54515af826687f036895
tree01a801811614e88c600632716746395ceac17b1f
parent22e7478ddbcb670e33fab72d0bbe7c394c3a2c84
ext3: Fix deadlock in data=journal mode when fs is frozen

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: Jan Kara <jack@suse.cz>
fs/ext3/inode.c