aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-08-08 17:58:52 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-16 12:16:44 -0500
commit306bb73d12f13684ffcd735838c3e6f7515ab626 (patch)
treed66d10a4ed03f325194a595a7b6e87d8c0f21206 /drivers
parent6de88d72927dc85297b3075024487313c4ba3a2e (diff)
fix the crap in dst/dcore
* don't reinvent the wheels, please - open_bdev_exclusive() is there for purpose * both open_by_devnum() and open_bdev_exclusive() return ERR_PTR(...) upon error, not NULL Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/dst/dcore.c46
1 files changed, 5 insertions, 41 deletions
diff --git a/drivers/staging/dst/dcore.c b/drivers/staging/dst/dcore.c
index fd5bd0ea1e0d..c83ca7e3d048 100644
--- a/drivers/staging/dst/dcore.c
+++ b/drivers/staging/dst/dcore.c
@@ -403,7 +403,7 @@ static void dst_node_cleanup(struct dst_node *n)
403 403
404 if (n->bdev) { 404 if (n->bdev) {
405 sync_blockdev(n->bdev); 405 sync_blockdev(n->bdev);
406 blkdev_put(n->bdev, FMODE_READ|FMODE_WRITE); 406 close_bdev_exclusive(n->bdev, FMODE_READ|FMODE_WRITE);
407 } 407 }
408 408
409 dst_state_lock(st); 409 dst_state_lock(st);
@@ -464,37 +464,6 @@ void dst_node_put(struct dst_node *n)
464} 464}
465 465
466/* 466/*
467 * This function finds devices major/minor numbers for given pathname.
468 */
469static int dst_lookup_device(const char *path, dev_t *dev)
470{
471 int err;
472 struct nameidata nd;
473 struct inode *inode;
474
475 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
476 if (err)
477 return err;
478
479 inode = nd.path.dentry->d_inode;
480 if (!inode) {
481 err = -ENOENT;
482 goto out;
483 }
484
485 if (!S_ISBLK(inode->i_mode)) {
486 err = -ENOTBLK;
487 goto out;
488 }
489
490 *dev = inode->i_rdev;
491
492out:
493 path_put(&nd.path);
494 return err;
495}
496
497/*
498 * Setting up export device: lookup by the name, get its size 467 * Setting up export device: lookup by the name, get its size
499 * and setup listening socket, which will accept clients, which 468 * and setup listening socket, which will accept clients, which
500 * will submit IO for given storage. 469 * will submit IO for given storage.
@@ -503,17 +472,12 @@ static int dst_setup_export(struct dst_node *n, struct dst_ctl *ctl,
503 struct dst_export_ctl *le) 472 struct dst_export_ctl *le)
504{ 473{
505 int err; 474 int err;
506 dev_t dev = 0; /* gcc likes to scream here */
507 475
508 snprintf(n->info->local, sizeof(n->info->local), "%s", le->device); 476 snprintf(n->info->local, sizeof(n->info->local), "%s", le->device);
509 477
510 err = dst_lookup_device(le->device, &dev); 478 n->bdev = open_bdev_exclusive(le->device, FMODE_READ|FMODE_WRITE, NULL);
511 if (err) 479 if (IS_ERR(n->bdev))
512 return err; 480 return PTR_ERR(n->bdev);
513
514 n->bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE);
515 if (!n->bdev)
516 return -ENODEV;
517 481
518 if (n->size != 0) 482 if (n->size != 0)
519 n->size = min_t(loff_t, n->bdev->bd_inode->i_size, n->size); 483 n->size = min_t(loff_t, n->bdev->bd_inode->i_size, n->size);
@@ -528,7 +492,7 @@ static int dst_setup_export(struct dst_node *n, struct dst_ctl *ctl,
528 return 0; 492 return 0;
529 493
530err_out_cleanup: 494err_out_cleanup:
531 blkdev_put(n->bdev, FMODE_READ|FMODE_WRITE); 495 close_bdev_exclusive(n->bdev, FMODE_READ|FMODE_WRITE);
532 n->bdev = NULL; 496 n->bdev = NULL;
533 497
534 return err; 498 return err;