[sheepdog] [PATCH 1/2] object cache: fix wrong bmap calculation and flush offset

Liu Yuan namei.unix at gmail.com
Sun Jun 10 15:55:48 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>


Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 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 e100634..df3db1d 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -86,17 +86,17 @@ static uint64_t calc_object_bmap(size_t len, off_t offset)
 	uint64_t bmap = 0;
 
 	start = offset / CACHE_BLOCK_SIZE;
-	end = (offset + len - 1) / CACHE_BLOCK_SIZE;
+	end = DIV_ROUND_UP(len + offset, CACHE_BLOCK_SIZE);
+	nr = end - start;
 
-	nr = end - start + 1;
 	while (nr--)
 		set_bit(start + nr, &bmap);
 
 	return bmap;
 }
 
-static struct object_cache_entry *dirty_tree_insert(struct rb_root *root,
-		struct object_cache_entry *new)
+static struct object_cache_entry *
+dirty_tree_insert(struct rb_root *root, struct object_cache_entry *new)
 {
 	struct rb_node **p = &root->rb_node;
 	struct rb_node *parent = NULL;
@@ -573,7 +573,7 @@ static int push_cache_object(struct vnode_info *vnode_info, uint32_t vid,
 	hdr->epoch = sys_epoch();
 
 	hdr->obj.oid = oid;
-	hdr->obj.offset = 0;
+	hdr->obj.offset = offset;
 	hdr->obj.copies = sys->nr_copies;
 
 	fake_req.data = buf;
-- 
1.7.10.2




More information about the sheepdog mailing list