Skip to contentSkip to conversation

jbd2: Always set journal superblock checksum when writing out superblock

PATCH Superseded Darrick J. Wong 2 participants 4 messages May 10, 2013 – May 13, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jbd2: Always set journal superblock checksum when writing out superblock

Add a few missing calls to jbd2_superblock_csum_set just prior to calling jbd2_write_superblock. This fixes complaints about corrupt journals if metadata checksumming and journal checksumming are both enabled.

---
 fs/jbd2/journal.c |    2 ++
 1 file changed, 2 insertions(+)
fs/jbd2/journal.c +2 -0
index b6cdc57..a4c7678 100644
@@ -1348,6 +1348,7 @@ void jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
 
 	sb->s_sequence = cpu_to_be32(tail_tid);
 	sb->s_start    = cpu_to_be32(tail_block);
+	jbd2_superblock_csum_set(journal, sb);
 
 	jbd2_write_superblock(journal, write_op);
 
@@ -1381,6 +1382,7 @@ static void jbd2_mark_journal_empty(journal_t *journal)
 
 	sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
 	sb->s_start    = cpu_to_be32(0);
+	jbd2_superblock_csum_set(journal, sb);
 	read_unlock(&journal->j_state_lock);
 
 	jbd2_write_superblock(journal, WRITE_FUA);
#1 lore raw
Quoted 3 lines · Darrick J. Wong

Add a few missing calls to jbd2_superblock_csum_set just prior to calling jbd2_write_superblock. This fixes complaints about corrupt journals if metadata checksumming and journal checksumming are both enabled.

Why not just put this call inside jbd2_write_superblock()?

Cheers, Andreas

Quoted 29 lines

---
fs/jbd2/journal.c | 2 ++

1 file changed, 2 insertions(+)
fs/jbd2/journal.c +2 -1
index b6cdc57..a4c7678 100644
@@ -1348,6 +1348,7 @@ void jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
 
   sb->s_sequence = cpu_to_be32(tail_tid);
   sb->s_start    = cpu_to_be32(tail_block);
+    jbd2_superblock_csum_set(journal, sb);
 
   jbd2_write_superblock(journal, write_op);
 
@@ -1381,6 +1382,7 @@ static void jbd2_mark_journal_empty(journal_t *journal)
 
   sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
   sb->s_start    = cpu_to_be32(0);
+    jbd2_superblock_csum_set(journal, sb);
   read_unlock(&journal->j_state_lock);
 
   jbd2_write_superblock(journal, WRITE_FUA);
--

To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 7 lines · Andreas Dilger
Quoted 3 lines · Darrick J. Wong

Add a few missing calls to jbd2_superblock_csum_set just prior to calling jbd2_write_superblock. This fixes complaints about corrupt journals if metadata checksumming and journal checksumming are both enabled.

Why not just put this call inside jbd2_write_superblock()?

You're right, I was confused and thought j_state_lock also protected the sb. It doesn't, so we can avoid future programming errors by moving it. I'll fix the patch (and go see what mysteries 3.10 provides).

--D

Quoted 36 lines

Cheers, Andreas

Quoted 26 lines

---
fs/jbd2/journal.c | 2 ++

1 file changed, 2 insertions(+)
fs/jbd2/journal.c +2 -1
index b6cdc57..a4c7678 100644
@@ -1348,6 +1348,7 @@ void jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
 
   sb->s_sequence = cpu_to_be32(tail_tid);
   sb->s_start    = cpu_to_be32(tail_block);
+    jbd2_superblock_csum_set(journal, sb);
 
   jbd2_write_superblock(journal, write_op);
 
@@ -1381,6 +1382,7 @@ static void jbd2_mark_journal_empty(journal_t *journal)
 
   sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
   sb->s_start    = cpu_to_be32(0);
+    jbd2_superblock_csum_set(journal, sb);
   read_unlock(&journal->j_state_lock);
 
   jbd2_write_superblock(journal, WRITE_FUA);
--
Quoted 3 lines

To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH v2 1/1 jbd2: Always set journal superblock checksum when writing out superblock

Avoid future programming errors by making it so that the journal superblock checksum is set in jbd2_write_superblock. This fixes some journal checksum failures when metadata_csum is turned on.

---
 fs/jbd2/journal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jbd2/journal.c +1 -1
index 4576bec..85550bf 100644
@@ -1325,6 +1325,7 @@ static void jbd2_write_superblock(journal_t *journal, int write_op)
 	if (!(journal->j_flags & JBD2_BARRIER))
 		write_op &= ~(REQ_FUA | REQ_FLUSH);
 	lock_buffer(bh);
+	jbd2_superblock_csum_set(journal, journal->j_superblock);
 	if (buffer_write_io_error(bh)) {
 		/*
 		 * Oh, dear.  A previous attempt to write the journal
@@ -1436,7 +1437,6 @@ void jbd2_journal_update_sb_errno(journal_t *journal)
 	jbd_debug(1, "JBD2: updating superblock error (errno %d)\n",
 		  journal->j_errno);
 	sb->s_errno    = cpu_to_be32(journal->j_errno);
-	jbd2_superblock_csum_set(journal, sb);
 	read_unlock(&journal->j_state_lock);
 
 	jbd2_write_superblock(journal, WRITE_SYNC);