Skip to content

Commit eece075

Browse files
GuoqingJiangNeilBrown
authored andcommitted
md-cluster: only call complete(&cinfo->completion) when node join cluster
Introduce MD_CLUSTER_BEGIN_JOIN_CLUSTER flag to make sure complete(&cinfo->completion) is only be invoked when node join cluster. Otherwise node failure could also call the complete, and it doesn't make sense to do it. Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
1 parent 6e6d9f2 commit eece075

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/md/md-cluster.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct resync_info {
4545
/* md_cluster_info flags */
4646
#define MD_CLUSTER_WAITING_FOR_NEWDISK 1
4747
#define MD_CLUSTER_SUSPEND_READ_BALANCING 2
48+
#define MD_CLUSTER_BEGIN_JOIN_CLUSTER 3
4849

4950

5051
struct md_cluster_info {
@@ -320,10 +321,17 @@ static void recover_done(void *arg, struct dlm_slot *slots,
320321
struct md_cluster_info *cinfo = mddev->cluster_info;
321322

322323
cinfo->slot_number = our_slot;
323-
complete(&cinfo->completion);
324+
/* completion is only need to be complete when node join cluster,
325+
* it doesn't need to run during another node's failure */
326+
if (test_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state)) {
327+
complete(&cinfo->completion);
328+
clear_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state);
329+
}
324330
clear_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state);
325331
}
326332

333+
/* the ops is called when node join the cluster, and do lock recovery
334+
* if node failure occurs */
327335
static const struct dlm_lockspace_ops md_ls_ops = {
328336
.recover_prep = recover_prep,
329337
.recover_slot = recover_slot,
@@ -675,6 +683,7 @@ static int join(struct mddev *mddev, int nodes)
675683
INIT_LIST_HEAD(&cinfo->suspend_list);
676684
spin_lock_init(&cinfo->suspend_lock);
677685
init_completion(&cinfo->completion);
686+
set_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state);
678687

679688
mutex_init(&cinfo->sb_mutex);
680689
mddev->cluster_info = cinfo;

0 commit comments

Comments
 (0)