提交 d147543d 编写于 作者: I Ilya Dryomov

rbd: store rbd_options in rbd_device

Signed-off-by: NIlya Dryomov <idryomov@gmail.com>
Reviewed-by: NAlex Elder <elder@linaro.org>
上级 210c104c
...@@ -346,6 +346,7 @@ struct rbd_device { ...@@ -346,6 +346,7 @@ struct rbd_device {
struct rbd_image_header header; struct rbd_image_header header;
unsigned long flags; /* possibly lock protected */ unsigned long flags; /* possibly lock protected */
struct rbd_spec *spec; struct rbd_spec *spec;
struct rbd_options *opts;
char *header_name; char *header_name;
...@@ -4055,7 +4056,8 @@ static void rbd_spec_free(struct kref *kref) ...@@ -4055,7 +4056,8 @@ static void rbd_spec_free(struct kref *kref)
} }
static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc, static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
struct rbd_spec *spec) struct rbd_spec *spec,
struct rbd_options *opts)
{ {
struct rbd_device *rbd_dev; struct rbd_device *rbd_dev;
...@@ -4069,8 +4071,9 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc, ...@@ -4069,8 +4071,9 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
INIT_LIST_HEAD(&rbd_dev->node); INIT_LIST_HEAD(&rbd_dev->node);
init_rwsem(&rbd_dev->header_rwsem); init_rwsem(&rbd_dev->header_rwsem);
rbd_dev->spec = spec;
rbd_dev->rbd_client = rbdc; rbd_dev->rbd_client = rbdc;
rbd_dev->spec = spec;
rbd_dev->opts = opts;
/* Initialize the layout used for all rbd requests */ /* Initialize the layout used for all rbd requests */
...@@ -4086,6 +4089,7 @@ static void rbd_dev_destroy(struct rbd_device *rbd_dev) ...@@ -4086,6 +4089,7 @@ static void rbd_dev_destroy(struct rbd_device *rbd_dev)
{ {
rbd_put_client(rbd_dev->rbd_client); rbd_put_client(rbd_dev->rbd_client);
rbd_spec_put(rbd_dev->spec); rbd_spec_put(rbd_dev->spec);
kfree(rbd_dev->opts);
kfree(rbd_dev); kfree(rbd_dev);
} }
...@@ -5160,7 +5164,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev) ...@@ -5160,7 +5164,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev)
rbdc = __rbd_get_client(rbd_dev->rbd_client); rbdc = __rbd_get_client(rbd_dev->rbd_client);
ret = -ENOMEM; ret = -ENOMEM;
parent = rbd_dev_create(rbdc, parent_spec); parent = rbd_dev_create(rbdc, parent_spec, NULL);
if (!parent) if (!parent)
goto out_err; goto out_err;
...@@ -5406,9 +5410,6 @@ static ssize_t do_rbd_add(struct bus_type *bus, ...@@ -5406,9 +5410,6 @@ static ssize_t do_rbd_add(struct bus_type *bus,
rc = rbd_add_parse_args(buf, &ceph_opts, &rbd_opts, &spec); rc = rbd_add_parse_args(buf, &ceph_opts, &rbd_opts, &spec);
if (rc < 0) if (rc < 0)
goto err_out_module; goto err_out_module;
read_only = rbd_opts->read_only;
kfree(rbd_opts);
rbd_opts = NULL; /* done with this */
rbdc = rbd_get_client(ceph_opts); rbdc = rbd_get_client(ceph_opts);
if (IS_ERR(rbdc)) { if (IS_ERR(rbdc)) {
...@@ -5434,11 +5435,12 @@ static ssize_t do_rbd_add(struct bus_type *bus, ...@@ -5434,11 +5435,12 @@ static ssize_t do_rbd_add(struct bus_type *bus,
goto err_out_client; goto err_out_client;
} }
rbd_dev = rbd_dev_create(rbdc, spec); rbd_dev = rbd_dev_create(rbdc, spec, rbd_opts);
if (!rbd_dev) if (!rbd_dev)
goto err_out_client; goto err_out_client;
rbdc = NULL; /* rbd_dev now owns this */ rbdc = NULL; /* rbd_dev now owns this */
spec = NULL; /* rbd_dev now owns this */ spec = NULL; /* rbd_dev now owns this */
rbd_opts = NULL; /* rbd_dev now owns this */
rc = rbd_dev_image_probe(rbd_dev, true); rc = rbd_dev_image_probe(rbd_dev, true);
if (rc < 0) if (rc < 0)
...@@ -5446,6 +5448,7 @@ static ssize_t do_rbd_add(struct bus_type *bus, ...@@ -5446,6 +5448,7 @@ static ssize_t do_rbd_add(struct bus_type *bus,
/* If we are mapping a snapshot it must be marked read-only */ /* If we are mapping a snapshot it must be marked read-only */
read_only = rbd_dev->opts->read_only;
if (rbd_dev->spec->snap_id != CEPH_NOSNAP) if (rbd_dev->spec->snap_id != CEPH_NOSNAP)
read_only = true; read_only = true;
rbd_dev->mapping.read_only = read_only; rbd_dev->mapping.read_only = read_only;
...@@ -5470,6 +5473,7 @@ static ssize_t do_rbd_add(struct bus_type *bus, ...@@ -5470,6 +5473,7 @@ static ssize_t do_rbd_add(struct bus_type *bus,
rbd_put_client(rbdc); rbd_put_client(rbdc);
err_out_args: err_out_args:
rbd_spec_put(spec); rbd_spec_put(spec);
kfree(rbd_opts);
err_out_module: err_out_module:
module_put(THIS_MODULE); module_put(THIS_MODULE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册