Skip to contentSkip to conversation

Fix commit block write in JBD

PATCH In review Jan Kara 3 participants 6 messages Jan 23, 2008 – Jan 28, 2008 Journalling layer for block devices (JBD2)

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 Fix commit block write in JBD

Hi,

the patch below fixes preparation of commit block in
journal_write_commit_record(). Obviously the bug doesn't really matter since nobody reported it so far but let's cleanup the code... Andrew, could you please queue it up? Thanks.

Honza

Signature · 8 lines
Jan Kara <[email protected]>
SUSE Labs, CR
---

Commit block is expected to have several copies of the header. Fix the
bug Andrew has spotted ages ago.

Signed-off-by: Jan Kara <[email protected]>
fs/jbd/commit.c +1 -2
index 610264b..a69b240 100644
@@ -116,9 +116,8 @@ static int journal_write_commit_record(journal_t *journal,
 
 	bh = jh2bh(descriptor);
 
-	/* AKPM: buglet - add `i' to tmp! */
 	for (i = 0; i < bh->b_size; i += 512) {
-		journal_header_t *tmp = (journal_header_t*)bh->b_data;
+		journal_header_t *tmp = (journal_header_t*)(bh->b_data+i);
 		tmp->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER);
 		tmp->h_blocktype = cpu_to_be32(JFS_COMMIT_BLOCK);
 		tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);
author
#1 lore raw

PATCH 1/1 Fix commit block write in JBD2

Quoted 6 lines · Jan Kara

Hi,

the patch below fixes preparation of commit block in
journal_write_commit_record(). Obviously the bug doesn't really matter since nobody reported it so far but let's cleanup the code... Andrew, could you please queue it up? Thanks.

And the same fix for JBD2.

Honza

Signature · 8 lines
Jan Kara <[email protected]>
SUSE Labs, CR
---

Commit block is expected to have several copies of the header. Fix the
bug Andrew has spotted ages ago.

Signed-off-by: Jan Kara <[email protected]>
fs/jbd2/commit.c +1 -2
index 6986f33..ed61283 100644
@@ -116,9 +116,8 @@ static int journal_write_commit_record(journal_t *journal,
 
 	bh = jh2bh(descriptor);
 
-	/* AKPM: buglet - add `i' to tmp! */
 	for (i = 0; i < bh->b_size; i += 512) {
-		journal_header_t *tmp = (journal_header_t*)bh->b_data;
+		journal_header_t *tmp = (journal_header_t*)(bh->b_data+i);
 		tmp->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER);
 		tmp->h_blocktype = cpu_to_be32(JBD2_COMMIT_BLOCK);
 		tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);
#2 lore raw

Re: [PATCH] Fix commit block write in JBD2

Hi,
The loop was removed in journal checksum patch. There had been a
discussion (11 Jul 2007: [EXT4 set 8][PATCH 1/1]Add journal checksums) about this part of code as checksum info was added to commit block.

Regards,
Girish

Quoted 10 lines · Jan Kara
Quoted 6 lines · Jan Kara

Hi,

the patch below fixes preparation of commit block in
journal_write_commit_record(). Obviously the bug doesn't really matter since nobody reported it so far but let's cleanup the code... Andrew, could you please queue it up? Thanks.

And the same fix for JBD2.

Honza

author
#3 lore raw

Re: [PATCH] Fix commit block write in JBD2

Hi,

Quoted 3 lines · Girish Shilamkar

The loop was removed in journal checksum patch. There had been a
discussion (11 Jul 2007: [EXT4 set 8][PATCH 1/1]Add journal checksums) about this part of code as checksum info was added to commit block.

Ah, OK, thanks for explanation. So for JBD2 we don't need the patch
anymore. But for JBD it's still needed.

Honza

Quoted 12 lines · Jan Kara
Quoted 10 lines · Jan Kara
Quoted 6 lines

Hi,

the patch below fixes preparation of commit block in
journal_write_commit_record(). Obviously the bug doesn't really matter since nobody reported it so far but let's cleanup the code... Andrew, could you please queue it up? Thanks.

And the same fix for JBD2.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#4 lore raw
In reply to Jan Kara
Quoted 5 lines · On Wed, 23 Jan 2008 20:09:43 +0100 Jan Kara <[email protected]> wrote:

Commit block is expected to have several copies of the header. Fix the bug Andrew has spotted ages ago.

"ages" indeed.

Quoted 6 lines
fs/jbd/commit.c +0 -0
index 610264b..a69b240 100644

fs/jbd/commit.c static int journal_write_commit_record(journal_t *journal, · line 123

Quoted 10 lines
fs/jbd/commit.c +1 -2
@@ -116,9 +116,8 @@ static int journal_write_commit_record(journal_t *journal,
 
 	bh = jh2bh(descriptor);
 
-	/* AKPM: buglet - add `i' to tmp! */
 	for (i = 0; i < bh->b_size; i += 512) {
-		journal_header_t *tmp = (journal_header_t*)bh->b_data;
+		journal_header_t *tmp = (journal_header_t*)(bh->b_data+i);
 		tmp->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER);
 		tmp->h_blocktype = cpu_to_be32(JFS_COMMIT_BLOCK);
 		tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);

But I don't think we can _use_ this feature now. Because there are 100000000000 disks out there which didn't implement it.

So why not just remove the loop and do a single write?

author
#5 lore raw
Quoted 17 lines · Andrew Morton
Quoted 5 lines · On Wed, 23 Jan 2008 20:09:43 +0100 Jan Kara <[email protected]> wrote:

Commit block is expected to have several copies of the header. Fix the bug Andrew has spotted ages ago.

"ages" indeed.

Quoted 9 lines
fs/jbd/commit.c +0 -0
index 610264b..a69b240 100644
@@ -116,9 +116,8 @@ static int journal_write_commit_record(journal_t *journal,
 
 	bh = jh2bh(descriptor);
 
Quoted 11 lines

fs/jbd/commit.c static int journal_write_commit_record(journal_t *journal, · line 123

Quoted 7 lines
fs/jbd/commit.c +1 -2
-	/* AKPM: buglet - add `i' to tmp! */
 	for (i = 0; i < bh->b_size; i += 512) {
-		journal_header_t *tmp = (journal_header_t*)bh->b_data;
+		journal_header_t *tmp = (journal_header_t*)(bh->b_data+i);
 		tmp->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER);
 		tmp->h_blocktype = cpu_to_be32(JFS_COMMIT_BLOCK);
 		tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);

But I don't think we can _use_ this feature now. Because there are 100000000000 disks out there which didn't implement it. So why not just remove the loop and do a single write?

Yes, but OTOH once the filesystem gets mounted with a new kernel, the
journal gets quickly rewritten and we'll have correct commit blocks there. But since neither kernel nor e2fsprogs actually check for further sectors (they check for the header just in the beginning of a block), I agree that removing the loop completely is probably the best option. Nobody cared so far so I guess they won't care in future as well. I'll send you a replacement patch.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR