um: ubd: Add REQ_FLUSH suppport

UML's block device driver does not support write barriers,
to support this this patch adds REQ_FLUSH suppport.
Every time the block layer sends a REQ_FLUSH we fsync() now
our backing file to guarantee data consistency.

Reported-and-tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
Richard Weinberger
2013-08-18 13:30:06 +02:00
parent f75b1b1bed
commit 805f11a0d5
3 changed files with 50 additions and 1 deletions

View File

@@ -266,6 +266,15 @@ int os_write_file(int fd, const void *buf, int len)
return n;
}
int os_sync_file(int fd)
{
int n = fsync(fd);
if (n < 0)
return -errno;
return n;
}
int os_file_size(const char *file, unsigned long long *size_out)
{
struct uml_stat buf;