aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/commit.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2012-03-13 22:22:54 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-03-13 22:22:54 -0400
commit79feb521a44705262d15cc819a4117a447b11ea7 (patch)
treea4de6ed084b7a68c0885049d94841ce8334b64a7 /fs/jbd2/commit.c
parenta78bb11d7acd525623c6a0c2ff4e213d527573fa (diff)
jbd2: issue cache flush after checkpointing even with internal journal
When we reach jbd2_cleanup_journal_tail(), there is no guarantee that checkpointed buffers are on a stable storage - especially if buffers were written out by jbd2_log_do_checkpoint(), they are likely to be only in disk's caches. Thus when we update journal superblock effectively removing old transaction from journal, this write of superblock can get to stable storage before those checkpointed buffers which can result in filesystem corruption after a crash. Thus we must unconditionally issue a cache flush before we update journal superblock in these cases. A similar problem can also occur if journal superblock is written only in disk's caches, other transaction starts reusing space of the transaction cleaned from the log and power failure happens. Subsequent journal replay would still try to replay the old transaction but some of it's blocks may be already overwritten by the new transaction. For this reason we must use WRITE_FUA when updating log tail and we must first write new log tail to disk and update in-memory information only after that. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2/commit.c')
-rw-r--r--fs/jbd2/commit.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 6705717d9b7f..b89ef84786a7 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -341,7 +341,16 @@ void jbd2_journal_commit_transaction(journal_t *journal)
341 if (journal->j_flags & JBD2_FLUSHED) { 341 if (journal->j_flags & JBD2_FLUSHED) {
342 jbd_debug(3, "super block updated\n"); 342 jbd_debug(3, "super block updated\n");
343 mutex_lock(&journal->j_checkpoint_mutex); 343 mutex_lock(&journal->j_checkpoint_mutex);
344 jbd2_journal_update_sb_log_tail(journal); 344 /*
345 * We hold j_checkpoint_mutex so tail cannot change under us.
346 * We don't need any special data guarantees for writing sb
347 * since journal is empty and it is ok for write to be
348 * flushed only with transaction commit.
349 */
350 jbd2_journal_update_sb_log_tail(journal,
351 journal->j_tail_sequence,
352 journal->j_tail,
353 WRITE_SYNC);
345 mutex_unlock(&journal->j_checkpoint_mutex); 354 mutex_unlock(&journal->j_checkpoint_mutex);
346 } else { 355 } else {
347 jbd_debug(3, "superblock not updated\n"); 356 jbd_debug(3, "superblock not updated\n");