Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>

authored by

Alexander Aring and committed by
David Teigland
4db41bf4 f49da8c0

+5 -16
-1
fs/dlm/dlm_internal.h
··· 561 561 562 562 struct dlm_ls { 563 563 struct list_head ls_list; /* list of lockspaces */ 564 - dlm_lockspace_t *ls_local_handle; 565 564 uint32_t ls_global_id; /* global unique lockspace ID */ 566 565 uint32_t ls_generation; 567 566 uint32_t ls_exflags;
+3 -13
fs/dlm/lockspace.c
··· 38 38 39 39 if (rc) 40 40 return rc; 41 - ls = dlm_find_lockspace_local(ls->ls_local_handle); 41 + ls = dlm_find_lockspace_local(ls); 42 42 if (!ls) 43 43 return -EINVAL; 44 44 ··· 265 265 266 266 struct dlm_ls *dlm_find_lockspace_local(dlm_lockspace_t *lockspace) 267 267 { 268 - struct dlm_ls *ls; 268 + struct dlm_ls *ls = lockspace; 269 269 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); 280 271 return ls; 281 272 } 282 273 ··· 487 496 idr_init(&ls->ls_recover_idr); 488 497 spin_lock_init(&ls->ls_recover_idr_lock); 489 498 ls->ls_recover_list_count = 0; 490 - ls->ls_local_handle = ls; 491 499 init_waitqueue_head(&ls->ls_wait_general); 492 500 INIT_LIST_HEAD(&ls->ls_masters_list); 493 501 rwlock_init(&ls->ls_masters_lock);
+2 -2
fs/dlm/user.c
··· 454 454 if (params->flags & DLM_USER_LSFLG_FORCEFREE) 455 455 force = 2; 456 456 457 - lockspace = ls->ls_local_handle; 457 + lockspace = ls; 458 458 dlm_put_lockspace(ls); 459 459 460 460 /* The final dlm_release_lockspace waits for references to go to ··· 657 657 return -ENOMEM; 658 658 } 659 659 660 - proc->lockspace = ls->ls_local_handle; 660 + proc->lockspace = ls; 661 661 INIT_LIST_HEAD(&proc->asts); 662 662 INIT_LIST_HEAD(&proc->locks); 663 663 INIT_LIST_HEAD(&proc->unlocking);