Re: adding proper O_SYNC/O_DSYNC, was Re: O_DIRECT and barriers

From: Jamie Lokier
Date: Sun Aug 30 2009 - 13:49:13 EST


Ulrich Drepper wrote:
> On 08/28/2009 09:44 AM, Jamie Lokier wrote:
> >Although libc's __new_open() could have this:
> >
> > /* Old kernels only look at O_DSYNC. It's better than nothing. */
> > if (flags& O_SYNC)
> > flags |= O_DSYNC;
> >
> >Imho, it's better to not do that, and instead have
> >
> > #define O_SYNC (O_DSYNC|__O_SYNC_KERNEL)
>
> Why should it be better? You're replacing something the compiler can do
> with zero cost with active code.

You misread; I said the zero cost thing is better.

The only reason you might use the active code is this:

/* Upgrade O_DSYNC to O_SYNC. */

flags = fcntl(fd, F_GETFL, 0);
flags = (flags | O_SYNC) & ~O_DSYNC;
fcntl(fd, F_SETFL, flags);

I'm not sure if that should work in POSIX.

-- Jamie
--
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/