9d648dce创建于 2024年2月7日历史提交
From e8320323aea97e9bfddd8cd5f4b31ec525370eb3 Mon Sep 17 00:00:00 2001
From: Lixiaokeng <lixiaokeng@huawei.com>
Date: Tue, 23 Nov 2021 21:16:19 +0800
Subject: [PATCH] bugfix flush and sync before reboot

---
 libmpathutil/util.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libmpathutil/util.c b/libmpathutil/util.c
index 92f25a5..a89f0b4 100644
--- a/libmpathutil/util.c
+++ b/libmpathutil/util.c
@@ -318,6 +318,13 @@ int safe_write(int fd, const void *buf, size_t count)
 		count -= r;
 		buf = (const char *)buf + r;
 	}
+
+	/* sync->disk */
+	if (fsync(fd) < 0) {
+		condlog(0, "failed to fsync fd :%d", fd);
+		return -errno;
+	}
+
 	return 0;
 }
 
-- 
2.33.0