public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Dave Chinner <david@fromorbit.com>, Phil White <cerise-xfs@l.armory.com>
Cc: xfs@oss.sgi.com
Subject: Re: Problem with mkfs.xfs on a regular file
Date: Wed, 27 Nov 2013 20:39:55 -0600	[thread overview]
Message-ID: <5296ACFB.4030901@sandeen.net> (raw)
In-Reply-To: <20131127024713.GE10988@dastard>

On 11/26/13, 8:47 PM, Dave Chinner wrote:
> On Tue, Nov 26, 2013 at 06:31:19PM -0800, Phil White wrote:
>> Gents:
>>
>> I was making an image for a VM using everyone's favorite fs with a line
>> that looked something like this:
>> -------------
>> dd if=/dev/zero of=~/image bs=1024 count=1048576 && ./mkfs/mkfs.xfs && mount -o loop ~/image /mnt/loop
>> -------------
>>
>>
>> mkfs.xfs gave me this output:
>> -------------
>> meta-data=/root/image            isize=256    agcount=4, agsize=65536 blks
>>          =                       sectsz=512   attr=2, projid32bit=0
>> data     =                       bsize=4096   blocks=262144, imaxpct=25
>>          =                       sunit=0      swidth=0 blks
>> naming   =version 2              bsize=4096   ascii-ci=0
>> log      =internal log           bsize=4096   blocks=2560, version=2
>>          =                       sectsz=512   sunit=0 blks, lazy-count=1
>> realtime =none                   extsz=4096   blocks=0, rtextents=0
>> existing superblock read failed: Invalid argument
>> mkfs.xfs: pwrite64 failed: Invalid argument
>> mkfs.xfs: read failed: Invalid argument
>> -------------
> .....
>>
>> While it occurred to me that the problem might just be line 806 of some files
>> in xfsprogs, I threw it under a debugger and took a closer look.  The file
>> descriptor value in xi->dfd pointed at ~/image.  errno was set to 22.  I
>> thought that might indicate a problem with lseek(), so I rewrote the pwrite64()
>> and pread() as lseek()s and read()/write()
>>
>> As you may have guessed, this did me no good at all.
>>
>> It's trying to read/write 512 bytes at the beginning of the file which seems
>> reasonably innocuous.  I double checked the man page which says that under
>> 2.6, O_DIRECT writes can be aligned to 512 bytes without a problem.
> 
> That doesn't mean it is correct, because the man page also says:
> 
> " In Linux alignment restrictions vary by filesystem and kernel
> version and might be absent entirely."
> 
> So, I bet that your underlying filesystem (i.e. the host filesystem)
> has a sector size of 4k, and that's why direct Io on 512 byte
> alignment is failing. In that case, run "mkfs.xfs -s size=4k ..."
> and mkfs should just work fine...

Sadly, no.  Or at least, probably not.

__initbuf
	memalign(libxfs_device_alignment(), bytes);

where libxfs_device_alignment() does:

platform_align_blockdev
	        if (!max_block_alignment)
			return getpagesize();
		return max_block_alignment;
  
and through twisty paths through platform_findsizes(), max_block_alignment is BBSIZE, or 512.

IOWS: xfsprogs is a braindead package that doesn't know how to properly handle non-512-aligned DIO.  ;)  </snark>

We should fix xfsprogs, but I'm also looking making 4k "sector" xfs able to do 512 DIOs as long as the device under it can do 512 DIOS.

We got into the 4k DIO alignment because mkfs.xfs saw a 512 logical / 4k physical drive, and chose 4k for its own internal sector size, which is great in terms of doing metadata IO efficiently, but not so great in terms of rejecting 512 byte IOs that the drive could otherwise do.

-Eric

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2013-11-28  2:39 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 [this message]
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
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=5296ACFB.4030901@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=cerise-xfs@l.armory.com \
    --cc=david@fromorbit.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox