Commit c42d3240 authored by Pawel Baldysiak's avatar Pawel Baldysiak Committed by Song Liu

md: return -ENODEV if rdev has no mddev assigned

Mdadm expects that setting drive as faulty will fail with -EBUSY only if
this operation will cause RAID to be failed. If this happens, it will
try to stop the array. Currently -EBUSY might also be returned if rdev
is in the middle of the removal process - for example there is a race
with mdmon that already requested the drive to be failed/removed.

If rdev does not contain mddev, return -ENODEV instead, so the caller
can distinguish between those two cases and behave accordingly.
Reviewed-by: default avatarNeilBrown <[email protected]>
Signed-off-by: default avatarPawel Baldysiak <[email protected]>
Signed-off-by: default avatarSong Liu <[email protected]>
parent 2c88e3c7
......@@ -3380,10 +3380,10 @@ rdev_attr_store(struct kobject *kobj, struct attribute *attr,
return -EIO;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
rv = mddev ? mddev_lock(mddev): -EBUSY;
rv = mddev ? mddev_lock(mddev) : -ENODEV;
if (!rv) {
if (rdev->mddev == NULL)
rv = -EBUSY;
rv = -ENODEV;
rv = entry->store(rdev, page, length);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment