public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* PATCH] Perhaps invalid goal for file block #1 in ext3(2)_find_goal
@ 2004-11-30 12:40 stone_wang
  0 siblings, 0 replies; only message in thread
From: stone_wang @ 2004-11-30 12:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm


Hi:

I am learning how Ext2/3 works and how we could better use it for our servers.

In the process,i found something strange in ext3_find_goal:
when we create a file,write initial 4k bytes to it,then we reboot the system,and after that,we again append another 4k bytes to the file,thus the file becomes 8k bytes now;but under this condition,the file will be in 2 chunks,not continous.

I did simple tests(i reboot the system to make sure that the inode cache get outdated between the 2 write/append operations,and i am sure that under some VM pressure result will be the same--ext3_read_inode clear ei->i_next_alloc_block to zero):

#dd if=/dev/zero of=/root/4kfile bs=1024 count=4
#cp /root/4kfile tmpfile
# ll tmpfile 
-rw-r--r--  1 root root 4096 Dec 17 13:05 tmpfile
# filefrag tmpfile 
tmpfile: 1 extent found
------THEN I REBOOT THE LINUX SYSTEM----
#cat /root/4kfile >>tmpfile
# ll tmpfile 
-rw-r--r--  1 root root 8192 Dec 17 13:14 tmpfile
# filefrag tmpfile 
tmpfile: 2 extents found, perfection would be 1 extent

debugfs shows that there are free blocks just next to the block#0 of tmpfile.

Generally,continous creating/appending(without rebooting the system or VM pressure)a file get 1 extent.

Here are my simple patch for kernel 2.6.9,it works for me.

---2.6.9/fs/ext3/inode.c    2004-12-17 
+++2.6.9-ext3-find-goal-fixed/fs/ext3/inode.c     2004-12-17 
@@ -525,7 +525,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!=0)) {
                ei->i_next_alloc_block++;
                ei->i_next_alloc_goal++;
        }

Regards.

Peter Wang
2004.11.29

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-30 12:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-30 12:40 PATCH] Perhaps invalid goal for file block #1 in ext3(2)_find_goal stone_wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox