Patchwork jbd2: Always set journal superblock checksum when writing out superblock

login
register
mail settings
Submitter Darrick J. Wong
Date May 10, 2013, 11:40 p.m.
Message ID <20130510234013.GC5706@blackbox.djwong.org>
Download mbox | patch
Permalink /patch/243097/
State Superseded
Headers show

Comments

Darrick J. Wong - May 10, 2013, 11:40 p.m.
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.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/jbd2/journal.c |    2 ++
 1 file changed, 2 insertions(+)

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andreas Dilger - May 11, 2013, 4:56 a.m.
On 2013-05-10, at 17:40, "Darrick J. Wong" <darrick.wong@oracle.com> wrote:

> 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

> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/jbd2/journal.c |    2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index b6cdc57..a4c7678 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -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 majordomo@vger.kernel.org
> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Darrick J. Wong - May 13, 2013, 6:46 p.m.
On Fri, May 10, 2013 at 10:56:15PM -0600, Andreas Dilger wrote:
> On 2013-05-10, at 17:40, "Darrick J. Wong" <darrick.wong@oracle.com> wrote:
> 
> > 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
> 
> Cheers, Andreas
> 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > fs/jbd2/journal.c |    2 ++
> > 1 file changed, 2 insertions(+)
> > 
> > diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> > index b6cdc57..a4c7678 100644
> > --- a/fs/jbd2/journal.c
> > +++ b/fs/jbd2/journal.c
> > @@ -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 majordomo@vger.kernel.org
> > 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 majordomo@vger.kernel.org
> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index b6cdc57..a4c7678 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -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);