History

libceph, rbd, ceph: convert to use the new mount API

Convert the ceph filesystem to the new internal mount API as the old one will be obsoleted and removed. This allows greater flexibility in communication of mount parameters between userspace, the VFS and the filesystem. See Documentation/filesystems/mount_api.txt for more information. [ Numerous string handling, leak and regression fixes; rbd conversion was particularly broken and had to be redone almost from scratch. ]

David Howells committed 7 years ago

Commit 82995cc1 parent 196e2d68 files · +681 −673Browse files

Unified · Split

8 files
  1. drivers/block/rbd.c +153 −109
  2. fs/ceph/cache.c +5 −4
  3. fs/ceph/cache.h +3 −2
  4. fs/ceph/super.c +324 −322
  5. fs/ceph/super.h +0 −1
  6. include/linux/ceph/libceph.h +6 −4
  7. net/ceph/ceph_common.c +190 −229
  8. net/ceph/messenger.c +0 −2
drivers/block/rbd.c+153−109
@@ -34,7 +34,7 @@ · 33 unmodified lines
34#include <linux/ceph/cls_lock_client.h>34#include <linux/ceph/cls_lock_client.h>
35#include <linux/ceph/striper.h>35#include <linux/ceph/striper.h>
36#include <linux/ceph/decode.h>36#include <linux/ceph/decode.h>
37#include <linux/parser.h>37#include <linux/fs_parser.h>
38#include <linux/bsearch.h>38#include <linux/bsearch.h>
39 39
40#include <linux/kernel.h>40#include <linux/kernel.h>
@@ -838,34 +838,34 @@ enum { · 797 unmodified lines
838 Opt_queue_depth,838 Opt_queue_depth,
839 Opt_alloc_size,839 Opt_alloc_size,
840 Opt_lock_timeout,840 Opt_lock_timeout,
841 Opt_last_int,
842 /* int args above */841 /* int args above */
843 Opt_pool_ns,842 Opt_pool_ns,
844 Opt_last_string,
845 /* string args above */843 /* string args above */
846 Opt_read_only,844 Opt_read_only,
847 Opt_read_write,845 Opt_read_write,
848 Opt_lock_on_read,846 Opt_lock_on_read,
849 Opt_exclusive,847 Opt_exclusive,
850 Opt_notrim,848 Opt_notrim,
851 Opt_err
852};849};
853 850
854static match_table_t rbd_opts_tokens = {851static const struct fs_parameter_spec rbd_param_specs[] = {
855 {Opt_queue_depth, "queue_depth=%d"},852 fsparam_u32 ("alloc_size", Opt_alloc_size),
856 {Opt_alloc_size, "alloc_size=%d"},853 fsparam_flag ("exclusive", Opt_exclusive),
857 {Opt_lock_timeout, "lock_timeout=%d"},854 fsparam_flag ("lock_on_read", Opt_lock_on_read),
858 /* int args above */855 fsparam_u32 ("lock_timeout", Opt_lock_timeout),
859 {Opt_pool_ns, "_pool_ns=%s"},856 fsparam_flag ("notrim", Opt_notrim),
860 /* string args above */857 fsparam_string ("_pool_ns", Opt_pool_ns),
861 {Opt_read_only, "read_only"},858 fsparam_u32 ("queue_depth", Opt_queue_depth),
862 {Opt_read_only, "ro"}, /* Alternate spelling */859 fsparam_flag ("read_only", Opt_read_only),
863 {Opt_read_write, "read_write"},860 fsparam_flag ("read_write", Opt_read_write),
864 {Opt_read_write, "rw"}, /* Alternate spelling */861 fsparam_flag ("ro", Opt_read_only),
865 {Opt_lock_on_read, "lock_on_read"},862 fsparam_flag ("rw", Opt_read_write),
866 {Opt_exclusive, "exclusive"},863 {}
867 {Opt_notrim, "notrim"},864};
868 {Opt_err, NULL}865
866static const struct fs_parameter_description rbd_parameters = {
867 .name = "rbd",
868 .specs = rbd_param_specs,
869};869};
870 870
871struct rbd_options {871struct rbd_options {
@@ -886,87 +886,12 @@ struct rbd_options { · 14 unmodified lines
886#define RBD_EXCLUSIVE_DEFAULT false886#define RBD_EXCLUSIVE_DEFAULT false
887#define RBD_TRIM_DEFAULT true887#define RBD_TRIM_DEFAULT true
888 888
889struct parse_rbd_opts_ctx {889struct rbd_parse_opts_ctx {
890 struct rbd_spec *spec;890 struct rbd_spec *spec;
891 struct ceph_options *copts;
891 struct rbd_options *opts;892 struct rbd_options *opts;
892};893};
893 894
894static int parse_rbd_opts_token(char *c, void *private)
895{
896 struct parse_rbd_opts_ctx *pctx = private;
897 substring_t argstr[MAX_OPT_ARGS];
898 int token, intval, ret;
899
900 token = match_token(c, rbd_opts_tokens, argstr);
901 if (token < Opt_last_int) {
902 ret = match_int(&argstr[0], &intval);
903 if (ret < 0) {
904 pr_err("bad option arg (not int) at '%s'\n", c);
905 return ret;
906 }
907 dout("got int token %d val %d\n", token, intval);
908 } else if (token > Opt_last_int && token < Opt_last_string) {
909 dout("got string token %d val %s\n", token, argstr[0].from);
910 } else {
911 dout("got token %d\n", token);
912 }
913
914 switch (token) {
915 case Opt_queue_depth:
916 if (intval < 1) {
917 pr_err("queue_depth out of range\n");
918 return -EINVAL;
919 }
920 pctx->opts->queue_depth = intval;
921 break;
922 case Opt_alloc_size:
923 if (intval < SECTOR_SIZE) {
924 pr_err("alloc_size out of range\n");
925 return -EINVAL;
926 }
927 if (!is_power_of_2(intval)) {
928 pr_err("alloc_size must be a power of 2\n");
929 return -EINVAL;
930 }
931 pctx->opts->alloc_size = intval;
932 break;
933 case Opt_lock_timeout:
934 /* 0 is "wait forever" (i.e. infinite timeout) */
935 if (intval < 0 || intval > INT_MAX / 1000) {
936 pr_err("lock_timeout out of range\n");
937 return -EINVAL;
938 }
939 pctx->opts->lock_timeout = msecs_to_jiffies(intval * 1000);
940 break;
941 case Opt_pool_ns:
942 kfree(pctx->spec->pool_ns);
943 pctx->spec->pool_ns = match_strdup(argstr);
944 if (!pctx->spec->pool_ns)
945 return -ENOMEM;
946 break;
947 case Opt_read_only:
948 pctx->opts->read_only = true;
949 break;
950 case Opt_read_write:
951 pctx->opts->read_only = false;
952 break;
953 case Opt_lock_on_read:
954 pctx->opts->lock_on_read = true;
955 break;
956 case Opt_exclusive:
957 pctx->opts->exclusive = true;
958 break;
959 case Opt_notrim:
960 pctx->opts->trim = false;
961 break;
962 default:
963 /* libceph prints "bad option" msg */
964 return -EINVAL;
965 }
966
967 return 0;
968}
969
970static char* obj_op_name(enum obj_operation_type op_type)895static char* obj_op_name(enum obj_operation_type op_type)
971{896{
972 switch (op_type) {897 switch (op_type) {
@@ -6423,6 +6348,122 @@ static inline char *dup_token(const char **buf, size_t *lenp) · 5450 unmodified lines
6423 return dup;6348 return dup;
6424}6349}
6425 6350
6351static int rbd_parse_param(struct fs_parameter *param,
6352 struct rbd_parse_opts_ctx *pctx)
6353{
6354 struct rbd_options *opt = pctx->opts;
6355 struct fs_parse_result result;
6356 int token, ret;
6357
6358 ret = ceph_parse_param(param, pctx->copts, NULL);
6359 if (ret != -ENOPARAM)
6360 return ret;
6361
6362 token = fs_parse(NULL, &rbd_parameters, param, &result);
6363 dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
6364 if (token < 0) {
6365 if (token == -ENOPARAM) {
6366 return invalf(NULL, "rbd: Unknown parameter '%s'",
6367 param->key);
6368 }
6369 return token;
6370 }
6371
6372 switch (token) {
6373 case Opt_queue_depth:
6374 if (result.uint_32 < 1)
6375 goto out_of_range;
6376 opt->queue_depth = result.uint_32;
6377 break;
6378 case Opt_alloc_size:
6379 if (result.uint_32 < SECTOR_SIZE)
6380 goto out_of_range;
6381 if (!is_power_of_2(result.uint_32)) {
6382 return invalf(NULL, "rbd: alloc_size must be a power of 2");
6383 }
6384 opt->alloc_size = result.uint_32;
6385 break;
6386 case Opt_lock_timeout:
6387 /* 0 is "wait forever" (i.e. infinite timeout) */
6388 if (result.uint_32 > INT_MAX / 1000)
6389 goto out_of_range;
6390 opt->lock_timeout = msecs_to_jiffies(result.uint_32 * 1000);
6391 break;
6392 case Opt_pool_ns:
6393 kfree(pctx->spec->pool_ns);
6394 pctx->spec->pool_ns = param->string;
6395 param->string = NULL;
6396 break;
6397 case Opt_read_only:
6398 opt->read_only = true;
6399 break;
6400 case Opt_read_write:
6401 opt->read_only = false;
6402 break;
6403 case Opt_lock_on_read:
6404 opt->lock_on_read = true;
6405 break;
6406 case Opt_exclusive:
6407 opt->exclusive = true;
6408 break;
6409 case Opt_notrim:
6410 opt->trim = false;
6411 break;
6412 default:
6413 BUG();
6414 }
6415
6416 return 0;
6417
6418out_of_range:
6419 return invalf(NULL, "rbd: %s out of range", param->key);
6420}
6421
6422/*
6423 * This duplicates most of generic_parse_monolithic(), untying it from
6424 * fs_context and skipping standard superblock and security options.
6425 */
6426static int rbd_parse_options(char *options, struct rbd_parse_opts_ctx *pctx)
6427{
6428 char *key;
6429 int ret = 0;
6430
6431 dout("%s '%s'\n", __func__, options);
6432 while ((key = strsep(&options, ",")) != NULL) {
6433 if (*key) {
6434 struct fs_parameter param = {
6435 .key = key,
6436 .type = fs_value_is_string,
6437 };
6438 char *value = strchr(key, '=');
6439 size_t v_len = 0;
6440
6441 if (value) {
6442 if (value == key)
6443 continue;
6444 *value++ = 0;
6445 v_len = strlen(value);
6446 }
6447
6448
6449 if (v_len > 0) {
6450 param.string = kmemdup_nul(value, v_len,
6451 GFP_KERNEL);
6452 if (!param.string)
6453 return -ENOMEM;
6454 }
6455 param.size = v_len;
6456
6457 ret = rbd_parse_param(&param, pctx);
6458 kfree(param.string);
6459 if (ret)
6460 break;
6461 }
6462 }
6463
6464 return ret;
6465}
6466
6426/*6467/*
6427 * Parse the options provided for an "rbd add" (i.e., rbd image6468 * Parse the options provided for an "rbd add" (i.e., rbd image
6428 * mapping) request. These arrive via a write to /sys/bus/rbd/add,6469 * mapping) request. These arrive via a write to /sys/bus/rbd/add,
@@ -6474,8 +6515,7 @@ static int rbd_add_parse_args(const char *buf, · 45 unmodified lines
6474 const char *mon_addrs;6515 const char *mon_addrs;
6475 char *snap_name;6516 char *snap_name;
6476 size_t mon_addrs_size;6517 size_t mon_addrs_size;
6477 struct parse_rbd_opts_ctx pctx = { 0 };6518 struct rbd_parse_opts_ctx pctx = { 0 };
6478 struct ceph_options *copts;
6479 int ret;6519 int ret;
6480 6520
6481 /* The first four tokens are required */6521 /* The first four tokens are required */
@@ -6486,7 +6526,7 @@ static int rbd_add_parse_args(const char *buf, · 4 unmodified lines
6486 return -EINVAL;6526 return -EINVAL;
6487 }6527 }
6488 mon_addrs = buf;6528 mon_addrs = buf;
6489 mon_addrs_size = len + 1;6529 mon_addrs_size = len;
6490 buf += len;6530 buf += len;
6491 6531
6492 ret = -EINVAL;6532 ret = -EINVAL;
@@ -6536,6 +6576,10 @@ static int rbd_add_parse_args(const char *buf, · 43 unmodified lines
6536 *(snap_name + len) = '\0';6576 *(snap_name + len) = '\0';
6537 pctx.spec->snap_name = snap_name;6577 pctx.spec->snap_name = snap_name;
6538 6578
6579 pctx.copts = ceph_alloc_options();
6580 if (!pctx.copts)
6581 goto out_mem;
6582
6539 /* Initialize all rbd options to the defaults */6583 /* Initialize all rbd options to the defaults */
6540 6584
6541 pctx.opts = kzalloc(sizeof(*pctx.opts), GFP_KERNEL);6585 pctx.opts = kzalloc(sizeof(*pctx.opts), GFP_KERNEL);
@@ -6550,27 +6594,27 @@ static int rbd_add_parse_args(const char *buf, · 8 unmodified lines
6550 pctx.opts->exclusive = RBD_EXCLUSIVE_DEFAULT;6594 pctx.opts->exclusive = RBD_EXCLUSIVE_DEFAULT;
6551 pctx.opts->trim = RBD_TRIM_DEFAULT;6595 pctx.opts->trim = RBD_TRIM_DEFAULT;
6552 6596
6553 copts = ceph_parse_options(options, mon_addrs,6597 ret = ceph_parse_mon_ips(mon_addrs, mon_addrs_size, pctx.copts, NULL);
6554 mon_addrs + mon_addrs_size - 1,6598 if (ret)
6555 parse_rbd_opts_token, &pctx);
6556 if (IS_ERR(copts)) {
6557 ret = PTR_ERR(copts);
6558 goto out_err;6599 goto out_err;
6559 }
6560 kfree(options);
6561 6600
6562 *ceph_opts = copts;6601 ret = rbd_parse_options(options, &pctx);
6602 if (ret)
6603 goto out_err;
6604
6605 *ceph_opts = pctx.copts;
6563 *opts = pctx.opts;6606 *opts = pctx.opts;
6564 *rbd_spec = pctx.spec;6607 *rbd_spec = pctx.spec;
6565 6608 kfree(options);
6566 return 0;6609 return 0;
6610
6567out_mem:6611out_mem:
6568 ret = -ENOMEM;6612 ret = -ENOMEM;
6569out_err:6613out_err:
6570 kfree(pctx.opts);6614 kfree(pctx.opts);
6615 ceph_destroy_options(pctx.copts);
6571 rbd_spec_put(pctx.spec);6616 rbd_spec_put(pctx.spec);
6572 kfree(options);6617 kfree(options);
6573
6574 return ret;6618 return ret;
6575}6619}
6576 6620
fs/ceph/cache.c+5−4
@@ -8,6 +8,7 @@ · 7 unmodified lines
8 8
9#include <linux/ceph/ceph_debug.h>9#include <linux/ceph/ceph_debug.h>
10 10
11#include <linux/fs_context.h>
11#include "super.h"12#include "super.h"
12#include "cache.h"13#include "cache.h"
13 14
@@ -49,7 +50,7 @@ void ceph_fscache_unregister(void) · 35 unmodified lines
49 fscache_unregister_netfs(&ceph_cache_netfs);50 fscache_unregister_netfs(&ceph_cache_netfs);
50}51}
51 52
52int ceph_fscache_register_fs(struct ceph_fs_client* fsc)53int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc)
53{54{
54 const struct ceph_fsid *fsid = &fsc->client->fsid;55 const struct ceph_fsid *fsid = &fsc->client->fsid;
55 const char *fscache_uniq = fsc->mount_options->fscache_uniq;56 const char *fscache_uniq = fsc->mount_options->fscache_uniq;
@@ -66,8 +67,8 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc) · 10 unmodified lines
66 if (uniq_len && memcmp(ent->uniquifier, fscache_uniq, uniq_len))67 if (uniq_len && memcmp(ent->uniquifier, fscache_uniq, uniq_len))
67 continue;68 continue;
68 69
69 pr_err("fscache cookie already registered for fsid %pU\n", fsid);70 errorf(fc, "ceph: fscache cookie already registered for fsid %pU, use fsc=<uniquifier> option",
70 pr_err(" use fsc=%%s mount option to specify a uniquifier\n");71 fsid);
71 err = -EBUSY;72 err = -EBUSY;
72 goto out_unlock;73 goto out_unlock;
73 }74 }
@@ -95,7 +96,7 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc) · 21 unmodified lines
95 list_add_tail(&ent->list, &ceph_fscache_list);96 list_add_tail(&ent->list, &ceph_fscache_list);
96 } else {97 } else {
97 kfree(ent);98 kfree(ent);
98 pr_err("unable to register fscache cookie for fsid %pU\n",99 errorf(fc, "ceph: unable to register fscache cookie for fsid %pU",
99 fsid);100 fsid);
100 /* all other fs ignore this error */101 /* all other fs ignore this error */
101 }102 }
fs/ceph/cache.h+3−2
@@ -16,7 +16,7 @@ extern struct fscache_netfs ceph_cache_netfs; · 15 unmodified lines
16int ceph_fscache_register(void);16int ceph_fscache_register(void);
17void ceph_fscache_unregister(void);17void ceph_fscache_unregister(void);
18 18
19int ceph_fscache_register_fs(struct ceph_fs_client* fsc);19int ceph_fscache_register_fs(struct ceph_fs_client* fsc, struct fs_context *fc);
20void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc);20void ceph_fscache_unregister_fs(struct ceph_fs_client* fsc);
21 21
22void ceph_fscache_register_inode_cookie(struct inode *inode);22void ceph_fscache_register_inode_cookie(struct inode *inode);
@@ -88,7 +88,8 @@ static inline void ceph_fscache_unregister(void) · 65 unmodified lines
88{88{
89}89}
90 90
91static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc)91static inline int ceph_fscache_register_fs(struct ceph_fs_client* fsc,
92 struct fs_context *fc)
92{93{
93 return 0;94 return 0;
94}95}
fs/ceph/super.c+324−322
@@ -9,7 +9,8 @@ · 8 unmodified lines
9#include <linux/in6.h>9#include <linux/in6.h>
10#include <linux/module.h>10#include <linux/module.h>
11#include <linux/mount.h>11#include <linux/mount.h>
12#include <linux/parser.h>12#include <linux/fs_context.h>
13#include <linux/fs_parser.h>
13#include <linux/sched.h>14#include <linux/sched.h>
14#include <linux/seq_file.h>15#include <linux/seq_file.h>
15#include <linux/slab.h>16#include <linux/slab.h>
@@ -138,280 +139,308 @@ enum { · 122 unmodified lines
138 Opt_readdir_max_entries,139 Opt_readdir_max_entries,
139 Opt_readdir_max_bytes,140 Opt_readdir_max_bytes,
140 Opt_congestion_kb,141 Opt_congestion_kb,
141 Opt_last_int,
142 /* int args above */142 /* int args above */
143 Opt_snapdirname,143 Opt_snapdirname,
144 Opt_mds_namespace,144 Opt_mds_namespace,
145 Opt_fscache_uniq,
146 Opt_recover_session,145 Opt_recover_session,
147 Opt_last_string,146 Opt_source,
148 /* string args above */147 /* string args above */
149 Opt_dirstat,148 Opt_dirstat,
150 Opt_nodirstat,
151 Opt_rbytes,149 Opt_rbytes,
152 Opt_norbytes,
153 Opt_asyncreaddir,150 Opt_asyncreaddir,
154 Opt_noasyncreaddir,
155 Opt_dcache,151 Opt_dcache,
156 Opt_nodcache,
157 Opt_ino32,152 Opt_ino32,
158 Opt_noino32,
159 Opt_fscache,153 Opt_fscache,
160 Opt_nofscache,
161 Opt_poolperm,154 Opt_poolperm,
162 Opt_nopoolperm,
163 Opt_require_active_mds,155 Opt_require_active_mds,
164 Opt_norequire_active_mds,
165#ifdef CONFIG_CEPH_FS_POSIX_ACL
166 Opt_acl,156 Opt_acl,
167#endif
168 Opt_noacl,
169 Opt_quotadf,157 Opt_quotadf,
170 Opt_noquotadf,
171 Opt_copyfrom,158 Opt_copyfrom,
172 Opt_nocopyfrom,
173};159};
174 160
175static match_table_t fsopt_tokens = {161enum ceph_recover_session_mode {
176 {Opt_wsize, "wsize=%d"},162 ceph_recover_session_no,
177 {Opt_rsize, "rsize=%d"},163 ceph_recover_session_clean
178 {Opt_rasize, "rasize=%d"},164};
179 {Opt_caps_wanted_delay_min, "caps_wanted_delay_min=%d"},165
180 {Opt_caps_wanted_delay_max, "caps_wanted_delay_max=%d"},166static const struct fs_parameter_enum ceph_mount_param_enums[] = {
181 {Opt_caps_max, "caps_max=%d"},167 { Opt_recover_session, "no", ceph_recover_session_no },
182 {Opt_readdir_max_entries, "readdir_max_entries=%d"},168 { Opt_recover_session, "clean", ceph_recover_session_clean },
183 {Opt_readdir_max_bytes, "readdir_max_bytes=%d"},169 {}
184 {Opt_congestion_kb, "write_congestion_kb=%d"},170};
185 /* int args above */171
186 {Opt_snapdirname, "snapdirname=%s"},172static const struct fs_parameter_spec ceph_mount_param_specs[] = {
187 {Opt_mds_namespace, "mds_namespace=%s"},173 fsparam_flag_no ("acl", Opt_acl),
188 {Opt_recover_session, "recover_session=%s"},174 fsparam_flag_no ("asyncreaddir", Opt_asyncreaddir),
189 {Opt_fscache_uniq, "fsc=%s"},175 fsparam_u32 ("caps_max", Opt_caps_max),
190 /* string args above */176 fsparam_u32 ("caps_wanted_delay_max", Opt_caps_wanted_delay_max),
191 {Opt_dirstat, "dirstat"},177 fsparam_u32 ("caps_wanted_delay_min", Opt_caps_wanted_delay_min),
192 {Opt_nodirstat, "nodirstat"},178 fsparam_s32 ("write_congestion_kb", Opt_congestion_kb),
193 {Opt_rbytes, "rbytes"},179 fsparam_flag_no ("copyfrom", Opt_copyfrom),
194 {Opt_norbytes, "norbytes"},180 fsparam_flag_no ("dcache", Opt_dcache),
195 {Opt_asyncreaddir, "asyncreaddir"},181 fsparam_flag_no ("dirstat", Opt_dirstat),
196 {Opt_noasyncreaddir, "noasyncreaddir"},182 __fsparam (fs_param_is_string, "fsc", Opt_fscache,
197 {Opt_dcache, "dcache"},183 fs_param_neg_with_no | fs_param_v_optional),
198 {Opt_nodcache, "nodcache"},184 fsparam_flag_no ("ino32", Opt_ino32),
199 {Opt_ino32, "ino32"},185 fsparam_string ("mds_namespace", Opt_mds_namespace),
200 {Opt_noino32, "noino32"},186 fsparam_flag_no ("poolperm", Opt_poolperm),
201 {Opt_fscache, "fsc"},187 fsparam_flag_no ("quotadf", Opt_quotadf),
202 {Opt_nofscache, "nofsc"},188 fsparam_u32 ("rasize", Opt_rasize),
203 {Opt_poolperm, "poolperm"},189 fsparam_flag_no ("rbytes", Opt_rbytes),
204 {Opt_nopoolperm, "nopoolperm"},190 fsparam_s32 ("readdir_max_bytes", Opt_readdir_max_bytes),
205 {Opt_require_active_mds, "require_active_mds"},191 fsparam_s32 ("readdir_max_entries", Opt_readdir_max_entries),
206 {Opt_norequire_active_mds, "norequire_active_mds"},192 fsparam_enum ("recover_session", Opt_recover_session),
207#ifdef CONFIG_CEPH_FS_POSIX_ACL193 fsparam_flag_no ("require_active_mds", Opt_require_active_mds),
208 {Opt_acl, "acl"},194 fsparam_u32 ("rsize", Opt_rsize),
209#endif195 fsparam_string ("snapdirname", Opt_snapdirname),
210 {Opt_noacl, "noacl"},196 fsparam_string ("source", Opt_source),
211 {Opt_quotadf, "quotadf"},197 fsparam_u32 ("wsize", Opt_wsize),
212 {Opt_noquotadf, "noquotadf"},198 {}
213 {Opt_copyfrom, "copyfrom"},199};
214 {Opt_nocopyfrom, "nocopyfrom"},200
215 {-1, NULL}201static const struct fs_parameter_description ceph_mount_parameters = {
202 .name = "ceph",
203 .specs = ceph_mount_param_specs,
204 .enums = ceph_mount_param_enums,
216};205};
217 206
218static int parse_fsopt_token(char *c, void *private)207struct ceph_parse_opts_ctx {
208 struct ceph_options *copts;
209 struct ceph_mount_options *opts;
210};
211
212/*
213 * Parse the source parameter. Distinguish the server list from the path.
214 * Internally we do not include the leading '/' in the path.
215 *
216 * The source will look like:
217 * <server_spec>[,<server_spec>...]:[<path>]
218 * where
219 * <server_spec> is <ip>[:<port>]
220 * <path> is optional, but if present must begin with '/'
221 */
222static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc)
219{223{
220 struct ceph_mount_options *fsopt = private;224 struct ceph_parse_opts_ctx *pctx = fc->fs_private;
221 substring_t argstr[MAX_OPT_ARGS];225 struct ceph_mount_options *fsopt = pctx->opts;
222 int token, intval, ret;226 char *dev_name = param->string, *dev_name_end;
227 int ret;
223 228
224 token = match_token((char *)c, fsopt_tokens, argstr);229 dout("%s '%s'\n", __func__, dev_name);
225 if (token < 0)230 if (!dev_name || !*dev_name)
226 return -EINVAL;231 return invalf(fc, "ceph: Empty source");
227 232
228 if (token < Opt_last_int) {233 dev_name_end = strchr(dev_name, '/');
229 ret = match_int(&argstr[0], &intval);234 if (dev_name_end) {
230 if (ret < 0) {235 if (strlen(dev_name_end) > 1) {
231 pr_err("bad option arg (not int) at '%s'\n", c);236 kfree(fsopt->server_path);
232 return ret;237 fsopt->server_path = kstrdup(dev_name_end, GFP_KERNEL);
238 if (!fsopt->server_path)
239 return -ENOMEM;
233 }240 }
234 dout("got int token %d val %d\n", token, intval);
235 } else if (token > Opt_last_int && token < Opt_last_string) {
236 dout("got string token %d val %s\n", token,
237 argstr[0].from);
238 } else {241 } else {
239 dout("got token %d\n", token);242 dev_name_end = dev_name + strlen(dev_name);
240 }243 }
241 244
245 dev_name_end--; /* back up to ':' separator */
246 if (dev_name_end < dev_name || *dev_name_end != ':')
247 return invalf(fc, "ceph: No path or : separator in source");
248
249 dout("device name '%.*s'\n", (int)(dev_name_end - dev_name), dev_name);
250 if (fsopt->server_path)
251 dout("server path '%s'\n", fsopt->server_path);
252
253 ret = ceph_parse_mon_ips(param->string, dev_name_end - dev_name,
254 pctx->copts, fc);
255 if (ret)
256 return ret;
257
258 fc->source = param->string;
259 param->string = NULL;
260 return 0;
261}
262
263static int ceph_parse_mount_param(struct fs_context *fc,
264 struct fs_parameter *param)
265{
266 struct ceph_parse_opts_ctx *pctx = fc->fs_private;
267 struct ceph_mount_options *fsopt = pctx->opts;
268 struct fs_parse_result result;
269 unsigned int mode;
270 int token, ret;
271
272 ret = ceph_parse_param(param, pctx->copts, fc);
273 if (ret != -ENOPARAM)
274 return ret;
275
276 token = fs_parse(fc, &ceph_mount_parameters, param, &result);
277 dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
278 if (token < 0)
279 return token;
280
242 switch (token) {281 switch (token) {
243 case Opt_snapdirname:282 case Opt_snapdirname:
244 kfree(fsopt->snapdir_name);283 kfree(fsopt->snapdir_name);
245 fsopt->snapdir_name = kstrndup(argstr[0].from,284 fsopt->snapdir_name = param->string;
246 argstr[0].to-argstr[0].from,285 param->string = NULL;
247 GFP_KERNEL);
248 if (!fsopt->snapdir_name)
249 return -ENOMEM;
250 break;286 break;
251 case Opt_mds_namespace:287 case Opt_mds_namespace:
252 kfree(fsopt->mds_namespace);288 kfree(fsopt->mds_namespace);
253 fsopt->mds_namespace = kstrndup(argstr[0].from,289 fsopt->mds_namespace = param->string;
254 argstr[0].to-argstr[0].from,290 param->string = NULL;
255 GFP_KERNEL);
256 if (!fsopt->mds_namespace)
257 return -ENOMEM;
258 break;291 break;
259 case Opt_recover_session:292 case Opt_recover_session:
260 if (!strncmp(argstr[0].from, "no",293 mode = result.uint_32;
261 argstr[0].to - argstr[0].from)) {294 if (mode == ceph_recover_session_no)
262 fsopt->flags &= ~CEPH_MOUNT_OPT_CLEANRECOVER;295 fsopt->flags &= ~CEPH_MOUNT_OPT_CLEANRECOVER;
263 } else if (!strncmp(argstr[0].from, "clean",296 else if (mode == ceph_recover_session_clean)
264 argstr[0].to - argstr[0].from)) {
265 fsopt->flags |= CEPH_MOUNT_OPT_CLEANRECOVER;297 fsopt->flags |= CEPH_MOUNT_OPT_CLEANRECOVER;
266 } else {298 else
267 return -EINVAL;299 BUG();
268 }
269 break;
270 case Opt_fscache_uniq:
271#ifdef CONFIG_CEPH_FSCACHE
272 kfree(fsopt->fscache_uniq);
273 fsopt->fscache_uniq = kstrndup(argstr[0].from,
274 argstr[0].to-argstr[0].from,
275 GFP_KERNEL);
276 if (!fsopt->fscache_uniq)
277 return -ENOMEM;
278 fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
279 break;300 break;
280#else301 case Opt_source:
281 pr_err("fscache support is disabled\n");302 if (fc->source)
282 return -EINVAL;303 return invalf(fc, "ceph: Multiple sources specified");
283#endif304 return ceph_parse_source(param, fc);
284 case Opt_wsize:305 case Opt_wsize:
285 if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)306 if (result.uint_32 < PAGE_SIZE ||
286 return -EINVAL;307 result.uint_32 > CEPH_MAX_WRITE_SIZE)
287 fsopt->wsize = ALIGN(intval, PAGE_SIZE);308 goto out_of_range;
309 fsopt->wsize = ALIGN(result.uint_32, PAGE_SIZE);
288 break;310 break;
289 case Opt_rsize:311 case Opt_rsize:
290 if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_READ_SIZE)312 if (result.uint_32 < PAGE_SIZE ||
291 return -EINVAL;313 result.uint_32 > CEPH_MAX_READ_SIZE)
292 fsopt->rsize = ALIGN(intval, PAGE_SIZE);314 goto out_of_range;
315 fsopt->rsize = ALIGN(result.uint_32, PAGE_SIZE);
293 break;316 break;
294 case Opt_rasize:317 case Opt_rasize:
295 if (intval < 0)318 fsopt->rasize = ALIGN(result.uint_32, PAGE_SIZE);
296 return -EINVAL;
297 fsopt->rasize = ALIGN(intval, PAGE_SIZE);
298 break;319 break;
299 case Opt_caps_wanted_delay_min:320 case Opt_caps_wanted_delay_min:
300 if (intval < 1)321 if (result.uint_32 < 1)
301 return -EINVAL;322 goto out_of_range;
302 fsopt->caps_wanted_delay_min = intval;323 fsopt->caps_wanted_delay_min = result.uint_32;
303 break;324 break;
304 case Opt_caps_wanted_delay_max:325 case Opt_caps_wanted_delay_max:
305 if (intval < 1)326 if (result.uint_32 < 1)
306 return -EINVAL;327 goto out_of_range;
307 fsopt->caps_wanted_delay_max = intval;328 fsopt->caps_wanted_delay_max = result.uint_32;
308 break;329 break;
309 case Opt_caps_max:330 case Opt_caps_max:
310 if (intval < 0)331 fsopt->caps_max = result.uint_32;
311 return -EINVAL;
312 fsopt->caps_max = intval;
313 break;332 break;
314 case Opt_readdir_max_entries:333 case Opt_readdir_max_entries:
315 if (intval < 1)334 if (result.uint_32 < 1)
316 return -EINVAL;335 goto out_of_range;
317 fsopt->max_readdir = intval;336 fsopt->max_readdir = result.uint_32;
318 break;337 break;
319 case Opt_readdir_max_bytes:338 case Opt_readdir_max_bytes:
320 if (intval < (int)PAGE_SIZE && intval != 0)339 if (result.uint_32 < PAGE_SIZE && result.uint_32 != 0)
321 return -EINVAL;340 goto out_of_range;
322 fsopt->max_readdir_bytes = intval;341 fsopt->max_readdir_bytes = result.uint_32;
323 break;342 break;
324 case Opt_congestion_kb:343 case Opt_congestion_kb:
325 if (intval < 1024) /* at least 1M */344 if (result.uint_32 < 1024) /* at least 1M */
326 return -EINVAL;345 goto out_of_range;
327 fsopt->congestion_kb = intval;346 fsopt->congestion_kb = result.uint_32;
328 break;347 break;
329 case Opt_dirstat:348 case Opt_dirstat:
330 fsopt->flags |= CEPH_MOUNT_OPT_DIRSTAT;349 if (!result.negated)
331 break;350 fsopt->flags |= CEPH_MOUNT_OPT_DIRSTAT;
332 case Opt_nodirstat:351 else
333 fsopt->flags &= ~CEPH_MOUNT_OPT_DIRSTAT;352 fsopt->flags &= ~CEPH_MOUNT_OPT_DIRSTAT;
334 break;353 break;
335 case Opt_rbytes:354 case Opt_rbytes:
336 fsopt->flags |= CEPH_MOUNT_OPT_RBYTES;355 if (!result.negated)
337 break;356 fsopt->flags |= CEPH_MOUNT_OPT_RBYTES;
338 case Opt_norbytes:357 else
339 fsopt->flags &= ~CEPH_MOUNT_OPT_RBYTES;358 fsopt->flags &= ~CEPH_MOUNT_OPT_RBYTES;
340 break;359 break;
341 case Opt_asyncreaddir:360 case Opt_asyncreaddir:
342 fsopt->flags &= ~CEPH_MOUNT_OPT_NOASYNCREADDIR;361 if (!result.negated)
343 break;362 fsopt->flags &= ~CEPH_MOUNT_OPT_NOASYNCREADDIR;
344 case Opt_noasyncreaddir:363 else
345 fsopt->flags |= CEPH_MOUNT_OPT_NOASYNCREADDIR;364 fsopt->flags |= CEPH_MOUNT_OPT_NOASYNCREADDIR;
346 break;365 break;
347 case Opt_dcache:366 case Opt_dcache:
348 fsopt->flags |= CEPH_MOUNT_OPT_DCACHE;367 if (!result.negated)
349 break;368 fsopt->flags |= CEPH_MOUNT_OPT_DCACHE;
350 case Opt_nodcache:369 else
351 fsopt->flags &= ~CEPH_MOUNT_OPT_DCACHE;370 fsopt->flags &= ~CEPH_MOUNT_OPT_DCACHE;
352 break;371 break;
353 case Opt_ino32:372 case Opt_ino32:
354 fsopt->flags |= CEPH_MOUNT_OPT_INO32;373 if (!result.negated)
355 break;374 fsopt->flags |= CEPH_MOUNT_OPT_INO32;
356 case Opt_noino32:375 else
357 fsopt->flags &= ~CEPH_MOUNT_OPT_INO32;376 fsopt->flags &= ~CEPH_MOUNT_OPT_INO32;
358 break;377 break;
378
359 case Opt_fscache:379 case Opt_fscache:
360#ifdef CONFIG_CEPH_FSCACHE380#ifdef CONFIG_CEPH_FSCACHE
361 fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
362 kfree(fsopt->fscache_uniq);381 kfree(fsopt->fscache_uniq);
363 fsopt->fscache_uniq = NULL;382 fsopt->fscache_uniq = NULL;
383 if (result.negated) {
384 fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE;
385 } else {
386 fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
387 fsopt->fscache_uniq = param->string;
388 param->string = NULL;
389 }
364 break;390 break;
365#else391#else
366 pr_err("fscache support is disabled\n");392 return invalf(fc, "ceph: fscache support is disabled");
367 return -EINVAL;
368#endif393#endif
369 case Opt_nofscache:
370 fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE;
371 kfree(fsopt->fscache_uniq);
372 fsopt->fscache_uniq = NULL;
373 break;
374 case Opt_poolperm:394 case Opt_poolperm:
375 fsopt->flags &= ~CEPH_MOUNT_OPT_NOPOOLPERM;395 if (!result.negated)
376 break;396 fsopt->flags &= ~CEPH_MOUNT_OPT_NOPOOLPERM;
377 case Opt_nopoolperm:397 else
378 fsopt->flags |= CEPH_MOUNT_OPT_NOPOOLPERM;398 fsopt->flags |= CEPH_MOUNT_OPT_NOPOOLPERM;
379 break;399 break;
380 case Opt_require_active_mds:400 case Opt_require_active_mds:
381 fsopt->flags &= ~CEPH_MOUNT_OPT_MOUNTWAIT;401 if (!result.negated)
382 break;402 fsopt->flags &= ~CEPH_MOUNT_OPT_MOUNTWAIT;
383 case Opt_norequire_active_mds:403 else
384 fsopt->flags |= CEPH_MOUNT_OPT_MOUNTWAIT;404 fsopt->flags |= CEPH_MOUNT_OPT_MOUNTWAIT;
385 break;405 break;
386 case Opt_quotadf:406 case Opt_quotadf:
387 fsopt->flags &= ~CEPH_MOUNT_OPT_NOQUOTADF;407 if (!result.negated)
388 break;408 fsopt->flags &= ~CEPH_MOUNT_OPT_NOQUOTADF;
389 case Opt_noquotadf:409 else
390 fsopt->flags |= CEPH_MOUNT_OPT_NOQUOTADF;410 fsopt->flags |= CEPH_MOUNT_OPT_NOQUOTADF;
391 break;411 break;
392 case Opt_copyfrom:412 case Opt_copyfrom:
393 fsopt->flags &= ~CEPH_MOUNT_OPT_NOCOPYFROM;413 if (!result.negated)
394 break;414 fsopt->flags &= ~CEPH_MOUNT_OPT_NOCOPYFROM;
395 case Opt_nocopyfrom:415 else
396 fsopt->flags |= CEPH_MOUNT_OPT_NOCOPYFROM;416 fsopt->flags |= CEPH_MOUNT_OPT_NOCOPYFROM;
397 break;417 break;
398#ifdef CONFIG_CEPH_FS_POSIX_ACL
399 case Opt_acl:418 case Opt_acl:
400 fsopt->sb_flags |= SB_POSIXACL;419 if (!result.negated) {
401 break;420#ifdef CONFIG_CEPH_FS_POSIX_ACL
421 fc->sb_flags |= SB_POSIXACL;
422#else
423 return invalf(fc, "ceph: POSIX ACL support is disabled");
402#endif424#endif
403 case Opt_noacl:425 } else {
404 fsopt->sb_flags &= ~SB_POSIXACL;426 fc->sb_flags &= ~SB_POSIXACL;
427 }
405 break;428 break;
406 default:429 default:
407 BUG_ON(token);430 BUG();
408 }431 }
409 return 0;432 return 0;
433
434out_of_range:
435 return invalf(fc, "ceph: %s out of range", param->key);
410}436}
411 437
412static void destroy_mount_options(struct ceph_mount_options *args)438static void destroy_mount_options(struct ceph_mount_options *args)
413{439{
414 dout("destroy_mount_options %p\n", args);440 dout("destroy_mount_options %p\n", args);
441 if (!args)
442 return;
443
415 kfree(args->snapdir_name);444 kfree(args->snapdir_name);
416 kfree(args->mds_namespace);445 kfree(args->mds_namespace);
417 kfree(args->server_path);446 kfree(args->server_path);
@@ -459,91 +488,6 @@ static int compare_mount_options(struct ceph_mount_options *new_fsopt, · 41 unmodified lines
459 return ceph_compare_options(new_opt, fsc->client);488 return ceph_compare_options(new_opt, fsc->client);
460}489}
461 490
462static int parse_mount_options(struct ceph_mount_options **pfsopt,
463 struct ceph_options **popt,
464 int flags, char *options,
465 const char *dev_name)
466{
467 struct ceph_mount_options *fsopt;
468 const char *dev_name_end;
469 int err;
470
471 if (!dev_name || !*dev_name)
472 return -EINVAL;
473
474 fsopt = kzalloc(sizeof(*fsopt), GFP_KERNEL);
475 if (!fsopt)
476 return -ENOMEM;
477
478 dout("parse_mount_options %p, dev_name '%s'\n", fsopt, dev_name);
479
480 fsopt->sb_flags = flags;
481 fsopt->flags = CEPH_MOUNT_OPT_DEFAULT;
482
483 fsopt->wsize = CEPH_MAX_WRITE_SIZE;
484 fsopt->rsize = CEPH_MAX_READ_SIZE;
485 fsopt->rasize = CEPH_RASIZE_DEFAULT;
486 fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL);
487 if (!fsopt->snapdir_name) {
488 err = -ENOMEM;
489 goto out;
490 }
491
492 fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT;
493 fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT;
494 fsopt->max_readdir = CEPH_MAX_READDIR_DEFAULT;
495 fsopt->max_readdir_bytes = CEPH_MAX_READDIR_BYTES_DEFAULT;
496 fsopt->congestion_kb = default_congestion_kb();
497
498 /*
499 * Distinguish the server list from the path in "dev_name".
500 * Internally we do not include the leading '/' in the path.
501 *
502 * "dev_name" will look like:
503 * <server_spec>[,<server_spec>...]:[<path>]
504 * where
505 * <server_spec> is <ip>[:<port>]
506 * <path> is optional, but if present must begin with '/'
507 */
508 dev_name_end = strchr(dev_name, '/');
509 if (dev_name_end) {
510 if (strlen(dev_name_end) > 1) {
511 fsopt->server_path = kstrdup(dev_name_end, GFP_KERNEL);
512 if (!fsopt->server_path) {
513 err = -ENOMEM;
514 goto out;
515 }
516 }
517 } else {
518 dev_name_end = dev_name + strlen(dev_name);
519 }
520 err = -EINVAL;
521 dev_name_end--; /* back up to ':' separator */
522 if (dev_name_end < dev_name || *dev_name_end != ':') {
523 pr_err("device name is missing path (no : separator in %s)\n",
524 dev_name);
525 goto out;
526 }
527 dout("device name '%.*s'\n", (int)(dev_name_end - dev_name), dev_name);
528 if (fsopt->server_path)
529 dout("server path '%s'\n", fsopt->server_path);
530
531 *popt = ceph_parse_options(options, dev_name, dev_name_end,
532 parse_fsopt_token, (void *)fsopt);
533 if (IS_ERR(*popt)) {
534 err = PTR_ERR(*popt);
535 goto out;
536 }
537
538 /* success */
539 *pfsopt = fsopt;
540 return 0;
541
542out:
543 destroy_mount_options(fsopt);
544 return err;
545}
546
547/**491/**
548 * ceph_show_options - Show mount options in /proc/mounts492 * ceph_show_options - Show mount options in /proc/mounts
549 * @m: seq_file to write to493 * @m: seq_file to write to
@@ -587,7 +531,7 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root) · 37 unmodified lines
587 seq_puts(m, ",noquotadf");531 seq_puts(m, ",noquotadf");
588 532
589#ifdef CONFIG_CEPH_FS_POSIX_ACL533#ifdef CONFIG_CEPH_FS_POSIX_ACL
590 if (fsopt->sb_flags & SB_POSIXACL)534 if (root->d_sb->s_flags & SB_POSIXACL)
591 seq_puts(m, ",acl");535 seq_puts(m, ",acl");
592 else536 else
593 seq_puts(m, ",noacl");537 seq_puts(m, ",noacl");
@@ -860,12 +804,6 @@ static void ceph_umount_begin(struct super_block *sb) · 266 unmodified lines
860 fsc->filp_gen++; // invalidate open files804 fsc->filp_gen++; // invalidate open files
861}805}
862 806
863static int ceph_remount(struct super_block *sb, int *flags, char *data)
864{
865 sync_filesystem(sb);
866 return 0;
867}
868
869static const struct super_operations ceph_super_ops = {807static const struct super_operations ceph_super_ops = {
870 .alloc_inode = ceph_alloc_inode,808 .alloc_inode = ceph_alloc_inode,
871 .free_inode = ceph_free_inode,809 .free_inode = ceph_free_inode,
@@ -874,7 +812,6 @@ static const struct super_operations ceph_super_ops = { · 2 unmodified lines
874 .evict_inode = ceph_evict_inode,812 .evict_inode = ceph_evict_inode,
875 .sync_fs = ceph_sync_fs,813 .sync_fs = ceph_sync_fs,
876 .put_super = ceph_put_super,814 .put_super = ceph_put_super,
877 .remount_fs = ceph_remount,
878 .show_options = ceph_show_options,815 .show_options = ceph_show_options,
879 .statfs = ceph_statfs,816 .statfs = ceph_statfs,
880 .umount_begin = ceph_umount_begin,817 .umount_begin = ceph_umount_begin,
@@ -935,7 +872,8 @@ out: · 54 unmodified lines
935/*872/*
936 * mount: join the ceph cluster, and open root directory.873 * mount: join the ceph cluster, and open root directory.
937 */874 */
938static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc)875static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc,
876 struct fs_context *fc)
939{877{
940 int err;878 int err;
941 unsigned long started = jiffies; /* note the start time */879 unsigned long started = jiffies; /* note the start time */
@@ -952,7 +890,7 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) · 10 unmodified lines
952 890
953 /* setup fscache */891 /* setup fscache */
954 if (fsc->mount_options->flags & CEPH_MOUNT_OPT_FSCACHE) {892 if (fsc->mount_options->flags & CEPH_MOUNT_OPT_FSCACHE) {
955 err = ceph_fscache_register_fs(fsc);893 err = ceph_fscache_register_fs(fsc, fc);
956 if (err < 0)894 if (err < 0)
957 goto out;895 goto out;
958 }896 }
@@ -987,18 +925,16 @@ out: · 28 unmodified lines
987 return ERR_PTR(err);925 return ERR_PTR(err);
988}926}
989 927
990static int ceph_set_super(struct super_block *s, void *data)928static int ceph_set_super(struct super_block *s, struct fs_context *fc)
991{929{
992 struct ceph_fs_client *fsc = data;930 struct ceph_fs_client *fsc = s->s_fs_info;
993 int ret;931 int ret;
994 932
995 dout("set_super %p data %p\n", s, data);933 dout("set_super %p\n", s);
996 934
997 s->s_flags = fsc->mount_options->sb_flags;
998 s->s_maxbytes = MAX_LFS_FILESIZE;935 s->s_maxbytes = MAX_LFS_FILESIZE;
999 936
1000 s->s_xattr = ceph_xattr_handlers;937 s->s_xattr = ceph_xattr_handlers;
1001 s->s_fs_info = fsc;
1002 fsc->sb = s;938 fsc->sb = s;
1003 fsc->max_file_size = 1ULL << 40; /* temp value until we get mdsmap */939 fsc->max_file_size = 1ULL << 40; /* temp value until we get mdsmap */
1004 940
@@ -1010,24 +946,18 @@ static int ceph_set_super(struct super_block *s, void *data) · 5 unmodified lines
1010 s->s_time_min = 0;946 s->s_time_min = 0;
1011 s->s_time_max = U32_MAX;947 s->s_time_max = U32_MAX;
1012 948
1013 ret = set_anon_super(s, NULL); /* what is that second arg for? */949 ret = set_anon_super_fc(s, fc);
1014 if (ret != 0)950 if (ret != 0)
1015 goto fail;951 fsc->sb = NULL;
1016
1017 return ret;
1018
1019fail:
1020 s->s_fs_info = NULL;
1021 fsc->sb = NULL;
1022 return ret;952 return ret;
1023}953}
1024 954
1025/*955/*
1026 * share superblock if same fs AND options956 * share superblock if same fs AND options
1027 */957 */
1028static int ceph_compare_super(struct super_block *sb, void *data)958static int ceph_compare_super(struct super_block *sb, struct fs_context *fc)
1029{959{
1030 struct ceph_fs_client *new = data;960 struct ceph_fs_client *new = fc->s_fs_info;
1031 struct ceph_mount_options *fsopt = new->mount_options;961 struct ceph_mount_options *fsopt = new->mount_options;
1032 struct ceph_options *opt = new->client->options;962 struct ceph_options *opt = new->client->options;
1033 struct ceph_fs_client *other = ceph_sb_to_client(sb);963 struct ceph_fs_client *other = ceph_sb_to_client(sb);
@@ -1043,7 +973,7 @@ static int ceph_compare_super(struct super_block *sb, void *data) · 9 unmodified lines
1043 dout("fsid doesn't match\n");973 dout("fsid doesn't match\n");
1044 return 0;974 return 0;
1045 }975 }
1046 if (fsopt->sb_flags != other->mount_options->sb_flags) {976 if (fc->sb_flags != (sb->s_flags & ~SB_BORN)) {
1047 dout("flags differ\n");977 dout("flags differ\n");
1048 return 0;978 return 0;
1049 }979 }
@@ -1073,46 +1003,46 @@ static int ceph_setup_bdi(struct super_block *sb, struct ceph_fs_client *fsc) · 23 unmodified lines
1073 return 0;1003 return 0;
1074}1004}
1075 1005
1076static struct dentry *ceph_mount(struct file_system_type *fs_type,1006static int ceph_get_tree(struct fs_context *fc)
1077 int flags, const char *dev_name, void *data)
1078{1007{
1008 struct ceph_parse_opts_ctx *pctx = fc->fs_private;
1079 struct super_block *sb;1009 struct super_block *sb;
1080 struct ceph_fs_client *fsc;1010 struct ceph_fs_client *fsc;
1081 struct dentry *res;1011 struct dentry *res;
1012 int (*compare_super)(struct super_block *, struct fs_context *) =
1013 ceph_compare_super;
1082 int err;1014 int err;
1083 int (*compare_super)(struct super_block *, void *) = ceph_compare_super;
1084 struct ceph_mount_options *fsopt = NULL;
1085 struct ceph_options *opt = NULL;
1086 1015
1087 dout("ceph_mount\n");1016 dout("ceph_get_tree\n");
1017
1018 if (!fc->source)
1019 return invalf(fc, "ceph: No source");
1088 1020
1089#ifdef CONFIG_CEPH_FS_POSIX_ACL1021#ifdef CONFIG_CEPH_FS_POSIX_ACL
1090 flags |= SB_POSIXACL;1022 fc->sb_flags |= SB_POSIXACL;
1091#endif1023#endif
1092 err = parse_mount_options(&fsopt, &opt, flags, data, dev_name);
1093 if (err < 0) {
1094 res = ERR_PTR(err);
1095 goto out_final;
1096 }
1097 1024
1098 /* create client (which we may/may not use) */1025 /* create client (which we may/may not use) */
1099 fsc = create_fs_client(fsopt, opt);1026 fsc = create_fs_client(pctx->opts, pctx->copts);
1027 pctx->opts = NULL;
1028 pctx->copts = NULL;
1100 if (IS_ERR(fsc)) {1029 if (IS_ERR(fsc)) {
1101 res = ERR_CAST(fsc);1030 err = PTR_ERR(fsc);
1102 goto out_final;1031 goto out_final;
1103 }1032 }
1104 1033
1105 err = ceph_mdsc_init(fsc);1034 err = ceph_mdsc_init(fsc);
1106 if (err < 0) {1035 if (err < 0)
1107 res = ERR_PTR(err);
1108 goto out;1036 goto out;
1109 }
1110 1037
1111 if (ceph_test_opt(fsc->client, NOSHARE))1038 if (ceph_test_opt(fsc->client, NOSHARE))
1112 compare_super = NULL;1039 compare_super = NULL;
1113 sb = sget(fs_type, compare_super, ceph_set_super, flags, fsc);1040
1041 fc->s_fs_info = fsc;
1042 sb = sget_fc(fc, compare_super, ceph_set_super);
1043 fc->s_fs_info = NULL;
1114 if (IS_ERR(sb)) {1044 if (IS_ERR(sb)) {
1115 res = ERR_CAST(sb);1045 err = PTR_ERR(sb);
1116 goto out;1046 goto out;
1117 }1047 }
1118 1048
@@ -1123,18 +1053,19 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type, · 4 unmodified lines
1123 } else {1053 } else {
1124 dout("get_sb using new client %p\n", fsc);1054 dout("get_sb using new client %p\n", fsc);
1125 err = ceph_setup_bdi(sb, fsc);1055 err = ceph_setup_bdi(sb, fsc);
1126 if (err < 0) {1056 if (err < 0)
1127 res = ERR_PTR(err);
1128 goto out_splat;1057 goto out_splat;
1129 }
1130 }1058 }
1131 1059
1132 res = ceph_real_mount(fsc);1060 res = ceph_real_mount(fsc, fc);
1133 if (IS_ERR(res))1061 if (IS_ERR(res)) {
1062 err = PTR_ERR(res);
1134 goto out_splat;1063 goto out_splat;
1064 }
1135 dout("root %p inode %p ino %llx.%llx\n", res,1065 dout("root %p inode %p ino %llx.%llx\n", res,
1136 d_inode(res), ceph_vinop(d_inode(res)));1066 d_inode(res), ceph_vinop(d_inode(res)));
1137 return res;1067 fc->root = fsc->sb->s_root;
1068 return 0;
1138 1069
1139out_splat:1070out_splat:
1140 ceph_mdsc_close_sessions(fsc->mdsc);1071 ceph_mdsc_close_sessions(fsc->mdsc);
@@ -1144,8 +1075,79 @@ out_splat: · 3 unmodified lines
1144out:1075out:
1145 destroy_fs_client(fsc);1076 destroy_fs_client(fsc);
1146out_final:1077out_final:
1147 dout("ceph_mount fail %ld\n", PTR_ERR(res));1078 dout("ceph_get_tree fail %d\n", err);
1148 return res;1079 return err;
1080}
1081
1082static void ceph_free_fc(struct fs_context *fc)
1083{
1084 struct ceph_parse_opts_ctx *pctx = fc->fs_private;
1085
1086 if (pctx) {
1087 destroy_mount_options(pctx->opts);
1088 ceph_destroy_options(pctx->copts);
1089 kfree(pctx);
1090 }
1091}
1092
1093static int ceph_reconfigure_fc(struct fs_context *fc)
1094{
1095 sync_filesystem(fc->root->d_sb);
1096 return 0;
1097}
1098
1099static const struct fs_context_operations ceph_context_ops = {
1100 .free = ceph_free_fc,
1101 .parse_param = ceph_parse_mount_param,
1102 .get_tree = ceph_get_tree,
1103 .reconfigure = ceph_reconfigure_fc,
1104};
1105
1106/*
1107 * Set up the filesystem mount context.
1108 */
1109static int ceph_init_fs_context(struct fs_context *fc)
1110{
1111 struct ceph_parse_opts_ctx *pctx;
1112 struct ceph_mount_options *fsopt;
1113
1114 pctx = kzalloc(sizeof(*pctx), GFP_KERNEL);
1115 if (!pctx)
1116 return -ENOMEM;
1117
1118 pctx->copts = ceph_alloc_options();
1119 if (!pctx->copts)
1120 goto nomem;
1121
1122 pctx->opts = kzalloc(sizeof(*pctx->opts), GFP_KERNEL);
1123 if (!pctx->opts)
1124 goto nomem;
1125
1126 fsopt = pctx->opts;
1127 fsopt->flags = CEPH_MOUNT_OPT_DEFAULT;
1128
1129 fsopt->wsize = CEPH_MAX_WRITE_SIZE;
1130 fsopt->rsize = CEPH_MAX_READ_SIZE;
1131 fsopt->rasize = CEPH_RASIZE_DEFAULT;
1132 fsopt->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL);
1133 if (!fsopt->snapdir_name)
1134 goto nomem;
1135
1136 fsopt->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT;
1137 fsopt->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT;
1138 fsopt->max_readdir = CEPH_MAX_READDIR_DEFAULT;
1139 fsopt->max_readdir_bytes = CEPH_MAX_READDIR_BYTES_DEFAULT;
1140 fsopt->congestion_kb = default_congestion_kb();
1141
1142 fc->fs_private = pctx;
1143 fc->ops = &ceph_context_ops;
1144 return 0;
1145
1146nomem:
1147 destroy_mount_options(pctx->opts);
1148 ceph_destroy_options(pctx->copts);
1149 kfree(pctx);
1150 return -ENOMEM;
1149}1151}
1150 1152
1151static void ceph_kill_sb(struct super_block *s)1153static void ceph_kill_sb(struct super_block *s)
@@ -1172,7 +1174,7 @@ static void ceph_kill_sb(struct super_block *s) · 20 unmodified lines
1172static struct file_system_type ceph_fs_type = {1174static struct file_system_type ceph_fs_type = {
1173 .owner = THIS_MODULE,1175 .owner = THIS_MODULE,
1174 .name = "ceph",1176 .name = "ceph",
1175 .mount = ceph_mount,1177 .init_fs_context = ceph_init_fs_context,
1176 .kill_sb = ceph_kill_sb,1178 .kill_sb = ceph_kill_sb,
1177 .fs_flags = FS_RENAME_DOES_D_MOVE,1179 .fs_flags = FS_RENAME_DOES_D_MOVE,
1178};1180};
fs/ceph/super.h+0−1
@@ -74,7 +74,6 @@ · 73 unmodified lines
74 74
75struct ceph_mount_options {75struct ceph_mount_options {
76 int flags;76 int flags;
77 int sb_flags;
78 77
79 int wsize; /* max write size */78 int wsize; /* max write size */
80 int rsize; /* max read size */79 int rsize; /* max read size */
include/linux/ceph/libceph.h+6−4
@@ -280,10 +280,12 @@ extern const char *ceph_msg_type_name(int type); · 279 unmodified lines
280extern int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid);280extern int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid);
281extern void *ceph_kvmalloc(size_t size, gfp_t flags);281extern void *ceph_kvmalloc(size_t size, gfp_t flags);
282 282
283extern struct ceph_options *ceph_parse_options(char *options,283struct fs_parameter;
284 const char *dev_name, const char *dev_name_end,284struct ceph_options *ceph_alloc_options(void);
285 int (*parse_extra_token)(char *c, void *private),285int ceph_parse_mon_ips(const char *buf, size_t len, struct ceph_options *opt,
286 void *private);286 struct fs_context *fc);
287int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
288 struct fs_context *fc);
287int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,289int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
288 bool show_all);290 bool show_all);
289extern void ceph_destroy_options(struct ceph_options *opt);291extern void ceph_destroy_options(struct ceph_options *opt);
net/ceph/ceph_common.c+190−229
@@ -11,7 +11,7 @@ · 10 unmodified lines
11#include <linux/module.h>11#include <linux/module.h>
12#include <linux/mount.h>12#include <linux/mount.h>
13#include <linux/nsproxy.h>13#include <linux/nsproxy.h>
14#include <linux/parser.h>14#include <linux/fs_parser.h>
15#include <linux/sched.h>15#include <linux/sched.h>
16#include <linux/sched/mm.h>16#include <linux/sched/mm.h>
17#include <linux/seq_file.h>17#include <linux/seq_file.h>
@@ -254,58 +254,77 @@ enum { · 236 unmodified lines
254 Opt_mount_timeout,254 Opt_mount_timeout,
255 Opt_osd_idle_ttl,255 Opt_osd_idle_ttl,
256 Opt_osd_request_timeout,256 Opt_osd_request_timeout,
257 Opt_last_int,
258 /* int args above */257 /* int args above */
259 Opt_fsid,258 Opt_fsid,
260 Opt_name,259 Opt_name,
261 Opt_secret,260 Opt_secret,
262 Opt_key,261 Opt_key,
263 Opt_ip,262 Opt_ip,
264 Opt_last_string,
265 /* string args above */263 /* string args above */
266 Opt_share,264 Opt_share,
267 Opt_noshare,
268 Opt_crc,265 Opt_crc,
269 Opt_nocrc,
270 Opt_cephx_require_signatures,266 Opt_cephx_require_signatures,
271 Opt_nocephx_require_signatures,
272 Opt_cephx_sign_messages,267 Opt_cephx_sign_messages,
273 Opt_nocephx_sign_messages,
274 Opt_tcp_nodelay,268 Opt_tcp_nodelay,
275 Opt_notcp_nodelay,
276 Opt_abort_on_full,269 Opt_abort_on_full,
277};270};
278 271
279static match_table_t opt_tokens = {272static const struct fs_parameter_spec ceph_param_specs[] = {
280 {Opt_osdtimeout, "osdtimeout=%d"},273 fsparam_flag ("abort_on_full", Opt_abort_on_full),
281 {Opt_osdkeepalivetimeout, "osdkeepalive=%d"},274 fsparam_flag_no ("cephx_require_signatures", Opt_cephx_require_signatures),
282 {Opt_mount_timeout, "mount_timeout=%d"},275 fsparam_flag_no ("cephx_sign_messages", Opt_cephx_sign_messages),
283 {Opt_osd_idle_ttl, "osd_idle_ttl=%d"},276 fsparam_flag_no ("crc", Opt_crc),
284 {Opt_osd_request_timeout, "osd_request_timeout=%d"},277 fsparam_string ("fsid", Opt_fsid),
285 /* int args above */278 fsparam_string ("ip", Opt_ip),
286 {Opt_fsid, "fsid=%s"},279 fsparam_string ("key", Opt_key),
287 {Opt_name, "name=%s"},280 fsparam_u32 ("mount_timeout", Opt_mount_timeout),
288 {Opt_secret, "secret=%s"},281 fsparam_string ("name", Opt_name),
289 {Opt_key, "key=%s"},282 fsparam_u32 ("osd_idle_ttl", Opt_osd_idle_ttl),
290 {Opt_ip, "ip=%s"},283 fsparam_u32 ("osd_request_timeout", Opt_osd_request_timeout),
291 /* string args above */284 fsparam_u32 ("osdkeepalive", Opt_osdkeepalivetimeout),
292 {Opt_share, "share"},285 __fsparam (fs_param_is_s32, "osdtimeout", Opt_osdtimeout,
293 {Opt_noshare, "noshare"},286 fs_param_deprecated),
294 {Opt_crc, "crc"},287 fsparam_string ("secret", Opt_secret),
295 {Opt_nocrc, "nocrc"},288 fsparam_flag_no ("share", Opt_share),
296 {Opt_cephx_require_signatures, "cephx_require_signatures"},289 fsparam_flag_no ("tcp_nodelay", Opt_tcp_nodelay),
297 {Opt_nocephx_require_signatures, "nocephx_require_signatures"},290 {}
298 {Opt_cephx_sign_messages, "cephx_sign_messages"},291};
299 {Opt_nocephx_sign_messages, "nocephx_sign_messages"},292
300 {Opt_tcp_nodelay, "tcp_nodelay"},293static const struct fs_parameter_description ceph_parameters = {
301 {Opt_notcp_nodelay, "notcp_nodelay"},294 .name = "libceph",
302 {Opt_abort_on_full, "abort_on_full"},295 .specs = ceph_param_specs,
303 {-1, NULL}
304};296};
305 297
298struct ceph_options *ceph_alloc_options(void)
299{
300 struct ceph_options *opt;
301
302 opt = kzalloc(sizeof(*opt), GFP_KERNEL);
303 if (!opt)
304 return NULL;
305
306 opt->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*opt->mon_addr),
307 GFP_KERNEL);
308 if (!opt->mon_addr) {
309 kfree(opt);
310 return NULL;
311 }
312
313 opt->flags = CEPH_OPT_DEFAULT;
314 opt->osd_keepalive_timeout = CEPH_OSD_KEEPALIVE_DEFAULT;
315 opt->mount_timeout = CEPH_MOUNT_TIMEOUT_DEFAULT;
316 opt->osd_idle_ttl = CEPH_OSD_IDLE_TTL_DEFAULT;
317 opt->osd_request_timeout = CEPH_OSD_REQUEST_TIMEOUT_DEFAULT;
318 return opt;
319}
320EXPORT_SYMBOL(ceph_alloc_options);
321
306void ceph_destroy_options(struct ceph_options *opt)322void ceph_destroy_options(struct ceph_options *opt)
307{323{
308 dout("destroy_options %p\n", opt);324 dout("destroy_options %p\n", opt);
325 if (!opt)
326 return;
327
309 kfree(opt->name);328 kfree(opt->name);
310 if (opt->key) {329 if (opt->key) {
311 ceph_crypto_key_destroy(opt->key);330 ceph_crypto_key_destroy(opt->key);
@@ -317,7 +336,9 @@ void ceph_destroy_options(struct ceph_options *opt) · 5 unmodified lines
317EXPORT_SYMBOL(ceph_destroy_options);336EXPORT_SYMBOL(ceph_destroy_options);
318 337
319/* get secret from key store */338/* get secret from key store */
320static int get_secret(struct ceph_crypto_key *dst, const char *name) {339static int get_secret(struct ceph_crypto_key *dst, const char *name,
340 struct fs_context *fc)
341{
321 struct key *ukey;342 struct key *ukey;
322 int key_err;343 int key_err;
323 int err = 0;344 int err = 0;
@@ -330,20 +351,20 @@ static int get_secret(struct ceph_crypto_key *dst, const char *name) { · 6 unmodified lines
330 key_err = PTR_ERR(ukey);351 key_err = PTR_ERR(ukey);
331 switch (key_err) {352 switch (key_err) {
332 case -ENOKEY:353 case -ENOKEY:
333 pr_warn("ceph: Mount failed due to key not found: %s\n",354 errorf(fc, "libceph: Failed due to key not found: %s",
334 name);355 name);
335 break;356 break;
336 case -EKEYEXPIRED:357 case -EKEYEXPIRED:
337 pr_warn("ceph: Mount failed due to expired key: %s\n",358 errorf(fc, "libceph: Failed due to expired key: %s",
338 name);359 name);
339 break;360 break;
340 case -EKEYREVOKED:361 case -EKEYREVOKED:
341 pr_warn("ceph: Mount failed due to revoked key: %s\n",362 errorf(fc, "libceph: Failed due to revoked key: %s",
342 name);363 name);
343 break;364 break;
344 default:365 default:
345 pr_warn("ceph: Mount failed due to unknown key error %d: %s\n",366 errorf(fc, "libceph: Failed due to key error %d: %s",
346 key_err, name);367 key_err, name);
347 }368 }
348 err = -EPERM;369 err = -EPERM;
349 goto out;370 goto out;
@@ -361,217 +382,157 @@ out: · 11 unmodified lines
361 return err;382 return err;
362}383}
363 384
364struct ceph_options *385int ceph_parse_mon_ips(const char *buf, size_t len, struct ceph_options *opt,
365ceph_parse_options(char *options, const char *dev_name,386 struct fs_context *fc)
366 const char *dev_name_end,
367 int (*parse_extra_token)(char *c, void *private),
368 void *private)
369{387{
370 struct ceph_options *opt;388 int ret;
371 const char *c;
372 int err = -ENOMEM;
373 substring_t argstr[MAX_OPT_ARGS];
374
375 opt = kzalloc(sizeof(*opt), GFP_KERNEL);
376 if (!opt)
377 return ERR_PTR(-ENOMEM);
378 opt->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*opt->mon_addr),
379 GFP_KERNEL);
380 if (!opt->mon_addr)
381 goto out;
382
383 dout("parse_options %p options '%s' dev_name '%s'\n", opt, options,
384 dev_name);
385
386 /* start with defaults */
387 opt->flags = CEPH_OPT_DEFAULT;
388 opt->osd_keepalive_timeout = CEPH_OSD_KEEPALIVE_DEFAULT;
389 opt->mount_timeout = CEPH_MOUNT_TIMEOUT_DEFAULT;
390 opt->osd_idle_ttl = CEPH_OSD_IDLE_TTL_DEFAULT;
391 opt->osd_request_timeout = CEPH_OSD_REQUEST_TIMEOUT_DEFAULT;
392 389
393 /* get mon ip(s) */
394 /* ip1[:port1][,ip2[:port2]...] */390 /* ip1[:port1][,ip2[:port2]...] */
395 err = ceph_parse_ips(dev_name, dev_name_end, opt->mon_addr,391 ret = ceph_parse_ips(buf, buf + len, opt->mon_addr, CEPH_MAX_MON,
396 CEPH_MAX_MON, &opt->num_mon);392 &opt->num_mon);
397 if (err < 0)393 if (ret) {
398 goto out;394 errorf(fc, "libceph: Failed to parse monitor IPs: %d", ret);
395 return ret;
396 }
399 397
400 /* parse mount options */398 return 0;
401 while ((c = strsep(&options, ",")) != NULL) {399}
402 int token, intval;400EXPORT_SYMBOL(ceph_parse_mon_ips);
403 if (!*c)401
404 continue;402int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
405 err = -EINVAL;403 struct fs_context *fc)
406 token = match_token((char *)c, opt_tokens, argstr);404{
407 if (token < 0 && parse_extra_token) {405 struct fs_parse_result result;
408 /* extra? */406 int token, err;
409 err = parse_extra_token((char *)c, private);407
410 if (err < 0) {408 token = fs_parse(fc, &ceph_parameters, param, &result);
411 pr_err("bad option at '%s'\n", c);409 dout("%s fs_parse '%s' token %d\n", __func__, param->key, token);
412 goto out;410 if (token < 0)
413 }411 return token;
414 continue;412
415 }413 switch (token) {
416 if (token < Opt_last_int) {414 case Opt_ip:
417 err = match_int(&argstr[0], &intval);415 err = ceph_parse_ips(param->string,
418 if (err < 0) {416 param->string + param->size,
419 pr_err("bad option arg (not int) at '%s'\n", c);417 &opt->my_addr,
420 goto out;418 1, NULL);
421 }419 if (err) {
422 dout("got int token %d val %d\n", token, intval);420 errorf(fc, "libceph: Failed to parse ip: %d", err);
423 } else if (token > Opt_last_int && token < Opt_last_string) {421 return err;
424 dout("got string token %d val %s\n", token,
425 argstr[0].from);
426 } else {
427 dout("got token %d\n", token);
428 }422 }
429 switch (token) {423 opt->flags |= CEPH_OPT_MYIP;
430 case Opt_ip:424 break;
431 err = ceph_parse_ips(argstr[0].from,
432 argstr[0].to,
433 &opt->my_addr,
434 1, NULL);
435 if (err < 0)
436 goto out;
437 opt->flags |= CEPH_OPT_MYIP;
438 break;
439 425
440 case Opt_fsid:426 case Opt_fsid:
441 err = parse_fsid(argstr[0].from, &opt->fsid);427 err = parse_fsid(param->string, &opt->fsid);
442 if (err == 0)428 if (err) {
443 opt->flags |= CEPH_OPT_FSID;429 errorf(fc, "libceph: Failed to parse fsid: %d", err);
444 break;430 return err;
445 case Opt_name:431 }
446 kfree(opt->name);432 opt->flags |= CEPH_OPT_FSID;
447 opt->name = kstrndup(argstr[0].from,433 break;
448 argstr[0].to-argstr[0].from,434 case Opt_name:
449 GFP_KERNEL);435 kfree(opt->name);
450 if (!opt->name) {436 opt->name = param->string;
451 err = -ENOMEM;437 param->string = NULL;
452 goto out;438 break;
453 }439 case Opt_secret:
454 break;440 ceph_crypto_key_destroy(opt->key);
455 case Opt_secret:441 kfree(opt->key);
456 ceph_crypto_key_destroy(opt->key);
457 kfree(opt->key);
458
459 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
460 if (!opt->key) {
461 err = -ENOMEM;
462 goto out;
463 }
464 err = ceph_crypto_key_unarmor(opt->key, argstr[0].from);
465 if (err < 0)
466 goto out;
467 break;
468 case Opt_key:
469 ceph_crypto_key_destroy(opt->key);
470 kfree(opt->key);
471
472 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
473 if (!opt->key) {
474 err = -ENOMEM;
475 goto out;
476 }
477 err = get_secret(opt->key, argstr[0].from);
478 if (err < 0)
479 goto out;
480 break;
481 442
482 /* misc */443 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
483 case Opt_osdtimeout:444 if (!opt->key)
484 pr_warn("ignoring deprecated osdtimeout option\n");445 return -ENOMEM;
485 break;446 err = ceph_crypto_key_unarmor(opt->key, param->string);
486 case Opt_osdkeepalivetimeout:447 if (err) {
487 /* 0 isn't well defined right now, reject it */448 errorf(fc, "libceph: Failed to parse secret: %d", err);
488 if (intval < 1 || intval > INT_MAX / 1000) {449 return err;
489 pr_err("osdkeepalive out of range\n");450 }
490 err = -EINVAL;451 break;
491 goto out;452 case Opt_key:
492 }453 ceph_crypto_key_destroy(opt->key);
493 opt->osd_keepalive_timeout =454 kfree(opt->key);
494 msecs_to_jiffies(intval * 1000);
495 break;
496 case Opt_osd_idle_ttl:
497 /* 0 isn't well defined right now, reject it */
498 if (intval < 1 || intval > INT_MAX / 1000) {
499 pr_err("osd_idle_ttl out of range\n");
500 err = -EINVAL;
501 goto out;
502 }
503 opt->osd_idle_ttl = msecs_to_jiffies(intval * 1000);
504 break;
505 case Opt_mount_timeout:
506 /* 0 is "wait forever" (i.e. infinite timeout) */
507 if (intval < 0 || intval > INT_MAX / 1000) {
508 pr_err("mount_timeout out of range\n");
509 err = -EINVAL;
510 goto out;
511 }
512 opt->mount_timeout = msecs_to_jiffies(intval * 1000);
513 break;
514 case Opt_osd_request_timeout:
515 /* 0 is "wait forever" (i.e. infinite timeout) */
516 if (intval < 0 || intval > INT_MAX / 1000) {
517 pr_err("osd_request_timeout out of range\n");
518 err = -EINVAL;
519 goto out;
520 }
521 opt->osd_request_timeout = msecs_to_jiffies(intval * 1000);
522 break;
523 455
524 case Opt_share:456 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
457 if (!opt->key)
458 return -ENOMEM;
459 return get_secret(opt->key, param->string, fc);
460
461 case Opt_osdtimeout:
462 warnf(fc, "libceph: Ignoring osdtimeout");
463 break;
464 case Opt_osdkeepalivetimeout:
465 /* 0 isn't well defined right now, reject it */
466 if (result.uint_32 < 1 || result.uint_32 > INT_MAX / 1000)
467 goto out_of_range;
468 opt->osd_keepalive_timeout =
469 msecs_to_jiffies(result.uint_32 * 1000);
470 break;
471 case Opt_osd_idle_ttl:
472 /* 0 isn't well defined right now, reject it */
473 if (result.uint_32 < 1 || result.uint_32 > INT_MAX / 1000)
474 goto out_of_range;
475 opt->osd_idle_ttl = msecs_to_jiffies(result.uint_32 * 1000);
476 break;
477 case Opt_mount_timeout:
478 /* 0 is "wait forever" (i.e. infinite timeout) */
479 if (result.uint_32 > INT_MAX / 1000)
480 goto out_of_range;
481 opt->mount_timeout = msecs_to_jiffies(result.uint_32 * 1000);
482 break;
483 case Opt_osd_request_timeout:
484 /* 0 is "wait forever" (i.e. infinite timeout) */
485 if (result.uint_32 > INT_MAX / 1000)
486 goto out_of_range;
487 opt->osd_request_timeout =
488 msecs_to_jiffies(result.uint_32 * 1000);
489 break;
490
491 case Opt_share:
492 if (!result.negated)
525 opt->flags &= ~CEPH_OPT_NOSHARE;493 opt->flags &= ~CEPH_OPT_NOSHARE;
526 break;494 else
527 case Opt_noshare:
528 opt->flags |= CEPH_OPT_NOSHARE;495 opt->flags |= CEPH_OPT_NOSHARE;
529 break;496 break;
530 497 case Opt_crc:
531 case Opt_crc:498 if (!result.negated)
532 opt->flags &= ~CEPH_OPT_NOCRC;499 opt->flags &= ~CEPH_OPT_NOCRC;
533 break;500 else
534 case Opt_nocrc:
535 opt->flags |= CEPH_OPT_NOCRC;501 opt->flags |= CEPH_OPT_NOCRC;
536 break;502 break;
537 503 case Opt_cephx_require_signatures:
538 case Opt_cephx_require_signatures:504 if (!result.negated)
539 opt->flags &= ~CEPH_OPT_NOMSGAUTH;505 opt->flags &= ~CEPH_OPT_NOMSGAUTH;
540 break;506 else
541 case Opt_nocephx_require_signatures:
542 opt->flags |= CEPH_OPT_NOMSGAUTH;507 opt->flags |= CEPH_OPT_NOMSGAUTH;
543 break;508 break;
544 case Opt_cephx_sign_messages:509 case Opt_cephx_sign_messages:
510 if (!result.negated)
545 opt->flags &= ~CEPH_OPT_NOMSGSIGN;511 opt->flags &= ~CEPH_OPT_NOMSGSIGN;
546 break;512 else
547 case Opt_nocephx_sign_messages:
548 opt->flags |= CEPH_OPT_NOMSGSIGN;513 opt->flags |= CEPH_OPT_NOMSGSIGN;
549 break;514 break;
550 515 case Opt_tcp_nodelay:
551 case Opt_tcp_nodelay:516 if (!result.negated)
552 opt->flags |= CEPH_OPT_TCP_NODELAY;517 opt->flags |= CEPH_OPT_TCP_NODELAY;
553 break;518 else
554 case Opt_notcp_nodelay:
555 opt->flags &= ~CEPH_OPT_TCP_NODELAY;519 opt->flags &= ~CEPH_OPT_TCP_NODELAY;
556 break;520 break;
557 521
558 case Opt_abort_on_full:522 case Opt_abort_on_full:
559 opt->flags |= CEPH_OPT_ABORT_ON_FULL;523 opt->flags |= CEPH_OPT_ABORT_ON_FULL;
560 break;524 break;
561 525
562 default:526 default:
563 BUG_ON(token);527 BUG();
564 }
565 }528 }
566 529
567 /* success */530 return 0;
568 return opt;
569 531
570out:532out_of_range:
571 ceph_destroy_options(opt);533 return invalf(fc, "libceph: %s out of range", param->key);
572 return ERR_PTR(err);
573}534}
574EXPORT_SYMBOL(ceph_parse_options);535EXPORT_SYMBOL(ceph_parse_param);
575 536
576int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,537int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
577 bool show_all)538 bool show_all)
net/ceph/messenger.c+0−2
@@ -2004,10 +2004,8 @@ int ceph_parse_ips(const char *c, const char *end, · 2003 unmodified lines
2004 return 0;2004 return 0;
2005 2005
2006bad:2006bad:
2007 pr_err("parse_ips bad ip '%.*s'\n", (int)(end - c), c);
2008 return ret;2007 return ret;
2009}2008}
2010EXPORT_SYMBOL(ceph_parse_ips);
2011 2009
2012static int process_banner(struct ceph_connection *con)2010static int process_banner(struct ceph_connection *con)
2013{2011{

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t