From: Dave Chinner <david@fromorbit.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Phil White <cerise-xfs@l.armory.com>, xfs@oss.sgi.com
Subject: Re: Problem with mkfs.xfs on a regular file
Date: Fri, 29 Nov 2013 08:12:13 +1100 [thread overview]
Message-ID: <20131128211213.GP10988@dastard> (raw)
In-Reply-To: <52976210.5070804@sandeen.net>
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:
$ sudo xfs_repair -n /storage/broken.img
Phase 1 - find and verify superblock...
xfs_repair: read failed: Invalid argument
Repair fails on the file which has a smaller sector size than the
host filesystem, unless you tell it is working on a file, not a
block device:
$ sudo xfs_repair -n -f /storage/broken.img
Phase 1 - find and verify superblock...
Phase 2 - using internal log
- scan filesystem freespace and inode maps...
- found root inode chunk
Phase 3 - for each AG...
- scan (but don't clear) agi unlinked lists...
- process known inodes and perform inode discovery...
- agno = 0
would have corrected attribute entry count in inode 649642 from 40 to 0
local inode 649790 attr too small (size = 1, min size = 4)
bad attribute fork in inode 649790, would clear attr fork
would have cleared inode 649790
....
And so behaviour is identical to mkfs...
> - scan filesystem freespace and inode maps...
> ...
>
> $ xfs_metadump fsfile fsfile.meta
>
> $ file fsfile.meta
> fsfile.meta: XFS filesystem metadump image
>
> etc
>
> > Indeed, if we don't require users to tell mkfs that it's a file,
> > what do we do with non-existent device names when they are provided
> > by the user? Just create the file rather than returning ENOENT? So
> > suddenly /dev/ fills up with fileystem images because of typos?
>
> That won't happen because it doesn't create a new file unless -d file
> is specified, so I guess that's one difference. i.e. with -d file
> it'll create a file of the requested size; without it, it will mkfs
> it to whatever size the file already is, or if it doesn't exist,
> return -ENOENT.
>
> > Principle of Least Surprise says that ENOENT is the correct
> > behaviour, hence it follows that "-d file" is needed and should be
> > properly checked and enforced. I'll add this to the start of the
> > patch set I'm currently working on that fixes all of the mkfs input
> > parameter validation problems I've found over the past couple of
> > weeks...
>
> Well, I hope it doesn't stop mkfs.xfs from mkfs'ing an existing
> file image, which has always worked before...
that's what stat() is for.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2013-11-28 21:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-27 2:31 Problem with mkfs.xfs on a regular file Phil White
2013-11-27 2:36 ` Phil White
2013-11-27 2:38 ` Nathan Scott
2013-11-27 2:41 ` Phil White
2013-11-27 2:47 ` Dave Chinner
2013-11-27 2:47 ` Dave Chinner
2013-11-28 2:39 ` Eric Sandeen
2013-11-28 5:16 ` Dave Chinner
2013-11-28 5:34 ` Eric Sandeen
2013-11-28 10:01 ` Dave Chinner
2013-11-28 11:47 ` Phil White
2013-11-28 15:38 ` Eric Sandeen
2013-11-28 15:32 ` Eric Sandeen
2013-11-28 21:12 ` Dave Chinner [this message]
2013-11-29 1:28 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131128211213.GP10988@dastard \
--to=david@fromorbit.com \
--cc=cerise-xfs@l.armory.com \
--cc=sandeen@sandeen.net \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.