Lines Matching +full:cluster +full:- +full:mode

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.
44 ls = dlm_find_lockspace_local(ls->ls_local_handle); in dlm_control_store()
46 return -EINVAL; in dlm_control_store()
56 ret = -EINVAL; in dlm_control_store()
64 int rc = kstrtoint(buf, 0, &ls->ls_uevent_result); in dlm_event_store()
68 set_bit(LSFL_UEVENT_WAIT, &ls->ls_flags); in dlm_event_store()
69 wake_up(&ls->ls_uevent_wait); in dlm_event_store()
75 return snprintf(buf, PAGE_SIZE, "%u\n", ls->ls_global_id); in dlm_id_show()
80 int rc = kstrtouint(buf, 0, &ls->ls_global_id); in dlm_id_store()
100 set_bit(LSFL_NODIR, &ls->ls_flags); in dlm_nodir_store()
112 return snprintf(buf, PAGE_SIZE, "%d\n", ls->ls_recover_nodeid); in dlm_recover_nodeid_show()
122 .attr = {.name = "control", .mode = S_IWUSR},
127 .attr = {.name = "event_done", .mode = S_IWUSR},
132 .attr = {.name = "id", .mode = S_IRUGO | S_IWUSR},
138 .attr = {.name = "nodir", .mode = S_IRUGO | S_IWUSR},
144 .attr = {.name = "recover_status", .mode = S_IRUGO},
149 .attr = {.name = "recover_nodeid", .mode = S_IRUGO},
169 return a->show ? a->show(ls, buf) : 0; in dlm_attr_show()
177 return a->store ? a->store(ls, buf, len) : len; in dlm_attr_store()
202 kobject_uevent(&ls->ls_kobj, KOBJ_ONLINE); in do_uevent()
204 kobject_uevent(&ls->ls_kobj, KOBJ_OFFLINE); in do_uevent()
211 wait_event(ls->ls_uevent_wait, in do_uevent()
212 test_and_clear_bit(LSFL_UEVENT_WAIT, &ls->ls_flags)); in do_uevent()
214 log_rinfo(ls, "group event done %d", ls->ls_uevent_result); in do_uevent()
216 return ls->ls_uevent_result; in do_uevent()
223 add_uevent_var(env, "LOCKSPACE=%s", ls->ls_name); in dlm_uevent()
241 return -ENOMEM; in dlm_lockspace_init()
257 if (time_after_eq(jiffies, ls->ls_scan_time + in find_ls_to_scan()
275 ls->ls_scan_time = jiffies; in dlm_scand()
280 ls->ls_scan_time += HZ; in dlm_scand()
314 if (ls->ls_global_id == id) { in dlm_find_lockspace_global()
315 atomic_inc(&ls->ls_count); in dlm_find_lockspace_global()
331 if (ls->ls_local_handle == lockspace) { in dlm_find_lockspace_local()
332 atomic_inc(&ls->ls_count); in dlm_find_lockspace_local()
348 if (ls->ls_device.minor == minor) { in dlm_find_lockspace_device()
349 atomic_inc(&ls->ls_count); in dlm_find_lockspace_device()
361 if (atomic_dec_and_test(&ls->ls_count)) in dlm_put_lockspace()
362 wake_up(&ls->ls_count_wait); in dlm_put_lockspace()
368 wait_event(ls->ls_count_wait, atomic_read(&ls->ls_count) == 0); in remove_lockspace()
371 if (atomic_read(&ls->ls_count) != 0) { in remove_lockspace()
376 WARN_ON(ls->ls_create_count != 0); in remove_lockspace()
377 list_del(&ls->ls_list); in remove_lockspace()
406 static int new_lockspace(const char *name, const char *cluster, in new_lockspace() argument
417 return -EINVAL; in new_lockspace()
420 return -EINVAL; in new_lockspace()
423 return -EINVAL; in new_lockspace()
427 error = -EUNATCH; in new_lockspace()
433 *ops_result = -EOPNOTSUPP; in new_lockspace()
438 if (!cluster) in new_lockspace()
439 log_print("dlm cluster name '%s' is being used without an application provided cluster name", in new_lockspace()
442 if (dlm_config.ci_recover_callbacks && cluster && in new_lockspace()
443 strncmp(cluster, dlm_config.ci_cluster_name, DLM_LOCKSPACE_LEN)) { in new_lockspace()
444 log_print("dlm cluster name '%s' does not match " in new_lockspace()
445 "the application cluster name '%s'", in new_lockspace()
446 dlm_config.ci_cluster_name, cluster); in new_lockspace()
447 error = -EBADR; in new_lockspace()
455 WARN_ON(ls->ls_create_count <= 0); in new_lockspace()
456 if (ls->ls_namelen != namelen) in new_lockspace()
458 if (memcmp(ls->ls_name, name, namelen)) in new_lockspace()
461 error = -EEXIST; in new_lockspace()
464 ls->ls_create_count++; in new_lockspace()
474 error = -ENOMEM; in new_lockspace()
479 memcpy(ls->ls_name, name, namelen); in new_lockspace()
480 ls->ls_namelen = namelen; in new_lockspace()
481 ls->ls_lvblen = lvblen; in new_lockspace()
482 atomic_set(&ls->ls_count, 0); in new_lockspace()
483 init_waitqueue_head(&ls->ls_count_wait); in new_lockspace()
484 ls->ls_flags = 0; in new_lockspace()
485 ls->ls_scan_time = jiffies; in new_lockspace()
488 ls->ls_ops = ops; in new_lockspace()
489 ls->ls_ops_arg = ops_arg; in new_lockspace()
500 set_bit(LSFL_TIMEWARN, &ls->ls_flags); in new_lockspace()
506 ls->ls_exflags = (flags & ~(DLM_LSFL_TIMEWARN | DLM_LSFL_FS | in new_lockspace()
512 ls->ls_exflags = (flags & ~(DLM_LSFL_FS | DLM_LSFL_NEWEXCL)); in new_lockspace()
516 ls->ls_rsbtbl_size = size; in new_lockspace()
518 ls->ls_rsbtbl = vmalloc(array_size(size, sizeof(struct dlm_rsbtable))); in new_lockspace()
519 if (!ls->ls_rsbtbl) in new_lockspace()
522 ls->ls_rsbtbl[i].keep.rb_node = NULL; in new_lockspace()
523 ls->ls_rsbtbl[i].toss.rb_node = NULL; in new_lockspace()
524 spin_lock_init(&ls->ls_rsbtbl[i].lock); in new_lockspace()
527 spin_lock_init(&ls->ls_remove_spin); in new_lockspace()
528 init_waitqueue_head(&ls->ls_remove_wait); in new_lockspace()
531 ls->ls_remove_names[i] = kzalloc(DLM_RESNAME_MAXLEN+1, in new_lockspace()
533 if (!ls->ls_remove_names[i]) in new_lockspace()
537 idr_init(&ls->ls_lkbidr); in new_lockspace()
538 spin_lock_init(&ls->ls_lkbidr_spin); in new_lockspace()
540 INIT_LIST_HEAD(&ls->ls_waiters); in new_lockspace()
541 mutex_init(&ls->ls_waiters_mutex); in new_lockspace()
542 INIT_LIST_HEAD(&ls->ls_orphans); in new_lockspace()
543 mutex_init(&ls->ls_orphans_mutex); in new_lockspace()
545 INIT_LIST_HEAD(&ls->ls_timeout); in new_lockspace()
546 mutex_init(&ls->ls_timeout_mutex); in new_lockspace()
549 INIT_LIST_HEAD(&ls->ls_new_rsb); in new_lockspace()
550 spin_lock_init(&ls->ls_new_rsb_spin); in new_lockspace()
552 INIT_LIST_HEAD(&ls->ls_nodes); in new_lockspace()
553 INIT_LIST_HEAD(&ls->ls_nodes_gone); in new_lockspace()
554 ls->ls_num_nodes = 0; in new_lockspace()
555 ls->ls_low_nodeid = 0; in new_lockspace()
556 ls->ls_total_weight = 0; in new_lockspace()
557 ls->ls_node_array = NULL; in new_lockspace()
559 memset(&ls->ls_stub_rsb, 0, sizeof(struct dlm_rsb)); in new_lockspace()
560 ls->ls_stub_rsb.res_ls = ls; in new_lockspace()
562 ls->ls_debug_rsb_dentry = NULL; in new_lockspace()
563 ls->ls_debug_waiters_dentry = NULL; in new_lockspace()
565 init_waitqueue_head(&ls->ls_uevent_wait); in new_lockspace()
566 ls->ls_uevent_result = 0; in new_lockspace()
567 init_completion(&ls->ls_recovery_done); in new_lockspace()
568 ls->ls_recovery_result = -1; in new_lockspace()
570 mutex_init(&ls->ls_cb_mutex); in new_lockspace()
571 INIT_LIST_HEAD(&ls->ls_cb_delay); in new_lockspace()
573 ls->ls_recoverd_task = NULL; in new_lockspace()
574 mutex_init(&ls->ls_recoverd_active); in new_lockspace()
575 spin_lock_init(&ls->ls_recover_lock); in new_lockspace()
576 spin_lock_init(&ls->ls_rcom_spin); in new_lockspace()
577 get_random_bytes(&ls->ls_rcom_seq, sizeof(uint64_t)); in new_lockspace()
578 ls->ls_recover_status = 0; in new_lockspace()
579 ls->ls_recover_seq = 0; in new_lockspace()
580 ls->ls_recover_args = NULL; in new_lockspace()
581 init_rwsem(&ls->ls_in_recovery); in new_lockspace()
582 init_rwsem(&ls->ls_recv_active); in new_lockspace()
583 INIT_LIST_HEAD(&ls->ls_requestqueue); in new_lockspace()
584 atomic_set(&ls->ls_requestqueue_cnt, 0); in new_lockspace()
585 init_waitqueue_head(&ls->ls_requestqueue_wait); in new_lockspace()
586 mutex_init(&ls->ls_requestqueue_mutex); in new_lockspace()
587 spin_lock_init(&ls->ls_clear_proc_locks); in new_lockspace()
594 ls->ls_recover_buf = kmalloc(DLM_MAX_SOCKET_BUFSIZE, GFP_NOFS); in new_lockspace()
595 if (!ls->ls_recover_buf) in new_lockspace()
598 ls->ls_slot = 0; in new_lockspace()
599 ls->ls_num_slots = 0; in new_lockspace()
600 ls->ls_slots_size = 0; in new_lockspace()
601 ls->ls_slots = NULL; in new_lockspace()
603 INIT_LIST_HEAD(&ls->ls_recover_list); in new_lockspace()
604 spin_lock_init(&ls->ls_recover_list_lock); in new_lockspace()
605 idr_init(&ls->ls_recover_idr); in new_lockspace()
606 spin_lock_init(&ls->ls_recover_idr_lock); in new_lockspace()
607 ls->ls_recover_list_count = 0; in new_lockspace()
608 ls->ls_local_handle = ls; in new_lockspace()
609 init_waitqueue_head(&ls->ls_wait_general); in new_lockspace()
610 INIT_LIST_HEAD(&ls->ls_root_list); in new_lockspace()
611 init_rwsem(&ls->ls_root_sem); in new_lockspace()
614 ls->ls_create_count = 1; in new_lockspace()
615 list_add(&ls->ls_list, &lslist); in new_lockspace()
626 init_waitqueue_head(&ls->ls_recover_lock_wait); in new_lockspace()
630 * initializes ls_in_recovery as locked in "down" mode. We need in new_lockspace()
632 * has to start out in down mode. in new_lockspace()
641 wait_event(ls->ls_recover_lock_wait, in new_lockspace()
642 test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags)); in new_lockspace()
647 ls->ls_kobj.kset = dlm_kset; in new_lockspace()
648 error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL, in new_lockspace()
649 "%s", ls->ls_name); in new_lockspace()
652 kobject_uevent(&ls->ls_kobj, KOBJ_ADD); in new_lockspace()
656 cluster infrastructure.) Once it's done that, it tells us who the in new_lockspace()
665 wait_for_completion(&ls->ls_recovery_done); in new_lockspace()
666 error = ls->ls_recovery_result; in new_lockspace()
679 kfree(ls->ls_node_array); in new_lockspace()
686 list_del(&ls->ls_list); in new_lockspace()
688 idr_destroy(&ls->ls_recover_idr); in new_lockspace()
689 kfree(ls->ls_recover_buf); in new_lockspace()
691 idr_destroy(&ls->ls_lkbidr); in new_lockspace()
694 kfree(ls->ls_remove_names[i]); in new_lockspace()
695 vfree(ls->ls_rsbtbl); in new_lockspace()
698 kobject_put(&ls->ls_kobj); in new_lockspace()
706 static int __dlm_new_lockspace(const char *name, const char *cluster, in __dlm_new_lockspace() argument
720 error = new_lockspace(name, cluster, flags, lvblen, ops, ops_arg, in __dlm_new_lockspace()
736 int dlm_new_lockspace(const char *name, const char *cluster, uint32_t flags, in dlm_new_lockspace() argument
741 return __dlm_new_lockspace(name, cluster, flags | DLM_LSFL_FS, lvblen, in dlm_new_lockspace()
745 int dlm_new_user_lockspace(const char *name, const char *cluster, in dlm_new_user_lockspace() argument
751 return __dlm_new_lockspace(name, cluster, flags, lvblen, ops, in dlm_new_user_lockspace()
759 return lkb->lkb_nodeid == 0 && lkb->lkb_grmode != DLM_LOCK_IV; in lkb_idr_is_local()
771 if (lkb->lkb_lvbptr && lkb->lkb_flags & DLM_IFL_MSTCPY) in lkb_idr_free()
772 dlm_free_lvb(lkb->lkb_lvbptr); in lkb_idr_free()
786 spin_lock(&ls->ls_lkbidr_spin); in lockspace_busy()
788 rv = idr_for_each(&ls->ls_lkbidr, lkb_idr_is_any, ls); in lockspace_busy()
790 rv = idr_for_each(&ls->ls_lkbidr, lkb_idr_is_local, ls); in lockspace_busy()
794 spin_unlock(&ls->ls_lkbidr_spin); in lockspace_busy()
807 if (ls->ls_create_count == 1) { in release_lockspace()
809 rv = -EBUSY; in release_lockspace()
812 ls->ls_create_count = 0; in release_lockspace()
815 } else if (ls->ls_create_count > 1) { in release_lockspace()
816 rv = --ls->ls_create_count; in release_lockspace()
818 rv = -EINVAL; in release_lockspace()
846 idr_destroy(&ls->ls_recover_idr); in release_lockspace()
847 kfree(ls->ls_recover_buf); in release_lockspace()
853 idr_for_each(&ls->ls_lkbidr, lkb_idr_free, ls); in release_lockspace()
854 idr_destroy(&ls->ls_lkbidr); in release_lockspace()
860 for (i = 0; i < ls->ls_rsbtbl_size; i++) { in release_lockspace()
861 while ((n = rb_first(&ls->ls_rsbtbl[i].keep))) { in release_lockspace()
863 rb_erase(n, &ls->ls_rsbtbl[i].keep); in release_lockspace()
867 while ((n = rb_first(&ls->ls_rsbtbl[i].toss))) { in release_lockspace()
869 rb_erase(n, &ls->ls_rsbtbl[i].toss); in release_lockspace()
874 vfree(ls->ls_rsbtbl); in release_lockspace()
877 kfree(ls->ls_remove_names[i]); in release_lockspace()
879 while (!list_empty(&ls->ls_new_rsb)) { in release_lockspace()
880 rsb = list_first_entry(&ls->ls_new_rsb, struct dlm_rsb, in release_lockspace()
882 list_del(&rsb->res_hashchain); in release_lockspace()
891 kfree(ls->ls_recover_args); in release_lockspace()
894 kfree(ls->ls_node_array); in release_lockspace()
896 kobject_put(&ls->ls_kobj); in release_lockspace()
911 * 0 - don't destroy lockspace if it has any LKBs
912 * 1 - destroy lockspace if it has remote LKBs but not if it has local LKBs
913 * 2 - destroy lockspace regardless of LKBs
914 * 3 - destroy lockspace as part of a forced shutdown
924 return -EINVAL; in dlm_release_lockspace()
930 ls_count--; in dlm_release_lockspace()
947 if (!test_bit(LSFL_RUNNING, &ls->ls_flags)) { in dlm_stop_lockspaces()
968 if (WARN_ON(!rwsem_is_locked(&ls->ls_in_recovery) || in dlm_stop_lockspaces_check()