diff options
author | Alexander Aring <aahringo@redhat.com> | 2024-05-28 17:12:34 -0400 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2024-05-31 11:04:54 -0500 |
commit | 4db41bf4f04f75d5bcf52c500cbec11a2e159a06 (patch) | |
tree | b85655c6d3d5d5fa3e79a644b46985e678bfaa2f /fs/dlm/lockspace.c | |
parent | f49da8c09f93ad2b220ee44091123aa9693eefde (diff) |
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>
Diffstat (limited to 'fs/dlm/lockspace.c')
-rw-r--r-- | fs/dlm/lockspace.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index b6a1a6eb7f277..8155d7475c796 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c @@ -38,7 +38,7 @@ static ssize_t dlm_control_store(struct dlm_ls *ls, const char *buf, size_t len) if (rc) return rc; - ls = dlm_find_lockspace_local(ls->ls_local_handle); + ls = dlm_find_lockspace_local(ls); if (!ls) return -EINVAL; @@ -265,18 +265,9 @@ struct dlm_ls *dlm_find_lockspace_global(uint32_t id) struct dlm_ls *dlm_find_lockspace_local(dlm_lockspace_t *lockspace) { - struct dlm_ls *ls; + struct dlm_ls *ls = lockspace; - spin_lock_bh(&lslist_lock); - list_for_each_entry(ls, &lslist, ls_list) { - if (ls->ls_local_handle == lockspace) { - atomic_inc(&ls->ls_count); - goto out; - } - } - ls = NULL; - out: - spin_unlock_bh(&lslist_lock); + atomic_inc(&ls->ls_count); return ls; } @@ -496,7 +487,6 @@ static int new_lockspace(const char *name, const char *cluster, idr_init(&ls->ls_recover_idr); spin_lock_init(&ls->ls_recover_idr_lock); ls->ls_recover_list_count = 0; - ls->ls_local_handle = ls; init_waitqueue_head(&ls->ls_wait_general); INIT_LIST_HEAD(&ls->ls_masters_list); rwlock_init(&ls->ls_masters_lock); |