diff --git a/src/shutdown/detach-dm.c b/src/shutdown/detach-dm.c index f6f672c75ad..bddd748d634 100644 --- a/src/shutdown/detach-dm.c +++ b/src/shutdown/detach-dm.c @@ -15,7 +15,7 @@ #include "devnum-util.h" #include "errno-util.h" #include "fd-util.h" -#include "sync-util.h" +#include "shutdown.h" typedef struct DeviceMapper { char *path; @@ -93,7 +93,6 @@ static int dm_list_get(DeviceMapper **head) { static int delete_dm(DeviceMapper *m) { _cleanup_close_ int fd = -EBADF; - int r; assert(m); assert(major(m->devnum) != 0); @@ -103,9 +102,11 @@ static int delete_dm(DeviceMapper *m) { if (fd < 0) return -errno; - 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); + _cleanup_close_ int block_fd = open(m->path, O_RDONLY|O_CLOEXEC|O_NONBLOCK); + if (block_fd < 0) + log_debug_errno(errno, "Failed to open DM block device %s for syncing, ignoring: %m", m->path); + else + (void) sync_with_progress(block_fd); return RET_NERRNO(ioctl(fd, DM_DEV_REMOVE, &(struct dm_ioctl) { .version = { diff --git a/src/shutdown/detach-loopback.c b/src/shutdown/detach-loopback.c index 267509f7d02..8778a9e0c44 100644 --- a/src/shutdown/detach-loopback.c +++ b/src/shutdown/detach-loopback.c @@ -18,6 +18,7 @@ #include "detach-loopback.h" #include "device-util.h" #include "fd-util.h" +#include "shutdown.h" typedef struct LoopbackDevice { char *path; @@ -111,8 +112,7 @@ static int delete_loopback(const char *device) { /* 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); + (void) sync_with_progress(fd); if (ioctl(fd, LOOP_CLR_FD, 0) < 0) { if (errno == ENXIO) /* Nothing bound, didn't do anything */ diff --git a/src/shutdown/detach-md.c b/src/shutdown/detach-md.c index ac46670f04f..b1aad976e57 100644 --- a/src/shutdown/detach-md.c +++ b/src/shutdown/detach-md.c @@ -17,6 +17,7 @@ #include "devnum-util.h" #include "errno-util.h" #include "fd-util.h" +#include "shutdown.h" #include "string-util.h" typedef struct RaidDevice { @@ -133,8 +134,7 @@ static int delete_md(RaidDevice *m) { if (fd < 0) return -errno; - if (fsync(fd) < 0) - log_debug_errno(errno, "Failed to sync MD block device %s, ignoring: %m", m->path); + (void) sync_with_progress(fd); return RET_NERRNO(ioctl(fd, STOP_ARRAY, NULL)); }