[sheepdog] [PATCH 2/3] object_cache: fix dirty bitmap size

MORITA Kazutaka morita.kazutaka at gmail.com
Fri Aug 2 09:14:40 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

The type of bitmap is not uint64_t, but unsigned long.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/object_cache.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 27d544d..c12719b 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -28,7 +28,7 @@
 
 #define CACHE_INDEX_MASK      (CACHE_CREATE_BIT)
 
-#define CACHE_BLOCK_SIZE      ((UINT64_C(1) << 10) * 64) /* 64 KB */
+#define CACHE_BLOCK_SIZE      (BITOP_WORD(SD_DATA_OBJ_SIZE))
 
 #define CACHE_OBJECT_SIZE (SD_DATA_OBJ_SIZE / 1024 / 1024) /* M */
 
@@ -43,7 +43,7 @@ struct global_cache {
 struct object_cache_entry {
 	uint32_t idx; /* Index of this entry */
 	refcnt_t refcnt; /* Reference count of this entry */
-	uint64_t bmap; /* Each bit represents one dirty block in object */
+	unsigned long 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 */
 	struct list_head dirty_list; /* For dirty list of object cache */
@@ -116,7 +116,7 @@ static inline bool idx_has_vdi_bit(uint32_t idx)
 	return !!(idx & CACHE_VDI_BIT);
 }
 
-static uint64_t calc_object_bmap(size_t len, off_t offset)
+static unsigned long calc_object_bmap(size_t len, off_t offset)
 {
 	int start, end, nr;
 	unsigned long bmap = 0;
@@ -128,7 +128,7 @@ static uint64_t calc_object_bmap(size_t len, off_t offset)
 	while (nr--)
 		set_bit(start + nr, &bmap);
 
-	return (uint64_t)bmap;
+	return bmap;
 }
 
 static inline void get_cache_entry(struct object_cache_entry *entry)
@@ -715,7 +715,7 @@ static void add_to_lru_cache(struct object_cache *oc, uint32_t idx, bool create)
 	list_add_tail(&entry->lru_list, &oc->lru_head);
 	if (create) {
 		/* Cache lock assure it is not raced with pusher */
-		entry->bmap = UINT64_MAX;
+		entry->bmap = ULONG_MAX;
 		entry->idx |= CACHE_CREATE_BIT;
 		add_to_dirty_list(entry);
 	}
-- 
1.7.9.5




More information about the sheepdog mailing list