public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: <stone_wang@sohu.com>
To: <linux-kernel@vger.kernel.org>
Cc: <akpm@osdl.org>
Subject: PATCH] Perhaps invalid goal for file block #1 in ext3(2)_find_goal
Date: Tue, 30 Nov 2004 20:40:23 +0800 (CST)	[thread overview]
Message-ID: <13462255.1101818423343.JavaMail.postfix@mx20.mail.sohu.com> (raw)


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

                 reply	other threads:[~2004-11-30 12:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13462255.1101818423343.JavaMail.postfix@mx20.mail.sohu.com \
    --to=stone_wang@sohu.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox