From 9485f22ddc19f6699857f1baa9897302c5f71dbd Mon Sep 17 00:00:00 2001 From: Roman Tarasov Date: Mon, 10 Aug 2026 01:26:05 +0300 Subject: [PATCH] Disable forced detach for MD devices --- src/sm_mount_device.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/sm_mount_device.c b/src/sm_mount_device.c index e8091e4..63fd2bb 100644 --- a/src/sm_mount_device.c +++ b/src/sm_mount_device.c @@ -377,31 +377,16 @@ static bool detach_md_unit(int unit_id, req.md_version = MDIOVERSION; req.md_unit = (unsigned int)unit_id; - bool detach_accepted = false; - int detach_errno = 0; if (ioctl(fd, MDIOCDETACH, &req) != 0) { - int initial_errno = errno; - req.md_options = MD_FORCE; - if (ioctl(fd, MDIOCDETACH, &req) != 0) { - detach_errno = errno; - log_debug(" [IMG][%s] detach %d failed: %s", - attach_backend_name(ATTACH_BACKEND_MD), unit_id, - strerror(detach_errno)); - } else { - detach_accepted = true; - log_debug(" [IMG][%s] detach %d forced after error: %s", - attach_backend_name(ATTACH_BACKEND_MD), unit_id, - strerror(initial_errno)); - } - } else { - detach_accepted = true; - } - close(fd); - - if (!detach_accepted) { + int detach_errno = errno; + log_debug(" [IMG][%s] detach %d failed: %s", + attach_backend_name(ATTACH_BACKEND_MD), unit_id, + strerror(detach_errno)); + close(fd); return finish_failed_detach(ATTACH_BACKEND_MD, unit_id, devname, &request_state, detach_errno); } + close(fd); return finish_accepted_detach(ATTACH_BACKEND_MD, unit_id, state, &request_state);