All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	ocfs2-devel@oss.oracle.com
Subject: [PATCH 2/3] ocfs2: Remove a useless spinlock
Date: Tue, 19 Jul 2022 12:01:35 +0200	[thread overview]
Message-ID: <8ba7004d330cbe5f626539a8a3bff696d0c4285e.1658224839.git.christophe.jaillet@wanadoo.fr> (raw)
In-Reply-To: <bd6796635e58f9c47cf857573c3b9474a00ce26a.1658224839.git.christophe.jaillet@wanadoo.fr>

'node_map_lock' is a spinlock only used to protect calls to set_bit(),
clear_bit() and test_bit().

{set|clear}_bit() are already atomic and don't need this extra spinlock.
test_bit() only reads the bitmap for a given bit.

Remove this useless spinlock.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
test_bit() is NOT documented as an atomic function. However, I can't see
how it could return a wrong result here.

So review with care. There is maybe something I don't think about that is
lurking here.
---
 fs/ocfs2/heartbeat.c | 11 ++++-------
 fs/ocfs2/ocfs2.h     |  2 --
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c
index 1d72e0788943..4863ad35c242 100644
--- a/fs/ocfs2/heartbeat.c
+++ b/fs/ocfs2/heartbeat.c
@@ -35,7 +35,6 @@ static void ocfs2_node_map_init(struct ocfs2_node_map *map)
 
 void ocfs2_init_node_maps(struct ocfs2_super *osb)
 {
-	spin_lock_init(&osb->node_map_lock);
 	ocfs2_node_map_init(&osb->osb_recovering_orphan_dirs);
 }
 
