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.
125 return -EINVAL; in dlm_check_zero_and_dlm_running()
128 return -EBUSY; in dlm_check_zero_and_dlm_running()
140 return -EPERM; in cluster_tcp_port_store()
164 return -EPERM; in cluster_set()
180 #define CLUSTER_ATTR(name, check_cb) \ argument
181 static ssize_t cluster_##name##_store(struct config_item *item, \
184 return cluster_set(&dlm_config.ci_##name, check_cb, buf, len); \
186 static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \
188 return snprintf(buf, PAGE_SIZE, "%u\n", dlm_config.ci_##name); \
190 CONFIGFS_ATTR(cluster_, name);
202 return -EINVAL; in dlm_check_protocol_and_dlm_running()
206 return -EBUSY; in dlm_check_protocol_and_dlm_running()
214 return -EINVAL; in dlm_check_zero()
222 return -EINVAL; in dlm_check_buffer_size()
305 struct list_head list; /* space->members */
309 int comm_seq; /* copy of cm->seq when nd->nodeid is set */
408 const char *name) in make_cluster() argument
421 cl->sps = sps; in make_cluster()
422 cl->cms = cms; in make_cluster()
424 config_group_init_type_name(&cl->group, name, &cluster_type); in make_cluster()
425 config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type); in make_cluster()
426 config_group_init_type_name(&cms->cs_group, "comms", &comms_type); in make_cluster()
428 configfs_add_default_group(&sps->ss_group, &cl->group); in make_cluster()
429 configfs_add_default_group(&cms->cs_group, &cl->group); in make_cluster()
431 space_list = &sps->ss_group; in make_cluster()
432 comm_list = &cms->cs_group; in make_cluster()
433 return &cl->group; in make_cluster()
439 return ERR_PTR(-ENOMEM); in make_cluster()
446 configfs_remove_default_groups(&cl->group); in drop_cluster()
458 kfree(cl->sps); in release_cluster()
459 kfree(cl->cms); in release_cluster()
463 static struct config_group *make_space(struct config_group *g, const char *name) in make_space() argument
474 config_group_init_type_name(&sp->group, name, &space_type); in make_space()
476 config_group_init_type_name(&nds->ns_group, "nodes", &nodes_type); in make_space()
477 configfs_add_default_group(&nds->ns_group, &sp->group); in make_space()
479 INIT_LIST_HEAD(&sp->members); in make_space()
480 mutex_init(&sp->members_lock); in make_space()
481 sp->members_count = 0; in make_space()
482 sp->nds = nds; in make_space()
483 return &sp->group; in make_space()
488 return ERR_PTR(-ENOMEM); in make_space()
495 /* assert list_empty(&sp->members) */ in drop_space()
497 configfs_remove_default_groups(&sp->group); in drop_space()
504 kfree(sp->nds); in release_space()
508 static struct config_item *make_comm(struct config_group *g, const char *name) in make_comm() argument
510 struct dlm_comm *cm; in make_comm() local
514 rv = kstrtouint(name, 0, &nodeid); in make_comm()
518 cm = kzalloc(sizeof(struct dlm_comm), GFP_NOFS); in make_comm()
519 if (!cm) in make_comm()
520 return ERR_PTR(-ENOMEM); in make_comm()
522 config_item_init_type_name(&cm->item, name, &comm_type); in make_comm()
524 cm->seq = dlm_comm_count++; in make_comm()
525 if (!cm->seq) in make_comm()
526 cm->seq = dlm_comm_count++; in make_comm()
528 cm->nodeid = nodeid; in make_comm()
529 cm->local = 0; in make_comm()
530 cm->addr_count = 0; in make_comm()
531 cm->mark = 0; in make_comm()
532 return &cm->item; in make_comm()
537 struct dlm_comm *cm = config_item_to_comm(i); in drop_comm() local
538 if (local_comm == cm) in drop_comm()
540 dlm_midcomms_close(cm->nodeid); in drop_comm()
541 while (cm->addr_count--) in drop_comm()
542 kfree(cm->addr[cm->addr_count]); in drop_comm()
548 struct dlm_comm *cm = config_item_to_comm(i); in release_comm() local
549 kfree(cm); in release_comm()
552 static struct config_item *make_node(struct config_group *g, const char *name) in make_node() argument
554 struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent); in make_node()
560 rv = kstrtouint(name, 0, &nodeid); in make_node()
566 return ERR_PTR(-ENOMEM); in make_node()
568 config_item_init_type_name(&nd->item, name, &node_type); in make_node()
569 nd->nodeid = nodeid; in make_node()
570 nd->weight = 1; /* default weight of 1 if none is set */ in make_node()
571 nd->new = 1; /* set to 0 once it's been read by dlm_nodeid_list() */ in make_node()
573 nd->comm_seq = seq; in make_node()
575 mutex_lock(&sp->members_lock); in make_node()
576 list_add(&nd->list, &sp->members); in make_node()
577 sp->members_count++; in make_node()
578 mutex_unlock(&sp->members_lock); in make_node()
580 return &nd->item; in make_node()
585 struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent); in drop_node()
588 mutex_lock(&sp->members_lock); in drop_node()
589 list_del(&nd->list); in drop_node()
590 sp->members_count--; in drop_node()
591 mutex_unlock(&sp->members_lock); in drop_node()
649 return sprintf(buf, "%d\n", config_item_to_comm(item)->local); in comm_local_show()
655 struct dlm_comm *cm = config_item_to_comm(item); in comm_local_store() local
656 int rc = kstrtoint(buf, 0, &cm->local); in comm_local_store()
660 if (cm->local && !local_comm) in comm_local_store()
661 local_comm = cm; in comm_local_store()
668 struct dlm_comm *cm = config_item_to_comm(item); in comm_addr_store() local
673 return -EINVAL; in comm_addr_store()
675 if (cm->addr_count >= DLM_MAX_ADDR_COUNT) in comm_addr_store()
676 return -ENOSPC; in comm_addr_store()
680 return -ENOMEM; in comm_addr_store()
684 rv = dlm_midcomms_addr(cm->nodeid, addr); in comm_addr_store()
690 cm->addr[cm->addr_count++] = addr; in comm_addr_store()
696 struct dlm_comm *cm = config_item_to_comm(item); in comm_addr_list_show() local
712 for (i = 0; i < cm->addr_count; i++) { in comm_addr_list_show()
713 addr = cm->addr[i]; in comm_addr_list_show()
715 switch(addr->ss_family) { in comm_addr_list_show()
718 s = sprintf(buf0, "AF_INET %pI4\n", &addr_in->sin_addr.s_addr); in comm_addr_list_show()
722 s = sprintf(buf0, "AF_INET6 %pI6\n", &addr_in6->sin6_addr); in comm_addr_list_show()
728 allowance -= s; in comm_addr_list_show()
736 return 4096 - allowance; in comm_addr_list_show()
741 return sprintf(buf, "%u\n", config_item_to_comm(item)->mark); in comm_mark_show()
759 rc = dlm_lowcomms_nodes_set_mark(comm->nodeid, mark); in comm_mark_store()
763 comm->mark = mark; in comm_mark_store()
802 return sprintf(buf, "%d\n", config_item_to_node(item)->weight); in node_weight_show()
808 int rc = kstrtoint(buf, 0, &config_item_to_node(item)->weight); in node_weight_store()
828 static struct dlm_space *get_space(char *name) in get_space() argument
835 mutex_lock(&space_list->cg_subsys->su_mutex); in get_space()
836 i = config_group_find_item(space_list, name); in get_space()
837 mutex_unlock(&space_list->cg_subsys->su_mutex); in get_space()
844 config_item_put(&sp->group.cg_item); in put_space()
850 struct dlm_comm *cm = NULL; in get_comm() local
858 list_for_each_entry(i, &comm_list->cg_children, ci_entry) { in get_comm()
859 cm = config_item_to_comm(i); in get_comm()
861 if (cm->nodeid != nodeid) in get_comm()
869 cm = NULL; in get_comm()
870 return cm; in get_comm()
873 static void put_comm(struct dlm_comm *cm) in put_comm() argument
875 config_item_put(&cm->item); in put_comm()
889 return -EEXIST; in dlm_config_nodes()
891 mutex_lock(&sp->members_lock); in dlm_config_nodes()
892 if (!sp->members_count) { in dlm_config_nodes()
893 rv = -EINVAL; in dlm_config_nodes()
898 count = sp->members_count; in dlm_config_nodes()
902 rv = -ENOMEM; in dlm_config_nodes()
907 list_for_each_entry(nd, &sp->members, list) { in dlm_config_nodes()
908 node->nodeid = nd->nodeid; in dlm_config_nodes()
909 node->weight = nd->weight; in dlm_config_nodes()
910 node->new = nd->new; in dlm_config_nodes()
911 node->comm_seq = nd->comm_seq; in dlm_config_nodes()
914 nd->new = 0; in dlm_config_nodes()
921 mutex_unlock(&sp->members_lock); in dlm_config_nodes()
928 struct dlm_comm *cm; in dlm_comm_seq() local
931 cm = get_comm(nodeid); in dlm_comm_seq()
934 cm = get_comm(nodeid); in dlm_comm_seq()
937 if (!cm) in dlm_comm_seq()
938 return -EEXIST; in dlm_comm_seq()
940 *seq = cm->seq; in dlm_comm_seq()
941 put_comm(cm); in dlm_comm_seq()
947 return local_comm->nodeid; in dlm_our_nodeid()
954 return -1; in dlm_our_addr()
955 if (num + 1 > local_comm->addr_count) in dlm_our_addr()
956 return -1; in dlm_our_addr()
957 memcpy(addr, local_comm->addr[num], sizeof(*addr)); in dlm_our_addr()