[sheepdog] [PATCH] object cache: fix bmap calculation
Liu Yuan
namei.unix at gmail.com
Mon May 21 17:08:05 CEST 2012
From: Liu Yuan <tailai.ly at taobao.com>
It uses 64 bits to represent 4M objects, so each bits will represent 64K data
or object_cache_flush_and_delete() will fail.
- add two eprintf for read/write_cache_object()
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/object_cache.c | 10 ++++++++--
sheep/sheep_priv.h | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index efd815f..461f8a7 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -284,8 +284,11 @@ static int write_cache_object(uint32_t vid, uint32_t idx, void *buf, size_t coun
eprintf("%m\n");
goto out;
}
- if (size != count)
+ if (size != count) {
+ eprintf("size %zu, count:%zu, offset %zu %m\n",
+ size, count, offset);
ret = SD_RES_EIO;
+ }
out:
close(fd);
strbuf_release(&p);
@@ -318,8 +321,11 @@ static int read_cache_object(uint32_t vid, uint32_t idx, void *buf, size_t count
eprintf("%m\n");
goto out;
}
- if (size != count)
+ if (size != count) {
+ eprintf("size %zu, count:%zu, offset %zu %m\n",
+ size, count, offset);
ret = SD_RES_EIO;
+ }
out:
close(fd);
strbuf_release(&p);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index a86d98e..e9e9d08 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -420,7 +420,7 @@ static inline int sys_can_halt(void)
#define CACHE_VDI_SHIFT 31
#define CACHE_VDI_BIT (UINT32_C(1) << CACHE_VDI_SHIFT)
-#define CACHE_BLOCK_SIZE (UINT32_C(128) << 10) /* 128 KB */
+#define CACHE_BLOCK_SIZE ((UINT64_C(1) << 10) * 64) /* 64 KB */
struct object_cache {
uint32_t vid;
--
1.7.10.2
More information about the sheepdog
mailing list