[dm-devel] [PATCH] libmultipath: sync before reboot

lixiaokeng lixiaokeng at huawei.com
Thu Dec 2 14:30:10 UTC 2021


If reboot within 5s of registering prkey, there will some zero
be added to /etc/multipath/prkeys. The reason is that cache is
not flushed to the disk.

Here fsync(fd) to fix it.

Signed-off-by: Lixiaokeng <lixiaokeng at huawei.com>
Signed-off-by: Jianbing Jiao <jiangjianbiang at huawei.com>
---
 libmultipath/util.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libmultipath/util.c b/libmultipath/util.c
index ea858409..f7e9c783 100644
--- a/libmultipath/util.c
+++ b/libmultipath/util.c
@@ -368,6 +368,11 @@ int safe_write(int fd, const void *buf, size_t count)
 		count -= r;
 		buf = (const char *)buf + r;
 	}
+
+	if (fsync(fd) < 0) {
+		condlog(0, "failed to fsync fd :%d", fd);
+		return -errno;
+	}
 	return 0;
 }

-- 




More information about the dm-devel mailing list