Lines Matching +full:dout +full:- +full:default +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0-only
4 #include <linux/backing-dev.h>
10 #include <keys/ceph-type.h>
97 default: return "unknown"; in ceph_msg_type_name()
107 if (client->have_fsid) { in ceph_check_fsid()
108 if (ceph_fsid_compare(&client->fsid, fsid)) { in ceph_check_fsid()
110 &client->fsid, fsid); in ceph_check_fsid()
111 return -1; in ceph_check_fsid()
114 memcpy(&client->fsid, fsid, sizeof(*fsid)); in ceph_check_fsid()
125 return -1; in strcmp_null()
135 struct ceph_options *opt2 = client->options; in ceph_compare_options()
144 if (!net_eq(current->nsproxy->net_ns, read_pnet(&client->msgr.net))) in ceph_compare_options()
145 return -1; in ceph_compare_options()
151 ret = strcmp_null(opt1->name, opt2->name); in ceph_compare_options()
155 if (opt1->key && !opt2->key) in ceph_compare_options()
156 return -1; in ceph_compare_options()
157 if (!opt1->key && opt2->key) in ceph_compare_options()
159 if (opt1->key && opt2->key) { in ceph_compare_options()
160 if (opt1->key->type != opt2->key->type) in ceph_compare_options()
161 return -1; in ceph_compare_options()
162 if (opt1->key->created.tv_sec != opt2->key->created.tv_sec) in ceph_compare_options()
163 return -1; in ceph_compare_options()
164 if (opt1->key->created.tv_nsec != opt2->key->created.tv_nsec) in ceph_compare_options()
165 return -1; in ceph_compare_options()
166 if (opt1->key->len != opt2->key->len) in ceph_compare_options()
167 return -1; in ceph_compare_options()
168 if (opt1->key->key && !opt2->key->key) in ceph_compare_options()
169 return -1; in ceph_compare_options()
170 if (!opt1->key->key && opt2->key->key) in ceph_compare_options()
172 if (opt1->key->key && opt2->key->key) { in ceph_compare_options()
173 ret = memcmp(opt1->key->key, opt2->key->key, opt1->key->len); in ceph_compare_options()
179 ret = ceph_compare_crush_locs(&opt1->crush_locs, &opt2->crush_locs); in ceph_compare_options()
184 for (i = 0; i < opt1->num_mon; i++) { in ceph_compare_options()
185 if (ceph_monmap_contains(client->monc.monmap, in ceph_compare_options()
186 &opt1->mon_addr[i])) in ceph_compare_options()
189 return -1; in ceph_compare_options()
197 int err = -EINVAL; in ceph_parse_fsid()
200 dout("%s '%s'\n", __func__, str); in ceph_parse_fsid()
201 tmp[2] = 0; in ceph_parse_fsid()
213 fsid->fsid[i] = d & 0xff; in ceph_parse_fsid()
215 str += 2; in ceph_parse_fsid()
220 dout("%s ret %d got fsid %pU\n", __func__, err, fsid); in ceph_parse_fsid()
277 {"prefer-crc", Opt_ms_mode_prefer_crc},
278 {"prefer-secure", Opt_ms_mode_prefer_secure},
316 opt->crush_locs = RB_ROOT; in ceph_alloc_options()
317 opt->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*opt->mon_addr), in ceph_alloc_options()
319 if (!opt->mon_addr) { in ceph_alloc_options()
324 opt->flags = CEPH_OPT_DEFAULT; in ceph_alloc_options()
325 opt->osd_keepalive_timeout = CEPH_OSD_KEEPALIVE_DEFAULT; in ceph_alloc_options()
326 opt->mount_timeout = CEPH_MOUNT_TIMEOUT_DEFAULT; in ceph_alloc_options()
327 opt->osd_idle_ttl = CEPH_OSD_IDLE_TTL_DEFAULT; in ceph_alloc_options()
328 opt->osd_request_timeout = CEPH_OSD_REQUEST_TIMEOUT_DEFAULT; in ceph_alloc_options()
329 opt->read_from_replica = CEPH_READ_FROM_REPLICA_DEFAULT; in ceph_alloc_options()
330 opt->con_modes[0] = CEPH_CON_MODE_UNKNOWN; in ceph_alloc_options()
331 opt->con_modes[1] = CEPH_CON_MODE_UNKNOWN; in ceph_alloc_options()
338 dout("destroy_options %p\n", opt); in ceph_destroy_options()
342 ceph_clear_crush_locs(&opt->crush_locs); in ceph_destroy_options()
343 kfree(opt->name); in ceph_destroy_options()
344 if (opt->key) { in ceph_destroy_options()
345 ceph_crypto_key_destroy(opt->key); in ceph_destroy_options()
346 kfree(opt->key); in ceph_destroy_options()
348 kfree(opt->mon_addr); in ceph_destroy_options()
364 /* request_key errors don't map nicely to mount(2) in get_secret()
368 case -ENOKEY: in get_secret()
372 case -EKEYEXPIRED: in get_secret()
376 case -EKEYREVOKED: in get_secret()
380 default: in get_secret()
384 err = -EPERM; in get_secret()
388 ckey = ukey->payload.data[0]; in get_secret()
407 ret = ceph_parse_ips(buf, buf + len, opt->mon_addr, CEPH_MAX_MON, in ceph_parse_mon_ips()
408 &opt->num_mon, delim); in ceph_parse_mon_ips()
426 dout("%s fs_parse '%s' token %d\n", __func__, param->key, token); in ceph_parse_param()
432 err = ceph_parse_ips(param->string, in ceph_parse_param()
433 param->string + param->size, in ceph_parse_param()
434 &opt->my_addr, 1, NULL, ','); in ceph_parse_param()
439 opt->flags |= CEPH_OPT_MYIP; in ceph_parse_param()
443 err = ceph_parse_fsid(param->string, &opt->fsid); in ceph_parse_param()
448 opt->flags |= CEPH_OPT_FSID; in ceph_parse_param()
451 kfree(opt->name); in ceph_parse_param()
452 opt->name = param->string; in ceph_parse_param()
453 param->string = NULL; in ceph_parse_param()
456 ceph_crypto_key_destroy(opt->key); in ceph_parse_param()
457 kfree(opt->key); in ceph_parse_param()
459 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL); in ceph_parse_param()
460 if (!opt->key) in ceph_parse_param()
461 return -ENOMEM; in ceph_parse_param()
462 err = ceph_crypto_key_unarmor(opt->key, param->string); in ceph_parse_param()
469 ceph_crypto_key_destroy(opt->key); in ceph_parse_param()
470 kfree(opt->key); in ceph_parse_param()
472 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL); in ceph_parse_param()
473 if (!opt->key) in ceph_parse_param()
474 return -ENOMEM; in ceph_parse_param()
475 return get_secret(opt->key, param->string, &log); in ceph_parse_param()
477 ceph_clear_crush_locs(&opt->crush_locs); in ceph_parse_param()
478 err = ceph_parse_crush_location(param->string, in ceph_parse_param()
479 &opt->crush_locs); in ceph_parse_param()
489 opt->read_from_replica = 0; in ceph_parse_param()
492 opt->read_from_replica = CEPH_OSD_FLAG_BALANCE_READS; in ceph_parse_param()
495 opt->read_from_replica = CEPH_OSD_FLAG_LOCALIZE_READS; in ceph_parse_param()
497 default: in ceph_parse_param()
504 opt->con_modes[0] = CEPH_CON_MODE_UNKNOWN; in ceph_parse_param()
505 opt->con_modes[1] = CEPH_CON_MODE_UNKNOWN; in ceph_parse_param()
508 opt->con_modes[0] = CEPH_CON_MODE_CRC; in ceph_parse_param()
509 opt->con_modes[1] = CEPH_CON_MODE_UNKNOWN; in ceph_parse_param()
512 opt->con_modes[0] = CEPH_CON_MODE_SECURE; in ceph_parse_param()
513 opt->con_modes[1] = CEPH_CON_MODE_UNKNOWN; in ceph_parse_param()
516 opt->con_modes[0] = CEPH_CON_MODE_CRC; in ceph_parse_param()
517 opt->con_modes[1] = CEPH_CON_MODE_SECURE; in ceph_parse_param()
520 opt->con_modes[0] = CEPH_CON_MODE_SECURE; in ceph_parse_param()
521 opt->con_modes[1] = CEPH_CON_MODE_CRC; in ceph_parse_param()
523 default: in ceph_parse_param()
532 opt->osd_keepalive_timeout = in ceph_parse_param()
539 opt->osd_idle_ttl = msecs_to_jiffies(result.uint_32 * 1000); in ceph_parse_param()
545 opt->mount_timeout = msecs_to_jiffies(result.uint_32 * 1000); in ceph_parse_param()
551 opt->osd_request_timeout = in ceph_parse_param()
557 opt->flags &= ~CEPH_OPT_NOSHARE; in ceph_parse_param()
559 opt->flags |= CEPH_OPT_NOSHARE; in ceph_parse_param()
563 opt->flags &= ~CEPH_OPT_NOCRC; in ceph_parse_param()
565 opt->flags |= CEPH_OPT_NOCRC; in ceph_parse_param()
575 opt->flags &= ~CEPH_OPT_NOMSGSIGN; in ceph_parse_param()
577 opt->flags |= CEPH_OPT_NOMSGSIGN; in ceph_parse_param()
581 opt->flags |= CEPH_OPT_TCP_NODELAY; in ceph_parse_param()
583 opt->flags &= ~CEPH_OPT_TCP_NODELAY; in ceph_parse_param()
587 opt->flags |= CEPH_OPT_ABORT_ON_FULL; in ceph_parse_param()
590 opt->flags |= CEPH_OPT_RXBOUNCE; in ceph_parse_param()
593 default: in ceph_parse_param()
600 return inval_plog(&log, "%s out of range", param->key); in ceph_parse_param()
607 struct ceph_options *opt = client->options; in ceph_print_client_options()
608 size_t pos = m->count; in ceph_print_client_options()
611 if (opt->name) { in ceph_print_client_options()
613 seq_escape(m, opt->name, ", \t\n\\"); in ceph_print_client_options()
616 if (opt->key) in ceph_print_client_options()
619 if (!RB_EMPTY_ROOT(&opt->crush_locs)) { in ceph_print_client_options()
621 for (n = rb_first(&opt->crush_locs); ; ) { in ceph_print_client_options()
625 seq_printf(m, "%s:%s", loc->cl_loc.cl_type_name, in ceph_print_client_options()
626 loc->cl_loc.cl_name); in ceph_print_client_options()
635 if (opt->read_from_replica == CEPH_OSD_FLAG_BALANCE_READS) { in ceph_print_client_options()
637 } else if (opt->read_from_replica == CEPH_OSD_FLAG_LOCALIZE_READS) { in ceph_print_client_options()
640 if (opt->con_modes[0] != CEPH_CON_MODE_UNKNOWN) { in ceph_print_client_options()
641 if (opt->con_modes[0] == CEPH_CON_MODE_CRC && in ceph_print_client_options()
642 opt->con_modes[1] == CEPH_CON_MODE_UNKNOWN) { in ceph_print_client_options()
644 } else if (opt->con_modes[0] == CEPH_CON_MODE_SECURE && in ceph_print_client_options()
645 opt->con_modes[1] == CEPH_CON_MODE_UNKNOWN) { in ceph_print_client_options()
647 } else if (opt->con_modes[0] == CEPH_CON_MODE_CRC && in ceph_print_client_options()
648 opt->con_modes[1] == CEPH_CON_MODE_SECURE) { in ceph_print_client_options()
649 seq_puts(m, "ms_mode=prefer-crc,"); in ceph_print_client_options()
650 } else if (opt->con_modes[0] == CEPH_CON_MODE_SECURE && in ceph_print_client_options()
651 opt->con_modes[1] == CEPH_CON_MODE_CRC) { in ceph_print_client_options()
652 seq_puts(m, "ms_mode=prefer-secure,"); in ceph_print_client_options()
656 if (opt->flags & CEPH_OPT_FSID) in ceph_print_client_options()
657 seq_printf(m, "fsid=%pU,", &opt->fsid); in ceph_print_client_options()
658 if (opt->flags & CEPH_OPT_NOSHARE) in ceph_print_client_options()
660 if (opt->flags & CEPH_OPT_NOCRC) in ceph_print_client_options()
662 if (opt->flags & CEPH_OPT_NOMSGSIGN) in ceph_print_client_options()
664 if ((opt->flags & CEPH_OPT_TCP_NODELAY) == 0) in ceph_print_client_options()
666 if (show_all && (opt->flags & CEPH_OPT_ABORT_ON_FULL)) in ceph_print_client_options()
668 if (opt->flags & CEPH_OPT_RXBOUNCE) in ceph_print_client_options()
671 if (opt->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT) in ceph_print_client_options()
673 jiffies_to_msecs(opt->mount_timeout) / 1000); in ceph_print_client_options()
674 if (opt->osd_idle_ttl != CEPH_OSD_IDLE_TTL_DEFAULT) in ceph_print_client_options()
676 jiffies_to_msecs(opt->osd_idle_ttl) / 1000); in ceph_print_client_options()
677 if (opt->osd_keepalive_timeout != CEPH_OSD_KEEPALIVE_DEFAULT) in ceph_print_client_options()
679 jiffies_to_msecs(opt->osd_keepalive_timeout) / 1000); in ceph_print_client_options()
680 if (opt->osd_request_timeout != CEPH_OSD_REQUEST_TIMEOUT_DEFAULT) in ceph_print_client_options()
682 jiffies_to_msecs(opt->osd_request_timeout) / 1000); in ceph_print_client_options()
685 if (m->count != pos) in ceph_print_client_options()
686 m->count--; in ceph_print_client_options()
694 return &client->msgr.inst.addr; in ceph_client_addr()
700 return client->monc.auth->global_id; in ceph_client_gid()
719 return ERR_PTR(-ENOMEM); in ceph_create_client()
721 client->private = private; in ceph_create_client()
722 client->options = opt; in ceph_create_client()
724 mutex_init(&client->mount_mutex); in ceph_create_client()
725 init_waitqueue_head(&client->auth_wq); in ceph_create_client()
726 client->auth_err = 0; in ceph_create_client()
728 client->extra_mon_dispatch = NULL; in ceph_create_client()
729 client->supported_features = CEPH_FEATURES_SUPPORTED_DEFAULT; in ceph_create_client()
730 client->required_features = CEPH_FEATURES_REQUIRED_DEFAULT; in ceph_create_client()
733 client->required_features |= CEPH_FEATURE_MSG_AUTH; in ceph_create_client()
737 myaddr = &client->options->my_addr; in ceph_create_client()
739 ceph_messenger_init(&client->msgr, myaddr); in ceph_create_client()
742 err = ceph_monc_init(&client->monc, client); in ceph_create_client()
745 err = ceph_osdc_init(&client->osdc, client); in ceph_create_client()
752 ceph_monc_stop(&client->monc); in ceph_create_client()
754 ceph_messenger_fini(&client->msgr); in ceph_create_client()
762 dout("destroy_client %p\n", client); in ceph_destroy_client()
764 atomic_set(&client->msgr.stopping, 1); in ceph_destroy_client()
767 ceph_osdc_stop(&client->osdc); in ceph_destroy_client()
768 ceph_monc_stop(&client->monc); in ceph_destroy_client()
769 ceph_messenger_fini(&client->msgr); in ceph_destroy_client()
773 ceph_destroy_options(client->options); in ceph_destroy_client()
776 dout("destroy_client %p done\n", client); in ceph_destroy_client()
782 ceph_messenger_reset_nonce(&client->msgr); in ceph_reset_client_addr()
783 ceph_monc_reopen_session(&client->monc); in ceph_reset_client_addr()
784 ceph_osdc_reopen_osds(&client->osdc); in ceph_reset_client_addr()
793 return client->monc.monmap && client->monc.monmap->epoch && in have_mon_and_osd_map()
794 client->osdc.osdmap && client->osdc.osdmap->epoch; in have_mon_and_osd_map()
802 unsigned long timeout = client->options->mount_timeout; in __ceph_open_session()
806 err = ceph_monc_open_session(&client->monc); in __ceph_open_session()
812 return -ETIMEDOUT; in __ceph_open_session()
815 dout("mount waiting for mon_map\n"); in __ceph_open_session()
816 err = wait_event_interruptible_timeout(client->auth_wq, in __ceph_open_session()
817 have_mon_and_osd_map(client) || (client->auth_err < 0), in __ceph_open_session()
821 if (client->auth_err < 0) in __ceph_open_session()
822 return client->auth_err; in __ceph_open_session()
826 &client->fsid); in __ceph_open_session()
838 dout("open_session start\n"); in ceph_open_session()
839 mutex_lock(&client->mount_mutex); in ceph_open_session()
843 mutex_unlock(&client->mount_mutex); in ceph_open_session()
854 ret = ceph_monc_get_version(&client->monc, "osdmap", &newest_epoch); in ceph_wait_for_latest_osdmap()
858 if (client->osdc.osdmap->epoch >= newest_epoch) in ceph_wait_for_latest_osdmap()
861 ceph_osdc_maybe_request_map(&client->osdc); in ceph_wait_for_latest_osdmap()
862 return ceph_monc_wait_osdmap(&client->monc, newest_epoch, timeout); in ceph_wait_for_latest_osdmap()
900 dout("exit_ceph_lib\n"); in exit_ceph_lib()