summaryrefslogtreecommitdiffstats
path: root/src/shutdown
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-09-22 11:19:37 +0200
committerLennart Poettering <lennart@poettering.net>2020-09-23 18:33:48 +0200
commit4534b32c7394d9f5c9d49820f11b9f07fe41b079 (patch)
tree4e58d2a2da42ce35f5b952034e7338cd81250072 /src/shutdown
parentupdate TODO (diff)
downloadsystemd-4534b32c7394d9f5c9d49820f11b9f07fe41b079.tar.xz
systemd-4534b32c7394d9f5c9d49820f11b9f07fe41b079.zip
shutdown: fsync() before detaching loopback devices
This is a follow-up for cae1e8fb88c5a6b0960a2d0be3df8755f0c78462: we also call the detach ioctls in the shutdown code, hence add the fsync()s there too, just to be safe.
Diffstat (limited to 'src/shutdown')
-rw-r--r--src/shutdown/umount.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c
index 0eb694c1af..307944c657 100644
--- a/src/shutdown/umount.c
+++ b/src/shutdown/umount.c
@@ -387,8 +387,15 @@ static int delete_loopback(const char *device) {
assert(device);
fd = open(device, O_RDONLY|O_CLOEXEC);
- if (fd < 0)
+ if (fd < 0) {
+ log_debug_errno(errno, "Failed to open loopback device %s: %m", device);
return errno == ENOENT ? 0 : -errno;
+ }
+
+ /* Loopback block devices don't sync in-flight blocks when we clear the fd, hence sync explicitly
+ * first */
+ if (fsync(fd) < 0)
+ log_debug_errno(errno, "Failed to sync loop block device %s, ignoring: %m", device);
if (ioctl(fd, LOOP_CLR_FD, 0) < 0) {
if (errno == ENXIO) /* Nothing bound, didn't do anything */