Subject: RE: direct I/O again
To: Bill Studenmund <>
From: Gordon Waidhofer <>
List: tech-kern
Date: 03/28/2006 19:31:12
> To be honest, I think that as long as i/os don't overlap, we're fine. I
> think it's ok for an O_DIRECT write to be happening at the same time as a
> non-direct read, assuming they cover different parts of the file.

It's very difficult to define "the right thing" if they do overlap.
If the application layer isn't taking care of such races, arbitrary
rules in the kernel or (the|a) file system won't save them.

Consider stat(2). Sometime during the processing the vnode lock
is released, struct st copied out to userland, and control returned
to userland. The result is best described that at some time between
when stat() was called and stat() returned the attributes looked
like this. They could -- although rarely -- change between the
vnode lock being released and the return of control to userland.
There is non-zero probability that the struct st in userland is
stale before control is returned to the application, let alone
whether it's accurate when acted upon (like ls(1) printing).

These races simply can't be overcome below the syscall level.

In short, nobody should worry about serializing intersecting
direct reads/writes (or non-direct for that matter) too much.
Don't worry, be happy.

> Take care,
> Bill