<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 29, 2016 at 9:11 PM, Eric Sandeen <span dir="ltr"><<a href="mailto:sandeen@sandeen.net" target="_blank">sandeen@sandeen.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5"><br>
<br>
On 4/29/16 9:47 AM, Jan Tulak wrote:<br>
> From: Dave Chinner <<a href="mailto:dchinner@redhat.com">dchinner@redhat.com</a>><br>
><br>
> If the device is actually a file, and "-d file" is not specified,<br>
> mkfs will try to treat it as a block device and get stuff wrong.<br>
> Image files don't necessarily have the same sector sizes as the<br>
> block device or filesystem underlying the image file, nor should we<br>
> be issuing discard ioctls on image files.<br>
><br>
> To fix this sanely, only require "-d file" if the device name is<br>
> invalid to trigger creation of the file. Otherwise, use stat() to<br>
> determine if the device is a file or block device and deal with that<br>
> appropriately by setting the "isfile" variables and turning off<br>
> direct IO. Then ensure that we check the "isfile" options before<br>
> doing things that are specific to block devices.<br>
><br>
> Other file/blockdev issues fixed:<br>
>       - use getstr to detect specifying the data device name<br>
>         twice.<br>
>       - check file/size/name parameters before anything else.<br>
>       - overwrite checks need to be done before the image file is<br>
>         opened and potentially truncated.<br>
>       - blkid_get_topology() should not be called for image files,<br>
>         so warn when it is called that way.<br>
>       - zero_old_xfs_structures() emits a spurious error:<br>
>               "existing superblock read failed: Success"<br>
>         when it is run on a truncated image file. Don't warn if we<br>
>         see this problem on an image file.<br>
>       - Don't issue discards on image files.<br>
>       - Use fsync() for image files, not BLKFLSBUF in<br>
>         platform_flush_device() for Linux.<br>
><br>
> Signed-off-by: Dave Chinner <<a href="mailto:dchinner@redhat.com">dchinner@redhat.com</a>><br>
> Signed-off-by: Jan Tulak <<a href="mailto:jtulak@redhat.com">jtulak@redhat.com</a>><br>
><br>
> ---<br>
> CHANGES:<br>
> * read image file size in advance of O_TRUNC in case of dfile&&dcreat<br>
> Signed-off-by: Jan Tulak <<a href="mailto:jtulak@redhat.com">jtulak@redhat.com</a>><br>
> ---<br>
>  libxfs/init.c   |  21 ++++++-<br>
>  libxfs/linux.c  |  11 +++-<br>
>  mkfs/xfs_mkfs.c | 182 ++++++++++++++++++++++++++++++++++++++------------------<br>
>  3 files changed, 154 insertions(+), 60 deletions(-)<br>
><br>
> diff --git a/libxfs/init.c b/libxfs/init.c<br>
> index 8d747e8..c7ae00d 100644<br>
> --- a/libxfs/init.c<br>
> +++ b/libxfs/init.c<br>
> @@ -253,8 +253,15 @@ libxfs_init(libxfs_init_t *a)<br>
>       rtname = a->rtname;<br>
>       a->dfd = a->logfd = a->rtfd = -1;<br>
>       a->ddev = a->logdev = a->rtdev = 0;<br>
> -     a->dbsize = a->lbsize = a->rtbsize = 0;<br>
> -     a->dsize = a->logBBsize = a->logBBstart = a->rtsize = 0;<br>
> +     a->lbsize = a->rtbsize = 0;<br>
> +     a->logBBsize = a->logBBstart = a->rtsize = 0;<br>
> +<br>
> +     // We can reset dbsize only when it is not a file, or we won't<br>
> +     // truncate it. Otherwise, we loose the size of the file forever.<br>
<br>
</div></div>please don't use c++ comments in xfsprogs, we use /* comments */<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Sorry. ​:-[ ​</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
...<br>
<span class=""><br>
>  static void<br>
> +check_device_type(<br>
> +     const char      *name,<br>
> +     int             *isfile,<br>
> +     bool            no_size,<br>
> +     bool            no_name,<br>
> +     int             *create,<br>
> +     bool            force_overwrite,<br>
> +     const char      *optname)<br>
> +{<br>
> +     struct stat64 statbuf;<br>
> +     /*<br>
> +     if (*isfile && (no_size || no_name)) {<br>
> +             fprintf(stderr,<br>
> +     _("if -%s file then -%s name and -%s size are required\n"),<br>
> +                     optname, optname, optname);<br>
> +             usage();<br>
> +     }*/<br>
<br>
</span>What is this?<br>
<br></blockquote><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">​Again :-[</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I commented it out during the development and then forgot to really delete it.​</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Jan, I'm just going to go back to the original patches posted in your V2 series,<br>
and either give them Reviewed-by's, or send followup fix-up patches with a<br>
<br>
Eric Sandeen <<a href="mailto:sandeen@redhat.com">sandeen@redhat.com</a>>: fixed up foo, bar, baz<br>
<br>
tag and a Reviewed-by to go with it, I think that might be the fastest path to<br>
finally getting this stuff merged.<br>
<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">​OK, whatever you think is the best. :-)​</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Jan</div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Thanks,<br>
-Eric<br>
<div class=""><div class="h5"><br>
_______________________________________________<br>
xfs mailing list<br>
<a href="mailto:xfs@oss.sgi.com">xfs@oss.sgi.com</a><br>
<a href="http://oss.sgi.com/mailman/listinfo/xfs" rel="noreferrer" target="_blank">http://oss.sgi.com/mailman/listinfo/xfs</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Jan Tulak<br></div><a href="mailto:jtulak@redhat.com" target="_blank">jtulak@redhat.com</a> / <a href="mailto:jan@tulak.me" target="_blank">jan@tulak.me</a></div></div></div></div>
</div></div>