[sheepdog] [PATCH v3 1/2] sheep/http: add macro ONODE_HDR_SIZE
Robin Dong
robin.k.dong at gmail.com
Mon Mar 3 09:00:14 CET 2014
From: Robin Dong <sanbai at taobao.com>
Add macro ONODE_HDR_SIZE to replace BLOCK_SIZE in http with which the
code will be more easier to understand.
Signed-off-by: Robin Dong <sanbai at taobao.com>
---
sheep/http/kv.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/sheep/http/kv.c b/sheep/http/kv.c
index 6f648e3..07f5347 100644
--- a/sheep/http/kv.c
+++ b/sheep/http/kv.c
@@ -54,6 +54,8 @@ struct onode_extent {
#define ONODE_INIT 1 /* created and allocated space, but no data */
#define ONODE_COMPLETE 2 /* data upload complete */
+#define ONODE_HDR_SIZE BLOCK_SIZE
+
struct kv_onode {
union {
struct {
@@ -69,10 +71,10 @@ struct kv_onode {
uint8_t flags;
};
- uint8_t pad[BLOCK_SIZE];
+ uint8_t pad[ONODE_HDR_SIZE];
};
union {
- uint8_t data[SD_DATA_OBJ_SIZE - BLOCK_SIZE];
+ uint8_t data[SD_DATA_OBJ_SIZE - ONODE_HDR_SIZE];
struct onode_extent o_extent[0];
};
};
@@ -615,7 +617,7 @@ out:
/* Object operations */
-#define KV_ONODE_INLINE_SIZE (SD_DATA_OBJ_SIZE - BLOCK_SIZE)
+#define KV_ONODE_INLINE_SIZE (SD_DATA_OBJ_SIZE - ONODE_HDR_SIZE)
static int vdi_read_write(uint32_t vid, char *data, size_t length,
off_t offset, bool is_read)
@@ -771,7 +773,7 @@ static int onode_populate_data(struct kv_onode *onode, struct http_request *req)
goto out;
}
ret = sd_write_object(onode->oid, (char *)onode,
- BLOCK_SIZE + size, 0, false);
+ ONODE_HDR_SIZE + size, 0, false);
if (ret != SD_RES_SUCCESS)
goto out;
} else {
@@ -803,7 +805,7 @@ static int onode_do_create(struct kv_onode *onode, struct sd_inode *inode,
else
len = sizeof(struct onode_extent) * onode->nr_extent;
- ret = sd_write_object(oid, (char *)onode, BLOCK_SIZE + len,
+ ret = sd_write_object(oid, (char *)onode, ONODE_HDR_SIZE + len,
0, create);
if (ret != SD_RES_SUCCESS) {
sd_err("failed to create object, %" PRIx64, oid);
--
1.7.12.4
More information about the sheepdog
mailing list