summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-table.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-11-13 11:55:17 +0100
committerTejun Heo <tj@kernel.org>2010-11-13 11:55:17 +0100
commite09b457bdb7e8d23fc54dcef0930ac697d8de895 (patch)
tree41035bf61a8acb08292d01c0f66e5450502688af /drivers/md/dm-table.c
parent37004c42f7240035bc2726c340c4efa726b4818e (diff)
downloadop-kernel-dev-e09b457bdb7e8d23fc54dcef0930ac697d8de895.zip
op-kernel-dev-e09b457bdb7e8d23fc54dcef0930ac697d8de895.tar.gz
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/dm-table.c')
-rw-r--r--drivers/md/dm-table.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 90267f8..2c876ff 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,
bdev = open_by_devnum(dev, d->dm_dev.mode);
if (IS_ERR(bdev))
return PTR_ERR(bdev);
- r = bd_claim_by_disk(bdev, _claim_ptr, dm_disk(md));
- if (r)
+
+ r = bd_claim(bdev, _claim_ptr);
+ if (r) {
blkdev_put(bdev, d->dm_dev.mode);
- else
- d->dm_dev.bdev = bdev;
- return r;
+ return r;
+ }
+
+ r = bd_link_disk_holder(bdev, dm_disk(md));
+ if (r) {
+ bd_release(bdev);
+ blkdev_put(bdev, d->dm_dev.mode);
+ return r;
+ }
+
+ d->dm_dev.bdev = bdev;
+ return 0;
}
/*
@@ -344,7 +354,8 @@ static void close_dev(struct dm_dev_internal *d, struct mapped_device *md)
if (!d->dm_dev.bdev)
return;
- bd_release_from_disk(d->dm_dev.bdev, dm_disk(md));
+ bd_unlink_disk_holder(d->dm_dev.bdev);
+ bd_release(d->dm_dev.bdev);
blkdev_put(d->dm_dev.bdev, d->dm_dev.mode);
d->dm_dev.bdev = NULL;
}
OpenPOWER on IntegriCloud