From b78d0e2856c5401d77839f95d9ae7d829abfa010 Mon Sep 17 00:00:00 2001 From: Akilesh Kailash Date: Wed, 29 Nov 2023 11:24:28 -0800 Subject: [PATCH] snapshotctl: fsync after writing every 1MB buffer Sync writes after every 1MB instead of flushing at the end. Bug: 299011882 Test: Boot device off snapshots Change-Id: If91168ec92c2b2995bdf296ea1c7d4c261b12411 Signed-off-by: Akilesh Kailash --- fs_mgr/libsnapshot/snapshotctl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs_mgr/libsnapshot/snapshotctl.cpp b/fs_mgr/libsnapshot/snapshotctl.cpp index ebaca2dbe..0396a55d6 100644 --- a/fs_mgr/libsnapshot/snapshotctl.cpp +++ b/fs_mgr/libsnapshot/snapshotctl.cpp @@ -227,8 +227,12 @@ bool MapSnapshots::WriteSnapshotPatch(std::string cow_device, std::string patch) if (file_offset >= dev_sz) { break; } + + if (fsync(cfd.get()) < 0) { + PLOG(ERROR) << "Fsync failed at offset: " << file_offset << " size: " << to_read; + return false; + } } - fsync(cfd.get()); return true; }