[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 09/34] io: fsync before closing a file channel
From: |
Fabiano Rosas |
Subject: |
[PATCH v4 09/34] io: fsync before closing a file channel |
Date: |
Tue, 20 Feb 2024 19:41:13 -0300 |
Make sure the data is flushed to disk before closing file
channels. This is to ensure data is on disk and not lost in the event
of a host crash.
This is currently being implemented to affect the migration code when
migrating to a file, but all QIOChannelFile users should benefit from
the change.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
- improved commit message
---
io/channel-file.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/io/channel-file.c b/io/channel-file.c
index a6ad7770c6..d4706fa592 100644
--- a/io/channel-file.c
+++ b/io/channel-file.c
@@ -242,6 +242,11 @@ static int qio_channel_file_close(QIOChannel *ioc,
{
QIOChannelFile *fioc = QIO_CHANNEL_FILE(ioc);
+ if (qemu_fdatasync(fioc->fd) < 0) {
+ error_setg_errno(errp, errno,
+ "Unable to synchronize file data with storage
device");
+ return -1;
+ }
if (qemu_close(fioc->fd) < 0) {
error_setg_errno(errp, errno,
"Unable to close file");
--
2.35.3
- Re: [PATCH v4 02/34] tests/qtest/migration: Rename fd_proto test, (continued)
- [PATCH v4 03/34] tests/qtest/migration: Add a fd + file test, Fabiano Rosas, 2024/02/20
- [PATCH v4 04/34] migration/multifd: Remove p->quit from recv side, Fabiano Rosas, 2024/02/20
- [PATCH v4 05/34] migration/multifd: Release recv sem_sync earlier, Fabiano Rosas, 2024/02/20
- [PATCH v4 06/34] io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file, Fabiano Rosas, 2024/02/20
- [PATCH v4 07/34] io: Add generic pwritev/preadv interface, Fabiano Rosas, 2024/02/20
- [PATCH v4 08/34] io: implement io_pwritev/preadv for QIOChannelFile, Fabiano Rosas, 2024/02/20
- [PATCH v4 09/34] io: fsync before closing a file channel,
Fabiano Rosas <=
- [PATCH v4 10/34] migration/qemu-file: add utility methods for working with seekable channels, Fabiano Rosas, 2024/02/20
- [PATCH v4 11/34] migration/ram: Introduce 'fixed-ram' migration capability, Fabiano Rosas, 2024/02/20
- Re: [PATCH v4 11/34] migration/ram: Introduce 'fixed-ram' migration capability, Peter Xu, 2024/02/25
- Re: [PATCH v4 11/34] migration/ram: Introduce 'fixed-ram' migration capability, Peter Xu, 2024/02/25
[PATCH v4 12/34] migration: Add fixed-ram URI compatibility check, Fabiano Rosas, 2024/02/20