lkml.org 
[lkml]   [2004]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectPATCH] Perhaps invalid goal for file block #1 in ext3(2)_find_goal

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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.056 / U:3.696 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site