diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2016-08-12 01:42:41 -0400 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2016-09-21 12:09:44 -0400 |
commit | fccb60a42cdd863aa80f32214ae58ae13936c927 (patch) | |
tree | 4af1e586d9250be17c8fb8f48042bd8d20d62055 | |
parent | 5f0aa21da6cc620b08e5f69f51db29cb1f722174 (diff) |
md-cluster: convert the completion to wait queue
Previously, we used completion to sync between require dlm lock
and sync_ast, however we will have to expose completion.wait
and completion.done in dlm_lock_sync_interruptible (introduced
later), it is not a common usage for completion, so convert
related things to wait queue.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
-rw-r--r-- | drivers/md/md-cluster.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index b4dc211923c7..c94715159b9b 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c | |||
@@ -25,7 +25,8 @@ struct dlm_lock_resource { | |||
25 | struct dlm_lksb lksb; | 25 | struct dlm_lksb lksb; |
26 | char *name; /* lock name. */ | 26 | char *name; /* lock name. */ |
27 | uint32_t flags; /* flags to pass to dlm_lock() */ | 27 | uint32_t flags; /* flags to pass to dlm_lock() */ |
28 | struct completion completion; /* completion for synchronized locking */ | 28 | wait_queue_head_t sync_locking; /* wait queue for synchronized locking */ |
29 | bool sync_locking_done; | ||
29 | void (*bast)(void *arg, int mode); /* blocking AST function pointer*/ | 30 | void (*bast)(void *arg, int mode); /* blocking AST function pointer*/ |
30 | struct mddev *mddev; /* pointing back to mddev. */ | 31 | struct mddev *mddev; /* pointing back to mddev. */ |
31 | int mode; | 32 | int mode; |
@@ -118,7 +119,8 @@ static void sync_ast(void *arg) | |||
118 | struct dlm_lock_resource *res; | 119 | struct dlm_lock_resource *res; |
119 | 120 | ||
120 | res = arg; | 121 | res = arg; |
121 | complete(&res->completion); | 122 | res->sync_locking_done = true; |
123 | wake_up(&res->sync_locking); | ||
122 | } | 124 | } |
123 | 125 | ||
124 | static int dlm_lock_sync(struct dlm_lock_resource *res, int mode) | 126 | static int dlm_lock_sync(struct dlm_lock_resource *res, int mode) |
@@ -130,7 +132,8 @@ static int dlm_lock_sync(struct dlm_lock_resource *res, int mode) | |||
130 | 0, sync_ast, res, res->bast); | 132 | 0, sync_ast, res, res->bast); |
131 | if (ret) | 133 | if (ret) |
132 | return ret; | 134 | return ret; |
133 | wait_for_completion(&res->completion); | 135 | wait_event(res->sync_locking, res->sync_locking_done); |
136 | res->sync_locking_done = false; | ||
134 | if (res->lksb.sb_status == 0) | 137 | if (res->lksb.sb_status == 0) |
135 | res->mode = mode; | 138 | res->mode = mode; |
136 | return res->lksb.sb_status; | 139 | return res->lksb.sb_status; |
@@ -151,7 +154,8 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev, | |||
151 | res = kzalloc(sizeof(struct dlm_lock_resource), GFP_KERNEL); | 154 | res = kzalloc(sizeof(struct dlm_lock_resource), GFP_KERNEL); |
152 | if (!res) | 155 | if (!res) |
153 | return NULL; | 156 | return NULL; |
154 | init_completion(&res->completion); | 157 | init_waitqueue_head(&res->sync_locking); |
158 | res->sync_locking_done = false; | ||
155 | res->ls = cinfo->lockspace; | 159 | res->ls = cinfo->lockspace; |
156 | res->mddev = mddev; | 160 | res->mddev = mddev; |
157 | res->mode = DLM_LOCK_IV; | 161 | res->mode = DLM_LOCK_IV; |
@@ -208,7 +212,7 @@ static void lockres_free(struct dlm_lock_resource *res) | |||
208 | if (unlikely(ret != 0)) | 212 | if (unlikely(ret != 0)) |
209 | pr_err("failed to unlock %s return %d\n", res->name, ret); | 213 | pr_err("failed to unlock %s return %d\n", res->name, ret); |
210 | else | 214 | else |
211 | wait_for_completion(&res->completion); | 215 | wait_event(res->sync_locking, res->sync_locking_done); |
212 | 216 | ||
213 | kfree(res->name); | 217 | kfree(res->name); |
214 | kfree(res->lksb.sb_lvbptr); | 218 | kfree(res->lksb.sb_lvbptr); |