29 static struct mutex ls_lock;
35 static ssize_t dlm_control_store(
struct dlm_ls *ls,
const char *
buf,
size_t len)
58 static ssize_t dlm_event_store(
struct dlm_ls *ls,
const char *buf,
size_t len)
71 static ssize_t dlm_id_store(
struct dlm_ls *ls,
const char *buf,
size_t len)
82 static ssize_t dlm_nodir_store(
struct dlm_ls *ls,
const char *buf,
size_t len)
90 static ssize_t dlm_recover_status_show(
struct dlm_ls *ls,
char *buf)
96 static ssize_t dlm_recover_nodeid_show(
struct dlm_ls *ls,
char *buf)
107 static struct dlm_attr dlm_attr_control = {
108 .attr = {.name =
"control", .mode =
S_IWUSR},
109 .store = dlm_control_store
112 static struct dlm_attr dlm_attr_event = {
113 .attr = {.name =
"event_done", .mode =
S_IWUSR},
114 .store = dlm_event_store
117 static struct dlm_attr dlm_attr_id = {
120 .store = dlm_id_store
123 static struct dlm_attr dlm_attr_nodir = {
125 .show = dlm_nodir_show,
126 .store = dlm_nodir_store
129 static struct dlm_attr dlm_attr_recover_status = {
130 .attr = {.name =
"recover_status", .mode =
S_IRUGO},
131 .show = dlm_recover_status_show
134 static struct dlm_attr dlm_attr_recover_nodeid = {
135 .attr = {.name =
"recover_nodeid", .mode =
S_IRUGO},
136 .show = dlm_recover_nodeid_show
140 &dlm_attr_control.
attr,
141 &dlm_attr_event.
attr,
143 &dlm_attr_nodir.
attr,
144 &dlm_attr_recover_status.
attr,
145 &dlm_attr_recover_nodeid.
attr,
154 return a->
show ? a->
show(ls, buf) : 0;
158 const char *buf,
size_t len)
162 return a->
store ? a->
store(ls, buf, len) : len;
165 static void lockspace_kobj_release(
struct kobject *
k)
171 static const struct sysfs_ops dlm_attr_ops = {
172 .show = dlm_attr_show,
173 .store = dlm_attr_store,
177 .default_attrs = dlm_attrs,
178 .sysfs_ops = &dlm_attr_ops,
179 .release = lockspace_kobj_release,
182 static struct kset *dlm_kset;
184 static int do_uevent(
struct dlm_ls *ls,
int in)
193 log_debug(ls,
"%s the lockspace group...", in ?
"joining" :
"leaving");
209 log_error(ls,
"group %s failed %d %d", in ?
"join" :
"leave",
224 .uevent = dlm_uevent,
231 INIT_LIST_HEAD(&lslist);
247 static struct dlm_ls *find_ls_to_scan(
void)
251 spin_lock(&lslist_lock);
255 spin_unlock(&lslist_lock);
259 spin_unlock(&lslist_lock);
263 static int dlm_scand(
void *
data)
268 ls = find_ls_to_scan();
286 static int dlm_scand_start(
void)
299 static void dlm_scand_stop(
void)
308 spin_lock(&lslist_lock);
318 spin_unlock(&lslist_lock);
326 spin_lock(&lslist_lock);
335 spin_unlock(&lslist_lock);
343 spin_lock(&lslist_lock);
352 spin_unlock(&lslist_lock);
358 spin_lock(&lslist_lock);
360 spin_unlock(&lslist_lock);
363 static void remove_lockspace(
struct dlm_ls *ls)
366 spin_lock(&lslist_lock);
370 spin_unlock(&lslist_lock);
373 spin_unlock(&lslist_lock);
378 static int threads_start(
void)
382 error = dlm_scand_start();
384 log_print(
"cannot start dlm_scand thread %d", error);
391 log_print(
"cannot start dlm lowcomms %d", error);
403 static void threads_stop(
void)
409 static int new_lockspace(
const char *
name,
const char *
cluster,
422 if (!lvblen || (lvblen % 8))
429 log_print(
"dlm user daemon not available");
434 if (ops && ops_result) {
441 if (
dlm_config.ci_recover_callbacks && cluster &&
443 log_print(
"dlm cluster name %s mismatch %s",
451 spin_lock(&lslist_lock);
467 spin_unlock(&lslist_lock);
503 for (i = 0; i <
size; i++) {
585 spin_lock(&lslist_lock);
587 list_add(&ls->
ls_list, &lslist);
588 spin_unlock(&lslist_lock);
593 log_error(ls,
"can't start dlm_callback %d", error);
609 log_error(ls,
"can't start dlm_recoverd %d", error);
632 error = do_uevent(ls, 1);
656 spin_lock(&lslist_lock);
658 spin_unlock(&lslist_lock);
688 error = threads_start();
692 error = new_lockspace(name, cluster, flags, lvblen, ops, ops_arg,
693 ops_result, lockspace);
705 static int lkb_idr_is_local(
int id,
void *p,
void *data)
714 static int lkb_idr_is_any(
int id,
void *p,
void *data)
719 static int lkb_idr_free(
int id,
void *p,
void *data)
734 static int lockspace_busy(
struct dlm_ls *ls,
int force)
741 }
else if (force == 1) {
750 static int release_lockspace(
struct dlm_ls *ls,
int force)
756 busy = lockspace_busy(ls, force);
758 spin_lock(&lslist_lock);
772 spin_unlock(&lslist_lock);
775 log_debug(ls,
"release_lockspace no remove %d", rv);
788 remove_lockspace(ls);
841 log_debug(ls,
"release_lockspace final free");
874 error = release_lockspace(ls, force);
889 spin_lock(&lslist_lock);
893 spin_unlock(&lslist_lock);
894 log_error(ls,
"no userland control daemon, stopping lockspace");
898 spin_unlock(&lslist_lock);