xfs
[Top] [All Lists]

Re: [PATCH 2/2] xfs: only set extent size hint when asked

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH 2/2] xfs: only set extent size hint when asked
From: Iustin Pop <iusty@xxxxxxxxx>
Date: Tue, 30 Sep 2014 07:58:29 +0200
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1412041565-18873-3-git-send-email-david@xxxxxxxxxxxxx>
Mail-followup-to: Dave Chinner <david@xxxxxxxxxxxxx>, xfs@xxxxxxxxxxx
References: <1412041565-18873-1-git-send-email-david@xxxxxxxxxxxxx> <1412041565-18873-3-git-send-email-david@xxxxxxxxxxxxx>
User-agent: Mutt/1.5.23 (2014-03-12)
On Tue, Sep 30, 2014 at 11:46:05AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@xxxxxxxxxx>
> 
> Currently the extent size hint is set unconditionally in
> xfs_ioctl_setattr(), even when the FSX_EXTSIZE flag is not set. This
> means we can set values from uninitialised stack variables. Hence
> only set the extent size hint from userspace when both the mask
> falg is set and the inode has the XFS_DIFLAG_EXTSIZE flag set to
> indicate that we should have an extent size hint set on the inode.
> 
> Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
> ---
>  fs/xfs/xfs_ioctl.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 87c3bd1..24c926b 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1231,13 +1231,25 @@ xfs_ioctl_setattr(
>  
>       }
>  
> -     if (mask & FSX_EXTSIZE)
> -             ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
>       if (mask & FSX_XFLAGS) {
>               xfs_set_diflags(ip, fa->fsx_xflags);
>               xfs_diflags_to_linux(ip);
>       }
>  
> +     /*
> +      * Only set the extent size hint if we've already determined that the
> +      * extent size hint should be set on the inode. If no extent size flags
> +      * are set on the inode then unconditionally clear the extent size hint.
> +      */
> +     if (mask & FSX_EXTSIZE) {
> +             int     extsize = 0;
> +
> +             if (ip->i_d.di_flags &
> +                             (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
> +                     extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
> +             ip->i_d.di_extsize = extsize;

Quick question: this sounds sane, but it will have the following effect
(if I understand things correctly): updating other flags on the inode
(e.g. XFS_XFLAG_NOATIME) might change the recorded extent size. True, it
will correct the size if not appropriate and it will have a noop impact,
but still it will be an unrelated inode change. Would it make sense to
document this in the xfsctl man page then?

thanks,
iustin

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