xfs
[Top] [All Lists]

Re: preallocation

To: Ying-Hung Chen <ying@xxxxxxxxxxxxxx>
Subject: Re: preallocation
From: David Chinner <dgc@xxxxxxx>
Date: Thu, 29 Sep 2005 16:59:49 +1000
Cc: linux-xfs@xxxxxxxxxxx
In-reply-to: <433B8B8F.9010300@xxxxxxxxxxxxxx>
References: <4337ADB7.3060700@xxxxxxxxxxxxxx> <43381317.8040007@xxxxxxx> <433B8B8F.9010300@xxxxxxxxxxxxxx>
Sender: linux-xfs-bounce@xxxxxxxxxxx
User-agent: Mutt/1.4.1i
On Thu, Sep 29, 2005 at 02:37:03PM +0800, Ying-Hung Chen wrote:
> Hi, I just tried the preallocation method Eric provided:
> 
> after run the xfs_allocate code to allocate 52MB each (see
> xfs_preallocate.cpp)
> 
> [root@localhost hdb4]# xfs_bmap 00001.ivf
> 00001.ivf:
>         0: [0..106495]: 96..106591
> 
> [root@localhost hdb4]# du -sh 00001.ivf
> 52M     00001.ivf
> 
> and when I writing data in it (see recorder_simulator.cpp) bascially i
> am simulating 16 cocurrent streams (up to 50MB, so there are still space
> left)
> 
> I got heavy fragmentations (shown below)

> did I do anything wrong?

Yes:

> class RecorderSimulator : public ACE_Task_Base
> {
> public:
>       RecorderSimulator()//:cuException(NULL)
>       {
>               //sprintf(test_file,"05%d.ivf", getcount());
>       }
> 
>       int svc()
>       {
>               char data[WRITE_BLOCK];
>               while(1)
>               {
>                       sprintf(test_file,"%05d.ivf", getcount());
>                       
>                       cout << "Writing to file "<< test_file<<endl;
>                       FILE * f = fopen(test_file, "w+b");

What does "w" do when opening the file?

       w      Truncate  file to zero length or create text file for writing.
              The stream is positioned at the beginning of the file.

       w+     Open for reading and writing.  The file is created if it does
              not exist, otherwise it is  truncated.  The stream is positioned
              at the beginning of the file.
`

It truncates it. IOWS, it throws away the prealloc you did externally
to this program. You need to do the preallocation after the truncation
but before you start writing.

Cheers,

Dave.
-- 
Dave Chinner
R&D Software Enginner
SGI Australian Software Group


<Prev in Thread] Current Thread [Next in Thread>