Skip to content

Commit 4db41bf

Browse files
Alexander Aringteigland
authored andcommitted
dlm: remove ls_local_handle from struct dlm_ls
This patch removes ls_local_handle from struct dlm_ls as it stores the ls pointer of the top level structure itesef and this isn't necessary. There is a lookup functionality to lookup the lockspace in dlm_find_lockspace_local() but the given input parameter is the pointer already. This might be more safe to lookup a lockspace but given a wrong lockspace pointer is a bug in the code and we save the additional lookup here. The dlm_ls structure can be still hidden by using dlm_lockspace_t handle pointer. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent f49da8c commit 4db41bf

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

fs/dlm/dlm_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ struct rcom_lock {
561561

562562
struct dlm_ls {
563563
struct list_head ls_list; /* list of lockspaces */
564-
dlm_lockspace_t *ls_local_handle;
565564
uint32_t ls_global_id; /* global unique lockspace ID */
566565
uint32_t ls_generation;
567566
uint32_t ls_exflags;

fs/dlm/lockspace.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len)
3838

3939
if (rc)
4040
return rc;
41-
ls = dlm_find_lockspace_local(ls->ls_local_handle);
41+
ls = dlm_find_lockspace_local(ls);
4242
if (!ls)
4343
return -EINVAL;
4444

@@ -265,18 +265,9 @@ struct dlm_ls *dlm_find_lockspace_global(uint32_t id)
265265

266266
struct dlm_ls *dlm_find_lockspace_local(dlm_lockspace_t *lockspace)
267267
{
268-
struct dlm_ls *ls;
268+
struct dlm_ls *ls = lockspace;
269269

270-
spin_lock_bh(&lslist_lock);
271-
list_for_each_entry(ls, &lslist, ls_list) {
272-
if (ls->ls_local_handle == lockspace) {
273-
atomic_inc(&ls->ls_count);
274-
goto out;
275-
}
276-
}
277-
ls = NULL;
278-
out:
279-
spin_unlock_bh(&lslist_lock);
270+
atomic_inc(&ls->ls_count);
280271
return ls;
281272
}
282273

@@ -496,7 +487,6 @@ static int new_lockspace(const char *name, const char *cluster,
496487
idr_init(&ls->ls_recover_idr);
497488
spin_lock_init(&ls->ls_recover_idr_lock);
498489
ls->ls_recover_list_count = 0;
499-
ls->ls_local_handle = ls;
500490
init_waitqueue_head(&ls->ls_wait_general);
501491
INIT_LIST_HEAD(&ls->ls_masters_list);
502492
rwlock_init(&ls->ls_masters_lock);

fs/dlm/user.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static int device_remove_lockspace(struct dlm_lspace_params *params)
454454
if (params->flags & DLM_USER_LSFLG_FORCEFREE)
455455
force = 2;
456456

457-
lockspace = ls->ls_local_handle;
457+
lockspace = ls;
458458
dlm_put_lockspace(ls);
459459

460460
/* The final dlm_release_lockspace waits for references to go to
@@ -657,7 +657,7 @@ static int device_open(struct inode *inode, struct file *file)
657657
return -ENOMEM;
658658
}
659659

660-
proc->lockspace = ls->ls_local_handle;
660+
proc->lockspace = ls;
661661
INIT_LIST_HEAD(&proc->asts);
662662
INIT_LIST_HEAD(&proc->locks);
663663
INIT_LIST_HEAD(&proc->unlocking);

0 commit comments

Comments
 (0)