Re: O_DIRECT

From: Rogier Wolff
Date: Sat Jul 24 2004 - 04:57:40 EST


On Tue, Jul 20, 2004 at 08:48:24PM +0200, bert hubert wrote:
> On Tue, Jul 20, 2004 at 10:27:57AM -0700, Shesha Sreenivasamurthy wrote:
> > I am having trouble with O_DIRECT. Trying to read or write from a block
> > device partition.
> >
> > 1. Can O_DIRECT be used on a plain block device partition say
> > "/dev/sda11" without having a filesystem on it.
>
> As fas as I know, yes, but be aware that O_DIRECT requires page aligned
> addresses! (an integral of 4096 on most systems).

Agreed, and I can tell you it works with raw disk devices. The code
we use is:

p = malloc (blocksize + PAGE_SIZE);
buf = (void *) (( ((long)p) + PAGE_SIZE -1 ) & ~(PAGE_SIZE-1));

Roger.

--
** R.E.Wolff@xxxxxxxxxxxx ** http://www.BitWizard.nl/ ** +31-15-2600998 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
**** "Linux is like a wigwam - no windows, no gates, apache inside!" ****
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/