return NULL;
}
+static struct md_rdev * find_rdev_nr_rcu(struct mddev *mddev, int nr)
+{
+ struct md_rdev *rdev;
+
+ rdev_for_each_rcu(rdev, mddev)
+ if (rdev->desc_nr == nr)
+ return rdev;
+
+ return NULL;
+}
+
static struct md_rdev * find_rdev(struct mddev * mddev, dev_t dev)
{
struct md_rdev *rdev;
return NULL;
}
+static struct md_rdev * find_rdev_rcu(struct mddev * mddev, dev_t dev)
+{
+ struct md_rdev *rdev;
+
+ rdev_for_each_rcu(rdev, mddev)
+ if (rdev->bdev->bd_dev == dev)
+ return rdev;
+
+ return NULL;
+}
+
static struct md_personality *find_pers(int level, char *clevel)
{
struct md_personality *pers;
int nr,working,insync,failed,spare;
struct md_rdev *rdev;
- nr=working=insync=failed=spare=0;
- rdev_for_each(rdev, mddev) {
+ nr = working = insync = failed = spare = 0;
+ rcu_read_lock();
+ rdev_for_each_rcu(rdev, mddev) {
nr++;
if (test_bit(Faulty, &rdev->flags))
failed++;
spare++;
}
}
+ rcu_read_unlock();
info.major_version = mddev->major_version;
info.minor_version = mddev->minor_version;
if (copy_from_user(&info, arg, sizeof(info)))
return -EFAULT;
- rdev = find_rdev_nr(mddev, info.number);
+ rcu_read_lock();
+ rdev = find_rdev_nr_rcu(mddev, info.number);
if (rdev) {
info.major = MAJOR(rdev->bdev->bd_dev);
info.minor = MINOR(rdev->bdev->bd_dev);
info.raid_disk = -1;
info.state = (1<<MD_DISK_REMOVED);
}
+ rcu_read_unlock();
if (copy_to_user(arg, &info, sizeof(info)))
return -EFAULT;
static int set_disk_faulty(struct mddev *mddev, dev_t dev)
{
struct md_rdev *rdev;
+ int err = 0;
if (mddev->pers == NULL)
return -ENODEV;
- rdev = find_rdev(mddev, dev);
+ rcu_read_lock();
+ rdev = find_rdev_rcu(mddev, dev);
if (!rdev)
- return -ENODEV;
-
- md_error(mddev, rdev);
- if (!test_bit(Faulty, &rdev->flags))
- return -EBUSY;
- return 0;
+ err = -ENODEV;
+ else {
+ md_error(mddev, rdev);
+ if (!test_bit(Faulty, &rdev->flags))
+ err = -EBUSY;
+ }
+ rcu_read_unlock();
+ return err;
}
/*
goto abort;
}
+ /* Some actions do not requires the mutex */
+ switch (cmd) {
+ case GET_ARRAY_INFO:
+ if (!mddev->raid_disks && !mddev->external)
+ err = -ENODEV;
+ else
+ err = get_array_info(mddev, argp);
+ goto abort;
+
+ case GET_DISK_INFO:
+ if (!mddev->raid_disks && !mddev->external)
+ err = -ENODEV;
+ else
+ err = get_disk_info(mddev, argp);
+ goto abort;
+
+ case SET_DISK_FAULTY:
+ err = set_disk_faulty(mddev, new_decode_dev(arg));
+ goto abort;
+ }
+
err = mddev_lock(mddev);
if (err) {
printk(KERN_INFO
*/
switch (cmd)
{
- case GET_ARRAY_INFO:
- err = get_array_info(mddev, argp);
- goto done_unlock;
-
case GET_BITMAP_FILE:
err = get_bitmap_file(mddev, argp);
goto done_unlock;
- case GET_DISK_INFO:
- err = get_disk_info(mddev, argp);
- goto done_unlock;
-
case RESTART_ARRAY_RW:
err = restart_array(mddev);
goto done_unlock;
err = hot_add_disk(mddev, new_decode_dev(arg));
goto done_unlock;
- case SET_DISK_FAULTY:
- err = set_disk_faulty(mddev, new_decode_dev(arg));
- goto done_unlock;
-
case RUN_ARRAY:
err = do_md_run(mddev);
goto done_unlock;