Let's put a time-out on this syncing.
Inspired-by: #34289 #34283
#include "devnum-util.h"
#include "errno-util.h"
#include "fd-util.h"
-#include "sync-util.h"
+#include "shutdown.h"
typedef struct DeviceMapper {
char *path;
static int delete_dm(DeviceMapper *m) {
_cleanup_close_ int fd = -EBADF;
- int r;
assert(m);
assert(major(m->devnum) != 0);
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 = {
#include "detach-loopback.h"
#include "device-util.h"
#include "fd-util.h"
+#include "shutdown.h"
typedef struct LoopbackDevice {
char *path;
/* 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 */
#include "devnum-util.h"
#include "errno-util.h"
#include "fd-util.h"
+#include "shutdown.h"
#include "string-util.h"
typedef struct RaidDevice {
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));
}