Re: Preallocation with direct IO?

Dave Chinner
2011-12-29T20:57:51Z

On Thu, Dec 29, 2011 at 01:10:49PM +0000, amit.sahrawat83@gmail.com wrote:
> Hi, I am using a test setup which is doing write using multiple
> threads using direct IO. The buffer size which is used to write is
> 512KB. After continously running this for long duration - i
> observe that number of extents in each file is getting
> huge(2K..4K..). I observed that each extent is of 512KB(aligned to
> write buffer size). I wish to have low number of extents(i.e,
> reduce fragmentation)... In case of buffered IO- preallocation
> works good alongwith the mount option 'allocsize'. Is there
> anything which can be done for Direct IO? Please advice for
> reducing fragmentation with direct IO.

Direct IO does not do any implicit preallocation. The filesystem
simply gets out of the way of direct IO as it is assumed you know
what you are doing.

i.e. you know how to use the fallocate() or ioctl(XFS_IOC_RESVSP64)
calls to preallocate space or to set up extent size hints to use
larger allocations than the IO being done during syscalls...

Cheers,

Dave.
--
Dave Chinner
david@fromorbit.com