md: clear WantReplacement once disk is removed
authorGuoqing Jiang <gqjiang@suse.com>
Mon, 24 Apr 2017 07:58:04 +0000 (15:58 +0800)
committerShaohua Li <shli@fb.com>
Tue, 25 Apr 2017 16:36:29 +0000 (09:36 -0700)
We can clear 'WantReplacement' flag directly no
matter it's replacement existed or not since the
semantic is same as before.

Also since the disk is removed from array, then
it is straightforward to remove 'WantReplacement'
flag and the comments in raid10/5 can be removed
as well.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c

index 14a9d36b25b8f681549055cec283643bb3a5c756..70a596c10306aacda32526e62a57cdc6bfc50003 100644 (file)
@@ -1831,9 +1831,9 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
                        p->rdev = repl;
                        conf->mirrors[conf->raid_disks + number].rdev = NULL;
                        unfreeze_array(conf);
-                       clear_bit(WantReplacement, &rdev->flags);
-               } else
-                       clear_bit(WantReplacement, &rdev->flags);
+               }
+
+               clear_bit(WantReplacement, &rdev->flags);
                err = md_integrity_register(mddev);
        }
 abort:
index 5de951bcd24c035833b751ce9e2771d2efb011f9..2883b720a265d86aa8fe0474e48e07acec42389d 100644 (file)
@@ -1874,13 +1874,9 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
                           * but will never see neither -- if they are careful.
                           */
                p->replacement = NULL;
-               clear_bit(WantReplacement, &rdev->flags);
-       } else
-               /* We might have just remove the Replacement as faulty
-                * Clear the flag just in case
-                */
-               clear_bit(WantReplacement, &rdev->flags);
+       }
 
+       clear_bit(WantReplacement, &rdev->flags);
        err = md_integrity_register(mddev);
 
 abort:
index 356cd9c7c753eb656030d68cc4435f911d3ba18c..3d971e5a1b0e9fed8d486b549a88b0191f10a061 100644 (file)
@@ -7603,15 +7603,12 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
                           * but will never see neither - if they are careful
                           */
                p->replacement = NULL;
-               clear_bit(WantReplacement, &rdev->flags);
 
                if (!err)
                        err = log_modify(conf, p->rdev, true);
-       } else
-               /* We might have just removed the Replacement as faulty-
-                * clear the bit just in case
-                */
-               clear_bit(WantReplacement, &rdev->flags);
+       }
+
+       clear_bit(WantReplacement, &rdev->flags);
 abort:
 
        print_raid5_conf(conf);