xfs
[Top] [All Lists]

Re: [PATCH 04/27] xfs: don't use speculative prealloc for small files

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH 04/27] xfs: don't use speculative prealloc for small files
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Wed, 12 Jun 2013 12:10:00 -0400
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1371032567-21772-5-git-send-email-david@xxxxxxxxxxxxx>
References: <1371032567-21772-1-git-send-email-david@xxxxxxxxxxxxx> <1371032567-21772-5-git-send-email-david@xxxxxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6
On 06/12/2013 06:22 AM, Dave Chinner wrote:
> From: Dave Chinner <dchinner@xxxxxxxxxx>
> 
...
> ---
>  fs/xfs/xfs_iomap.c |   13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 8f8aaee..14be676 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -284,6 +284,15 @@ xfs_iomap_eof_want_preallocate(
>               return 0;
>  
>       /*
> +      * If the file is smaller than the minimum prealloc and we are using
> +      * dynamic preallocation, don't do any preallocation at all as it is
> +      * likely this is the only write to the file that is going to be done.
> +      */
> +     if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) &&
> +         XFS_ISIZE(ip) < mp->m_writeio_blocks)
> +             return 0;
> +

I stuck this on a box, got a 64k prealloc on an 8k file and then noticed
this was comparing inode size against a block count. This should
probably be:

        XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_writeio_blocks)

Given that, we avoid preallocs entirely until the file size reaches the
minimum write size (assuming dynamic prealloc mode).

> +     /*
>        * If there are any real blocks past eof, then don't
>        * do any speculative allocation.
>        */
> @@ -345,6 +354,10 @@ xfs_iomap_eof_prealloc_initial_size(
>       if (mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)
>               return 0;
>  
> +     /* If the file is small, then use the minimum prealloc */
> +     if (XFS_ISIZE(ip) < mp->m_dalign)
> +             return 0;
> +
...

... and the same fsb->b conversion applies here.

If the file is larger than the minimum write size but smaller than the
stripe unit, we prealloc by the minimum prealloc size (m_writeio_blocks)
until the file grows beyond the stripe unit. That means if the stripe
unit is smaller than m_writeio_blocks or not specified, we'd just start
right into the dynamic prealloc algorithm. Seems reasonable.

Brian

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