[sheepdog] [PATCH 3/8] sheep: use refcnt_t in object cache

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


From: Hitoshi Mitake <mitake.hitoshi at gmail.com>

This patch lets object cache employ refcnt_t for its reference
counting of cache entries.

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

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 0aaf882..2825743 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -42,7 +42,7 @@ struct global_cache {
 
 struct object_cache_entry {
 	uint32_t idx; /* Index of this entry */
-	int refcnt; /* Reference count of this entry */
+	refcnt_t refcnt; /* Reference count of this entry */
 	uint64_t bmap; /* Each bit represents one dirty block in object */
 	struct object_cache *oc; /* Object cache this entry belongs to */
 	struct rb_node node; /* For lru tree of object cache */
@@ -133,17 +133,17 @@ static uint64_t calc_object_bmap(size_t len, off_t offset)
 
 static inline void get_cache_entry(struct object_cache_entry *entry)
 {
-	uatomic_inc(&entry->refcnt);
+	refcnt_inc(&entry->refcnt);
 }
 
 static inline void put_cache_entry(struct object_cache_entry *entry)
 {
-	uatomic_dec(&entry->refcnt);
+	refcnt_dec(&entry->refcnt);
 }
 
 static inline bool entry_in_use(struct object_cache_entry *entry)
 {
-	return uatomic_read(&entry->refcnt) > 0;
+	return refcnt_read(&entry->refcnt) > 0;
 }
 
 /*
-- 
1.7.10.4




More information about the sheepdog mailing list