linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] jbd2: Always set journal superblock checksum when writing out superblock
@ 2013-05-10 23:40 Darrick J. Wong
  2013-05-11  4:56 ` Andreas Dilger
  0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2013-05-10 23:40 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-kernel, linux-ext4, linux-fsdevel

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(+)

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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] jbd2: Always set journal superblock checksum when writing out superblock
  2013-05-10 23:40 [PATCH] jbd2: Always set journal superblock checksum when writing out superblock Darrick J. Wong
@ 2013-05-11  4:56 ` Andreas Dilger
  2013-05-13 18:46   ` Darrick J. Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Dilger @ 2013-05-11  4:56 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Theodore Ts'o, linux-ext4, linux-fsdevel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] jbd2: Always set journal superblock checksum when writing out superblock
  2013-05-11  4:56 ` Andreas Dilger
@ 2013-05-13 18:46   ` Darrick J. Wong
  2013-05-13 21:49     ` [PATCH v2] " Darrick J. Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2013-05-13 18:46 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: Theodore Ts'o, linux-ext4, linux-fsdevel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] jbd2: Always set journal superblock checksum when writing out superblock
  2013-05-13 18:46   ` Darrick J. Wong
@ 2013-05-13 21:49     ` Darrick J. Wong
  0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2013-05-13 21:49 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Andreas Dilger, linux-ext4, linux-fsdevel

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.

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

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-05-13 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-10 23:40 [PATCH] jbd2: Always set journal superblock checksum when writing out superblock Darrick J. Wong
2013-05-11  4:56 ` Andreas Dilger
2013-05-13 18:46   ` Darrick J. Wong
2013-05-13 21:49     ` [PATCH v2] " Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).