Bug 593517 - mdadm -f / -r doesn't work on non-present devices.
Summary: mdadm -f / -r doesn't work on non-present devices.
Alias: None
Product: Fedora
Classification: Fedora
Component: mdadm
Version: 12
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Doug Ledford
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2010-05-19 03:01 UTC by Maciej Żenczykowski
Modified: 2010-07-06 19:01 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-07-05 20:54:25 UTC
Type: ---

Attachments (Terms of Use)

Description Maciej Żenczykowski 2010-05-19 03:01:03 UTC
$ 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 09:15:27 UTC

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 20:54:25 UTC
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 18:39:04 UTC
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 19:01:31 UTC

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