aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan E Brassow <jbrassow@redhat.com>2011-10-31 16:21:26 -0400
committerAlasdair G Kergon <agk@redhat.com>2011-10-31 16:21:26 -0400
commit2e727c3ca1beff05f27b6207a795790f222bf8d8 (patch)
treed00c9aeea0173051fe3bbd4398697acab9ab61ca
parent5a25f0eb707bbb4a5aaaf19c933605a6dbaf77a5 (diff)
dm: raid fix device status indicator when array initializing
When devices in a RAID array are not in-sync, they are supposed to be reported as such in the status output as an 'a' character, which means "alive, but not in-sync". But when the entire array is rebuilt 'A' is being used, which is incorrect. This patch corrects this to 'a'. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm-raid.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 86df8b2cf927..7503a20d04a7 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1017,30 +1017,56 @@ static int raid_status(struct dm_target *ti, status_type_t type,
1017 struct raid_set *rs = ti->private; 1017 struct raid_set *rs = ti->private;
1018 unsigned raid_param_cnt = 1; /* at least 1 for chunksize */ 1018 unsigned raid_param_cnt = 1; /* at least 1 for chunksize */
1019 unsigned sz = 0; 1019 unsigned sz = 0;
1020 int i; 1020 int i, array_in_sync = 0;
1021 sector_t sync; 1021 sector_t sync;
1022 1022
1023 switch (type) { 1023 switch (type) {
1024 case STATUSTYPE_INFO: 1024 case STATUSTYPE_INFO:
1025 DMEMIT("%s %d ", rs->raid_type->name, rs->md.raid_disks); 1025 DMEMIT("%s %d ", rs->raid_type->name, rs->md.raid_disks);
1026 1026
1027 for (i = 0; i < rs->md.raid_disks; i++) {
1028 if (test_bit(Faulty, &rs->dev[i].rdev.flags))
1029 DMEMIT("D");
1030 else if (test_bit(In_sync, &rs->dev[i].rdev.flags))
1031 DMEMIT("A");
1032 else
1033 DMEMIT("a");
1034 }
1035
1036 if (test_bit(MD_RECOVERY_RUNNING, &rs->md.recovery)) 1027 if (test_bit(MD_RECOVERY_RUNNING, &rs->md.recovery))
1037 sync = rs->md.curr_resync_completed; 1028 sync = rs->md.curr_resync_completed;
1038 else 1029 else
1039 sync = rs->md.recovery_cp; 1030 sync = rs->md.recovery_cp;
1040 1031
1041 if (sync > rs->md.resync_max_sectors) 1032 if (sync >= rs->md.resync_max_sectors) {
1033 array_in_sync = 1;
1042 sync = rs->md.resync_max_sectors; 1034 sync = rs->md.resync_max_sectors;
1035 } else {
1036 /*
1037 * The array may be doing an initial sync, or it may
1038 * be rebuilding individual components. If all the
1039 * devices are In_sync, then it is the array that is
1040 * being initialized.
1041 */
1042 for (i = 0; i < rs->md.raid_disks; i++)
1043 if (!test_bit(In_sync, &rs->dev[i].rdev.flags))
1044 array_in_sync = 1;
1045 }
1046 /*
1047 * Status characters:
1048 * 'D' = Dead/Failed device
1049 * 'a' = Alive but not in-sync
1050 * 'A' = Alive and in-sync
1051 */
1052 for (i = 0; i < rs->md.raid_disks; i++) {
1053 if (test_bit(Faulty, &rs->dev[i].rdev.flags))
1054 DMEMIT("D");
1055 else if (!array_in_sync ||
1056 !test_bit(In_sync, &rs->dev[i].rdev.flags))
1057 DMEMIT("a");
1058 else
1059 DMEMIT("A");
1060 }
1043 1061
1062 /*
1063 * In-sync ratio:
1064 * The in-sync ratio shows the progress of:
1065 * - Initializing the array
1066 * - Rebuilding a subset of devices of the array
1067 * The user can distinguish between the two by referring
1068 * to the status characters.
1069 */
1044 DMEMIT(" %llu/%llu", 1070 DMEMIT(" %llu/%llu",
1045 (unsigned long long) sync, 1071 (unsigned long long) sync,
1046 (unsigned long long) rs->md.resync_max_sectors); 1072 (unsigned long long) rs->md.resync_max_sectors);