Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MD: Remember the last sync operation that was performed

MD: Remember the last sync operation that was performed

This patch adds a field to the mddev structure to track the last
sync operation that was performed. This is especially useful when
it comes to what is recorded in mismatch_cnt in sysfs. If the
last operation was "data-check", then it reports the number of
descrepancies found by the user-initiated check. If it was a
"repair" operation, then it is reporting the number of
descrepancies repaired. etc.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>

authored by

Jonathan Brassow and committed by
NeilBrown
c4a39551 eea136d6

+32 -9
+1
Documentation/device-mapper/dm-raid.txt
··· 223 223 1.5.0 Add message interface to allow manipulation of the sync_action. 224 224 New status (STATUSTYPE_INFO) fields: sync_action and mismatch_cnt. 225 225 1.5.1 Add ability to restore transiently failed devices on resume. 226 + 1.5.2 'mismatch_cnt' is zero unless [last_]sync_action is "check".
+2 -1
drivers/md/dm-raid.c
··· 1388 1388 * performing a "check" of the array. 1389 1389 */ 1390 1390 DMEMIT(" %llu", 1391 + (strcmp(rs->md.last_sync_action, "check")) ? 0 : 1391 1392 (unsigned long long) 1392 1393 atomic64_read(&rs->md.resync_mismatches)); 1393 1394 break; ··· 1652 1651 1653 1652 static struct target_type raid_target = { 1654 1653 .name = "raid", 1655 - .version = {1, 5, 1}, 1654 + .version = {1, 5, 2}, 1656 1655 .module = THIS_MODULE, 1657 1656 .ctr = raid_ctr, 1658 1657 .dtr = raid_dtr,
+21 -8
drivers/md/md.c
··· 521 521 init_waitqueue_head(&mddev->recovery_wait); 522 522 mddev->reshape_position = MaxSector; 523 523 mddev->reshape_backwards = 0; 524 + mddev->last_sync_action = "none"; 524 525 mddev->resync_min = 0; 525 526 mddev->resync_max = MaxSector; 526 527 mddev->level = LEVEL_NONE; ··· 4273 4272 return len; 4274 4273 } 4275 4274 4275 + static struct md_sysfs_entry md_scan_mode = 4276 + __ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store); 4277 + 4278 + static ssize_t 4279 + last_sync_action_show(struct mddev *mddev, char *page) 4280 + { 4281 + return sprintf(page, "%s\n", mddev->last_sync_action); 4282 + } 4283 + 4284 + static struct md_sysfs_entry md_last_scan_mode = __ATTR_RO(last_sync_action); 4285 + 4276 4286 static ssize_t 4277 4287 mismatch_cnt_show(struct mddev *mddev, char *page) 4278 4288 { ··· 4291 4279 (unsigned long long) 4292 4280 atomic64_read(&mddev->resync_mismatches)); 4293 4281 } 4294 - 4295 - static struct md_sysfs_entry md_scan_mode = 4296 - __ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store); 4297 - 4298 4282 4299 4283 static struct md_sysfs_entry md_mismatches = __ATTR_RO(mismatch_cnt); 4300 4284 ··· 4694 4686 4695 4687 static struct attribute *md_redundancy_attrs[] = { 4696 4688 &md_scan_mode.attr, 4689 + &md_last_scan_mode.attr, 4697 4690 &md_mismatches.attr, 4698 4691 &md_sync_min.attr, 4699 4692 &md_sync_max.attr, ··· 7338 7329 sector_t last_check; 7339 7330 int skipped = 0; 7340 7331 struct md_rdev *rdev; 7341 - char *desc; 7332 + char *desc, *action = NULL; 7342 7333 struct blk_plug plug; 7343 7334 7344 7335 /* just incase thread restarts... */ ··· 7348 7339 return; 7349 7340 7350 7341 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { 7351 - if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) 7342 + if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) { 7352 7343 desc = "data-check"; 7353 - else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) 7344 + action = "check"; 7345 + } else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { 7354 7346 desc = "requested-resync"; 7355 - else 7347 + action = "repair"; 7348 + } else 7356 7349 desc = "resync"; 7357 7350 } else if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)) 7358 7351 desc = "reshape"; 7359 7352 else 7360 7353 desc = "recovery"; 7354 + 7355 + mddev->last_sync_action = action ?: desc; 7361 7356 7362 7357 /* we overload curr_resync somewhat here. 7363 7358 * 0 == not engaged in resync at all
+8
drivers/md/md.h
··· 268 268 269 269 struct md_thread *thread; /* management thread */ 270 270 struct md_thread *sync_thread; /* doing resync or reconstruct */ 271 + 272 + /* 'last_sync_action' is initialized to "none". It is set when a 273 + * sync operation (i.e "data-check", "requested-resync", "resync", 274 + * "recovery", or "reshape") is started. It holds this value even 275 + * when the sync thread is "frozen" (interrupted) or "idle" (stopped 276 + * or finished). It is overwritten when a new sync operation is begun. 277 + */ 278 + char *last_sync_action; 271 279 sector_t curr_resync; /* last block scheduled */ 272 280 /* As resync requests can complete out of order, we cannot easily track 273 281 * how much resync has been completed. So we occasionally pause until