lkml.org 
[lkml]   [2005]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: read failed EINVAL with O_DIRECT flag
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-04-13 21:35    [W:0.051 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site