提交 0357ba27 编写于 作者: G Guoqing Jiang 提交者: Shaohua Li

md-cluster: show array's status more accurate

When resync or recovery is happening in one node,
other nodes don't show the appropriate info now.

For example, when create an array in master node
without "--assume-clean", then assemble the array
in slave nodes, you can see "resync=PENDING" when
read /proc/mdstat in slave nodes. However, the info
is confusing since "PENDING" status is introduced
for start array in read-only mode.

We introduce RESYNCING_REMOTE flag to indicate that
resync thread is running in remote node. The flags
is set when node receive RESYNCING msg. And we clear
the REMOTE flag in following cases:

1. resync or recover is finished in master node,
   which means slaves receive msg with both lo
   and hi are set to 0.
2. node continues resync/recovery in recover_bitmaps.
3. when resync_finish is called.

Then we show accurate information in status_resync
by check REMOTE flags and with other conditions.
Signed-off-by: NGuoqing Jiang <gqjiang@suse.com>
Reviewed-by: NNeilBrown <neilb@suse.com>
Signed-off-by: NShaohua Li <shli@fb.com>
上级 010228e4
...@@ -338,8 +338,14 @@ static void recover_bitmaps(struct md_thread *thread) ...@@ -338,8 +338,14 @@ static void recover_bitmaps(struct md_thread *thread)
/* wake up thread to continue resync in case resync /* wake up thread to continue resync in case resync
* is not finished */ * is not finished */
if (mddev->recovery_cp != MaxSector) { if (mddev->recovery_cp != MaxSector) {
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); /*
md_wakeup_thread(mddev->thread); * clear the REMOTE flag since we will launch
* resync thread in current node.
*/
clear_bit(MD_RESYNCING_REMOTE,
&mddev->recovery);
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
md_wakeup_thread(mddev->thread);
} }
} }
clear_bit: clear_bit:
...@@ -458,6 +464,11 @@ static void process_suspend_info(struct mddev *mddev, ...@@ -458,6 +464,11 @@ static void process_suspend_info(struct mddev *mddev,
struct suspend_info *s; struct suspend_info *s;
if (!hi) { if (!hi) {
/*
* clear the REMOTE flag since resync or recovery is finished
* in remote node.
*/
clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
remove_suspend_info(mddev, slot); remove_suspend_info(mddev, slot);
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
...@@ -586,6 +597,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg) ...@@ -586,6 +597,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
revalidate_disk(mddev->gendisk); revalidate_disk(mddev->gendisk);
break; break;
case RESYNCING: case RESYNCING:
set_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
process_suspend_info(mddev, le32_to_cpu(msg->slot), process_suspend_info(mddev, le32_to_cpu(msg->slot),
le64_to_cpu(msg->low), le64_to_cpu(msg->low),
le64_to_cpu(msg->high)); le64_to_cpu(msg->high));
...@@ -1266,6 +1278,8 @@ static int resync_info_update(struct mddev *mddev, sector_t lo, sector_t hi) ...@@ -1266,6 +1278,8 @@ static int resync_info_update(struct mddev *mddev, sector_t lo, sector_t hi)
static int resync_finish(struct mddev *mddev) static int resync_finish(struct mddev *mddev)
{ {
struct md_cluster_info *cinfo = mddev->cluster_info; struct md_cluster_info *cinfo = mddev->cluster_info;
clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery);
dlm_unlock_sync(cinfo->resync_lockres); dlm_unlock_sync(cinfo->resync_lockres);
return resync_info_update(mddev, 0, 0); return resync_info_update(mddev, 0, 0);
} }
......
...@@ -7680,6 +7680,23 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev) ...@@ -7680,6 +7680,23 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev)
resync -= atomic_read(&mddev->recovery_active); resync -= atomic_read(&mddev->recovery_active);
if (resync == 0) { if (resync == 0) {
if (test_bit(MD_RESYNCING_REMOTE, &mddev->recovery)) {
struct md_rdev *rdev;
rdev_for_each(rdev, mddev)
if (rdev->raid_disk >= 0 &&
!test_bit(Faulty, &rdev->flags) &&
rdev->recovery_offset != MaxSector &&
rdev->recovery_offset) {
seq_printf(seq, "\trecover=REMOTE");
return 1;
}
if (mddev->reshape_position != MaxSector)
seq_printf(seq, "\treshape=REMOTE");
else
seq_printf(seq, "\tresync=REMOTE");
return 1;
}
if (mddev->recovery_cp < MaxSector) { if (mddev->recovery_cp < MaxSector) {
seq_printf(seq, "\tresync=PENDING"); seq_printf(seq, "\tresync=PENDING");
return 1; return 1;
......
...@@ -496,6 +496,7 @@ enum recovery_flags { ...@@ -496,6 +496,7 @@ enum recovery_flags {
MD_RECOVERY_FROZEN, /* User request to abort, and not restart, any action */ MD_RECOVERY_FROZEN, /* User request to abort, and not restart, any action */
MD_RECOVERY_ERROR, /* sync-action interrupted because io-error */ MD_RECOVERY_ERROR, /* sync-action interrupted because io-error */
MD_RECOVERY_WAIT, /* waiting for pers->start() to finish */ MD_RECOVERY_WAIT, /* waiting for pers->start() to finish */
MD_RESYNCING_REMOTE, /* remote node is running resync thread */
}; };
static inline int __must_check mddev_lock(struct mddev *mddev) static inline int __must_check mddev_lock(struct mddev *mddev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册