aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2018-07-03 09:28:43 -0400
committerIlya Dryomov <idryomov@gmail.com>2018-08-02 15:26:11 -0400
commitc300156bc734796e251fa31b07dff2af2f572889 (patch)
tree7f2e5c1afdfe6d2df34255e5d7936fde76ffa494
parent2f56b6bae73b2d65ef4816ca89341facc53d3361 (diff)
rbd: pass rbd_spec into parse_rbd_opts_token()
In preparation for _pool_ns client option, make rbd_spec available inside parse_rbd_opts_token(). Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r--drivers/block/rbd.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 4e8949b88b05..df3fb58720c0 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -776,9 +776,14 @@ struct rbd_options {
776#define RBD_EXCLUSIVE_DEFAULT false 776#define RBD_EXCLUSIVE_DEFAULT false
777#define RBD_TRIM_DEFAULT true 777#define RBD_TRIM_DEFAULT true
778 778
779struct parse_rbd_opts_ctx {
780 struct rbd_spec *spec;
781 struct rbd_options *opts;
782};
783
779static int parse_rbd_opts_token(char *c, void *private) 784static int parse_rbd_opts_token(char *c, void *private)
780{ 785{
781 struct rbd_options *rbd_opts = private; 786 struct parse_rbd_opts_ctx *pctx = private;
782 substring_t argstr[MAX_OPT_ARGS]; 787 substring_t argstr[MAX_OPT_ARGS];
783 int token, intval, ret; 788 int token, intval, ret;
784 789
@@ -802,7 +807,7 @@ static int parse_rbd_opts_token(char *c, void *private)
802 pr_err("queue_depth out of range\n"); 807 pr_err("queue_depth out of range\n");
803 return -EINVAL; 808 return -EINVAL;
804 } 809 }
805 rbd_opts->queue_depth = intval; 810 pctx->opts->queue_depth = intval;
806 break; 811 break;
807 case Opt_lock_timeout: 812 case Opt_lock_timeout:
808 /* 0 is "wait forever" (i.e. infinite timeout) */ 813 /* 0 is "wait forever" (i.e. infinite timeout) */
@@ -810,22 +815,22 @@ static int parse_rbd_opts_token(char *c, void *private)
810 pr_err("lock_timeout out of range\n"); 815 pr_err("lock_timeout out of range\n");
811 return -EINVAL; 816 return -EINVAL;
812 } 817 }
813 rbd_opts->lock_timeout = msecs_to_jiffies(intval * 1000); 818 pctx->opts->lock_timeout = msecs_to_jiffies(intval * 1000);
814 break; 819 break;
815 case Opt_read_only: 820 case Opt_read_only:
816 rbd_opts->read_only = true; 821 pctx->opts->read_only = true;
817 break; 822 break;
818 case Opt_read_write: 823 case Opt_read_write:
819 rbd_opts->read_only = false; 824 pctx->opts->read_only = false;
820 break; 825 break;
821 case Opt_lock_on_read: 826 case Opt_lock_on_read:
822 rbd_opts->lock_on_read = true; 827 pctx->opts->lock_on_read = true;
823 break; 828 break;
824 case Opt_exclusive: 829 case Opt_exclusive:
825 rbd_opts->exclusive = true; 830 pctx->opts->exclusive = true;
826 break; 831 break;
827 case Opt_notrim: 832 case Opt_notrim:
828 rbd_opts->trim = false; 833 pctx->opts->trim = false;
829 break; 834 break;
830 default: 835 default:
831 /* libceph prints "bad option" msg */ 836 /* libceph prints "bad option" msg */
@@ -5146,8 +5151,7 @@ static int rbd_add_parse_args(const char *buf,
5146 const char *mon_addrs; 5151 const char *mon_addrs;
5147 char *snap_name; 5152 char *snap_name;
5148 size_t mon_addrs_size; 5153 size_t mon_addrs_size;
5149 struct rbd_spec *spec = NULL; 5154 struct parse_rbd_opts_ctx pctx = { 0 };
5150 struct rbd_options *rbd_opts = NULL;
5151 struct ceph_options *copts; 5155 struct ceph_options *copts;
5152 int ret; 5156 int ret;
5153 5157
@@ -5171,22 +5175,22 @@ static int rbd_add_parse_args(const char *buf,
5171 goto out_err; 5175 goto out_err;
5172 } 5176 }
5173 5177
5174 spec = rbd_spec_alloc(); 5178 pctx.spec = rbd_spec_alloc();
5175 if (!spec) 5179 if (!pctx.spec)
5176 goto out_mem; 5180 goto out_mem;
5177 5181
5178 spec->pool_name = dup_token(&buf, NULL); 5182 pctx.spec->pool_name = dup_token(&buf, NULL);
5179 if (!spec->pool_name) 5183 if (!pctx.spec->pool_name)
5180 goto out_mem; 5184 goto out_mem;
5181 if (!*spec->pool_name) { 5185 if (!*pctx.spec->pool_name) {
5182 rbd_warn(NULL, "no pool name provided"); 5186 rbd_warn(NULL, "no pool name provided");
5183 goto out_err; 5187 goto out_err;
5184 } 5188 }
5185 5189
5186 spec->image_name = dup_token(&buf, NULL); 5190 pctx.spec->image_name = dup_token(&buf, NULL);
5187 if (!spec->image_name) 5191 if (!pctx.spec->image_name)
5188 goto out_mem; 5192 goto out_mem;
5189 if (!*spec->image_name) { 5193 if (!*pctx.spec->image_name) {
5190 rbd_warn(NULL, "no image name provided"); 5194 rbd_warn(NULL, "no image name provided");
5191 goto out_err; 5195 goto out_err;
5192 } 5196 }
@@ -5207,24 +5211,24 @@ static int rbd_add_parse_args(const char *buf,
5207 if (!snap_name) 5211 if (!snap_name)
5208 goto out_mem; 5212 goto out_mem;
5209 *(snap_name + len) = '\0'; 5213 *(snap_name + len) = '\0';
5210 spec->snap_name = snap_name; 5214 pctx.spec->snap_name = snap_name;
5211 5215
5212 /* Initialize all rbd options to the defaults */ 5216 /* Initialize all rbd options to the defaults */
5213 5217
5214 rbd_opts = kzalloc(sizeof (*rbd_opts), GFP_KERNEL); 5218 pctx.opts = kzalloc(sizeof(*pctx.opts), GFP_KERNEL);
5215 if (!rbd_opts) 5219 if (!pctx.opts)
5216 goto out_mem; 5220 goto out_mem;
5217 5221
5218 rbd_opts->read_only = RBD_READ_ONLY_DEFAULT; 5222 pctx.opts->read_only = RBD_READ_ONLY_DEFAULT;
5219 rbd_opts->queue_depth = RBD_QUEUE_DEPTH_DEFAULT; 5223 pctx.opts->queue_depth = RBD_QUEUE_DEPTH_DEFAULT;
5220 rbd_opts->lock_timeout = RBD_LOCK_TIMEOUT_DEFAULT; 5224 pctx.opts->lock_timeout = RBD_LOCK_TIMEOUT_DEFAULT;
5221 rbd_opts->lock_on_read = RBD_LOCK_ON_READ_DEFAULT; 5225 pctx.opts->lock_on_read = RBD_LOCK_ON_READ_DEFAULT;
5222 rbd_opts->exclusive = RBD_EXCLUSIVE_DEFAULT; 5226 pctx.opts->exclusive = RBD_EXCLUSIVE_DEFAULT;
5223 rbd_opts->trim = RBD_TRIM_DEFAULT; 5227 pctx.opts->trim = RBD_TRIM_DEFAULT;
5224 5228
5225 copts = ceph_parse_options(options, mon_addrs, 5229 copts = ceph_parse_options(options, mon_addrs,
5226 mon_addrs + mon_addrs_size - 1, 5230 mon_addrs + mon_addrs_size - 1,
5227 parse_rbd_opts_token, rbd_opts); 5231 parse_rbd_opts_token, &pctx);
5228 if (IS_ERR(copts)) { 5232 if (IS_ERR(copts)) {
5229 ret = PTR_ERR(copts); 5233 ret = PTR_ERR(copts);
5230 goto out_err; 5234 goto out_err;
@@ -5232,15 +5236,15 @@ static int rbd_add_parse_args(const char *buf,
5232 kfree(options); 5236 kfree(options);
5233 5237
5234 *ceph_opts = copts; 5238 *ceph_opts = copts;
5235 *opts = rbd_opts; 5239 *opts = pctx.opts;
5236 *rbd_spec = spec; 5240 *rbd_spec = pctx.spec;
5237 5241
5238 return 0; 5242 return 0;
5239out_mem: 5243out_mem:
5240 ret = -ENOMEM; 5244 ret = -ENOMEM;
5241out_err: 5245out_err:
5242 kfree(rbd_opts); 5246 kfree(pctx.opts);
5243 rbd_spec_put(spec); 5247 rbd_spec_put(pctx.spec);
5244 kfree(options); 5248 kfree(options);
5245 5249
5246 return ret; 5250 return ret;