Commit 70e96bef authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

[PATCH] MD - Get rid of find_rdev_all

Get rid of find_rdev_all

find_rdev_all is now only used to check if a device is already
used in an md array.

We change lock_rdev so that it claims the bdev for
the specific rdev rather than for rdevs in general.
Now lock_rdev will check if the bdev is inuse by another array
or not, so the find_rdev_all check isn't needed and is removed,
along with find_rdev_all itself.

We also make sure that the error code from lock_rdev is
propagated up properly.
parent a0f86742
...@@ -603,7 +603,7 @@ static int lock_rdev(mdk_rdev_t *rdev) ...@@ -603,7 +603,7 @@ static int lock_rdev(mdk_rdev_t *rdev)
err = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_RAW); err = blkdev_get(bdev, FMODE_READ|FMODE_WRITE, 0, BDEV_RAW);
if (err) if (err)
return err; return err;
err = bd_claim(bdev, lock_rdev); err = bd_claim(bdev, rdev);
if (err) { if (err) {
blkdev_put(bdev, BDEV_RAW); blkdev_put(bdev, BDEV_RAW);
return err; return err;
...@@ -819,19 +819,6 @@ static int uuid_equal(mdk_rdev_t *rdev1, mdk_rdev_t *rdev2) ...@@ -819,19 +819,6 @@ static int uuid_equal(mdk_rdev_t *rdev1, mdk_rdev_t *rdev2)
return 0; return 0;
} }
static mdk_rdev_t * find_rdev_all(kdev_t dev)
{
struct list_head *tmp;
mdk_rdev_t *rdev;
list_for_each(tmp, &all_raid_disks) {
rdev = list_entry(tmp, mdk_rdev_t, all);
if (kdev_same(rdev->dev, dev))
return rdev;
}
return NULL;
}
static int write_disk_sb(mdk_rdev_t * rdev) static int write_disk_sb(mdk_rdev_t * rdev)
{ {
kdev_t dev = rdev->dev; kdev_t dev = rdev->dev;
...@@ -1007,9 +994,6 @@ static mdk_rdev_t *md_import_device(kdev_t newdev, int on_disk) ...@@ -1007,9 +994,6 @@ static mdk_rdev_t *md_import_device(kdev_t newdev, int on_disk)
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
unsigned int size; unsigned int size;
if (find_rdev_all(newdev))
return ERR_PTR(-EEXIST);
rdev = (mdk_rdev_t *) kmalloc(sizeof(*rdev), GFP_KERNEL); rdev = (mdk_rdev_t *) kmalloc(sizeof(*rdev), GFP_KERNEL);
if (!rdev) { if (!rdev) {
printk(KERN_ERR "md: could not alloc mem for %s!\n", partition_name(newdev)); printk(KERN_ERR "md: could not alloc mem for %s!\n", partition_name(newdev));
...@@ -1021,10 +1005,10 @@ static mdk_rdev_t *md_import_device(kdev_t newdev, int on_disk) ...@@ -1021,10 +1005,10 @@ static mdk_rdev_t *md_import_device(kdev_t newdev, int on_disk)
goto abort_free; goto abort_free;
rdev->dev = newdev; rdev->dev = newdev;
if (lock_rdev(rdev)) { err = lock_rdev(rdev);
printk(KERN_ERR "md: could not lock %s, zero-size? Marking faulty.\n", if (err) {
printk(KERN_ERR "md: could not lock %s.\n",
partition_name(newdev)); partition_name(newdev));
err = -EINVAL;
goto abort_free; goto abort_free;
} }
rdev->desc_nr = -1; rdev->desc_nr = -1;
...@@ -2103,18 +2087,12 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) ...@@ -2103,18 +2087,12 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
unsigned int nr; unsigned int nr;
kdev_t dev; kdev_t dev;
dev = mk_kdev(info->major,info->minor); dev = mk_kdev(info->major,info->minor);
if (find_rdev_all(dev)) {
printk(KERN_WARNING "md: device %s already used in a RAID array!\n",
partition_name(dev));
return -EBUSY;
}
if (!mddev->sb) { if (!mddev->sb) {
/* expecting a device which has a superblock */ /* expecting a device which has a superblock */
rdev = md_import_device(dev, 1); rdev = md_import_device(dev, 1);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
printk(KERN_WARNING "md: md_import_device returned %ld\n", PTR_ERR(rdev)); printk(KERN_WARNING "md: md_import_device returned %ld\n", PTR_ERR(rdev));
return -EINVAL; return PTR_ERR(rdev);
} }
if (!list_empty(&mddev->disks)) { if (!list_empty(&mddev->disks)) {
mdk_rdev_t *rdev0 = list_entry(mddev->disks.next, mdk_rdev_t *rdev0 = list_entry(mddev->disks.next,
...@@ -2153,7 +2131,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) ...@@ -2153,7 +2131,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
rdev = md_import_device (dev, 0); rdev = md_import_device (dev, 0);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
printk(KERN_WARNING "md: error, md_import_device() returned %ld\n", PTR_ERR(rdev)); printk(KERN_WARNING "md: error, md_import_device() returned %ld\n", PTR_ERR(rdev));
return -EINVAL; return PTR_ERR(rdev);
} }
rdev->old_dev = dev; rdev->old_dev = dev;
rdev->desc_nr = info->number; rdev->desc_nr = info->number;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment