aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-10-26 00:34:42 -0400
committerAlex Elder <elder@inktank.com>2012-11-01 08:55:42 -0400
commit9d3997fdf4c82adfb37a4886a21eaa513ee071b6 (patch)
tree99f40b6a590525dcce9520ca07a622f725f007ed /drivers/block
parent859c31df9cee9d1e1308b3b024b61355e6a629a5 (diff)
rbd: don't pass rbd_dev to rbd_get_client()
The only reason rbd_dev is passed to rbd_get_client() is so its rbd_client field can get assigned. Instead, just return the rbd_client pointer as a result and have the caller do the assignment. Change rbd_put_client() so it takes an rbd_client structure, so follows the more typical symmetry with rbd_get_client(). Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index be85d925dfdb..a528d4ca7a67 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -467,23 +467,17 @@ static int parse_rbd_opts_token(char *c, void *private)
467 * Get a ceph client with specific addr and configuration, if one does 467 * Get a ceph client with specific addr and configuration, if one does
468 * not exist create it. 468 * not exist create it.
469 */ 469 */
470static int rbd_get_client(struct rbd_device *rbd_dev, 470static struct rbd_client *rbd_get_client(struct ceph_options *ceph_opts)
471 struct ceph_options *ceph_opts)
472{ 471{
473 struct rbd_client *rbdc; 472 struct rbd_client *rbdc;
474 473
475 rbdc = rbd_client_find(ceph_opts); 474 rbdc = rbd_client_find(ceph_opts);
476 if (rbdc) { 475 if (rbdc) /* using an existing client */
477 /* using an existing client */
478 ceph_destroy_options(ceph_opts); 476 ceph_destroy_options(ceph_opts);
479 } else { 477 else
480 rbdc = rbd_client_create(ceph_opts); 478 rbdc = rbd_client_create(ceph_opts);
481 if (IS_ERR(rbdc))
482 return PTR_ERR(rbdc);
483 }
484 rbd_dev->rbd_client = rbdc;
485 479
486 return 0; 480 return rbdc;
487} 481}
488 482
489/* 483/*
@@ -508,10 +502,9 @@ static void rbd_client_release(struct kref *kref)
508 * Drop reference to ceph client node. If it's not referenced anymore, release 502 * Drop reference to ceph client node. If it's not referenced anymore, release
509 * it. 503 * it.
510 */ 504 */
511static void rbd_put_client(struct rbd_device *rbd_dev) 505static void rbd_put_client(struct rbd_client *rbdc)
512{ 506{
513 kref_put(&rbd_dev->rbd_client->kref, rbd_client_release); 507 kref_put(&rbdc->kref, rbd_client_release);
514 rbd_dev->rbd_client = NULL;
515} 508}
516 509
517/* 510/*
@@ -3232,6 +3225,7 @@ static ssize_t rbd_add(struct bus_type *bus,
3232 struct ceph_options *ceph_opts = NULL; 3225 struct ceph_options *ceph_opts = NULL;
3233 struct rbd_options *rbd_opts = NULL; 3226 struct rbd_options *rbd_opts = NULL;
3234 struct rbd_spec *spec = NULL; 3227 struct rbd_spec *spec = NULL;
3228 struct rbd_client *rbdc;
3235 struct ceph_osd_client *osdc; 3229 struct ceph_osd_client *osdc;
3236 int rc = -ENOMEM; 3230 int rc = -ENOMEM;
3237 3231
@@ -3255,13 +3249,16 @@ static ssize_t rbd_add(struct bus_type *bus,
3255 3249
3256 rbd_dev->mapping.read_only = rbd_opts->read_only; 3250 rbd_dev->mapping.read_only = rbd_opts->read_only;
3257 3251
3258 rc = rbd_get_client(rbd_dev, ceph_opts); 3252 rbdc = rbd_get_client(ceph_opts);
3259 if (rc < 0) 3253 if (IS_ERR(rbdc)) {
3254 rc = PTR_ERR(rbdc);
3260 goto err_out_args; 3255 goto err_out_args;
3256 }
3257 rbd_dev->rbd_client = rbdc;
3261 ceph_opts = NULL; /* ceph_opts now owned by rbd_dev client */ 3258 ceph_opts = NULL; /* ceph_opts now owned by rbd_dev client */
3262 3259
3263 /* pick the pool */ 3260 /* pick the pool */
3264 osdc = &rbd_dev->rbd_client->client->osdc; 3261 osdc = &rbdc->client->osdc;
3265 rc = ceph_pg_poolid_by_name(osdc->osdmap, spec->pool_name); 3262 rc = ceph_pg_poolid_by_name(osdc->osdmap, spec->pool_name);
3266 if (rc < 0) 3263 if (rc < 0)
3267 goto err_out_client; 3264 goto err_out_client;
@@ -3353,7 +3350,7 @@ err_out_probe:
3353 rbd_header_free(&rbd_dev->header); 3350 rbd_header_free(&rbd_dev->header);
3354err_out_client: 3351err_out_client:
3355 kfree(rbd_dev->header_name); 3352 kfree(rbd_dev->header_name);
3356 rbd_put_client(rbd_dev); 3353 rbd_put_client(rbdc);
3357err_out_args: 3354err_out_args:
3358 if (ceph_opts) 3355 if (ceph_opts)
3359 ceph_destroy_options(ceph_opts); 3356 ceph_destroy_options(ceph_opts);
@@ -3398,7 +3395,7 @@ static void rbd_dev_release(struct device *dev)
3398 if (rbd_dev->watch_event) 3395 if (rbd_dev->watch_event)
3399 rbd_req_sync_unwatch(rbd_dev); 3396 rbd_req_sync_unwatch(rbd_dev);
3400 3397
3401 rbd_put_client(rbd_dev); 3398 rbd_put_client(rbd_dev->rbd_client);
3402 3399
3403 /* clean up and free blkdev */ 3400 /* clean up and free blkdev */
3404 rbd_free_disk(rbd_dev); 3401 rbd_free_disk(rbd_dev);