public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] md/raid1: small cleanups in MD and raid1 drivers
@ 2026-04-23 10:13 Abd-Alrhman Masalkhi
  2026-04-23 10:13 ` [PATCH 1/3] md/raid1: replace wait loop with wait_event_idle() in raid1_write_request() Abd-Alrhman Masalkhi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Abd-Alrhman Masalkhi @ 2026-04-23 10:13 UTC (permalink / raw)
  To: song, yukuai; +Cc: linux-raid, linux-kernel, Abd-Alrhman Masalkhi

Hi,

This small series contains three cleanups in the MD and raid1 drivers.

Thanks,
Abd-Alrhman

Abd-Alrhman Masalkhi (3):
  md/raid1: replace wait loop with wait_event_idle() in
    raid1_write_request()
  md: use mddev_is_dm() instead of open-coding gendisk checks
  md: use ATTRIBUTE_GROUPS() for md default sysfs attributes

 drivers/md/md.c    | 16 ++++------------
 drivers/md/raid1.c | 15 ++++-----------
 2 files changed, 8 insertions(+), 23 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] md/raid1: replace wait loop with wait_event_idle() in raid1_write_request()
  2026-04-23 10:13 [PATCH 0/3] md/raid1: small cleanups in MD and raid1 drivers Abd-Alrhman Masalkhi
@ 2026-04-23 10:13 ` Abd-Alrhman Masalkhi
  2026-04-23 10:13 ` [PATCH 2/3] md: use mddev_is_dm() instead of open-coding gendisk checks Abd-Alrhman Masalkhi
  2026-04-23 10:13 ` [PATCH 3/3] md: use ATTRIBUTE_GROUPS() for md default sysfs attributes Abd-Alrhman Masalkhi
  2 siblings, 0 replies; 4+ messages in thread
From: Abd-Alrhman Masalkhi @ 2026-04-23 10:13 UTC (permalink / raw)
  To: song, yukuai; +Cc: linux-raid, linux-kernel, Abd-Alrhman Masalkhi

The wait loop is equivalent to wait_event_idle() and can be simplified
by usaing it for improving readability.

Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
---
 drivers/md/raid1.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index cc9914bd15c1..b549be9174bb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1488,21 +1488,14 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
 	    mddev->cluster_ops->area_resyncing(mddev, WRITE,
 		     bio->bi_iter.bi_sector, bio_end_sector(bio))) {
 
-		DEFINE_WAIT(w);
 		if (bio->bi_opf & REQ_NOWAIT) {
 			bio_wouldblock_error(bio);
 			return;
 		}
-		for (;;) {
-			prepare_to_wait(&conf->wait_barrier,
-					&w, TASK_IDLE);
-			if (!mddev->cluster_ops->area_resyncing(mddev, WRITE,
-							bio->bi_iter.bi_sector,
-							bio_end_sector(bio)))
-				break;
-			schedule();
-		}
-		finish_wait(&conf->wait_barrier, &w);
+		wait_event_idle(conf->wait_barrier,
+				!mddev->cluster_ops->area_resyncing(mddev, WRITE,
+								    bio->bi_iter.bi_sector,
+								    bio_end_sector(bio)));
 	}
 
 	/*
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] md: use mddev_is_dm() instead of open-coding gendisk checks
  2026-04-23 10:13 [PATCH 0/3] md/raid1: small cleanups in MD and raid1 drivers Abd-Alrhman Masalkhi
  2026-04-23 10:13 ` [PATCH 1/3] md/raid1: replace wait loop with wait_event_idle() in raid1_write_request() Abd-Alrhman Masalkhi
@ 2026-04-23 10:13 ` Abd-Alrhman Masalkhi
  2026-04-23 10:13 ` [PATCH 3/3] md: use ATTRIBUTE_GROUPS() for md default sysfs attributes Abd-Alrhman Masalkhi
  2 siblings, 0 replies; 4+ messages in thread
From: Abd-Alrhman Masalkhi @ 2026-04-23 10:13 UTC (permalink / raw)
  To: song, yukuai; +Cc: linux-raid, linux-kernel, Abd-Alrhman Masalkhi

Replace direct checks on mddev->gendisk with mddev_is_dm() in
md_handle_request() and md_run().

Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
---
 drivers/md/md.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index ac71640ff3a8..346d071c1b8e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -417,7 +417,7 @@ bool md_handle_request(struct mddev *mddev, struct bio *bio)
 
 	if (!mddev->pers->make_request(mddev, bio)) {
 		percpu_ref_put(&mddev->active_io);
-		if (!mddev->gendisk && mddev->pers->prepare_suspend)
+		if (mddev_is_dm(mddev) && mddev->pers->prepare_suspend)
 			return false;
 		goto check_suspended;
 	}
@@ -6584,7 +6584,7 @@ int md_run(struct mddev *mddev)
 	}
 
 	/* dm-raid expect sync_thread to be frozen until resume */
