[lkml]   [2005]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: A problem about DIRECT IO on ext3
On Mon, 17 Oct 2005, Jens Axboe wrote:
>> how to correct this problem ?
> See your buffer address, it's not aligned. You need to align that as
> well. This is needed because the hardware will dma directly to the user
> buffer, and to be on the safe side we require the same alignment as the
> block layer will normally generate for file system io.
> So in short, just align your read buffer to the same as your block size
> and you will be fine. Example:
> #define BS (4096)
> #define MASK (BS - 1)
> #define ALIGN(buf) (((unsigned long) (buf) + MASK) & ~(MASK))
> char *ptr = malloc(BS + MASK);
> char *buf = (char *) ALIGN(ptr);
> read(fd, buf, BS);

Shouldn't one use posix_memalign(3) for that?

Grzegorz Kulewski
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-10-17 11:15    [W:0.041 / U:14.380 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site