diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2015-06-22 06:24:48 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2015-06-25 11:30:55 -0400 |
commit | d147543d7943eaa549a569143b7815482585fb91 (patch) | |
tree | f83b24ac438c29e9661907746ba9e0716cc36ec2 | |
parent | 210c104c544e5be321fc5b78e74b596d36820332 (diff) |
rbd: store rbd_options in rbd_device
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
-rw-r--r-- | drivers/block/rbd.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4de8c9167c4b..e502bce02d2c 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -346,6 +346,7 @@ struct rbd_device { | |||
346 | struct rbd_image_header header; | 346 | struct rbd_image_header header; |
347 | unsigned long flags; /* possibly lock protected */ | 347 | unsigned long flags; /* possibly lock protected */ |
348 | struct rbd_spec *spec; | 348 | struct rbd_spec *spec; |
349 | struct rbd_options *opts; | ||
349 | 350 | ||
350 | char *header_name; | 351 | char *header_name; |
351 | 352 | ||
@@ -4055,7 +4056,8 @@ static void rbd_spec_free(struct kref *kref) | |||
4055 | } | 4056 | } |
4056 | 4057 | ||
4057 | static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc, | 4058 | static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc, |
4058 | struct rbd_spec *spec) | 4059 | struct rbd_spec *spec, |
4060 | struct rbd_options *opts) | ||
4059 | { | 4061 | { |
4060 | struct rbd_device *rbd_dev; | 4062 | struct rbd_device *rbd_dev; |
4061 | 4063 | ||
@@ -4069,8 +4071,9 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc, | |||
4069 | INIT_LIST_HEAD(&rbd_dev->node); | 4071 | INIT_LIST_HEAD(&rbd_dev->node); |
4070 | init_rwsem(&rbd_dev->header_rwsem); | 4072 | init_rwsem(&rbd_dev->header_rwsem); |
4071 | 4073 | ||
4072 | rbd_dev->spec = spec; | ||
4073 | rbd_dev->rbd_client = rbdc; | 4074 | rbd_dev->rbd_client = rbdc; |
4075 | rbd_dev->spec = spec; | ||
4076 | rbd_dev->opts = opts; | ||
4074 | 4077 | ||
4075 | /* Initialize the layout used for all rbd requests */ | 4078 | /* Initialize the layout used for all rbd requests */ |
4076 | 4079 | ||
@@ -4086,6 +4089,7 @@ static void rbd_dev_destroy(struct rbd_device *rbd_dev) | |||
4086 | { | 4089 | { |
4087 | rbd_put_client(rbd_dev->rbd_client); | 4090 | rbd_put_client(rbd_dev->rbd_client); |
4088 | rbd_spec_put(rbd_dev->spec); | 4091 | rbd_spec_put(rbd_dev->spec); |
4092 | kfree(rbd_dev->opts); | ||
4089 | kfree(rbd_dev); | 4093 | kfree(rbd_dev); |
4090 | } | 4094 | } |
4091 | 4095 | ||
@@ -5160,7 +5164,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev) | |||
5160 | rbdc = __rbd_get_client(rbd_dev->rbd_client); | 5164 | rbdc = __rbd_get_client(rbd_dev->rbd_client); |
5161 | 5165 | ||
5162 | ret = -ENOMEM; | 5166 | ret = -ENOMEM; |
5163 | parent = rbd_dev_create(rbdc, parent_spec); | 5167 | parent = rbd_dev_create(rbdc, parent_spec, NULL); |
5164 | if (!parent) | 5168 | if (!parent) |
5165 | goto out_err; | 5169 | goto out_err; |
5166 | 5170 | ||
@@ -5406,9 +5410,6 @@ static ssize_t do_rbd_add(struct bus_type *bus, | |||
5406 | rc = rbd_add_parse_args(buf, &ceph_opts, &rbd_opts, &spec); | 5410 | rc = rbd_add_parse_args(buf, &ceph_opts, &rbd_opts, &spec); |
5407 | if (rc < 0) | 5411 | if (rc < 0) |
5408 | goto err_out_module; | 5412 | goto err_out_module; |
5409 | read_only = rbd_opts->read_only; | ||
5410 | kfree(rbd_opts); | ||
5411 | rbd_opts = NULL; /* done with this */ | ||
5412 | 5413 | ||
5413 | rbdc = rbd_get_client(ceph_opts); | 5414 | rbdc = rbd_get_client(ceph_opts); |
5414 | if (IS_ERR(rbdc)) { | 5415 | if (IS_ERR(rbdc)) { |
@@ -5434,11 +5435,12 @@ static ssize_t do_rbd_add(struct bus_type *bus, | |||
5434 | goto err_out_client; | 5435 | goto err_out_client; |
5435 | } | 5436 | } |
5436 | 5437 | ||
5437 | rbd_dev = rbd_dev_create(rbdc, spec); | 5438 | rbd_dev = rbd_dev_create(rbdc, spec, rbd_opts); |
5438 | if (!rbd_dev) | 5439 | if (!rbd_dev) |
5439 | goto err_out_client; | 5440 | goto err_out_client; |
5440 | rbdc = NULL; /* rbd_dev now owns this */ | 5441 | rbdc = NULL; /* rbd_dev now owns this */ |
5441 | spec = NULL; /* rbd_dev now owns this */ | 5442 | spec = NULL; /* rbd_dev now owns this */ |
5443 | rbd_opts = NULL; /* rbd_dev now owns this */ | ||
5442 | 5444 | ||
5443 | rc = rbd_dev_image_probe(rbd_dev, true); | 5445 | rc = rbd_dev_image_probe(rbd_dev, true); |
5444 | if (rc < 0) | 5446 | if (rc < 0) |
@@ -5446,6 +5448,7 @@ static ssize_t do_rbd_add(struct bus_type *bus, | |||
5446 | 5448 | ||
5447 | /* If we are mapping a snapshot it must be marked read-only */ | 5449 | /* If we are mapping a snapshot it must be marked read-only */ |
5448 | 5450 | ||
5451 | read_only = rbd_dev->opts->read_only; | ||
5449 | if (rbd_dev->spec->snap_id != CEPH_NOSNAP) | 5452 | if (rbd_dev->spec->snap_id != CEPH_NOSNAP) |
5450 | read_only = true; | 5453 | read_only = true; |
5451 | rbd_dev->mapping.read_only = read_only; | 5454 | rbd_dev->mapping.read_only = read_only; |
@@ -5470,6 +5473,7 @@ err_out_client: | |||
5470 | rbd_put_client(rbdc); | 5473 | rbd_put_client(rbdc); |
5471 | err_out_args: | 5474 | err_out_args: |
5472 | rbd_spec_put(spec); | 5475 | rbd_spec_put(spec); |
5476 | kfree(rbd_opts); | ||
5473 | err_out_module: | 5477 | err_out_module: |
5474 | module_put(THIS_MODULE); | 5478 | module_put(THIS_MODULE); |
5475 | 5479 | ||