cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH v6.3-rc1 10/12] fs: dlm: rsb hash table flag value to atomic ops
Date: Mon,  6 Mar 2023 15:48:17 -0500	[thread overview]
Message-ID: <20230306204819.2747646-11-aahringo@redhat.com> (raw)
In-Reply-To: <20230306204819.2747646-1-aahringo@redhat.com>

This patch moves the rsb hash table handling to atomic flag operations.
The flag operations for DLM_RTF_SHRINK are protected by
ls->ls_rsbtbl[b].lock. However we switch to atomic ops if new possible
flags will be used in a different way and don't assume such lock
dependencies.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 fs/dlm/dlm_internal.h | 4 ++--
 fs/dlm/lock.c         | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index b33473d9e3cf..e2925f554bc7 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -99,13 +99,13 @@ do { \
 }
 
 
-#define DLM_RTF_SHRINK		0x00000001
+#define DLM_RTF_SHRINK_BIT	0
 
 struct dlm_rsbtable {
 	struct rb_root		keep;
 	struct rb_root		toss;
 	spinlock_t		lock;
-	uint32_t		flags;
+	unsigned long		flags;
 };
 
 
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index ecb2deef6eae..507a03fe2279 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -1139,7 +1139,7 @@ static void toss_rsb(struct kref *kref)
 	rb_erase(&r->res_hashnode, &ls->ls_rsbtbl[r->res_bucket].keep);
 	rsb_insert(r, &ls->ls_rsbtbl[r->res_bucket].toss);
 	r->res_toss_time = jiffies;
-	ls->ls_rsbtbl[r->res_bucket].flags |= DLM_RTF_SHRINK;
+	set_bit(DLM_RTF_SHRINK_BIT, &ls->ls_rsbtbl[r->res_bucket].flags);
 	if (r->res_lvbptr) {
 		dlm_free_lvb(r->res_lvbptr);
 		r->res_lvbptr = NULL;
@@ -1588,7 +1588,7 @@ static void shrink_bucket(struct dlm_ls *ls, int b)
 
 	spin_lock(&ls->ls_rsbtbl[b].lock);
 
-	if (!(ls->ls_rsbtbl[b].flags & DLM_RTF_SHRINK)) {
+	if (!test_bit(DLM_RTF_SHRINK_BIT, &ls->ls_rsbtbl[b].flags)) {
 		spin_unlock(&ls->ls_rsbtbl[b].lock);
 		return;
 	}
@@ -1643,9 +1643,9 @@ static void shrink_bucket(struct dlm_ls *ls, int b)
 	}
 
 	if (need_shrink)
-		ls->ls_rsbtbl[b].flags |= DLM_RTF_SHRINK;
+		set_bit(DLM_RTF_SHRINK_BIT, &ls->ls_rsbtbl[b].flags);
 	else
-		ls->ls_rsbtbl[b].flags &= ~DLM_RTF_SHRINK;
+		clear_bit(DLM_RTF_SHRINK_BIT, &ls->ls_rsbtbl[b].flags);
 	spin_unlock(&ls->ls_rsbtbl[b].lock);
 
 	/*
-- 
2.31.1


  parent reply	other threads:[~2023-03-06 20:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06 20:48 [Cluster-devel] [PATCHv2 v6.3-rc1 00/12] fs: dlm: pending patches for v6.3-rc1 Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 01/12] fs: dlm: fix DLM_IFL_CB_PENDING gets overwritten Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 02/12] fs: dlm: add unbound flag to dlm_io workqueue Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 03/12] DLM: increase socket backlog to avoid hangs with 16 nodes Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 04/12] fs: dlm: remove deprecated code parts Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 05/12] fs: dlm: rename stub to local message flag Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 06/12] fs: dlm: remove DLM_IFL_LOCAL_MS flag Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 07/12] fs: dlm: store lkb distributed flags into own value Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 08/12] fs: dlm: change dflags to use atomic bits Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 09/12] fs: dlm: move internal flags to atomic ops Alexander Aring
2023-03-06 20:48 ` Alexander Aring [this message]
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 11/12] fs: dlm: switch lkb_sbflags " Alexander Aring
2023-03-06 20:48 ` [Cluster-devel] [PATCH v6.3-rc1 12/12] fs: dlm: switch ls_exflags " 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=20230306204819.2747646-11-aahringo@redhat.com \
    --to=aahringo@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 NNTP newsgroup(s).