aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJun'ichi Nomura <j-nomura@ce.jp.nec.com>2006-03-27 04:17:59 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-27 11:45:00 -0500
commitf165921df46a977e3561f1bd9f13a348441486d1 (patch)
treea44679427f97090aeb4d5ba62568a41f4b367763
parent5463c7904c952aa6b6804dd902c72a5332fa5221 (diff)
[PATCH] dm/md dependency tree in sysfs: dm to use bd_claim_by_disk
Use bd_claim_by_disk. Following symlinks are created if dm-0 maps to sda: /sys/block/dm-0/slaves/sda --> /sys/block/sda /sys/block/sda/holders/dm-0 --> /sys/block/dm-0 Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com> Cc: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/md/dm-table.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 84f4594afd3c..76610a6ac01c 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -350,7 +350,7 @@ static struct dm_dev *find_device(struct list_head *l, dev_t dev)
350/* 350/*
351 * Open a device so we can use it as a map destination. 351 * Open a device so we can use it as a map destination.
352 */ 352 */
353static int open_dev(struct dm_dev *d, dev_t dev) 353static int open_dev(struct dm_dev *d, dev_t dev, struct mapped_device *md)
354{ 354{
355 static char *_claim_ptr = "I belong to device-mapper"; 355 static char *_claim_ptr = "I belong to device-mapper";
356 struct block_device *bdev; 356 struct block_device *bdev;
@@ -362,7 +362,7 @@ static int open_dev(struct dm_dev *d, dev_t dev)
362 bdev = open_by_devnum(dev, d->mode); 362 bdev = open_by_devnum(dev, d->mode);
363 if (IS_ERR(bdev)) 363 if (IS_ERR(bdev))
364 return PTR_ERR(bdev); 364 return PTR_ERR(bdev);
365 r = bd_claim(bdev, _claim_ptr); 365 r = bd_claim_by_disk(bdev, _claim_ptr, dm_disk(md));
366 if (r) 366 if (r)
367 blkdev_put(bdev); 367 blkdev_put(bdev);
368 else 368 else
@@ -373,12 +373,12 @@ static int open_dev(struct dm_dev *d, dev_t dev)
373/* 373/*
374 * Close a device that we've been using. 374 * Close a device that we've been using.
375 */ 375 */
376static void close_dev(struct dm_dev *d) 376static void close_dev(struct dm_dev *d, struct mapped_device *md)
377{ 377{
378 if (!d->bdev) 378 if (!d->bdev)
379 return; 379 return;
380 380
381 bd_release(d->bdev); 381 bd_release_from_disk(d->bdev, dm_disk(md));
382 blkdev_put(d->bdev); 382 blkdev_put(d->bdev);
383 d->bdev = NULL; 383 d->bdev = NULL;
384} 384}
@@ -399,7 +399,7 @@ static int check_device_area(struct dm_dev *dd, sector_t start, sector_t len)
399 * careful to leave things as they were if we fail to reopen the 399 * careful to leave things as they were if we fail to reopen the
400 * device. 400 * device.
401 */ 401 */
402static int upgrade_mode(struct dm_dev *dd, int new_mode) 402static int upgrade_mode(struct dm_dev *dd, int new_mode, struct mapped_device *md)
403{ 403{
404 int r; 404 int r;
405 struct dm_dev dd_copy; 405 struct dm_dev dd_copy;
@@ -409,9 +409,9 @@ static int upgrade_mode(struct dm_dev *dd, int new_mode)
409 409
410 dd->mode |= new_mode; 410 dd->mode |= new_mode;
411 dd->bdev = NULL; 411 dd->bdev = NULL;
412 r = open_dev(dd, dev); 412 r = open_dev(dd, dev, md);
413 if (!r) 413 if (!r)
414 close_dev(&dd_copy); 414 close_dev(&dd_copy, md);
415 else 415 else
416 *dd = dd_copy; 416 *dd = dd_copy;
417 417
@@ -453,7 +453,7 @@ static int __table_get_device(struct dm_table *t, struct dm_target *ti,
453 dd->mode = mode; 453 dd->mode = mode;
454 dd->bdev = NULL; 454 dd->bdev = NULL;
455 455
456 if ((r = open_dev(dd, dev))) { 456 if ((r = open_dev(dd, dev, t->md))) {
457 kfree(dd); 457 kfree(dd);
458 return r; 458 return r;
459 } 459 }
@@ -464,7 +464,7 @@ static int __table_get_device(struct dm_table *t, struct dm_target *ti,
464 list_add(&dd->list, &t->devices); 464 list_add(&dd->list, &t->devices);
465 465
466 } else if (dd->mode != (mode | dd->mode)) { 466 } else if (dd->mode != (mode | dd->mode)) {
467 r = upgrade_mode(dd, mode); 467 r = upgrade_mode(dd, mode, t->md);
468 if (r) 468 if (r)
469 return r; 469 return r;
470 } 470 }
@@ -541,7 +541,7 @@ int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
541void dm_put_device(struct dm_target *ti, struct dm_dev *dd) 541void dm_put_device(struct dm_target *ti, struct dm_dev *dd)
542{ 542{
543 if (atomic_dec_and_test(&dd->count)) { 543 if (atomic_dec_and_test(&dd->count)) {
544 close_dev(dd); 544 close_dev(dd, ti->table->md);
545 list_del(&dd->list); 545 list_del(&dd->list);
546 kfree(dd); 546 kfree(dd);
547 } 547 }