Lines Matching +full:cm +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
5 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
6 ** Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
119 return sprintf(buf, "%s\n", cl->cl_cluster_name); in cluster_cluster_name_show()
129 strscpy(cl->cl_cluster_name, buf, sizeof(cl->cl_cluster_name)); in cluster_cluster_name_store()
143 return -EPERM; in cluster_set()
160 #define CLUSTER_ATTR(name, check_cb) \ argument
161 static ssize_t cluster_##name##_store(struct config_item *item, \
165 return cluster_set(cl, &cl->cl_##name, &dlm_config.ci_##name, \
168 static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \
171 return snprintf(buf, PAGE_SIZE, "%u\n", cl->cl_##name); \
173 CONFIGFS_ATTR(cluster_, name);
185 return -EINVAL; in dlm_check_protocol_and_dlm_running()
189 return -EBUSY; in dlm_check_protocol_and_dlm_running()
197 return -EINVAL; in dlm_check_zero_and_dlm_running()
200 return -EBUSY; in dlm_check_zero_and_dlm_running()
208 return -EINVAL; in dlm_check_zero()
216 return -EINVAL; in dlm_check_buffer_size()
300 struct list_head list; /* space->members */
304 int comm_seq; /* copy of cm->seq when nd->nodeid is set */
403 const char *name) in make_cluster() argument
416 cl->sps = sps; in make_cluster()
417 cl->cms = cms; in make_cluster()
419 config_group_init_type_name(&cl->group, name, &cluster_type); in make_cluster()
420 config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type); in make_cluster()
421 config_group_init_type_name(&cms->cs_group, "comms", &comms_type); in make_cluster()
423 configfs_add_default_group(&sps->ss_group, &cl->group); in make_cluster()
424 configfs_add_default_group(&cms->cs_group, &cl->group); in make_cluster()
426 cl->cl_tcp_port = dlm_config.ci_tcp_port; in make_cluster()
427 cl->cl_buffer_size = dlm_config.ci_buffer_size; in make_cluster()
428 cl->cl_rsbtbl_size = dlm_config.ci_rsbtbl_size; in make_cluster()
429 cl->cl_recover_timer = dlm_config.ci_recover_timer; in make_cluster()
430 cl->cl_toss_secs = dlm_config.ci_toss_secs; in make_cluster()
431 cl->cl_scan_secs = dlm_config.ci_scan_secs; in make_cluster()
432 cl->cl_log_debug = dlm_config.ci_log_debug; in make_cluster()
433 cl->cl_log_info = dlm_config.ci_log_info; in make_cluster()
434 cl->cl_protocol = dlm_config.ci_protocol; in make_cluster()
435 cl->cl_new_rsb_count = dlm_config.ci_new_rsb_count; in make_cluster()
436 cl->cl_recover_callbacks = dlm_config.ci_recover_callbacks; in make_cluster()
437 memcpy(cl->cl_cluster_name, dlm_config.ci_cluster_name, in make_cluster()
440 space_list = &sps->ss_group; in make_cluster()
441 comm_list = &cms->cs_group; in make_cluster()
442 return &cl->group; in make_cluster()
448 return ERR_PTR(-ENOMEM); in make_cluster()
455 configfs_remove_default_groups(&cl->group); in drop_cluster()
467 kfree(cl->sps); in release_cluster()
468 kfree(cl->cms); in release_cluster()
472 static struct config_group *make_space(struct config_group *g, const char *name) in make_space() argument
483 config_group_init_type_name(&sp->group, name, &space_type); in make_space()
485 config_group_init_type_name(&nds->ns_group, "nodes", &nodes_type); in make_space()
486 configfs_add_default_group(&nds->ns_group, &sp->group); in make_space()
488 INIT_LIST_HEAD(&sp->members); in make_space()
489 mutex_init(&sp->members_lock); in make_space()
490 sp->members_count = 0; in make_space()
491 sp->nds = nds; in make_space()
492 return &sp->group; in make_space()
497 return ERR_PTR(-ENOMEM); in make_space()
504 /* assert list_empty(&sp->members) */ in drop_space()
506 configfs_remove_default_groups(&sp->group); in drop_space()
513 kfree(sp->nds); in release_space()
517 static struct config_item *make_comm(struct config_group *g, const char *name) in make_comm() argument
519 struct dlm_comm *cm; in make_comm() local
521 cm = kzalloc(sizeof(struct dlm_comm), GFP_NOFS); in make_comm()
522 if (!cm) in make_comm()
523 return ERR_PTR(-ENOMEM); in make_comm()
525 config_item_init_type_name(&cm->item, name, &comm_type); in make_comm()
527 cm->seq = dlm_comm_count++; in make_comm()
528 if (!cm->seq) in make_comm()
529 cm->seq = dlm_comm_count++; in make_comm()
531 cm->nodeid = -1; in make_comm()
532 cm->local = 0; in make_comm()
533 cm->addr_count = 0; in make_comm()
534 cm->mark = 0; in make_comm()
535 return &cm->item; in make_comm()
540 struct dlm_comm *cm = config_item_to_comm(i); in drop_comm() local
541 if (local_comm == cm) in drop_comm()
543 dlm_midcomms_close(cm->nodeid); in drop_comm()
544 while (cm->addr_count--) in drop_comm()
545 kfree(cm->addr[cm->addr_count]); in drop_comm()
551 struct dlm_comm *cm = config_item_to_comm(i); in release_comm() local
552 kfree(cm); in release_comm()
555 static struct config_item *make_node(struct config_group *g, const char *name) in make_node() argument
557 struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent); in make_node()
562 return ERR_PTR(-ENOMEM); in make_node()
564 config_item_init_type_name(&nd->item, name, &node_type); in make_node()
565 nd->nodeid = -1; in make_node()
566 nd->weight = 1; /* default weight of 1 if none is set */ in make_node()
567 nd->new = 1; /* set to 0 once it's been read by dlm_nodeid_list() */ in make_node()
569 mutex_lock(&sp->members_lock); in make_node()
570 list_add(&nd->list, &sp->members); in make_node()
571 sp->members_count++; in make_node()
572 mutex_unlock(&sp->members_lock); in make_node()
574 return &nd->item; in make_node()
579 struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent); in drop_node()
582 mutex_lock(&sp->members_lock); in drop_node()
583 list_del(&nd->list); in drop_node()
584 sp->members_count--; in drop_node()
585 mutex_unlock(&sp->members_lock); in drop_node()
625 return sprintf(buf, "%d\n", config_item_to_comm(item)->nodeid); in comm_nodeid_show()
631 int rc = kstrtoint(buf, 0, &config_item_to_comm(item)->nodeid); in comm_nodeid_store()
640 return sprintf(buf, "%d\n", config_item_to_comm(item)->local); in comm_local_show()
646 struct dlm_comm *cm = config_item_to_comm(item); in comm_local_store() local
647 int rc = kstrtoint(buf, 0, &cm->local); in comm_local_store()
651 if (cm->local && !local_comm) in comm_local_store()
652 local_comm = cm; in comm_local_store()
659 struct dlm_comm *cm = config_item_to_comm(item); in comm_addr_store() local
664 return -EINVAL; in comm_addr_store()
666 if (cm->addr_count >= DLM_MAX_ADDR_COUNT) in comm_addr_store()
667 return -ENOSPC; in comm_addr_store()
671 return -ENOMEM; in comm_addr_store()
675 rv = dlm_midcomms_addr(cm->nodeid, addr); in comm_addr_store()
681 cm->addr[cm->addr_count++] = addr; in comm_addr_store()
687 struct dlm_comm *cm = config_item_to_comm(item); in comm_addr_list_show() local
703 for (i = 0; i < cm->addr_count; i++) { in comm_addr_list_show()
704 addr = cm->addr[i]; in comm_addr_list_show()
706 switch(addr->ss_family) { in comm_addr_list_show()
709 s = sprintf(buf0, "AF_INET %pI4\n", &addr_in->sin_addr.s_addr); in comm_addr_list_show()
713 s = sprintf(buf0, "AF_INET6 %pI6\n", &addr_in6->sin6_addr); in comm_addr_list_show()
719 allowance -= s; in comm_addr_list_show()
727 return 4096 - allowance; in comm_addr_list_show()
732 return sprintf(buf, "%u\n", config_item_to_comm(item)->mark); in comm_mark_show()
750 rc = dlm_lowcomms_nodes_set_mark(comm->nodeid, mark); in comm_mark_store()
754 comm->mark = mark; in comm_mark_store()
775 return sprintf(buf, "%d\n", config_item_to_node(item)->nodeid); in node_nodeid_show()
783 int rc = kstrtoint(buf, 0, &nd->nodeid); in node_nodeid_store()
787 dlm_comm_seq(nd->nodeid, &seq); in node_nodeid_store()
788 nd->comm_seq = seq; in node_nodeid_store()
794 return sprintf(buf, "%d\n", config_item_to_node(item)->weight); in node_weight_show()
800 int rc = kstrtoint(buf, 0, &config_item_to_node(item)->weight); in node_weight_store()
820 static struct dlm_space *get_space(char *name) in get_space() argument
827 mutex_lock(&space_list->cg_subsys->su_mutex); in get_space()
828 i = config_group_find_item(space_list, name); in get_space()
829 mutex_unlock(&space_list->cg_subsys->su_mutex); in get_space()
836 config_item_put(&sp->group.cg_item); in put_space()
842 struct dlm_comm *cm = NULL; in get_comm() local
850 list_for_each_entry(i, &comm_list->cg_children, ci_entry) { in get_comm()
851 cm = config_item_to_comm(i); in get_comm()
853 if (cm->nodeid != nodeid) in get_comm()
862 cm = NULL; in get_comm()
863 return cm; in get_comm()
866 static void put_comm(struct dlm_comm *cm) in put_comm() argument
868 config_item_put(&cm->item); in put_comm()
882 return -EEXIST; in dlm_config_nodes()
884 mutex_lock(&sp->members_lock); in dlm_config_nodes()
885 if (!sp->members_count) { in dlm_config_nodes()
886 rv = -EINVAL; in dlm_config_nodes()
891 count = sp->members_count; in dlm_config_nodes()
895 rv = -ENOMEM; in dlm_config_nodes()
900 list_for_each_entry(nd, &sp->members, list) { in dlm_config_nodes()
901 node->nodeid = nd->nodeid; in dlm_config_nodes()
902 node->weight = nd->weight; in dlm_config_nodes()
903 node->new = nd->new; in dlm_config_nodes()
904 node->comm_seq = nd->comm_seq; in dlm_config_nodes()
907 nd->new = 0; in dlm_config_nodes()
914 mutex_unlock(&sp->members_lock); in dlm_config_nodes()
921 struct dlm_comm *cm = get_comm(nodeid); in dlm_comm_seq() local
922 if (!cm) in dlm_comm_seq()
923 return -EEXIST; in dlm_comm_seq()
924 *seq = cm->seq; in dlm_comm_seq()
925 put_comm(cm); in dlm_comm_seq()
931 return local_comm->nodeid; in dlm_our_nodeid()
938 return -1; in dlm_our_addr()
939 if (num + 1 > local_comm->addr_count) in dlm_our_addr()
940 return -1; in dlm_our_addr()
941 memcpy(addr, local_comm->addr[num], sizeof(*addr)); in dlm_our_addr()