Lines Matching refs:ls
33 static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len) in dlm_control_store() argument
41 ls = dlm_find_lockspace_local(ls); in dlm_control_store()
42 if (!ls) in dlm_control_store()
47 dlm_ls_stop(ls); in dlm_control_store()
50 dlm_ls_start(ls); in dlm_control_store()
55 dlm_put_lockspace(ls); in dlm_control_store()
59 static ssize_t dlm_event_store(struct dlm_ls *ls, const char *buf, size_t len) in dlm_event_store() argument
61 int rc = kstrtoint(buf, 0, &ls->ls_uevent_result); in dlm_event_store()
65 set_bit(LSFL_UEVENT_WAIT, &ls->ls_flags); in dlm_event_store()
66 wake_up(&ls->ls_uevent_wait); in dlm_event_store()
70 static ssize_t dlm_id_show(struct dlm_ls *ls, char *buf) in dlm_id_show() argument
72 return snprintf(buf, PAGE_SIZE, "%u\n", ls->ls_global_id); in dlm_id_show()
75 static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len) in dlm_id_store() argument
77 int rc = kstrtouint(buf, 0, &ls->ls_global_id); in dlm_id_store()
84 static ssize_t dlm_nodir_show(struct dlm_ls *ls, char *buf) in dlm_nodir_show() argument
86 return snprintf(buf, PAGE_SIZE, "%u\n", dlm_no_directory(ls)); in dlm_nodir_show()
89 static ssize_t dlm_nodir_store(struct dlm_ls *ls, const char *buf, size_t len) in dlm_nodir_store() argument
97 set_bit(LSFL_NODIR, &ls->ls_flags); in dlm_nodir_store()
101 static ssize_t dlm_recover_status_show(struct dlm_ls *ls, char *buf) in dlm_recover_status_show() argument
103 uint32_t status = dlm_recover_status(ls); in dlm_recover_status_show()
107 static ssize_t dlm_recover_nodeid_show(struct dlm_ls *ls, char *buf) in dlm_recover_nodeid_show() argument
109 return snprintf(buf, PAGE_SIZE, "%d\n", ls->ls_recover_nodeid); in dlm_recover_nodeid_show()
164 struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj); in dlm_attr_show() local
166 return a->show ? a->show(ls, buf) : 0; in dlm_attr_show()
172 struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj); in dlm_attr_store() local
174 return a->store ? a->store(ls, buf, len) : len; in dlm_attr_store()
189 static int do_uevent(struct dlm_ls *ls, int in, unsigned int release_recover) in do_uevent() argument
195 kobject_uevent(&ls->ls_kobj, KOBJ_ONLINE); in do_uevent()
198 kobject_uevent_env(&ls->ls_kobj, KOBJ_OFFLINE, envp); in do_uevent()
201 log_rinfo(ls, "%s the lockspace group...", in ? "joining" : "leaving"); in do_uevent()
206 wait_event(ls->ls_uevent_wait, in do_uevent()
207 test_and_clear_bit(LSFL_UEVENT_WAIT, &ls->ls_flags)); in do_uevent()
209 log_rinfo(ls, "group event done %d", ls->ls_uevent_result); in do_uevent()
211 return ls->ls_uevent_result; in do_uevent()
216 const struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj); in dlm_uevent() local
218 add_uevent_var(env, "LOCKSPACE=%s", ls->ls_name); in dlm_uevent()
248 struct dlm_ls *ls; in dlm_find_lockspace_global() local
252 list_for_each_entry(ls, &lslist, ls_list) { in dlm_find_lockspace_global()
253 if (ls->ls_global_id == id) { in dlm_find_lockspace_global()
254 atomic_inc(&ls->ls_count); in dlm_find_lockspace_global()
258 ls = NULL; in dlm_find_lockspace_global()
261 return ls; in dlm_find_lockspace_global()
266 struct dlm_ls *ls = lockspace; in dlm_find_lockspace_local() local
268 atomic_inc(&ls->ls_count); in dlm_find_lockspace_local()
269 return ls; in dlm_find_lockspace_local()
274 struct dlm_ls *ls; in dlm_find_lockspace_device() local
277 list_for_each_entry(ls, &lslist, ls_list) { in dlm_find_lockspace_device()
278 if (ls->ls_device.minor == minor) { in dlm_find_lockspace_device()
279 atomic_inc(&ls->ls_count); in dlm_find_lockspace_device()
283 ls = NULL; in dlm_find_lockspace_device()
286 return ls; in dlm_find_lockspace_device()
289 void dlm_put_lockspace(struct dlm_ls *ls) in dlm_put_lockspace() argument
291 if (atomic_dec_and_test(&ls->ls_count)) in dlm_put_lockspace()
292 wake_up(&ls->ls_count_wait); in dlm_put_lockspace()
295 static void remove_lockspace(struct dlm_ls *ls) in remove_lockspace() argument
298 wait_event(ls->ls_count_wait, atomic_read(&ls->ls_count) == 0); in remove_lockspace()
301 if (atomic_read(&ls->ls_count) != 0) { in remove_lockspace()
306 WARN_ON(ls->ls_create_count != 0); in remove_lockspace()
307 list_del(&ls->ls_list); in remove_lockspace()
341 struct dlm_ls *ls = container_of(work, struct dlm_ls, ls_free_work); in free_lockspace() local
348 xa_for_each(&ls->ls_lkbxa, id, lkb) { in free_lockspace()
351 xa_destroy(&ls->ls_lkbxa); in free_lockspace()
356 rhashtable_free_and_destroy(&ls->ls_rsbtbl, rhash_free_rsb, NULL); in free_lockspace()
358 kfree(ls); in free_lockspace()
366 struct dlm_ls *ls; in new_lockspace() local
408 list_for_each_entry(ls, &lslist, ls_list) { in new_lockspace()
409 WARN_ON(ls->ls_create_count <= 0); in new_lockspace()
410 if (ls->ls_namelen != namelen) in new_lockspace()
412 if (memcmp(ls->ls_name, name, namelen)) in new_lockspace()
418 ls->ls_create_count++; in new_lockspace()
419 *lockspace = ls; in new_lockspace()
430 ls = kzalloc(sizeof(*ls), GFP_NOFS); in new_lockspace()
431 if (!ls) in new_lockspace()
433 memcpy(ls->ls_name, name, namelen); in new_lockspace()
434 ls->ls_namelen = namelen; in new_lockspace()
435 ls->ls_lvblen = lvblen; in new_lockspace()
436 atomic_set(&ls->ls_count, 0); in new_lockspace()
437 init_waitqueue_head(&ls->ls_count_wait); in new_lockspace()
438 ls->ls_flags = 0; in new_lockspace()
441 ls->ls_ops = ops; in new_lockspace()
442 ls->ls_ops_arg = ops_arg; in new_lockspace()
446 set_bit(LSFL_SOFTIRQ, &ls->ls_flags); in new_lockspace()
451 ls->ls_exflags = (flags & ~(DLM_LSFL_FS | DLM_LSFL_NEWEXCL | in new_lockspace()
454 INIT_LIST_HEAD(&ls->ls_slow_inactive); in new_lockspace()
455 INIT_LIST_HEAD(&ls->ls_slow_active); in new_lockspace()
456 rwlock_init(&ls->ls_rsbtbl_lock); in new_lockspace()
458 error = rhashtable_init(&ls->ls_rsbtbl, &dlm_rhash_rsb_params); in new_lockspace()
462 xa_init_flags(&ls->ls_lkbxa, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_BH); in new_lockspace()
463 rwlock_init(&ls->ls_lkbxa_lock); in new_lockspace()
465 INIT_LIST_HEAD(&ls->ls_waiters); in new_lockspace()
466 spin_lock_init(&ls->ls_waiters_lock); in new_lockspace()
467 INIT_LIST_HEAD(&ls->ls_orphans); in new_lockspace()
468 spin_lock_init(&ls->ls_orphans_lock); in new_lockspace()
470 INIT_LIST_HEAD(&ls->ls_nodes); in new_lockspace()
471 INIT_LIST_HEAD(&ls->ls_nodes_gone); in new_lockspace()
472 ls->ls_num_nodes = 0; in new_lockspace()
473 ls->ls_low_nodeid = 0; in new_lockspace()
474 ls->ls_total_weight = 0; in new_lockspace()
475 ls->ls_node_array = NULL; in new_lockspace()
477 memset(&ls->ls_local_rsb, 0, sizeof(struct dlm_rsb)); in new_lockspace()
478 ls->ls_local_rsb.res_ls = ls; in new_lockspace()
480 ls->ls_debug_rsb_dentry = NULL; in new_lockspace()
481 ls->ls_debug_waiters_dentry = NULL; in new_lockspace()
483 init_waitqueue_head(&ls->ls_uevent_wait); in new_lockspace()
484 ls->ls_uevent_result = 0; in new_lockspace()
485 init_completion(&ls->ls_recovery_done); in new_lockspace()
486 ls->ls_recovery_result = -1; in new_lockspace()
488 spin_lock_init(&ls->ls_cb_lock); in new_lockspace()
489 INIT_LIST_HEAD(&ls->ls_cb_delay); in new_lockspace()
491 INIT_WORK(&ls->ls_free_work, free_lockspace); in new_lockspace()
493 ls->ls_recoverd_task = NULL; in new_lockspace()
494 mutex_init(&ls->ls_recoverd_active); in new_lockspace()
495 spin_lock_init(&ls->ls_recover_lock); in new_lockspace()
496 spin_lock_init(&ls->ls_rcom_spin); in new_lockspace()
497 get_random_bytes(&ls->ls_rcom_seq, sizeof(uint64_t)); in new_lockspace()
498 ls->ls_recover_status = 0; in new_lockspace()
499 ls->ls_recover_seq = get_random_u64(); in new_lockspace()
500 ls->ls_recover_args = NULL; in new_lockspace()
501 init_rwsem(&ls->ls_in_recovery); in new_lockspace()
502 rwlock_init(&ls->ls_recv_active); in new_lockspace()
503 INIT_LIST_HEAD(&ls->ls_requestqueue); in new_lockspace()
504 rwlock_init(&ls->ls_requestqueue_lock); in new_lockspace()
505 spin_lock_init(&ls->ls_clear_proc_locks); in new_lockspace()
512 ls->ls_recover_buf = kmalloc(DLM_MAX_SOCKET_BUFSIZE, GFP_NOFS); in new_lockspace()
513 if (!ls->ls_recover_buf) { in new_lockspace()
518 ls->ls_slot = 0; in new_lockspace()
519 ls->ls_num_slots = 0; in new_lockspace()
520 ls->ls_slots_size = 0; in new_lockspace()
521 ls->ls_slots = NULL; in new_lockspace()
523 INIT_LIST_HEAD(&ls->ls_recover_list); in new_lockspace()
524 spin_lock_init(&ls->ls_recover_list_lock); in new_lockspace()
525 xa_init_flags(&ls->ls_recover_xa, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_BH); in new_lockspace()
526 spin_lock_init(&ls->ls_recover_xa_lock); in new_lockspace()
527 ls->ls_recover_list_count = 0; in new_lockspace()
528 init_waitqueue_head(&ls->ls_wait_general); in new_lockspace()
529 INIT_LIST_HEAD(&ls->ls_masters_list); in new_lockspace()
530 rwlock_init(&ls->ls_masters_lock); in new_lockspace()
531 INIT_LIST_HEAD(&ls->ls_dir_dump_list); in new_lockspace()
532 rwlock_init(&ls->ls_dir_dump_lock); in new_lockspace()
534 INIT_LIST_HEAD(&ls->ls_scan_list); in new_lockspace()
535 spin_lock_init(&ls->ls_scan_lock); in new_lockspace()
536 timer_setup(&ls->ls_scan_timer, dlm_rsb_scan, TIMER_DEFERRABLE); in new_lockspace()
539 ls->ls_create_count = 1; in new_lockspace()
540 list_add(&ls->ls_list, &lslist); in new_lockspace()
544 set_bit(LSFL_FS, &ls->ls_flags); in new_lockspace()
546 error = dlm_callback_start(ls); in new_lockspace()
548 log_error(ls, "can't start dlm_callback %d", error); in new_lockspace()
552 init_waitqueue_head(&ls->ls_recover_lock_wait); in new_lockspace()
561 error = dlm_recoverd_start(ls); in new_lockspace()
563 log_error(ls, "can't start dlm_recoverd %d", error); in new_lockspace()
567 wait_event(ls->ls_recover_lock_wait, in new_lockspace()
568 test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags)); in new_lockspace()
570 ls->ls_kobj.kset = dlm_kset; in new_lockspace()
571 error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL, in new_lockspace()
572 "%s", ls->ls_name); in new_lockspace()
575 kobject_uevent(&ls->ls_kobj, KOBJ_ADD); in new_lockspace()
583 error = do_uevent(ls, 1, 0); in new_lockspace()
588 wait_for_completion(&ls->ls_recovery_done); in new_lockspace()
589 error = ls->ls_recovery_result; in new_lockspace()
593 dlm_create_debug_file(ls); in new_lockspace()
595 log_rinfo(ls, "join complete"); in new_lockspace()
596 *lockspace = ls; in new_lockspace()
600 do_uevent(ls, 0, 0); in new_lockspace()
601 dlm_clear_members(ls); in new_lockspace()
602 kfree(ls->ls_node_array); in new_lockspace()
604 dlm_recoverd_stop(ls); in new_lockspace()
606 dlm_callback_stop(ls); in new_lockspace()
609 list_del(&ls->ls_list); in new_lockspace()
611 xa_destroy(&ls->ls_recover_xa); in new_lockspace()
612 kfree(ls->ls_recover_buf); in new_lockspace()
614 xa_destroy(&ls->ls_lkbxa); in new_lockspace()
615 rhashtable_destroy(&ls->ls_rsbtbl); in new_lockspace()
617 kobject_put(&ls->ls_kobj); in new_lockspace()
618 kfree(ls); in new_lockspace()
679 static int lockspace_busy(struct dlm_ls *ls, unsigned int release_option) in lockspace_busy() argument
685 read_lock_bh(&ls->ls_lkbxa_lock); in lockspace_busy()
687 xa_for_each(&ls->ls_lkbxa, id, lkb) { in lockspace_busy()
693 xa_for_each(&ls->ls_lkbxa, id, lkb) { in lockspace_busy()
703 read_unlock_bh(&ls->ls_lkbxa_lock); in lockspace_busy()
707 static int release_lockspace(struct dlm_ls *ls, unsigned int release_option) in release_lockspace() argument
711 busy = lockspace_busy(ls, release_option); in release_lockspace()
714 if (ls->ls_create_count == 1) { in release_lockspace()
719 ls->ls_create_count = 0; in release_lockspace()
722 } else if (ls->ls_create_count > 1) { in release_lockspace()
723 rv = --ls->ls_create_count; in release_lockspace()
730 log_debug(ls, "release_lockspace no remove %d", rv); in release_lockspace()
737 dlm_device_deregister(ls); in release_lockspace()
741 do_uevent(ls, 0, (release_option == DLM_RELEASE_RECOVER)); in release_lockspace()
743 dlm_recoverd_stop(ls); in release_lockspace()
748 clear_bit(LSFL_RUNNING, &ls->ls_flags); in release_lockspace()
749 timer_shutdown_sync(&ls->ls_scan_timer); in release_lockspace()
752 dlm_clear_members(ls); in release_lockspace()
756 dlm_callback_stop(ls); in release_lockspace()
758 remove_lockspace(ls); in release_lockspace()
760 dlm_delete_debug_file(ls); in release_lockspace()
762 kobject_put(&ls->ls_kobj); in release_lockspace()
764 xa_destroy(&ls->ls_recover_xa); in release_lockspace()
765 kfree(ls->ls_recover_buf); in release_lockspace()
771 dlm_purge_requestqueue(ls); in release_lockspace()
772 kfree(ls->ls_recover_args); in release_lockspace()
773 dlm_clear_members(ls); in release_lockspace()
774 dlm_clear_members_gone(ls); in release_lockspace()
775 kfree(ls->ls_node_array); in release_lockspace()
777 log_rinfo(ls, "%s final free", __func__); in release_lockspace()
780 queue_work(dlm_wq, &ls->ls_free_work); in release_lockspace()
797 struct dlm_ls *ls; in dlm_release_lockspace() local
803 ls = dlm_find_lockspace_local(lockspace); in dlm_release_lockspace()
804 if (!ls) in dlm_release_lockspace()
806 dlm_put_lockspace(ls); in dlm_release_lockspace()
809 error = release_lockspace(ls, release_option); in dlm_release_lockspace()
821 struct dlm_ls *ls; in dlm_stop_lockspaces() local
827 list_for_each_entry(ls, &lslist, ls_list) { in dlm_stop_lockspaces()
828 if (!test_bit(LSFL_RUNNING, &ls->ls_flags)) { in dlm_stop_lockspaces()
833 log_error(ls, "no userland control daemon, stopping lockspace"); in dlm_stop_lockspaces()
834 dlm_ls_stop(ls); in dlm_stop_lockspaces()