From: Andrew Morton <akpm@digeo.com>
To: Rob van Nieuwkerk <robn@verdi.et.tudelft.nl>
Cc: Joel.Becker@oracle.com, robn@verdi.et.tudelft.nl,
linux-kernel@vger.kernel.org
Subject: Re: O_DIRECT alignment requirements ?
Date: Wed, 9 Apr 2003 12:15:37 -0700 [thread overview]
Message-ID: <20030409121537.36ba3fce.akpm@digeo.com> (raw)
In-Reply-To: <200304091653.h39GrHR05341@verdi.et.tudelft.nl>
Rob van Nieuwkerk <robn@verdi.et.tudelft.nl> wrote:
>
>
> Joel Becker wrote:
> > On Wed, Apr 09, 2003 at 02:16:08PM +0200, Rob van Nieuwkerk wrote:
> > > I plan to use O_DIRECT in my application (on a partition, no fs).
> > > It is hard to find info on the exact requirements on the mandatory
> > > alignments of buffer, offset, transfer size: it's easy to find many
> > > contradicting documents. And checking the kernel source itself isn't
> > > trivial.
> >
> > In 2.4, your buffer, offset, and transfer size must be soft
> > blocksize aligned. That's the output of BLKBSZGET against the block
> > device. For unmounted partitions that is 512b, for most people's ext3
> > filesystems that is 4K. It is, FYI, the number set by set_blocksize().
>
> Hi Joel,
>
> Thank you for your reaction.
>
> I get 4096 with BLKBSZGET on several unmounted partitions on my system
> (RH 2.4.18-27.7.x kernel). Some give 1024 .. Maybe it is because I
> had them mounted first and unmounted them for the test ?
>
Yes, the blockdev initially comes up with a 1024 softblocksize. When you
mount a filesystem on the device, the soft blocksize gets rewritten to
(typically) 4096.
Unfortunately it remains at 4096 after the fs is unmounted, which is rather
silly.
In 2.5 you should use BLKSSZGET (sector-size, not block-size) to work out the
supported alignment.
I'm not sure what a good and general solution is really. You might have to
resort to probing the size at runtime, by trying increasing blocksizes until
it works.
next prev parent reply other threads:[~2003-04-09 19:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-09 12:16 O_DIRECT alignment requirements ? Rob van Nieuwkerk
2003-04-09 15:48 ` Joel Becker
2003-04-09 16:53 ` Rob van Nieuwkerk
2003-04-09 17:59 ` Joel Becker
2003-04-09 19:15 ` Andrew Morton [this message]
2003-04-09 21:09 ` Rob van Nieuwkerk
2003-04-09 23:27 ` Joel Becker
2003-04-10 16:33 ` Rob van Nieuwkerk
2003-04-09 18:08 ` Benjamin LaHaise
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=20030409121537.36ba3fce.akpm@digeo.com \
--to=akpm@digeo.com \
--cc=Joel.Becker@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robn@verdi.et.tudelft.nl \
/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