@@ -67,9 +66,8 @@ void ocfs2_node_map_set_bit(struct ocfs2_super *osb,
 	if (bit==-1)
 		return;
 	BUG_ON(bit >= map->num_nodes);
-	spin_lock(&osb->node_map_lock);
+
 	set_bit(bit, map->map);
-	spin_unlock(&osb->node_map_lock);
 }
 
 void ocfs2_node_map_clear_bit(struct ocfs2_super *osb,
@@ -79,9 +77,8 @@ void ocfs2_node_map_clear_bit(struct ocfs2_super *osb,
 	if (bit==-1)
 		return;
 	BUG_ON(bit >= map->num_nodes);
-	spin_lock(&osb->node_map_lock);
+
 	clear_bit(bit, map->map);
-	spin_unlock(&osb->node_map_lock);
 }
 
 int ocfs2_node_map_test_bit(struct ocfs2_super *osb,
@@ -89,13 +86,13 @@ int ocfs2_node_map_test_bit(struct ocfs2_super *osb,
 			    int bit)
 {
 	int ret;
+
 	if (bit >= map->num_nodes) {
 		mlog(ML_ERROR, "bit=%d map->num_nodes=%d\n", bit, map->num_nodes);
 		BUG();
 	}
-	spin_lock(&osb->node_map_lock);
+
 	ret = test_bit(bit, map->map);
-	spin_unlock(&osb->node_map_lock);
 	return ret;
 }
 
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 740b64238312..1df193b97c30 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -302,8 +302,6 @@ struct ocfs2_super
 
 	u32 *slot_recovery_generations;
 
-	spinlock_t node_map_lock;
-
 	u64 root_blkno;
 	u64 system_dir_blkno;
 	u64 bitmap_blkno;
-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Christophe JAILLET via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
To: Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 2/3] ocfs2: Remove a useless spinlock
Date: Tue, 19 Jul 2022 12:01:35 +0200	[thread overview]
Message-ID: <8ba7004d330cbe5f626539a8a3bff696d0c4285e.1658224839.git.christophe.jaillet@wanadoo.fr> (raw)
In-Reply-To: <bd6796635e58f9c47cf857573c3b9474a00ce26a.1658224839.git.christophe.jaillet@wanadoo.fr>

'node_map_lock' is a spinlock only used to protect calls to set_bit(),
clear_bit() and test_bit().

{set|clear}_bit() are already atomic and don't need this extra spinlock.
test_bit() only reads the bitmap for a given bit.

Remove this useless spinlock.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
test_bit() is NOT documented as an atomic function. However, I can't see
how it could return a wrong result here.

So review with care. There is maybe something I don't think about that is
lurking here.
---
 fs/ocfs2/heartbeat.c | 11 ++++-------
 fs/ocfs2/ocfs2.h     |  2 --
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c
index 1d72e0788943..4863ad35c242 100644
--- a/fs/ocfs2/heartbeat.c
+++ b/fs/ocfs2/heartbeat.c
@@ -35,7 +35,6 @@ static void ocfs2_node_map_init(struct ocfs2_node_map *map)
 
 void ocfs2_init_node_maps(struct ocfs2_super *osb)
 {
-	spin_lock_init(&osb->node_map_lock);
 	ocfs2_node_map_init(&osb->osb_recovering_orphan_dirs);
 }
 
@@ -67,9 +66,8 @@ void ocfs2_node_map_set_bit(struct ocfs2_super *osb,
 	if (bit==-1)
 		return;
 	BUG_ON(bit >= map->num_nodes);
-	spin_lock(&osb->node_map_lock);
+
 	set_bit(bit, map->map);
-	spin_unlock(&osb->node_map_lock);
 }
 
 void ocfs2_node_map_clear_bit(struct ocfs2_super *osb,
@@ -79,9 +77,8 @@ void ocfs2_node_map_clear_bit(struct ocfs2_super *osb,
 	if (bit==-1)
 		return;
 	BUG_ON(bit >= map->num_nodes);
-	spin_lock(&osb->node_map_lock);
+
 	clear_bit(bit, map->map);
-	spin_unlock(&osb->node_map_lock);
 }
 
 int ocfs2_node_map_test_bit(struct ocfs2_super *osb,
@@ -89,13 +86,13 @@ int ocfs2_node_map_test_bit(struct ocfs2_super *osb,
 			    int bit)
 {
 	int ret;
+
 	if (bit >= map->num_nodes) {
 		mlog(ML_ERROR, "bit=%d map->num_nodes=%d\n", bit, map->num_nodes);
 		BUG();
 	}
-	spin_lock(&osb->node_map_lock);
+
 	ret = test_bit(bit, map->map);
-	spin_unlock(&osb->node_map_lock);
 	return ret;
 }
 
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 740b64238312..1df193b97c30 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -302,8 +302,6 @@ struct ocfs2_super
 
 	u32 *slot_recovery_generations;
 
-	spinlock_t node_map_lock;
-
 	u64 root_blkno;
 	u64 system_dir_blkno;
 	u64 bitmap_blkno;
-- 
2.34.1


_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

  reply	other threads:[~2022-07-19 10:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 10:01 [PATCH 1/3] ocfs2: Remove some useless functions Christophe JAILLET
2022-07-19 10:01 ` [Ocfs2-devel] " Christophe JAILLET via Ocfs2-devel
2022-07-19 10:01 ` Christophe JAILLET [this message]
2022-07-19 10:01   ` [Ocfs2-devel] [PATCH 2/3] ocfs2: Remove a useless spinlock Christophe JAILLET via Ocfs2-devel
2022-07-19 10:24   ` David Laight
2022-07-19 10:24     ` [Ocfs2-devel] " David Laight via Ocfs2-devel
2022-07-19 13:25     ` Christophe JAILLET via Ocfs2-devel
2022-07-19 13:25       ` Christophe JAILLET
2022-07-19 14:19       ` [Ocfs2-devel] " David Laight via Ocfs2-devel
2022-07-19 14:19         ` David Laight
2022-07-20  1:59       ` Joseph Qi
2022-07-20  1:59         ` [Ocfs2-devel] " Joseph Qi via Ocfs2-devel
2022-07-20  8:26         ` Marion & Christophe JAILLET
2022-07-20  8:26           ` [Ocfs2-devel] " Marion & Christophe JAILLET via Ocfs2-devel
2022-07-20  9:48           ` Joseph Qi
2022-07-20  9:48             ` [Ocfs2-devel] " Joseph Qi via Ocfs2-devel
2022-07-20 13:32             ` Christophe JAILLET
2022-07-20 13:32               ` [Ocfs2-devel] " Christophe JAILLET via Ocfs2-devel
2022-07-21  1:53               ` Joseph Qi
2022-07-21  1:53                 ` [Ocfs2-devel] " Joseph Qi via Ocfs2-devel
2022-07-19 10:05 ` [PATCH 3/3] ocfs2: use the bitmap API to simplify code Christophe JAILLET
2022-07-19 10:05   ` [Ocfs2-devel] " Christophe JAILLET via Ocfs2-devel
2022-07-20  2:06   ` Joseph Qi
2022-07-20  2:06     ` [Ocfs2-devel] " Joseph Qi via Ocfs2-devel
2022-07-20  2:03 ` [PATCH 1/3] ocfs2: Remove some useless functions Joseph Qi
2022-07-20  2:03   ` [Ocfs2-devel] " Joseph Qi via Ocfs2-devel

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=8ba7004d330cbe5f626539a8a3bff696d0c4285e.1658224839.git.christophe.jaillet@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=jlbec@evilplan.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@oss.oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.