xfs
[Top] [All Lists]

Re: [PATCH 02/11] xfs: cleanup xfs_iomap_eof_align_last_fsb

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH 02/11] xfs: cleanup xfs_iomap_eof_align_last_fsb
From: Ben Myers <bpm@xxxxxxx>
Date: Wed, 4 Jan 2012 14:32:32 -0600
Cc: xfs@xxxxxxxxxxx
In-reply-to: <20111218200130.970786897@xxxxxxxxxxxxxxxxxxxxxx>
References: <20111218200003.557507716@xxxxxxxxxxxxxxxxxxxxxx> <20111218200130.970786897@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.18 (2008-05-17)
On Sun, Dec 18, 2011 at 03:00:05PM -0500, Christoph Hellwig wrote:
> Replace the nasty if, else if, elseif condition with more natural C flow
> that expressed the logic we want here better.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
> 
> ---
>  fs/xfs/xfs_iomap.c |   36 ++++++++++++++++++------------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> Index: xfs/fs/xfs/xfs_iomap.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_iomap.c       2011-11-17 12:07:52.580802800 +0100
> +++ xfs/fs/xfs/xfs_iomap.c    2011-11-30 10:57:35.649224495 +0100
> @@ -57,26 +57,26 @@ xfs_iomap_eof_align_last_fsb(
>       xfs_fileoff_t   *last_fsb)
>  {
>       xfs_fileoff_t   new_last_fsb = 0;
> -     xfs_extlen_t    align;
> +     xfs_extlen_t    align = 0;
>       int             eof, error;
>  
> -     if (XFS_IS_REALTIME_INODE(ip))
> -             ;
> -     /*
> -      * If mounted with the "-o swalloc" option, roundup the allocation
> -      * request to a stripe width boundary if the file size is >=
> -      * stripe width and we are allocating past the allocation eof.
> -      */
> -     else if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC) &&
> -             (ip->i_size >= XFS_FSB_TO_B(mp, mp->m_swidth)))
> -             new_last_fsb = roundup_64(*last_fsb, mp->m_swidth);
> -     /*
> -      * Roundup the allocation request to a stripe unit (m_dalign) boundary
> -      * if the file size is >= stripe unit size, and we are allocating past
> -      * the allocation eof.
> -      */
> -     else if (mp->m_dalign && (ip->i_size >= XFS_FSB_TO_B(mp, mp->m_dalign)))
> -             new_last_fsb = roundup_64(*last_fsb, mp->m_dalign);
> +     if (!XFS_IS_REALTIME_INODE(ip)) {
> +             /*
> +              * Round up the allocation request to a stripe unit
> +              * (m_dalign) boundary if the file size is >= stripe unit
> +              * size, and we are allocating past the allocation eof.
> +              *
> +              * If mounted with the "-o swalloc" option the alignment is
> +              * increased from the strip unit size to the stripe width.
> +              */
> +             if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))
> +                     align = mp->m_swidth;
> +             else if (mp->m_dalign)
> +                     align = mp->m_dalign;
> +
> +             if (align && ip->i_size >= XFS_FSB_TO_B(mp, align))
> +                     new_last_fsb = roundup_64(*last_fsb, align);
> +     }

The behavior looks equivalent and this is much easier on the eyes.
Looks good.

Reviewed-by: Ben Myers <bpm@xxxxxxx>

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [PATCH 02/11] xfs: cleanup xfs_iomap_eof_align_last_fsb, Ben Myers <=