md: Use ->curr_resync as last completed request when cleanly aborting resync.
authormajianpeng <majianpeng@gmail.com>
Mon, 19 Nov 2012 11:57:34 +0000 (19:57 +0800)
committerNeilBrown <neilb@suse.de>
Thu, 13 Dec 2012 08:52:11 +0000 (19:52 +1100)
If a resync is aborted cleanly, ->curr_resync is a reliable
record of where we got up to.
If there was an error it is less reliable but we always know that
->curr_resync_completed is safe.

So add a flag MD_RECOVERY_ERROR to differentiate between these cases
and set recovery_cp accordingly.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/md.c
drivers/md/md.h

index 6aefa44348196bf45175f28f675bac0e0d414f31..30ba223e5ed0726048801d1af65371e237cd9c60 100644 (file)
@@ -7180,6 +7180,7 @@ void md_done_sync(struct mddev *mddev, int blocks, int ok)
        wake_up(&mddev->recovery_wait);
        if (!ok) {
                set_bit(MD_RECOVERY_INTR, &mddev->recovery);
+               set_bit(MD_RECOVERY_ERROR, &mddev->recovery);
                md_wakeup_thread(mddev->thread);
                // stop recovery, signal do_sync ....
        }
@@ -7574,8 +7575,13 @@ void md_do_sync(struct md_thread *thread)
                                        printk(KERN_INFO
                                               "md: checkpointing %s of %s.\n",
                                               desc, mdname(mddev));
-                                       mddev->recovery_cp =
-                                               mddev->curr_resync_completed;
+                                       if (test_bit(MD_RECOVERY_ERROR,
+                                               &mddev->recovery))
+                                               mddev->recovery_cp =
+                                                       mddev->curr_resync_completed;
+                                       else
+                                               mddev->recovery_cp =
+                                                       mddev->curr_resync;
                                }
                        } else
                                mddev->recovery_cp = MaxSector;
index af443ab868db910f2db2d35d53ffacca701f1e60..c29e62ebc488ba4570798803f404803ad9c72de5 100644 (file)
@@ -307,6 +307,7 @@ struct mddev {
         * REQUEST:  user-space has requested a sync (used with SYNC)
         * CHECK:    user-space request for check-only, no repair
         * RESHAPE:  A reshape is happening
+        * ERROR:    sync-action interrupted because io-error
         *
         * If neither SYNC or RESHAPE are set, then it is a recovery.
         */
@@ -320,6 +321,7 @@ struct mddev {
 #define        MD_RECOVERY_CHECK       7
 #define MD_RECOVERY_RESHAPE    8
 #define        MD_RECOVERY_FROZEN      9
+#define        MD_RECOVERY_ERROR       10
 
        unsigned long                   recovery;
        /* If a RAID personality determines that recovery (of a particular