Bug 593517 - mdadm -f / -r doesn't work on non-present devices.
mdadm -f / -r doesn't work on non-present devices.
Product: Fedora
Classification: Fedora
Component: mdadm (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Doug Ledford
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2010-05-18 23:01 EDT by Maciej Żenczykowski
Modified: 2010-07-06 15:01 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2010-07-05 16:54:25 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Maciej Żenczykowski 2010-05-18 23:01:03 EDT
$ rpm -q --whatprovides `which mdadm`

If a raid drive (/dev/sdX) goes away (for example: because it was disconnected), then hotplug will remove the /dev/sdX{,y} entries.

At this point "mdadm -f /dev/mdZ /dev/sdXy" and "mdadm -r /dev/mdZ /dev/sdXy" will no longer work.

  echo faulty > /sys/block/mdZ/md/dev-sdXy/state
  echo remove > /sys/block/mdZ/md/dev-sdXy/state
works just fine.

mdadm should probably be fixed...?
Comment 1 Piergiorgio Sartor 2010-07-05 05:15:27 EDT

you should check the keyword "detached" for "-f" and "-r".

According to the man page, "mdadm -f/-r /dev/mdZ /dev/sdXy detached" should fail/remove devices not anymore present.

Hope this helps,


Comment 2 Maciej Żenczykowski 2010-07-05 16:54:25 EDT
Unfortunately, I don't believe that this is quite enough.

The following is untested, but (and I believe this is actually the setup I had when I ran into this):

- the array in question contained a read-only file system, as such no writes where ever issued to it
- the device which failed was marked as 'write-mostly', so reads would never go to it, unless there were no non-write-mostly devices.

As such the kernel would never attempt to access the missing device (writes impossible because of read-only filesystem, reads directed to other devices because of write-mostly) and thus would never mark the device as faulty.

Hence the need to manually mark it as failed/faulty (and only then remove it).

Furthermore I'm not convinced even the keyword "detached" would help us since the open doesn't return ENXIO - it just fails (the /dev/sdXy node is totally absent from the /dev directory because of hotplug).

*HOWEVER* next time I run into this I'll try it and see if "-f detached" and "-r detached" or "-r failed" will work...

I'll mark the bug as closed, and reopen if when I once more run into this I fail with the above-mentioned method.
Comment 3 Doug Ledford 2010-07-06 14:39:04 EDT
The usage of mdadm -f detached or failed should work as it finds the devices which are part of the array and otherwise not operational and removes them.  However, in future mdadm versions, mdadm -If also works and is going to be added to mdadm udev rules to cause devices that are hot-unplugged to automatically be removed from the raid array just as the device nodes are removed from /dev.
Comment 4 Maciej Żenczykowski 2010-07-06 15:01:31 EDT

Note You need to log in before you can comment on or make changes to this bug.