[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 05/23] io: fsync before closing a file channel
From: |
Fabiano Rosas |
Subject: |
[PATCH v6 05/23] io: fsync before closing a file channel |
Date: |
Thu, 29 Feb 2024 12:29:59 -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>
---
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
- [PATCH v6 00/23] migration: File based migration with multifd and mapped-ram, Fabiano Rosas, 2024/02/29
- [PATCH v6 01/23] migration/multifd: Cleanup multifd_recv_sync_main, Fabiano Rosas, 2024/02/29
- [PATCH v6 02/23] io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file, Fabiano Rosas, 2024/02/29
- [PATCH v6 04/23] io: implement io_pwritev/preadv for QIOChannelFile, Fabiano Rosas, 2024/02/29
- [PATCH v6 03/23] io: Add generic pwritev/preadv interface, Fabiano Rosas, 2024/02/29
- [PATCH v6 05/23] io: fsync before closing a file channel,
Fabiano Rosas <=
- [PATCH v6 06/23] migration/qemu-file: add utility methods for working with seekable channels, Fabiano Rosas, 2024/02/29
- [PATCH v6 08/23] migration: Add mapped-ram URI compatibility check, Fabiano Rosas, 2024/02/29
- [PATCH v6 07/23] migration/ram: Introduce 'mapped-ram' migration capability, Fabiano Rosas, 2024/02/29
- [PATCH v6 09/23] migration/ram: Add outgoing 'mapped-ram' migration, Fabiano Rosas, 2024/02/29
- [PATCH v6 10/23] migration/ram: Add incoming 'mapped-ram' migration, Fabiano Rosas, 2024/02/29
- [PATCH v6 11/23] tests/qtest/migration: Add tests for mapped-ram file-based migration, Fabiano Rosas, 2024/02/29
- [PATCH v6 13/23] migration/multifd: Decouple recv method from pages, Fabiano Rosas, 2024/02/29
- [PATCH v6 12/23] migration/multifd: Rename MultiFDSend|RecvParams::data to compress_data, Fabiano Rosas, 2024/02/29
- [PATCH v6 14/23] migration/multifd: Allow multifd without packets, Fabiano Rosas, 2024/02/29
- [PATCH v6 17/23] migration/multifd: Add outgoing QIOChannelFile support, Fabiano Rosas, 2024/02/29