Skip to contentSkip to conversation

md:For aborted a resync by request,using ->curr_resync as the last completed request rather than ->curr_resync_completed.

PATCH Applied majianpeng 2 participants 3 messages Nov 19, 2012 – Nov 20, 2012 MD RAID

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 1/1 md:For aborted a resync by request,using ->curr_resync as the last completed request rather than ->curr_resync_completed.

V0-->V1:
As suggested by neil, it added a flag MD_RECOVERY_ERROR to differentiate between an abort-due-to-error and an abort-due-to-request.We only deal with the later case.

Thanks!
Jianpeng

Aborting a resync maybe by io-error,or request(stop array or reboot system).
So we add a flag MD_RECOVERY_ERROR to differentiate between an abort-due-to-error and an abort-due-to-request.
For the later case,when resync aborted,it exec wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active)). So the ->curr_resync is the last completed request.

---
 drivers/md/md.c |   10 ++++++++--
 drivers/md/md.h |    2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/md/md.c +8 -2
index 9ab768a..5199657 100644
@@ -7172,6 +7172,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 ....
 	}
@@ -7558,8 +7559,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_cp))
+						mddev->recovery_cp =
+							mddev->curr_resync_completed;
+					else
+						mddev->recovery_cp =
+							mddev->curr_resync;
 				}
 			} else
 				mddev->recovery_cp = MaxSector;
drivers/md/md.h +2 -0
index af443ab..c29e62e 100644
@@ -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
Signature · 1 line
1.7.9.5
Applied
#1 lore raw
Quoted 62 lines · On Mon, 19 Nov 2012 19:57:34 +0800 majianpeng <[email protected]> wrote:

V0-->V1:
As suggested by neil, it added a flag MD_RECOVERY_ERROR to differentiate between an abort-due-to-error and an abort-due-to-request.We only deal with the later case.

Thanks!
Jianpeng

Aborting a resync maybe by io-error,or request(stop array or reboot system).
So we add a flag MD_RECOVERY_ERROR to differentiate between an abort-due-to-error and an abort-due-to-request.
For the later case,when resync aborted,it exec wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active)). So the ->curr_resync is the last completed request.

---
 drivers/md/md.c |   10 ++++++++--
 drivers/md/md.h |    2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/md/md.c +8 -2
index 9ab768a..5199657 100644
@@ -7172,6 +7172,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 ....
 	}
@@ -7558,8 +7559,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_cp))
+						mddev->recovery_cp =
+							mddev->curr_resync_completed;
+					else
+						mddev->recovery_cp =
+							mddev->curr_resync;
 				}
 			} else
 				mddev->recovery_cp = MaxSector;
drivers/md/md.h +1 -0
index af443ab..c29e62e 100644
@@ -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.
 	 */

drivers/md/md.h struct mddev { · line 327

Quoted 7 lines
drivers/md/md.h +1 -0
@@ -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

The attachment still have MS-windows line endings ("\r\n" instead of just "\n") but it wasn't too hard to strip those out.

Applied, thanks,
NeilBrown

author
#2 lore raw
Quoted 77 lines · On Mon, 19 Nov 2012 19:57:34 +0800 majianpeng <[email protected]> wrote:
Quoted 63 lines

V0-->V1:
As suggested by neil, it added a flag MD_RECOVERY_ERROR to differentiate between an abort-due-to-error and an abort-due-to-request.We only deal with the later case.

Thanks!
Jianpeng

Aborting a resync maybe by io-error,or request(stop array or reboot system).
So we add a flag MD_RECOVERY_ERROR to differentiate between an abort-due-to-error and an abort-due-to-request.
For the later case,when resync aborted,it exec wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active)). So the ->curr_resync is the last completed request.

---
 drivers/md/md.c |   10 ++++++++--
 drivers/md/md.h |    2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/md/md.c +8 -2
index 9ab768a..5199657 100644
@@ -7172,6 +7172,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 ....
 	}
@@ -7558,8 +7559,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_cp))
+						mddev->recovery_cp =
+							mddev->curr_resync_completed;
+					else
+						mddev->recovery_cp =
+							mddev->curr_resync;
 				}
 			} else
 				mddev->recovery_cp = MaxSector;
drivers/md/md.h +1 -0
index af443ab..c29e62e 100644
@@ -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.
 	 */

drivers/md/md.h struct mddev { · line 327

Quoted 7 lines
drivers/md/md.h +1 -0
@@ -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

The attachment still have MS-windows line endings ("\r\n" instead of just "\n") but it wasn't too hard to strip those out.

Quoted 4 lines

Applied, thanks,
NeilBrown

Sorry for that, i will check it and fix.
Thanks!
Jianpeng