[sheepdog] [PATCH v1 2/3] sheep/http: add variable 'data_len' for o_extent[]
Robin Dong
robin.k.dong at gmail.com
Thu Mar 13 11:45:35 CET 2014
From: Robin Dong <sanbai at taobao.com>
Since users could use append-operation to add 1MB data each times, the
'start' and 'count' in o_extent[] is not enough to describe the exact
length of data stored in o_extent (each o_extent may store only 1MB
data, which is small than SD_DATA_OBJ_SIZE).
Therefore we add variable 'data_len' in o_extent[] to identify the
length of data.
Signed-off-by: Robin Dong <sanbai at taobao.com>
---
sheep/http/kv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sheep/http/kv.c b/sheep/http/kv.c
index 07196ab..7326614 100644
--- a/sheep/http/kv.c
+++ b/sheep/http/kv.c
@@ -28,6 +28,7 @@ struct kv_bnode {
struct onode_extent {
uint64_t start;
uint64_t count;
+ uint64_t data_len;
};
/*
@@ -709,6 +710,7 @@ static int onode_allocate_extents(struct kv_onode *onode,
idx = onode->nr_extent;
onode->o_extent[idx].start = start;
onode->o_extent[idx].count = count;
+ onode->o_extent[idx].data_len = req->data_length;
onode->nr_extent++;
out:
return ret;
@@ -934,7 +936,7 @@ static int onode_read_extents(struct kv_onode *onode, struct http_request *req)
total_size = len;
for (i = 0; i < onode->nr_extent; i++) {
ext = onode->o_extent + i;
- ext_len = ext->count * SD_DATA_OBJ_SIZE;
+ ext_len = ext->data_len;
if (off >= ext_len) {
off -= ext_len;
continue;
--
1.7.12.4
More information about the sheepdog
mailing list