block/file-posix: allow -drive cache.direct=off live migration
Status from this message: Thanks, applied to my block tree:
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 4 repliesApplied
- v1 RFC2 patches 17 repliesSuperseded
Changes in v2 from the cover letter
* Add comment on !__linux__ situation [Fam]
* Add file-posix.c x-check-cache-dropped=on|off option [DaveG, Kevin]
Patches in v2 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | block/file-posix: implement bdrv_co_invalidate_cache() on Linuxblock/ | +46 | 0 replies | |
| 2/2 | block/file-posix: add x-check-page-cache=on|off optionblock/ qapi/ | +104 | 0 replies |
Reviews trailers per patch
None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Fam Zheng |
|---|---|
| Series | R-b |
| 1/2 | |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [Qemu-devel] [PATCH v2 0/2] block/file-posix: allow -drive cache.direct=off live migration
v2:
* Add comment on !__linux__ situation [Fam]
* Add file-posix.c x-check-cache-dropped=on|off option [DaveG, Kevin]
file-posix.c only supports shared storage live migration with -drive cache.direct=off due to cache consistency issues. There are two main shared storage configurations: files on NFS and host block devices on SAN LUNs.
The problem is that QEMU starts on the destination host before the source host has written everything out to the disk. The page cache on the destination host may contain stale data read when QEMU opened the image file (before migration handover). Using O_DIRECT avoids this problem but prevents users from taking advantage of the host page cache.
Although cache=none is the recommended setting for virtualization use cases, there are scenarios where cache=writeback makes sense. If the guest has much less RAM than the host or many guests share the same backing file, then the host page cache can significantly improve disk I/O performance.
This patch series implements .bdrv_co_invalidate_cache() for block/file-posix.c on Linux so that shared storage live migration works. I have sent it as an RFC because cache consistency is not binary, there are corner cases which I've described in the actual patch, and this may require more discussion.
Regarding NFS, QEMU relies on O_DIRECT rather than the close-to-open consistency model (see nfs(5)), which is the basic guarantee provided by NFS. After this patch cache consistency is no longer provided by O_DIRECT.
This patch series relies on fdatasync(2) (source) + posix_fadvise(POSIX_FADV_DONTNEED) (destination) instead. I believe it is safe for both NFS and SAN LUNs. Maybe we should use fsync(2) instead of fdatasync(2) so that NFS has up-to-date inode metadata?
Stefan Hajnoczi (2):
block/file-posix: implement bdrv_co_invalidate_cache() on Linux block/file-posix: add x-check-page-cache=on|off option
qapi/block-core.json | 7 ++- block/file-posix.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 150 insertions(+), 3 deletions(-)
Signature · 1 line
2.14.3