[sheepdog] [PATCH 6/9] sheep: unlock existing lock in a case of double locking

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Fri Jun 27 08:13:53 CEST 2014


Typical sheepdog clients issues two or more locking request
(SD_OP_LOCK_VDI, typically issued in the function
find_vdi_name() of clients) during their lifetime because it is
required when snapshots of their VDIs are taken. In such a case, an
existing lock becomes needless because the lock points snapshot. This
patch add a release procedure for the case.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/ops.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/sheep/ops.c b/sheep/ops.c
index 519e708..3469c61 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -239,6 +239,14 @@ static int cluster_lock_vdi_work(struct request *req)
 {
 	int ret;
 
+	if (req->ci->locking_interest_vid) {
+		/* 1 fd cannot lock more than 2 VIDs */
+		sd_debug("unlocking VID: %"PRIx32, req->ci->interest_vid);
+		notify_release_vdi(req->ci->interest_vid);
+		req->ci->locking_interest_vid = false;
+		req->ci->interest_vid = 0;
+	}
+
 	ret = cluster_get_vdi_info(req);
 	if (ret != SD_RES_SUCCESS)
 		return ret;
-- 
1.7.1




More information about the sheepdog mailing list