On Mon, Oct 10, 2011 at 10:06 AM, Aneesh Kumar K.V <aneesh.ku...@linux.vnet.ibm.com> wrote: > diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c > index 5c8b5ed..441a37f 100644 > --- a/hw/9pfs/virtio-9p-handle.c > +++ b/hw/9pfs/virtio-9p-handle.c > @@ -202,6 +202,15 @@ static ssize_t handle_pwritev(FsContext *ctx, int fd, > const struct iovec *iov, > return writev(fd, iov, iovcnt);
The sync_file_range(2) call below is dead-code since we'll return immediately after writev(2) completes. The writev(2) return value needs to be saved temporarily and then returned after sync_file_range(2). > } > #endif > + if (ctx->cache_flags & V9FS_WRITETHROUGH_CACHE) { -drive cache=writethrough means something different from 9pfs "writethrough". This is confusing so I wonder if there is a better name like immediate write-out. > + /* > + * Initiate a writeback. This is not a data integrity sync. > + * We want to ensure that we don't leave dirty pages in the cache > + * after write when cache=writethrough is sepcified. > + */ > + sync_file_range(fd, offset, 0, > + SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE); > + } I'm not sure whether SYNC_FILE_RANGE_WAIT_BEFORE is necessary. As a best-effort mechanism just SYNC_FILE_RANGE_WRITE does the job although a client that rapidly rewrites may be able to leave dirty pages in the host page cache. SYNC_FILE_RANGE_WAIT_BEFORE ensures that dirty pages get written out but it is no longer asynchronous because it blocks. Stefan