aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-10-26 00:34:41 -0400
committerAlex Elder <elder@inktank.com>2012-10-30 09:34:29 -0400
commit4e9afeba7aa9ca925a79d9ce82f1a8e79e14c291 (patch)
treed3abf30668d74c4e3cc92fc4e427aeec989a4475 /drivers/block/rbd.c
parent819d52bf72b61a8455024ff7863eed5d681e73c7 (diff)
rbd: pass and populate rbd_options structure
Have the caller pass the address of an rbd_options structure to rbd_add_parse_args(), to be initialized with the information gleaned as a result of the parse. I know, this is another near-reversal of a recent change... Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index ae16cf615f02..338cfadad63f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2842,15 +2842,16 @@ static inline char *dup_token(const char **buf, size_t *lenp)
2842 * Note: rbd_dev is assumed to have been initially zero-filled. 2842 * Note: rbd_dev is assumed to have been initially zero-filled.
2843 */ 2843 */
2844static struct ceph_options *rbd_add_parse_args(struct rbd_device *rbd_dev, 2844static struct ceph_options *rbd_add_parse_args(struct rbd_device *rbd_dev,
2845 const char *buf) 2845 const char *buf,
2846 struct rbd_options **opts)
2846{ 2847{
2847 size_t len; 2848 size_t len;
2848 const char *mon_addrs; 2849 const char *mon_addrs;
2849 size_t mon_addrs_size; 2850 size_t mon_addrs_size;
2850 char *options; 2851 char *options;
2851 struct ceph_options *err_ptr = ERR_PTR(-EINVAL); 2852 struct ceph_options *err_ptr = ERR_PTR(-EINVAL);
2852 struct rbd_options rbd_opts;
2853 struct ceph_options *ceph_opts; 2853 struct ceph_options *ceph_opts;
2854 struct rbd_options *rbd_opts = NULL;
2854 2855
2855 /* The first four tokens are required */ 2856 /* The first four tokens are required */
2856 2857
@@ -2899,17 +2900,17 @@ static struct ceph_options *rbd_add_parse_args(struct rbd_device *rbd_dev,
2899 2900
2900 /* Initialize all rbd options to the defaults */ 2901 /* Initialize all rbd options to the defaults */
2901 2902
2902 rbd_opts.read_only = RBD_READ_ONLY_DEFAULT; 2903 rbd_opts = kzalloc(sizeof (*rbd_opts), GFP_KERNEL);
2904 if (!rbd_opts)
2905 goto out_mem;
2906
2907 rbd_opts->read_only = RBD_READ_ONLY_DEFAULT;
2903 2908
2904 ceph_opts = ceph_parse_options(options, mon_addrs, 2909 ceph_opts = ceph_parse_options(options, mon_addrs,
2905 mon_addrs + mon_addrs_size - 1, 2910 mon_addrs + mon_addrs_size - 1,
2906 parse_rbd_opts_token, &rbd_opts); 2911 parse_rbd_opts_token, rbd_opts);
2907 kfree(options); 2912 kfree(options);
2908 2913 *opts = rbd_opts;
2909 /* Record the parsed rbd options */
2910
2911 if (!IS_ERR(ceph_opts))
2912 rbd_dev->mapping.read_only = rbd_opts.read_only;
2913 2914
2914 return ceph_opts; 2915 return ceph_opts;
2915out_mem: 2916out_mem:
@@ -3131,6 +3132,7 @@ static ssize_t rbd_add(struct bus_type *bus,
3131{ 3132{
3132 struct rbd_device *rbd_dev = NULL; 3133 struct rbd_device *rbd_dev = NULL;
3133 struct ceph_options *ceph_opts; 3134 struct ceph_options *ceph_opts;
3135 struct rbd_options *rbd_opts = NULL;
3134 struct ceph_osd_client *osdc; 3136 struct ceph_osd_client *osdc;
3135 int rc = -ENOMEM; 3137 int rc = -ENOMEM;
3136 3138
@@ -3139,7 +3141,7 @@ static ssize_t rbd_add(struct bus_type *bus,
3139 3141
3140 rbd_dev = kzalloc(sizeof(*rbd_dev), GFP_KERNEL); 3142 rbd_dev = kzalloc(sizeof(*rbd_dev), GFP_KERNEL);
3141 if (!rbd_dev) 3143 if (!rbd_dev)
3142 goto err_out_mem; 3144 return -ENOMEM;
3143 3145
3144 /* static rbd_device initialization */ 3146 /* static rbd_device initialization */
3145 spin_lock_init(&rbd_dev->lock); 3147 spin_lock_init(&rbd_dev->lock);
@@ -3148,11 +3150,12 @@ static ssize_t rbd_add(struct bus_type *bus,
3148 init_rwsem(&rbd_dev->header_rwsem); 3150 init_rwsem(&rbd_dev->header_rwsem);
3149 3151
3150 /* parse add command */ 3152 /* parse add command */
3151 ceph_opts = rbd_add_parse_args(rbd_dev, buf); 3153 ceph_opts = rbd_add_parse_args(rbd_dev, buf, &rbd_opts);
3152 if (IS_ERR(ceph_opts)) { 3154 if (IS_ERR(ceph_opts)) {
3153 rc = PTR_ERR(ceph_opts); 3155 rc = PTR_ERR(ceph_opts);
3154 goto err_out_mem; 3156 goto err_out_mem;
3155 } 3157 }
3158 rbd_dev->mapping.read_only = rbd_opts->read_only;
3156 3159
3157 rc = rbd_get_client(rbd_dev, ceph_opts); 3160 rc = rbd_get_client(rbd_dev, ceph_opts);
3158 if (rc < 0) 3161 if (rc < 0)
@@ -3219,6 +3222,8 @@ static ssize_t rbd_add(struct bus_type *bus,
3219 if (rc) 3222 if (rc)
3220 goto err_out_bus; 3223 goto err_out_bus;
3221 3224
3225 kfree(rbd_opts);
3226
3222 /* Everything's ready. Announce the disk to the world. */ 3227 /* Everything's ready. Announce the disk to the world. */
3223 3228
3224 add_disk(rbd_dev->disk); 3229 add_disk(rbd_dev->disk);
@@ -3232,6 +3237,8 @@ err_out_bus:
3232 /* this will also clean up rest of rbd_dev stuff */ 3237 /* this will also clean up rest of rbd_dev stuff */
3233 3238
3234 rbd_bus_del_dev(rbd_dev); 3239 rbd_bus_del_dev(rbd_dev);
3240 kfree(rbd_opts);
3241
3235 return rc; 3242 return rc;
3236 3243
3237err_out_disk: 3244err_out_disk:
@@ -3254,6 +3261,7 @@ err_out_args:
3254 kfree(rbd_dev->snap_name); 3261 kfree(rbd_dev->snap_name);
3255 kfree(rbd_dev->image_name); 3262 kfree(rbd_dev->image_name);
3256 kfree(rbd_dev->pool_name); 3263 kfree(rbd_dev->pool_name);
3264 kfree(rbd_opts);
3257err_out_mem: 3265err_out_mem:
3258 kfree(rbd_dev); 3266 kfree(rbd_dev);
3259 3267