diff options
author | Christoph Hellwig <hch@lst.de> | 2009-09-04 19:01:32 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-09-11 10:19:46 -0500 |
commit | 6f1953c4c14566d3303709869fd26201828b3ccf (patch) | |
tree | 522dacdca726cc3b8bc321e70791d03a3b543e72 /block | |
parent | e900a7b748316b5b5a98e41dde36a0cb8e15be5f (diff) | |
download | qemu-6f1953c4c14566d3303709869fd26201828b3ccf.zip qemu-6f1953c4c14566d3303709869fd26201828b3ccf.tar.gz qemu-6f1953c4c14566d3303709869fd26201828b3ccf.tar.bz2 |
block: use fdatasync instead of fsync if possible
If we are flushing the caches for our image files we only care about the
data (including the metadata required for accessing it) but not things
like timestamp updates. So try to use fdatasync instead of fsync to
implement the flush operations.
Unfortunately many operating systems still do not support fdatasync,
so we add a qemu_fdatasync wrapper that uses fdatasync if available
as per the _POSIX_SYNCHRONIZED_IO feature macro or fsync otherwise.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/cow.c | 2 | ||||
-rw-r--r-- | block/raw-posix.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/block/cow.c b/block/cow.c index 84818f1..a70854e 100644 --- a/block/cow.c +++ b/block/cow.c @@ -258,7 +258,7 @@ static int cow_create(const char *filename, QEMUOptionParameter *options) static void cow_flush(BlockDriverState *bs) { BDRVCowState *s = bs->opaque; - fsync(s->fd); + qemu_fdatasync(s->fd); } static QEMUOptionParameter cow_create_options[] = { diff --git a/block/raw-posix.c b/block/raw-posix.c index 2125d67..2ebc88f 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -723,7 +723,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options) static void raw_flush(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; - fsync(s->fd); + qemu_fdatasync(s->fd); } |