generic_file_buffered_write and O_SYNC

From: Nate Diller
Date: Fri Dec 15 2006 - 17:44:25 EST


So I'm trying to get an understanding of the interactions between the
various aio_read/aio_write paths, and I ran across this gem at the end
of generic_file_buffered_write:

/*
* For now, when the user asks for O_SYNC, we'll actually give O_DSYNC
*/
if (likely(status >= 0)) {
if (unlikely((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
if (!a_ops->writepage || !is_sync_kiocb(iocb))
status = generic_osync_inode(inode, mapping,
OSYNC_METADATA|OSYNC_DATA);
}
}

/*
* If we get here for O_DIRECT writes then we must have fallen through
* to buffered writes (block instantiation inside i_size). So we sync
* the file data here, to try to honour O_DIRECT expectations.
*/
if (unlikely(file->f_flags & O_DIRECT) && written)
status = filemap_write_and_wait(mapping);

So if there's a writepage function AND we're doing async i/o, then
skip the writeout for O_SYNC files. But always do writeout for dio,
synchronously. Why do we check for the existence of ->writepage, but
not ->writepages? Why do we ever skip writeback at all?

in addition to being poorly documented, this code looks to me like it
has a high likelyhood of being incorrect. can anyone clarify?

thanks

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