md/raid1: small cleanups in MD and raid1 drivers
cover md/raid1: small cleanups in MD and raid1 drivers
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(-)
Signature · 1 line
2.43.0
PATCH 1/3 md/raid1: replace wait loop with wait_event_idle() in raid1_write_request()
The wait loop is equivalent to wait_event_idle() and can be simplified by usaing it for improving readability.
--- drivers/md/raid1.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/md/raid1.c +4 -11
@@ -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))); }/*
Signature · 1 line
2.43.0
PATCH 2/3 md: use mddev_is_dm() instead of open-coding gendisk checks
In reply to Abd-Alrhman MasalkhiReplace direct checks on mddev->gendisk with mddev_is_dm() in md_handle_request() and md_run().
--- drivers/md/md.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/md.c +2 -2
@@ -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 */
Signature · 1 line
2.43.0
PATCH 3/3 md: use ATTRIBUTE_GROUPS() for md default sysfs attributes
In reply to Abd-Alrhman MasalkhiReplace the md_default_group and md_attr_groups with ATTRIBUTE_GROUPS().
--- drivers/md/md.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/md/md.c +2 -10
@@ -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 ;
Signature · 1 line
2.43.0
Yu Kuai
AppliedQuoted 13 lines · Abd-Alrhman Masalkhi
Hi,
This small series contains three cleanups in the MD and raid1 drivers.
Thanks,
Abd-AlrhmanAbd-Alrhman Masalkhi (3):
md/raid1: replace wait loop withwait_event_idle()in
raid1_write_request()
md: usemddev_is_dm()instead of open-coding gendisk checks
md: useATTRIBUTE_GROUPS()for md default sysfs attributes
Quoted 3 lines
drivers/md/md.c | 16 ++++------------ drivers/md/raid1.c | 15 ++++----------- 2 files changed, 8 insertions(+), 23 deletions(-)
Applied to md-7.1
Quoted 1 line
Signature · 2 lines
Thansk, Kuai