From: Heinz Mauelshagen <heinzm@xxxxxxxxxx> Signed-off-by: heinzm <heinzm@xxxxxxxxxx> --- drivers/md/md-faulty.c | 17 +++++++++++------ drivers/md/md-multipath.c | 9 ++++++--- drivers/md/md.c | 36 ++++++++++++++++++++++-------------- drivers/md/raid10.c | 10 ++++++---- drivers/md/raid5.c | 5 +++-- 5 files changed, 48 insertions(+), 29 deletions(-) diff --git a/drivers/md/md-faulty.c b/drivers/md/md-faulty.c index 33cb00115777..7ac286e28fcb 100644 --- a/drivers/md/md-faulty.c +++ b/drivers/md/md-faulty.c @@ -226,28 +226,33 @@ static void faulty_status(struct seq_file *seq, struct mddev *mddev) struct faulty_conf *conf = mddev->private; int n; - if ((n = atomic_read(&conf->counters[WriteTransient]))) + n = atomic_read(&conf->counters[WriteTransient]); + if (n) seq_printf(seq, " WriteTransient=%d(%d)", n, conf->period[WriteTransient]); - if ((n = atomic_read(&conf->counters[ReadTransient]))) + n = atomic_read(&conf->counters[ReadTransient]); + if (n) seq_printf(seq, " ReadTransient=%d(%d)", n, conf->period[ReadTransient]); - if ((n = atomic_read(&conf->counters[WritePersistent]))) + n = atomic_read(&conf->counters[WritePersistent]); + if (n) seq_printf(seq, " WritePersistent=%d(%d)", n, conf->period[WritePersistent]); - if ((n = atomic_read(&conf->counters[ReadPersistent]))) + n = atomic_read(&conf->counters[ReadPersistent]); + if (n) seq_printf(seq, " ReadPersistent=%d(%d)", n, conf->period[ReadPersistent]); - if ((n = atomic_read(&conf->counters[ReadFixable]))) + n = atomic_read(&conf->counters[ReadFixable]); + if (n) seq_printf(seq, " ReadFixable=%d(%d)", n, conf->period[ReadFixable]); - if ((n = atomic_read(&conf->counters[WriteAll]))) + if (atomic_read(&conf->counters[WriteAll])) seq_printf(seq, " WriteAll"); seq_printf(seq, " nfaults=%d", conf->nfaults); diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c index c6c0a76c5210..dd180199479b 100644 --- a/drivers/md/md-multipath.c +++ b/drivers/md/md-multipath.c @@ -216,8 +216,9 @@ static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev) print_multipath_conf(conf); - for (path = first; path <= last; path++) - if (!(p = conf->multipaths+path)->rdev) { + for (path = first; path <= last; path++) { + p = conf->multipaths+path; + if (!p->rdev) { disk_stack_limits(mddev->gendisk, rdev->bdev, rdev->data_offset << 9); @@ -233,6 +234,7 @@ static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev) err = 0; break; } + } print_multipath_conf(conf); @@ -302,7 +304,8 @@ static void multipathd(struct md_thread *thread) bio = &mp_bh->bio; bio->bi_iter.bi_sector = mp_bh->master_bio->bi_iter.bi_sector; - if ((mp_bh->path = multipath_map(conf)) < 0) { + mp_bh->path = multipath_map(conf); + if (mp_bh->path < 0) { pr_err("multipath: %pg: unrecoverable IO read error for block %llu\n", bio->bi_bdev, (unsigned long long)bio->bi_iter.bi_sector); diff --git a/drivers/md/md.c b/drivers/md/md.c index 132979e597dd..a48fbc80fc64 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2436,7 +2436,8 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev) if (mddev->raid_disks) mddev_create_serial_pool(mddev, rdev, false); - if ((err = kobject_add(&rdev->kobj, &mddev->kobj, "dev-%s", b))) + err = kobject_add(&rdev->kobj, &mddev->kobj, "dev-%s", b); + if (err) goto fail; /* failure here is OK */ @@ -3059,8 +3060,12 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) * will land in the local bitmap, which will be synced * by this node eventually */ - if (!mddev_is_clustered(rdev->mddev) || - (err = md_cluster_ops->gather_bitmaps(rdev)) == 0) { + if (mddev_is_clustered(rdev->mddev)) + err = md_cluster_ops->gather_bitmaps(rdev); + else + err = 0; + + if (!err) { clear_bit(Faulty, &rdev->flags); err = add_bound_rdev(rdev); } @@ -9401,17 +9406,20 @@ void md_check_recovery(struct mddev *mddev) goto not_running; set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery); - } else if ((spares = remove_and_add_spares(mddev, NULL))) { - clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); - clear_bit(MD_RECOVERY_CHECK, &mddev->recovery); - clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); - set_bit(MD_RECOVERY_RECOVER, &mddev->recovery); - } else if (mddev->recovery_cp < MaxSector) { - set_bit(MD_RECOVERY_SYNC, &mddev->recovery); - clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery); - } else if (!test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) - /* nothing to be done ... */ - goto not_running; + } else { + spares = remove_and_add_spares(mddev, NULL); + if (spares) { + clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); + clear_bit(MD_RECOVERY_CHECK, &mddev->recovery); + clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); + set_bit(MD_RECOVERY_RECOVER, &mddev->recovery); + } else if (mddev->recovery_cp < MaxSector) { + set_bit(MD_RECOVERY_SYNC, &mddev->recovery); + clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery); + } else if (!test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) + /* nothing to be done ... */ + goto not_running; + } if (mddev->pers->sync_request) { if (spares) { diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 7a15f794b839..8f3339e73f55 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1982,10 +1982,12 @@ static int _enough(struct r10conf *conf, int previous, int ignore) int this = first; while (n--) { struct md_rdev *rdev; - if (this != ignore && - (rdev = rcu_dereference(conf->mirrors[this].rdev)) && - test_bit(In_sync, &rdev->flags)) - cnt++; + if (this != ignore) { + rdev = rcu_dereference(conf->mirrors[this].rdev); + if (rdev && test_bit(In_sync, &rdev->flags)) + cnt++; + } + this = (this+1) % disks; } if (cnt == 0) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index d0b6a97200fa..4bdfbe1f8fcf 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -549,9 +549,10 @@ static int grow_buffers(struct stripe_head *sh, gfp_t gfp) for (i = 0; i < num; i++) { struct page *page; - if (!(page = alloc_page(gfp))) { + page = alloc_page(gfp); + if (!page) return 1; - } + sh->dev[i].page = page; sh->dev[i].orig_page = page; sh->dev[i].offset = 0; -- 2.39.2