diff options
author | Alex Elder <elder@inktank.com> | 2012-10-26 00:34:41 -0400 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2012-10-30 09:34:29 -0400 |
commit | 78cea76e0580befaf561c6989f4fc985bc66c8f7 (patch) | |
tree | f2eea48bc6dc2264a1ae4d912bbec4298e16a14a /drivers/block | |
parent | daba5fdb4c469838dcee4b8dd4fecf7be69fa218 (diff) |
rbd: move ceph_parse_options() call up
Move option parsing out of rbd_get_client() and into its caller.
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.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 589f56542df0..e83bddcca34e 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -453,27 +453,11 @@ static int parse_rbd_opts_token(char *c, void *private) | |||
453 | * Get a ceph client with specific addr and configuration, if one does | 453 | * Get a ceph client with specific addr and configuration, if one does |
454 | * not exist create it. | 454 | * not exist create it. |
455 | */ | 455 | */ |
456 | static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr, | 456 | static int rbd_get_client(struct rbd_device *rbd_dev, |
457 | size_t mon_addr_len, char *options) | 457 | struct ceph_options *ceph_opts) |
458 | { | 458 | { |
459 | struct rbd_options rbd_opts; | ||
460 | struct ceph_options *ceph_opts; | ||
461 | struct rbd_client *rbdc; | 459 | struct rbd_client *rbdc; |
462 | 460 | ||
463 | /* Initialize all rbd options to the defaults */ | ||
464 | |||
465 | rbd_opts.read_only = RBD_READ_ONLY_DEFAULT; | ||
466 | |||
467 | ceph_opts = ceph_parse_options(options, mon_addr, | ||
468 | mon_addr + mon_addr_len, | ||
469 | parse_rbd_opts_token, &rbd_opts); | ||
470 | if (IS_ERR(ceph_opts)) | ||
471 | return PTR_ERR(ceph_opts); | ||
472 | |||
473 | /* Record the parsed rbd options */ | ||
474 | |||
475 | rbd_dev->mapping.read_only = rbd_opts.read_only; | ||
476 | |||
477 | rbdc = rbd_client_find(ceph_opts); | 461 | rbdc = rbd_client_find(ceph_opts); |
478 | if (rbdc) { | 462 | if (rbdc) { |
479 | /* using an existing client */ | 463 | /* using an existing client */ |
@@ -3132,9 +3116,11 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
3132 | struct rbd_device *rbd_dev = NULL; | 3116 | struct rbd_device *rbd_dev = NULL; |
3133 | const char *mon_addrs = NULL; | 3117 | const char *mon_addrs = NULL; |
3134 | size_t mon_addrs_size = 0; | 3118 | size_t mon_addrs_size = 0; |
3119 | char *snap_name; | ||
3120 | struct rbd_options rbd_opts; | ||
3121 | struct ceph_options *ceph_opts; | ||
3135 | struct ceph_osd_client *osdc; | 3122 | struct ceph_osd_client *osdc; |
3136 | int rc = -ENOMEM; | 3123 | int rc = -ENOMEM; |
3137 | char *snap_name; | ||
3138 | 3124 | ||
3139 | if (!try_module_get(THIS_MODULE)) | 3125 | if (!try_module_get(THIS_MODULE)) |
3140 | return -ENODEV; | 3126 | return -ENODEV; |
@@ -3160,9 +3146,26 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
3160 | goto err_out_mem; | 3146 | goto err_out_mem; |
3161 | } | 3147 | } |
3162 | 3148 | ||
3163 | rc = rbd_get_client(rbd_dev, mon_addrs, mon_addrs_size - 1, options); | 3149 | /* Initialize all rbd options to the defaults */ |
3164 | if (rc < 0) | 3150 | |
3151 | rbd_opts.read_only = RBD_READ_ONLY_DEFAULT; | ||
3152 | |||
3153 | ceph_opts = ceph_parse_options(options, mon_addrs, | ||
3154 | mon_addrs + mon_addrs_size - 1, | ||
3155 | parse_rbd_opts_token, &rbd_opts); | ||
3156 | if (IS_ERR(ceph_opts)) { | ||
3157 | rc = PTR_ERR(ceph_opts); | ||
3165 | goto err_out_args; | 3158 | goto err_out_args; |
3159 | } | ||
3160 | |||
3161 | /* Record the parsed rbd options */ | ||
3162 | |||
3163 | rbd_dev->mapping.read_only = rbd_opts.read_only; | ||
3164 | |||
3165 | rc = rbd_get_client(rbd_dev, ceph_opts); | ||
3166 | if (rc < 0) | ||
3167 | goto err_out_opts; | ||
3168 | ceph_opts = NULL; /* ceph_opts now owned by rbd_dev client */ | ||
3166 | 3169 | ||
3167 | /* pick the pool */ | 3170 | /* pick the pool */ |
3168 | osdc = &rbd_dev->rbd_client->client->osdc; | 3171 | osdc = &rbd_dev->rbd_client->client->osdc; |
@@ -3254,6 +3257,9 @@ err_out_client: | |||
3254 | kfree(rbd_dev->header_name); | 3257 | kfree(rbd_dev->header_name); |
3255 | rbd_put_client(rbd_dev); | 3258 | rbd_put_client(rbd_dev); |
3256 | kfree(rbd_dev->image_id); | 3259 | kfree(rbd_dev->image_id); |
3260 | err_out_opts: | ||
3261 | if (ceph_opts) | ||
3262 | ceph_destroy_options(ceph_opts); | ||
3257 | err_out_args: | 3263 | err_out_args: |
3258 | kfree(rbd_dev->snap_name); | 3264 | kfree(rbd_dev->snap_name); |
3259 | kfree(rbd_dev->image_name); | 3265 | kfree(rbd_dev->image_name); |