From: Alexander Aring <aahringo@redhat.com>
To: teigland@redhat.com
Cc: gfs2@lists.linux.dev, aahringo@redhat.com
Subject: [PATCH dlm/next 04/10] dlm: remove ls_local_handle from struct dlm_ls
Date: Tue, 23 Apr 2024 15:55:53 -0400 [thread overview]
Message-ID: <20240423195559.1527187-4-aahringo@redhat.com> (raw)
In-Reply-To: <20240423195559.1527187-1-aahringo@redhat.com>
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>
---
fs/dlm/dlm_internal.h | 1 -
fs/dlm/lockspace.c | 16 +++-------------
fs/dlm/user.c | 4 ++--
3 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index 9085ba3b2f20..47e73d9838fd 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -568,7 +568,6 @@ struct rcom_lock {
struct dlm_ls {
struct list_head ls_list; /* list of lockspaces */
- dlm_lockspace_t *ls_local_handle;
uint32_t ls_global_id; /* global unique lockspace ID */
uint32_t ls_generation;
uint32_t ls_exflags;
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index ed23787271b1..21d8572c39c5 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;
}
@@ -495,7 +486,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);
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 3173b974e8c8..f6635a5314f4 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -454,7 +454,7 @@ static int device_remove_lockspace(struct dlm_lspace_params *params)
if (params->flags & DLM_USER_LSFLG_FORCEFREE)
force = 2;
- lockspace = ls->ls_local_handle;
+ lockspace = ls;
dlm_put_lockspace(ls);
/* 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)
return -ENOMEM;
}
- proc->lockspace = ls->ls_local_handle;
+ proc->lockspace = ls;
INIT_LIST_HEAD(&proc->asts);
INIT_LIST_HEAD(&proc->locks);
INIT_LIST_HEAD(&proc->unlocking);
--
2.43.0
next prev parent reply other threads:[~2024-04-23 19:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 19:55 [PATCH dlm/next 01/10] dlm: don't kref_init rsb created for toss list Alexander Aring
2024-04-23 19:55 ` [PATCH dlm/next 02/10] dlm: remove unused parameter in dlm_midcomms_addr Alexander Aring
2024-04-23 19:55 ` [PATCH dlm/next 03/10] dlm: make dlm_our_nodeid read mostly Alexander Aring
2024-04-23 19:55 ` Alexander Aring [this message]
2024-04-23 19:55 ` [PATCH dlm/next 05/10] dlm: drop own rsb pre allocation mechanism Alexander Aring
2024-04-23 19:55 ` [PATCH dlm/next 06/10] dlm: using rcu to avoid rsb lookup again Alexander Aring
2024-04-23 19:55 ` [PATCH dlm/next 07/10] dlm: move lkb idr to xarray datastructure Alexander Aring
2024-04-23 19:55 ` [PATCH dlm/next 08/10] dlm: move recover " Alexander Aring
2024-04-23 19:55 ` [PATCH dlm/next 09/10] dlm: merge nodeid field to master_nodeid Alexander Aring
2024-04-25 11:09 ` Alexander Aring
2024-04-23 19:55 ` [PATCH dlm/next 10/10] dlm: use is_master() where it's prossible Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240423195559.1527187-4-aahringo@redhat.com \
--to=aahringo@redhat.com \
--cc=gfs2@lists.linux.dev \
--cc=teigland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).