mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <rddunlap@osdl.org>
To: Yves Crespin <crespin.quartz@wanadoo.fr>
Cc: linux-kernel@vger.kernel.org
Subject: Re: read failed EINVAL with O_DIRECT flag
Date: Wed, 13 Apr 2005 12:26:14 -0700	[thread overview]
Message-ID: <20050413122614.32d1a382.rddunlap@osdl.org> (raw)
In-Reply-To: <425D1B83.50809@wanadoo.fr>

On Wed, 13 Apr 2005 15:15:47 +0200 Yves Crespin wrote:

| 
|  >| How can I obtains an buffer alignement from a "user program" ?
|  >
|  >I actually left that as an exercise (after I did it at home
|  >last night).  Did you read the hint (below)?
| 
| Well ... either with malloc() and alignement or posix_memalign(),
| read() still failed!
| My read buffer is in user space, so it's copy to kernel space.
| Inside the read() call, it's the kernel buffer which must be aligned?

No, it's the userspace buffer.  However...
the check below isn't even reached for ext3 filesystems in
Linux 2.4.  I.e., 2.4 does not support O_DIRECT for ext3fs.
mount a partition as -t ext2 and your (modified) program
works fine.  Or use 2.6.current...

Sorry to mislead you somewhat, although you do still need
the buffer alignment fixes.


|  >| >In fs/buffer.c, it wants the buffer & the length (size) to be aligned:
|  >| >
|  >| >function: brw_kiovec()
|  >| >
|  >| >    /*
|  >| >     * First, do some alignment and validity checks
|  >| >     */
|  >| >    for (i = 0; i < nr; i++) {
|  >| >        iobuf = iovec[i];
|  >| >        if ((iobuf->offset & (size-1)) ||
|  >| >            (iobuf->length & (size-1)))
|  >| >            return -EINVAL;
|  >| >        if (!iobuf->nr_pages)
|  >| >            panic("brw_kiovec: iobuf not initialised");
|  >| >    }
|  >| >
|  >| >so in your program, malloc() the buf [pointer] (larger than needed)
|  >| >and then align it to a page boundary and pass that aligned pointer
|  >| >to read().


---
~Randy

      reply	other threads:[~2005-04-13 19:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-11 19:14 Yves Crespin
2005-04-12  3:49 ` Randy.Dunlap
2005-04-12 16:16   ` Yves Crespin
2005-04-12 16:47     ` Randy.Dunlap
2005-04-13 13:15       ` Yves Crespin
2005-04-13 19:26         ` Randy.Dunlap [this message]

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=20050413122614.32d1a382.rddunlap@osdl.org \
    --to=rddunlap@osdl.org \
    --cc=crespin.quartz@wanadoo.fr \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®