-	if (mddev->gendisk)
+	if (!mddev_is_dm(mddev))
 		mddev->recovery = 0;
 
 	/* may be over-ridden by personality */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] md: use ATTRIBUTE_GROUPS() for md default sysfs attributes
  2026-04-23 10:13 [PATCH 0/3] md/raid1: small cleanups in MD and raid1 drivers Abd-Alrhman Masalkhi
  2026-04-23 10:13 ` [PATCH 1/3] md/raid1: replace wait loop with wait_event_idle() in raid1_write_request() Abd-Alrhman Masalkhi
  2026-04-23 10:13 ` [PATCH 2/3] md: use mddev_is_dm() instead of open-coding gendisk checks Abd-Alrhman Masalkhi
@ 2026-04-23 10:13 ` Abd-Alrhman Masalkhi
  2 siblings, 0 replies; 4+ messages in thread
From: Abd-Alrhman Masalkhi @ 2026-04-23 10:13 UTC (permalink / raw)
  To: song, yukuai; +Cc: linux-raid, linux-kernel, Abd-Alrhman Masalkhi

Replace the md_default_group and md_attr_groups with
ATTRIBUTE_GROUPS().

Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
---
 drivers/md/md.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 346d071c1b8e..0e55639211f2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6045,10 +6045,7 @@ static struct attribute *md_default_attrs[] = {
 	&md_logical_block_size.attr,
 	NULL,
 };
-
-static const struct attribute_group md_default_group = {
-	.attrs = md_default_attrs,
-};
+ATTRIBUTE_GROUPS(md_default);
 
 static struct attribute *md_redundancy_attrs[] = {
 	&md_scan_mode.attr,
@@ -6073,11 +6070,6 @@ static const struct attribute_group md_redundancy_group = {
 	.attrs = md_redundancy_attrs,
 };
 
-static const struct attribute_group *md_attr_groups[] = {
-	&md_default_group,
-	NULL,
-};
-
 static ssize_t
 md_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
 {
@@ -6154,7 +6146,7 @@ static const struct sysfs_ops md_sysfs_ops = {
 static const struct kobj_type md_ktype = {
 	.release	= md_kobj_release,
 	.sysfs_ops	= &md_sysfs_ops,
-	.default_groups	= md_attr_groups,
+	.default_groups	= md_default_groups,
 };
 
 int mdp_major = 0;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-23 10:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 10:13 [PATCH 0/3] md/raid1: small cleanups in MD and raid1 drivers Abd-Alrhman Masalkhi
2026-04-23 10:13 ` [PATCH 1/3] md/raid1: replace wait loop with wait_event_idle() in raid1_write_request() Abd-Alrhman Masalkhi
2026-04-23 10:13 ` [PATCH 2/3] md: use mddev_is_dm() instead of open-coding gendisk checks Abd-Alrhman Masalkhi
2026-04-23 10:13 ` [PATCH 3/3] md: use ATTRIBUTE_GROUPS() for md default sysfs attributes Abd-Alrhman Masalkhi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox