device-mapper-multipath: resume DM map after failed remove - #18793
Open
suresh-thelkar wants to merge 1 commit into
Open
device-mapper-multipath: resume DM map after failed remove#18793suresh-thelkar wants to merge 1 commit into
suresh-thelkar wants to merge 1 commit into
Conversation
_dm_flush_map() could leave a device-mapper map suspended indefinitely: after a failed DM_DEVICE_REMOVE it treated a dm_is_mpath() query error (-1) as "removed externally" and returned success without resuming, and its normal-path resume was a single unverified DM_DEVICE_RESUME. A leaked suspend hangs any flush/sync() on the device in uninterruptible D state and spreads node-wide until reboot. Add 0001-resume-dm-map-after-failed-remove.patch (0.9.6): verify the suspend, treat only dm_is_mpath()==0 as an external removal, and add dm_resume_and_verify() which retries and confirms the resume, reporting failure instead of leaking a suspended map. Bump release to 0.9.6-2.
suresh-thelkar
marked this pull request as ready for review
September 11, 2026 11:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_dm_flush_map()in multipath-tools 0.9.6 could leave a device-mapper mapsuspended indefinitely. After a failed
DM_DEVICE_REMOVE, it treated adm_is_mpath()query error (-1) as "removed externally" and returned successwithout resuming; its normal-path resume was also a single, unverified
DM_DEVICE_RESUME. A leaked suspend hangs any flush /sync()on that device inuninterruptible D state and spreads node-wide until reboot.
This PR adds a downstream patch that verifies the suspend, treats only
dm_is_mpath() == 0as an external removal, and adds a verifieddm_resume_and_verify()that retries and confirms the resume — reporting failureinstead of leaking a suspended map.
Root cause
During map teardown,
dm_flush_mapsuspends the DM map, thenDM_DEVICE_REMOVEfails with
-EBUSYbecause the device is still open (in production, udev ranblkidon the map's suspend/change event, raisingopen_countfrom 0 to 1 in thewindow between multipath's pre-check and the remove ioctl). The failed-remove path
then mis-classified the
dm_is_mpath()error and never issued a successfulDM_DEVICE_RESUME, leaving the mapSUSPENDED. Any subsequent page-cache flush /sync()on the device blocks forever in D state.The fix
Patch0: 0001-resume-dm-map-after-failed-remove.patch(against 0.9.6):dm_is_mpath() == 0as an external removal; a-1query error isnot a removal and must not short-circuit the resume.
dm_resume_and_verify()— retries and confirmsDM_DEVICE_RESUME, andreports failure instead of leaving the map suspended.
Testing
Reproducers (run as root in a disposable VM; scsi_debug / fake devices only).
Full sources are inline below. Build the injector first:
gcc -shared -fPIC -o dmfault.so dmfault.c -ldl.repro-icm-843545099-inject.sh multipath-inject— uses
dmfault.so(LD_PRELOAD, built fromdmfault.c) to force the exactfailed-remove +
dm_is_mpath()→-1condition.[ FAIL ]map leftSuspended[ PASS ]mapActive(resumed + verified)repro-icm-843545099.sh mechanism— shows asuspended map wedges a flush in D state and a resume drains it.
Expected result with this build:
multipath-injectreports PASS (mapActive).Reproducible sources are attached.
Risk / impact
device-mapper-multipathonly; no on-diskformat or ABI change.
instead of being left suspended — strictly safer (removes the hang).