summaryrefslogtreecommitdiff
path: root/src/shutdown/umount.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-09-22 11:23:35 +0200
committerLennart Poettering <lennart@poettering.net>2020-09-23 18:33:48 +0200
commite55299da4d75f1e33385f04fded002f23530de94 (patch)
tree9960488e8c2e2b9f03b8282c4954f4581f7e89d0 /src/shutdown/umount.c
parent32c4626c4c34a7deb9ddc5edfba98c3f171900c8 (diff)
downloadsystemd-e55299da4d75f1e33385f04fded002f23530de94.tar.gz
shutdown: also fsync() DM devices before going down
Similar reasons as the previous patch.
Diffstat (limited to 'src/shutdown/umount.c')
-rw-r--r--src/shutdown/umount.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c
index 89b05fcc3f..6eebaf7abc 100644
--- a/src/shutdown/umount.c
+++ b/src/shutdown/umount.c
@@ -23,6 +23,7 @@
#include "device-util.h"
#include "escape.h"
#include "fd-util.h"
+#include "fs-util.h"
#include "fstab-util.h"
#include "libmount-util.h"
#include "mount-setup.h"
@@ -447,27 +448,31 @@ static int delete_loopback(const char *device) {
return -EBUSY; /* Nothing changed, the device is still attached, hence it apparently is still busy */
}
-static int delete_dm(dev_t devnum) {
-
- struct dm_ioctl dm = {
- .version = {
- DM_VERSION_MAJOR,
- DM_VERSION_MINOR,
- DM_VERSION_PATCHLEVEL
- },
- .data_size = sizeof(dm),
- .dev = devnum,
- };
-
+static int delete_dm(MountPoint *m) {
_cleanup_close_ int fd = -1;
+ int r;
- assert(major(devnum) != 0);
+ assert(m);
+ assert(major(m->devnum) != 0);
+ assert(m->path);
fd = open("/dev/mapper/control", O_RDWR|O_CLOEXEC);
if (fd < 0)
return -errno;
- if (ioctl(fd, DM_DEV_REMOVE, &dm) < 0)
+ r = fsync_path_at(AT_FDCWD, m->path);
+ if (r < 0)
+ log_debug_errno(r, "Failed to sync DM block device %s, ignoring: %m", m->path);
+
+ if (ioctl(fd, DM_DEV_REMOVE, &(struct dm_ioctl) {
+ .version = {
+ DM_VERSION_MAJOR,
+ DM_VERSION_MINOR,
+ DM_VERSION_PATCHLEVEL
+ },
+ .data_size = sizeof(struct dm_ioctl),
+ .dev = m->devnum,
+ }) < 0)
return -errno;
return 0;
@@ -702,7 +707,7 @@ static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_lo
}
log_info("Detaching DM %s (%u:%u).", m->path, major(m->devnum), minor(m->devnum));
- r = delete_dm(m->devnum);
+ r = delete_dm(m);
if (r < 0) {
log_full_errno(umount_log_level, r, "Could not detach DM %s: %m", m->path);
n_failed++;