Skip to contentSkip to conversation

ext3_find_goal

PATCH In review [email protected] 2 participants 2 messages Jan 22, 2005 ext2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext3_find_goal

We found strange blocks layout in our mail server, after careful study, we got the reason and tried to fix it.

When loading an inode from buffer/disk(ext2/3_read_inode),then allocating the second block(block==1) of the corresponding file: i_next_alloc_block and i_next_alloc_goal are both zero,and in fact are not valid, but they(i_next_alloc_block/goal) take effect in the former codes. This causes non-contiguous file.

Below patch add a check,and fixes this.

Stone Wang.
2005.01.23

fs/ext2/inode.c +1 -1
diff -urN linux-2.6.10-rc2/fs/ext2/inode.c linux-2.6.10-rc2-fixed/fs/ext2/inode.c
@@ -354,7 +354,7 @@
 {
 	struct ext2_inode_info *ei = EXT2_I(inode);
 	write_lock(&ei->i_meta_lock);
-	if (block == ei->i_next_alloc_block + 1) {
+	if ((block == ei->i_next_alloc_block + 1)&& ei->i_next_alloc_goal) {
 		ei->i_next_alloc_block++;
 		ei->i_next_alloc_goal++;
 	} 
fs/ext3/inode.c +1 -1
diff -urN linux-2.6.10-rc2/fs/ext3/inode.c linux-2.6.10-rc2-fixed/fs/ext3/inode.c
@@ -464,7 +464,7 @@
 {
 	struct ext3_inode_info *ei = EXT3_I(inode);
 	/* Writer: ->i_next_alloc* */
-	if (block == ei->i_next_alloc_block + 1) {
+	if ((block == ei->i_next_alloc_block + 1)&& ei->i_next_alloc_goal) {
 		ei->i_next_alloc_block++;
 		ei->i_next_alloc_goal++;
 	}
#1 lore raw
Quoted 8 lines · [email protected] wrote:

We found strange blocks layout in our mail server, after careful study, we got the reason and tried to fix it.

When loading an inode from buffer/disk(ext2/3_read_inode),then allocating the second block(block==1) of the corresponding file: i_next_alloc_block and i_next_alloc_goal are both zero,and in fact are not valid, but they(i_next_alloc_block/goal) take effect in the former codes. This causes non-contiguous file.

Below patch add a check,and fixes this.

Good catch!