Thread (1 message) 1 message, 1 author, 2015-07-23

Re: [PATCH] ext4, jbd2: add REQ_FUA flag when recording an error flag

From: Theodore Ts'o <tytso@mit.edu>
Date: 2015-07-23 13:48:06
Subsystem: ext4 file system, filesystems (vfs and infrastructure), journalling layer for block devices (jbd2), the rest · Maintainers: "Theodore Ts'o", Alexander Viro, Christian Brauner, Jan Kara, Linus Torvalds

Possibly related (same subject, not in this thread)

quoted hunk
@@ -4638,7 +4639,10 @@ static int ext4_commit_super(struct super_block *sb,
int sync)
  ext4_superblock_csum_set(sb);
  mark_buffer_dirty(sbh);
  if (sync) {
-  error = sync_dirty_buffer(sbh);
+  if (journal->j_flags & JBD2_BARRIER)
+   error = __sync_dirty_buffer(sbh, WRITE_FUA);
+  else
+   error = sync_dirty_buffer(sbh);
   if (error)
    return error;
The problem with this is that the journal structure will not be
present in no-journal mode, so it will result in a NULL dereference.
So I've changed this to use test_opt(sb, BARRIER) instead.

   		     	    		 	  - Ted
						  
commit 564bc402526e437729ecafe3c3511f7cab9f0327
Author: Daeho Jeong [off-list ref]
Date:   Thu Jul 23 09:46:11 2015 -0400

    ext4, jbd2: add REQ_FUA flag when recording an error in the superblock
    
    When an error condition is detected, an error status should be recorded into
    superblocks of EXT4 or JBD2. However, the write request is submitted now
    without REQ_FUA flag, even in "barrier=1" mode, which is followed by
    panic() function in "errors=panic" mode. On mobile devices which make
    whole system reset as soon as kernel panic occurs, this write request
    containing an error flag will disappear just from storage cache without
    written to the physical cells. Therefore, when next start, even forever,
    the error flag cannot be shown in both superblocks, and e2fsck cannot fix
    the filesystem problems automatically, unless e2fsck is executed in
    force checking mode.
    
    [ Changed use test_opt(sb, BARRIER) of checking the journal flags -- TYT ]
    
    Signed-off-by: Daeho Jeong [off-list ref]
    Signed-off-by: Theodore Ts'o [off-list ref]
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 14909cd..a51db9c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4667,7 +4667,8 @@ static int ext4_commit_super(struct super_block *sb, int sync)
 	ext4_superblock_csum_set(sb);
 	mark_buffer_dirty(sbh);
 	if (sync) {
-		error = sync_dirty_buffer(sbh);
+		error = __sync_dirty_buffer(sbh,
+			test_opt(sb, BARRIER) ? WRITE_FUA : WRITE_SYNC);
 		if (error)
 			return error;
 
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 4ff3fad..fe1b4bd 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1456,7 +1456,7 @@ void jbd2_journal_update_sb_errno(journal_t *journal)
 	sb->s_errno    = cpu_to_be32(journal->j_errno);
 	read_unlock(&journal->j_state_lock);
 
-	jbd2_write_superblock(journal, WRITE_SYNC);
+	jbd2_write_superblock(journal, WRITE_FUA);
 }
 EXPORT_SYMBOL(jbd2_journal_update_sb_errno);
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help