linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] md-cluster: Only one thread should request DLM lock
@ 2015-10-22 13:31 rgoldwyn
  2015-10-22 13:31 ` [PATCH] md-cluster: Call update_raid_disks() if another node --grow's raid_disks rgoldwyn
  2015-10-23  2:11 ` [PATCH] md-cluster: Only one thread should request DLM lock Neil Brown
  0 siblings, 2 replies; 6+ messages in thread
From: rgoldwyn @ 2015-10-22 13:31 UTC (permalink / raw)
  To: linux-raid, neilb; +Cc: gqjiang, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

If a DLM lock is in progress, requesting the same DLM lock will
result in -EBUSY. Use a mutex to make sure only one thread requests
for dlm_lock() function at a time.

This will fix the error -EBUSY returned from DLM's validate_lock_args().

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 drivers/md/md-cluster.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 35ac2e8..9b977a2 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -29,6 +29,7 @@ struct dlm_lock_resource {
 	void (*bast)(void *arg, int mode); /* blocking AST function pointer*/
 	struct mddev *mddev; /* pointing back to mddev. */
 	int mode;
+	struct mutex res_lock;
 };
 
 struct suspend_info {
@@ -102,14 +103,19 @@ static int dlm_lock_sync(struct dlm_lock_resource *res, int mode)
 {
 	int ret = 0;
 
+	mutex_lock(&res->res_lock);
+
 	ret = dlm_lock(res->ls, mode, &res->lksb,
 			res->flags, res->name, strlen(res->name),
 			0, sync_ast, res, res->bast);
-	if (ret)
+	if (ret) {
+		mutex_unlock(&res->res_lock);
 		return ret;
+	}
 	wait_for_completion(&res->completion);
 	if (res->lksb.sb_status == 0)
 		res->mode = mode;
+	mutex_unlock(&res->res_lock);
 	return res->lksb.sb_status;
 }
 
@@ -134,6 +140,7 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
 	res->mode = DLM_LOCK_IV;
 	namelen = strlen(name);
 	res->name = kzalloc(namelen + 1, GFP_KERNEL);
+	mutex_init(&res->res_lock);
 	if (!res->name) {
 		pr_err("md-cluster: Unable to allocate resource name for resource %s\n", name);
 		goto out_err;
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-27 23:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-22 13:31 [PATCH] md-cluster: Only one thread should request DLM lock rgoldwyn
2015-10-22 13:31 ` [PATCH] md-cluster: Call update_raid_disks() if another node --grow's raid_disks rgoldwyn
2015-10-23  2:11 ` [PATCH] md-cluster: Only one thread should request DLM lock Neil Brown
2015-10-23 10:19   ` Goldwyn Rodrigues
2015-10-27 20:48     ` Neil Brown
2015-10-27 23:28       ` Goldwyn Rodrigues

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).