diff options
author | Tejun Heo <tj@kernel.org> | 2010-11-13 05:55:17 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2010-11-13 05:55:17 -0500 |
commit | e09b457bdb7e8d23fc54dcef0930ac697d8de895 (patch) | |
tree | 41035bf61a8acb08292d01c0f66e5450502688af /drivers/md | |
parent | 37004c42f7240035bc2726c340c4efa726b4818e (diff) |
block: simplify holder symlink handling
Code to manage symlinks in /sys/block/*/{holders|slaves} are overly
complex with multiple holder considerations, redundant extra
references to all involved kobjects, unused generic kobject holder
support and unnecessary mixup with bd_claim/release functionalities.
Strip it down to what's necessary (single gendisk holder) and make it
use a separate interface. This is a step for cleaning up
bd_claim/release. This patch makes dm-table slightly more complex but
it will be simplified again with further changes.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Neil Brown <neilb@suse.de>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Cc: dm-devel@redhat.com
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-table.c | 23 | ||||
-rw-r--r-- | drivers/md/md.c | 4 |
2 files changed, 19 insertions, 8 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 90267f8d64ee..2c876ffc63df 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -328,12 +328,22 @@ static int open_dev(struct dm_dev_internal *d, dev_t dev, | |||
328 | bdev = open_by_devnum(dev, d->dm_dev.mode); | 328 | bdev = open_by_devnum(dev, d->dm_dev.mode); |
329 | if (IS_ERR(bdev)) | 329 | if (IS_ERR(bdev)) |
330 | return PTR_ERR(bdev); | 330 | return PTR_ERR(bdev); |
331 | r = bd_claim_by_disk(bdev, _claim_ptr, dm_disk(md)); | 331 | |
332 | if (r) | 332 | r = bd_claim(bdev, _claim_ptr); |
333 | if (r) { | ||
333 | blkdev_put(bdev, d->dm_dev.mode); | 334 | blkdev_put(bdev, d->dm_dev.mode); |
334 | else | 335 | return r; |
335 | d->dm_dev.bdev = bdev; | 336 | } |
336 | return r; | 337 | |
338 | r = bd_link_disk_holder(bdev, dm_disk(md)); | ||
339 | if (r) { | ||
340 | bd_release(bdev); | ||
341 | blkdev_put(bdev, d->dm_dev.mode); | ||
342 | return r; | ||
343 | } | ||
344 | |||
345 | d->dm_dev.bdev = bdev; | ||
346 | return 0; | ||
337 | } | 347 | } |
338 | 348 | ||
339 | /* | 349 | /* |
@@ -344,7 +354,8 @@ static void close_dev(struct dm_dev_internal *d, struct mapped_device *md) | |||
344 | if (!d->dm_dev.bdev) | 354 | if (!d->dm_dev.bdev) |
345 | return; | 355 | return; |
346 | 356 | ||
347 | bd_release_from_disk(d->dm_dev.bdev, dm_disk(md)); | 357 | bd_unlink_disk_holder(d->dm_dev.bdev); |
358 | bd_release(d->dm_dev.bdev); | ||
348 | blkdev_put(d->dm_dev.bdev, d->dm_dev.mode); | 359 | blkdev_put(d->dm_dev.bdev, d->dm_dev.mode); |
349 | d->dm_dev.bdev = NULL; | 360 | d->dm_dev.bdev = NULL; |
350 | } | 361 | } |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 4e957f3140a8..c47644fca1a1 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1880,7 +1880,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1880 | rdev->sysfs_state = sysfs_get_dirent_safe(rdev->kobj.sd, "state"); | 1880 | rdev->sysfs_state = sysfs_get_dirent_safe(rdev->kobj.sd, "state"); |
1881 | 1881 | ||
1882 | list_add_rcu(&rdev->same_set, &mddev->disks); | 1882 | list_add_rcu(&rdev->same_set, &mddev->disks); |
1883 | bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk); | 1883 | bd_link_disk_holder(rdev->bdev, mddev->gendisk); |
1884 | 1884 | ||
1885 | /* May as well allow recovery to be retried once */ | 1885 | /* May as well allow recovery to be retried once */ |
1886 | mddev->recovery_disabled = 0; | 1886 | mddev->recovery_disabled = 0; |
@@ -1907,7 +1907,7 @@ static void unbind_rdev_from_array(mdk_rdev_t * rdev) | |||
1907 | MD_BUG(); | 1907 | MD_BUG(); |
1908 | return; | 1908 | return; |
1909 | } | 1909 | } |
1910 | bd_release_from_disk(rdev->bdev, rdev->mddev->gendisk); | 1910 | bd_unlink_disk_holder(rdev->bdev); |
1911 | list_del_rcu(&rdev->same_set); | 1911 | list_del_rcu(&rdev->same_set); |
1912 | printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b)); | 1912 | printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b)); |
1913 | rdev->mddev = NULL; | 1913 | rdev->mddev = NULL; |