xfs
[Top] [All Lists]

Re: [PATCH 1/2 V2] xfsprogs: try to handle mkfs of a file on 4k sector d

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: [PATCH 1/2 V2] xfsprogs: try to handle mkfs of a file on 4k sector device
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Fri, 6 Jun 2014 11:20:46 -0400
Cc: Eric Sandeen <sandeen@xxxxxxxxxx>, xfs-oss <xfs@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <5390C13E.6030205@xxxxxxxxxxx>
References: <53852A05.5040006@xxxxxxxxxx> <5390C13E.6030205@xxxxxxxxxxx>
User-agent: Mutt/1.5.23 (2014-03-12)
On Thu, Jun 05, 2014 at 02:13:02PM -0500, Eric Sandeen wrote:
> Try the xfs geometry ioctl if the mkfs target resides
> in a file; this gives us the equivalent of a device
> sector size.
> 
> If this fails, and there's a sector size mismatch
> between the host FS and the filesystem, then mkfs might
> fail - but that's no worse than it's been before.
> 
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> ---

Looks Ok...

Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>

> 
> V2: remove warning when FSGEOMETRY fails (i.e. on non-xfs
> filesystems) for now
> 
> diff --git a/libxfs/linux.c b/libxfs/linux.c
> index 2e07d54..3796fdd 100644
> --- a/libxfs/linux.c
> +++ b/libxfs/linux.c
> @@ -141,10 +141,20 @@ platform_findsizes(char *path, int fd, long long *sz, 
> int *bsz)
>               exit(1);
>       }
>       if ((st.st_mode & S_IFMT) == S_IFREG) {
> +             struct xfs_fsop_geom_v1 geom = { 0 };
> +
>               *sz = (long long)(st.st_size >> 9);
> -             *bsz = BBSIZE;
> -             if (BBSIZE > max_block_alignment)
> -                     max_block_alignment = BBSIZE;
> +             if (ioctl(fd, XFS_IOC_FSGEOMETRY_V1, &geom) < 0) {
> +                     /*
> +                      * fall back to BBSIZE; mkfs might fail if there's a
> +                      * size mismatch between the image & the host fs...
> +                      */
> +                     *bsz = BBSIZE;
> +             } else
> +                     *bsz = geom.sectsize;
> +
> +             if (*bsz > max_block_alignment)
> +                     max_block_alignment = *bsz;
>               return;
>       }
>  
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs

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