[sheepdog] [PATCH 7/8] sheep: use main_refcnt_t for request

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Tue Jul 9 04:36:41 CEST 2013


Get and put of request are only allowed for the main thread. So
this patch changes the type of current refnct of request from int
to main_refcnt_t.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/request.c    |    4 ++--
 sheep/sheep_priv.h |    2 +-
 sheep/vdi.c        |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sheep/request.c b/sheep/request.c
index 14d03a8..d06a749 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -498,7 +498,7 @@ static struct request *alloc_request(struct client_info *ci, int data_length)
 	}
 
 	INIT_LIST_HEAD(&req->request_list);
-	uatomic_set(&req->refcnt, 1);
+	main_refcnt_set(&req->refcnt, 1);
 
 	uatomic_inc(&sys->nr_outstanding_reqs);
 
@@ -520,7 +520,7 @@ void put_request(struct request *req)
 	struct client_info *ci = req->ci;
 	eventfd_t value = 1;
 
-	if (uatomic_sub_return(&req->refcnt, 1) > 0)
+	if (main_refcnt_dec_return(&req->refcnt) > 0)
 		return;
 
 	if (req->local)
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 21fe8b9..ae3f390 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -68,7 +68,7 @@ struct request {
 	struct list_head request_list;
 	struct list_head pending_list;
 
-	int refcnt;
+	main_refcnt_t refcnt;
 	bool local;
 	int local_req_efd;
 
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 0e38ba3..a77fe5a 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -856,7 +856,7 @@ static int start_deletion(struct request *req, uint32_t vid)
 	if (dw->count == 0)
 		goto out;
 
-	uatomic_inc(&req->refcnt);
+	main_refcnt_inc(&req->refcnt);
 
 	if (list_empty(&deletion_work_list)) {
 		list_add_tail(&dw->list, &deletion_work_list);
-- 
1.7.10.4




More information about the sheepdog mailing list