lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date: Tue, 26 Mar 2024 10:29:20 +0000
From: tada keisuke <keisuke1.tada@...xia.com>
To: "song@...nel.org" <song@...nel.org>,
        "yukuai3@...wei.com"
	<yukuai3@...wei.com>
CC: "linux-raid@...r.kernel.org" <linux-raid@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH 01/11] md: add infra for active_aligned_reads changes

Prepare to smoothly change the type of active_aligned_reads from atomic_t to percpu_ref.

Signed-off-by: Keisuke TADA <keisuke1.tada@...xia.com>
Signed-off-by: Toshifumi OHTAKE <toshifumi.ootake@...xia.com>
---
 drivers/md/raid5.c | 12 ++++++------
 drivers/md/raid5.h | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index f2e3c3e2d879..fd121629603c 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5436,7 +5436,7 @@ static void raid5_align_endio(struct bio *bi)
 
 	if (!error) {
 		bio_endio(raid_bi);
-		if (atomic_dec_and_test(&conf->active_aligned_reads))
+		if (active_aligned_reads_dec_and_test(conf))
 			wake_up(&conf->wait_for_quiescent);
 		return;
 	}
@@ -5500,7 +5500,7 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
 
 	did_inc = false;
 	if (conf->quiesce == 0) {
-		atomic_inc(&conf->active_aligned_reads);
+		active_aligned_reads_inc(conf);
 		did_inc = true;
 	}
 	/* need a memory barrier to detect the race with raid5_quiesce() */
@@ -5508,12 +5508,12 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
 		/* quiesce is in progress, so we need to undo io activation and wait
 		 * for it to finish
 		 */
-		if (did_inc && atomic_dec_and_test(&conf->active_aligned_reads))
+		if (did_inc && active_aligned_reads_dec_and_test(conf))
 			wake_up(&conf->wait_for_quiescent);
 		spin_lock_irq(&conf->device_lock);
 		wait_event_lock_irq(conf->wait_for_quiescent, conf->quiesce == 0,
 				    conf->device_lock);
-		atomic_inc(&conf->active_aligned_reads);
+		active_aligned_reads_inc(conf);
 		spin_unlock_irq(&conf->device_lock);
 	}
 
@@ -6609,7 +6609,7 @@ static int  retry_aligned_read(struct r5conf *conf, struct bio *raid_bio,
 
 	bio_endio(raid_bio);
 
-	if (atomic_dec_and_test(&conf->active_aligned_reads))
+	if (active_aligned_reads_dec_and_test(conf))
 		wake_up(&conf->wait_for_quiescent);
 	return handled;
 }
@@ -8620,7 +8620,7 @@ static void raid5_quiesce(struct mddev *mddev, int quiesce)
 		smp_store_release(&conf->quiesce, 2);
 		wait_event_cmd(conf->wait_for_quiescent,
 				    atomic_read(&conf->active_stripes) == 0 &&
-				    atomic_read(&conf->active_aligned_reads) == 0,
+				    active_aligned_reads_is_zero(conf),
 				    unlock_all_device_hash_locks_irq(conf),
 				    lock_all_device_hash_locks_irq(conf));
 		conf->quiesce = 1;
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index 9b5a7dc3f2a0..5bd6bb3540c5 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -696,6 +696,26 @@ struct r5conf {
 	struct r5pending_data	*next_pending_data;
 };
 
+static inline void active_aligned_reads_inc(struct r5conf *conf)
+{
+	atomic_inc(&conf->active_aligned_reads);
+}
+
+static inline void active_aligned_reads_dec(struct r5conf *conf)
+{
+	atomic_dec(&conf->active_aligned_reads);
+}
+
+static inline bool active_aligned_reads_is_zero(struct r5conf *conf)
+{
+	return atomic_read(&conf->active_aligned_reads) == 0;
+}
+
+static inline bool active_aligned_reads_dec_and_test(struct r5conf *conf)
+{
+	return atomic_dec_and_test(&conf->active_aligned_reads);
+}
+
 #if PAGE_SIZE == DEFAULT_STRIPE_SIZE
 #define RAID5_STRIPE_SIZE(conf)	STRIPE_SIZE
 #define RAID5_STRIPE_SHIFT(conf)	STRIPE_SHIFT
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