aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm/lockspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dlm/lockspace.c')
-rw-r--r--fs/dlm/lockspace.c50
1 files changed, 14 insertions, 36 deletions
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 6353a8384520..5c108c49cb8c 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -166,26 +166,7 @@ static struct kobj_type dlm_ktype = {
166 .release = lockspace_kobj_release, 166 .release = lockspace_kobj_release,
167}; 167};
168 168
169static struct kset dlm_kset = { 169static struct kset *dlm_kset;
170 .ktype = &dlm_ktype,
171};
172
173static int kobject_setup(struct dlm_ls *ls)
174{
175 char lsname[DLM_LOCKSPACE_LEN];
176 int error;
177
178 memset(lsname, 0, DLM_LOCKSPACE_LEN);
179 snprintf(lsname, DLM_LOCKSPACE_LEN, "%s", ls->ls_name);
180
181 error = kobject_set_name(&ls->ls_kobj, "%s", lsname);
182 if (error)
183 return error;
184
185 ls->ls_kobj.kset = &dlm_kset;
186 ls->ls_kobj.ktype = &dlm_ktype;
187 return 0;
188}
189 170
190static int do_uevent(struct dlm_ls *ls, int in) 171static int do_uevent(struct dlm_ls *ls, int in)
191{ 172{
@@ -220,24 +201,22 @@ static int do_uevent(struct dlm_ls *ls, int in)
220 201
221int dlm_lockspace_init(void) 202int dlm_lockspace_init(void)
222{ 203{
223 int error;
224
225 ls_count = 0; 204 ls_count = 0;
226 mutex_init(&ls_lock); 205 mutex_init(&ls_lock);
227 INIT_LIST_HEAD(&lslist); 206 INIT_LIST_HEAD(&lslist);
228 spin_lock_init(&lslist_lock); 207 spin_lock_init(&lslist_lock);
229 208
230 kobject_set_name(&dlm_kset.kobj, "dlm"); 209 dlm_kset = kset_create_and_add("dlm", NULL, kernel_kobj);
231 kobj_set_kset_s(&dlm_kset, kernel_subsys); 210 if (!dlm_kset) {
232 error = kset_register(&dlm_kset); 211 printk(KERN_WARNING "%s: can not create kset\n", __FUNCTION__);
233 if (error) 212 return -ENOMEM;
234 printk("dlm_lockspace_init: cannot register kset %d\n", error); 213 }
235 return error; 214 return 0;
236} 215}
237 216
238void dlm_lockspace_exit(void) 217void dlm_lockspace_exit(void)
239{ 218{
240 kset_unregister(&dlm_kset); 219 kset_unregister(dlm_kset);
241} 220}
242 221
243static int dlm_scand(void *data) 222static int dlm_scand(void *data)
@@ -549,13 +528,12 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
549 goto out_delist; 528 goto out_delist;
550 } 529 }
551 530
552 error = kobject_setup(ls); 531 ls->ls_kobj.kset = dlm_kset;
553 if (error) 532 error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL,
554 goto out_stop; 533 "%s", ls->ls_name);
555
556 error = kobject_register(&ls->ls_kobj);
557 if (error) 534 if (error)
558 goto out_stop; 535 goto out_stop;
536 kobject_uevent(&ls->ls_kobj, KOBJ_ADD);
559 537
560 /* let kobject handle freeing of ls if there's an error */ 538 /* let kobject handle freeing of ls if there's an error */
561 do_unreg = 1; 539 do_unreg = 1;
@@ -601,7 +579,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
601 kfree(ls->ls_rsbtbl); 579 kfree(ls->ls_rsbtbl);
602 out_lsfree: 580 out_lsfree:
603 if (do_unreg) 581 if (do_unreg)
604 kobject_unregister(&ls->ls_kobj); 582 kobject_put(&ls->ls_kobj);
605 else 583 else
606 kfree(ls); 584 kfree(ls);
607 out: 585 out:
@@ -750,7 +728,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
750 dlm_clear_members(ls); 728 dlm_clear_members(ls);
751 dlm_clear_members_gone(ls); 729 dlm_clear_members_gone(ls);
752 kfree(ls->ls_node_array); 730 kfree(ls->ls_node_array);
753 kobject_unregister(&ls->ls_kobj); 731 kobject_put(&ls->ls_kobj);
754 /* The ls structure will be freed when the kobject is done with */ 732 /* The ls structure will be freed when the kobject is done with */
755 733
756 mutex_lock(&ls_lock); 734 mutex_lock(&ls_lock);