xfs
[Top] [All Lists]

Re: Problem with mkfs.xfs on a regular file

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: Problem with mkfs.xfs on a regular file
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 29 Nov 2013 12:28:22 +1100
Cc: Phil White <cerise-xfs@xxxxxxxxxxxx>, xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20131128211213.GP10988@dastard>
References: <20131127023119.GB13101@boogeyman> <20131127024713.GE10988@dastard> <5296ACFB.4030901@xxxxxxxxxxx> <20131128051626.GM10988@dastard> <5296D5EB.2080008@xxxxxxxxxxx> <20131128100107.GN10988@dastard> <52976210.5070804@xxxxxxxxxxx> <20131128211213.GP10988@dastard>
User-agent: Mutt/1.5.21 (2010-09-15)
On Fri, Nov 29, 2013 at 08:12:13AM +1100, Dave Chinner wrote:
> On Thu, Nov 28, 2013 at 09:32:32AM -0600, Eric Sandeen wrote:
> > On 11/28/13, 4:01 AM, Dave Chinner wrote:
> > > On Wed, Nov 27, 2013 at 11:34:35PM -0600, Eric Sandeen wrote:
> > 
> > <snip>
> > 
> > >> Or maybe just stat() it, and DTRT?
> > > 
> > > Well, we need to stat it to make sure that it's a file if "-d file"
> > > is specified, and a block device if it's not. That will prevent this
> > > problem.  Every other xfsprogs utility has to be told that it is
> > > being pointed at an image file rather than a block device, so why
> > > should mkfs be any different?
> > 
> > The option is there but again I never really knew why.  They work
> > fine without -f, at least in general:
> 
> Just like mkfs works fine, *in general*. That doesn't mean they will always
> work, though:

FYI, here's the list of stuff on top of making mkfs detect files and
set the proper flags and avoid direct IO that I found while doing
this:

Other file/blockdev issues fixed:
        - use getstr to detect specifying the data device name
          twice.
        - check file/size/name parameters before anything else.
        - overwrite checks need to be done before the image file is
          opened and potentially truncated.
        - blkid_get_topology() should not be called for image files,
          so warn when it is called that way.
        - zero_old_xfs_structures() emits a spurious error:
                "existing superblock read failed: Success"
          when it is run on a truncated image file. Don't warn if we
          see this problem on an image file.
        - Don't issue discards on image files.
        - Use fsync() for image files, not BLKFLSBUF in
          platform_flush_device() for Linux.

And so now "-d file" is only needed to trigger creation of the
image file, or if you want to truncate the old file away completely
first...

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

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