Skip to contentSkip to conversation

libext2fs: don't swap extent-based journal backup on read

PATCH Applied Eric Sandeen 3 participants 3 messages Nov 10, 2009 – Nov 13, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libext2fs: don't swap extent-based journal backup on read

The f_illitable_flexbg test was failing on ppc, because e2fsck_move_ext3_journal is doing a direct memcmp of i_block with s_jnl_blocks, and failing.

This is because we don't swap extent data on read from disk; rather we do it when we access the extents. However, ext2fs_swap_super was swapping s_jnl_blocks unconditionally, so these didn't match.

Looks like we need to treat s_jnl_blocks the same as i_block, and swap it on access, not on read. Except for the last i_size bit...

---

lib/ext2fs/swapfs.c +11 -0
index 42bc01e..38f5f9b 100644
@@ -73,9 +73,19 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
 	sb->s_kbytes_written = ext2fs_swab64(sb->s_kbytes_written);
 	for (i=0; i < 4; i++)
 		sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);
+
+	/* if journal backup is for a valid extent-based journal... */
+	if (!ext2fs_extent_header_verify(sb->s_jnl_blocks,
+					 sizeof(sb->s_jnl_blocks))) {
+		/* ... swap only the journal i_size */
+		sb->s_jnl_blocks[16] = ext2fs_swab32(sb->s_jnl_blocks[16]);
+		/* and the extent data is not swapped on read */
+		return;
+	}
+
+	/* direct/indirect journal: swap it all */
 	for (i=0; i < 17; i++)
 		sb->s_jnl_blocks[i] = ext2fs_swab32(sb->s_jnl_blocks[i]);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Eric Sandeen

The f_illitable_flexbg test was failing on ppc, because e2fsck_move_ext3_journal is doing a direct memcmp of i_block with s_jnl_blocks, and failing.

Quoted 8 lines

This is because we don't swap extent data on read from disk; rather we do it when we access the extents. However, ext2fs_swap_super was swapping s_jnl_blocks unconditionally, so these didn't match.

Looks like we need to treat s_jnl_blocks the same as i_block, and swap it on access, not on read. Except for the last i_size bit...

Makes sense:

Quoted 14 lines

---

lib/ext2fs/swapfs.c +3 -0
index 42bc01e..38f5f9b 100644
@@ -73,9 +73,19 @@ void ext2fs_swap_super(struct ext2_super_block *  
 sb)
 	sb->s_kbytes_written = ext2fs_swab64(sb->s_kbytes_written);
 	for (i=0; i < 4; i++)
 		sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);
+
+	/* if journal backup is for a valid extent-based journal... */
+	if (!ext2fs_extent_header_verify(sb->s_jnl_blocks,

lib/ext2fs/swapfs.c void ext2fs_swap_super(struct ext2_super_block * · line 89

Quoted 10 lines
lib/ext2fs/swapfs.c +8 -0
+					 sizeof(sb->s_jnl_blocks))) {
+		/* ... swap only the journal i_size */
+		sb->s_jnl_blocks[16] = ext2fs_swab32(sb->s_jnl_blocks[16]);
+		/* and the extent data is not swapped on read */
+		return;
+	}
+
+	/* direct/indirect journal: swap it all */
 	for (i=0; i < 17; i++)
 		sb->s_jnl_blocks[i] = ext2fs_swab32(sb->s_jnl_blocks[i]);

I wouldn't object to fixing the formatting above to "for (i = 0; ...)"

Quoted 9 lines
lib/ext2fs/swapfs.c +0 -0
 }
 

void ext2fs_swap_group_desc(struct ext2_group_desc *gdp)

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

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

Applied
#2 lore raw
In reply to Eric Sandeen
Quoted 4 lines · Eric Sandeen

The f_illitable_flexbg test was failing on ppc, because e2fsck_move_ext3_journal is doing a direct memcmp of i_block with s_jnl_blocks, and failing.

Quoted 8 lines

This is because we don't swap extent data on read from disk; rather we do it when we access the extents. However, ext2fs_swap_super was swapping s_jnl_blocks unconditionally, so these didn't match.

Looks like we need to treat s_jnl_blocks the same as i_block, and swap it on access, not on read. Except for the last i_size bit...

Applied to the maint branch, thanks.

- Ted