Skip to content

Commit 8a4cf50

Browse files
Alexander Aringteigland
authored andcommitted
dlm: drop kobject release callback handling
This patch removes the releasing of the "struct dlm ls" resource out of the kobject handling. Instead we run kfree() after kobject_put() of the lockspace kobject structure that should always being the last put call. This prepares to split the releasing of all lockspace resources asynchronously in the background and just deregister everything in release_lockspace(). Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent d47b822 commit 8a4cf50

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

fs/dlm/lockspace.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,6 @@ static ssize_t dlm_attr_store(struct kobject *kobj, struct attribute *attr,
174174
return a->store ? a->store(ls, buf, len) : len;
175175
}
176176

177-
static void lockspace_kobj_release(struct kobject *k)
178-
{
179-
struct dlm_ls *ls = container_of(k, struct dlm_ls, ls_kobj);
180-
kfree(ls);
181-
}
182-
183177
static const struct sysfs_ops dlm_attr_ops = {
184178
.show = dlm_attr_show,
185179
.store = dlm_attr_store,
@@ -188,7 +182,6 @@ static const struct sysfs_ops dlm_attr_ops = {
188182
static struct kobj_type dlm_ktype = {
189183
.default_groups = dlm_groups,
190184
.sysfs_ops = &dlm_attr_ops,
191-
.release = lockspace_kobj_release,
192185
};
193186

194187
static struct kset *dlm_kset;
@@ -328,7 +321,6 @@ static int new_lockspace(const char *name, const char *cluster,
328321
int *ops_result, dlm_lockspace_t **lockspace)
329322
{
330323
struct dlm_ls *ls;
331-
int do_unreg = 0;
332324
int namelen = strlen(name);
333325
int error;
334326

@@ -530,9 +522,6 @@ static int new_lockspace(const char *name, const char *cluster,
530522
wait_event(ls->ls_recover_lock_wait,
531523
test_bit(LSFL_RECOVER_LOCK, &ls->ls_flags));
532524

533-
/* let kobject handle freeing of ls if there's an error */
534-
do_unreg = 1;
535-
536525
ls->ls_kobj.kset = dlm_kset;
537526
error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL,
538527
"%s", ls->ls_name);
@@ -580,10 +569,8 @@ static int new_lockspace(const char *name, const char *cluster,
580569
xa_destroy(&ls->ls_lkbxa);
581570
rhashtable_destroy(&ls->ls_rsbtbl);
582571
out_lsfree:
583-
if (do_unreg)
584-
kobject_put(&ls->ls_kobj);
585-
else
586-
kfree(ls);
572+
kobject_put(&ls->ls_kobj);
573+
kfree(ls);
587574
out:
588575
module_put(THIS_MODULE);
589576
return error;
@@ -743,6 +730,8 @@ static int release_lockspace(struct dlm_ls *ls, int force)
743730

744731
dlm_delete_debug_file(ls);
745732

733+
kobject_put(&ls->ls_kobj);
734+
746735
xa_destroy(&ls->ls_recover_xa);
747736
kfree(ls->ls_recover_buf);
748737

@@ -769,8 +758,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
769758
dlm_clear_members_gone(ls);
770759
kfree(ls->ls_node_array);
771760
log_rinfo(ls, "release_lockspace final free");
772-
kobject_put(&ls->ls_kobj);
773-
/* The ls structure will be freed when the kobject is done with */
761+
kfree(ls);
774762

775763
module_put(THIS_MODULE);
776764
return 0;

0 commit comments

Comments
 (0)