提交 5214ecc4 编写于 作者: A Alex Elder

rbd: have rbd_parse_args() report found mon_addrs size

The argument parsing routine already computes the size of the
mon_addrs buffer it extracts from the "command."  Pass it to the
caller so it can use it to provide the length to rbd_get_client().
Signed-off-by: NAlex Elder <elder@dreamhost.com>
上级 81a89793
...@@ -391,7 +391,9 @@ static int parse_rbd_opts_token(char *c, void *private) ...@@ -391,7 +391,9 @@ static int parse_rbd_opts_token(char *c, void *private)
* Get a ceph client with specific addr and configuration, if one does * Get a ceph client with specific addr and configuration, if one does
* not exist create it. * not exist create it.
*/ */
static struct rbd_client *rbd_get_client(const char *mon_addr, char *options) static struct rbd_client *rbd_get_client(const char *mon_addr,
size_t mon_addr_len,
char *options)
{ {
struct rbd_client *rbdc; struct rbd_client *rbdc;
struct ceph_options *opt; struct ceph_options *opt;
...@@ -404,7 +406,7 @@ static struct rbd_client *rbd_get_client(const char *mon_addr, char *options) ...@@ -404,7 +406,7 @@ static struct rbd_client *rbd_get_client(const char *mon_addr, char *options)
rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT; rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT;
opt = ceph_parse_options(options, mon_addr, opt = ceph_parse_options(options, mon_addr,
mon_addr + strlen(mon_addr), mon_addr + mon_addr_len,
parse_rbd_opts_token, rbd_opts); parse_rbd_opts_token, rbd_opts);
if (IS_ERR(opt)) { if (IS_ERR(opt)) {
kfree(rbd_opts); kfree(rbd_opts);
...@@ -2283,7 +2285,7 @@ static inline size_t copy_token(const char **buf, ...@@ -2283,7 +2285,7 @@ static inline size_t copy_token(const char **buf,
static int rbd_add_parse_args(struct rbd_device *rbd_dev, static int rbd_add_parse_args(struct rbd_device *rbd_dev,
const char *buf, const char *buf,
char *mon_addrs, char *mon_addrs,
size_t mon_addrs_size, size_t *mon_addrs_size,
char *options, char *options,
size_t options_size) size_t options_size)
{ {
...@@ -2291,9 +2293,10 @@ static int rbd_add_parse_args(struct rbd_device *rbd_dev, ...@@ -2291,9 +2293,10 @@ static int rbd_add_parse_args(struct rbd_device *rbd_dev,
/* The first four tokens are required */ /* The first four tokens are required */
len = copy_token(&buf, mon_addrs, mon_addrs_size); len = copy_token(&buf, mon_addrs, *mon_addrs_size);
if (!len || len >= mon_addrs_size) if (!len || len >= *mon_addrs_size)
return -EINVAL; return -EINVAL;
*mon_addrs_size = len + 1;
len = copy_token(&buf, options, options_size); len = copy_token(&buf, options, options_size);
if (!len || len >= options_size) if (!len || len >= options_size)
...@@ -2335,6 +2338,7 @@ static ssize_t rbd_add(struct bus_type *bus, ...@@ -2335,6 +2338,7 @@ static ssize_t rbd_add(struct bus_type *bus,
{ {
struct rbd_device *rbd_dev; struct rbd_device *rbd_dev;
char *mon_addrs = NULL; char *mon_addrs = NULL;
size_t mon_addrs_size;
char *options = NULL; char *options = NULL;
struct ceph_osd_client *osdc; struct ceph_osd_client *osdc;
int rc = -ENOMEM; int rc = -ENOMEM;
...@@ -2368,12 +2372,14 @@ static ssize_t rbd_add(struct bus_type *bus, ...@@ -2368,12 +2372,14 @@ static ssize_t rbd_add(struct bus_type *bus,
sprintf(rbd_dev->name, "%s%d", RBD_DRV_NAME, rbd_dev->id); sprintf(rbd_dev->name, "%s%d", RBD_DRV_NAME, rbd_dev->id);
/* parse add command */ /* parse add command */
rc = rbd_add_parse_args(rbd_dev, buf, mon_addrs, count, mon_addrs_size = count;
rc = rbd_add_parse_args(rbd_dev, buf, mon_addrs, &mon_addrs_size,
options, count); options, count);
if (rc) if (rc)
goto err_put_id; goto err_put_id;
rbd_dev->rbd_client = rbd_get_client(mon_addrs, options); rbd_dev->rbd_client = rbd_get_client(mon_addrs, mon_addrs_size - 1,
options);
if (IS_ERR(rbd_dev->rbd_client)) { if (IS_ERR(rbd_dev->rbd_client)) {
rc = PTR_ERR(rbd_dev->rbd_client); rc = PTR_ERR(rbd_dev->rbd_client);
goto err_put_id; goto err_put_id;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册