[sheepdog] [PATCH v2 6/6] add new MACRO SD_INODE_META_SIZE for sd_inode

Robin Dong robin.k.dong at gmail.com
Tue Oct 15 08:45:40 CEST 2013


Now the relation between MAX_DATA_OBJS and vdi-size is break, so we need a new
MACRO SD_INODE_META_SIZE to identify the size of inode->data_vdi_id[] and also
increase the number of MAX_DATA_OBJS.

Signed-off-by: Robin Dong <sanbai at taobao.com>
---
 dog/vdi.c                |    8 ++++----
 include/sheepdog_proto.h |    7 ++++---
 lib/option.c             |    3 +++
 sheep/ops.c              |    2 +-
 sheepfs/volume.c         |    2 +-
 5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/dog/vdi.c b/dog/vdi.c
index 11db50e..d9310e1 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -557,7 +557,7 @@ static int vdi_create(int argc, char **argv)
 	}
 
 	ret = sd_write_object(vid_to_vdi_oid(vid), 0, inode,
-			      sizeof(uint32_t) * MAX_DATA_OBJS,
+			      SD_INODE_INDEX_SIZE,
 			      SD_INODE_HEADER_SIZE, 0,
 			      inode->nr_copies, inode->copy_policy,
 			      false, true);
@@ -693,7 +693,7 @@ static int vdi_clone(int argc, char **argv)
 	}
 
 	ret = sd_write_object(vid_to_vdi_oid(new_vid), 0, new_inode,
-			      sizeof(uint32_t) * MAX_DATA_OBJS,
+			      SD_INODE_INDEX_SIZE,
 			      SD_INODE_HEADER_SIZE, 0,
 			      inode->nr_copies, inode->copy_policy,
 			      false, true);
@@ -1339,7 +1339,7 @@ static int vdi_write(int argc, char **argv)
 		if (create) {
 			ret = sd_write_object(vid_to_vdi_oid(vid), 0,
 					(char *)inode + SD_INODE_HEADER_SIZE,
-					sizeof(uint32_t) * MAX_DATA_OBJS,
+					SD_INODE_INDEX_SIZE,
 					SD_INODE_HEADER_SIZE,
 					flags, inode->nr_copies,
 					inode->copy_policy, false, false);
@@ -1826,7 +1826,7 @@ static int restore_obj(struct obj_backup *backup, uint32_t vid,
 	INODE_SET_VDI(inode, backup->idx, vid);
 	ret = sd_write_object(vid_to_vdi_oid(vid), 0,
 			(char *)inode + SD_INODE_HEADER_SIZE,
-			sizeof(uint32_t) * MAX_DATA_OBJS,
+			SD_INODE_INDEX_SIZE,
 			SD_INODE_HEADER_SIZE,
 			0, parent_inode->nr_copies,
 			parent_inode->copy_policy, false, true);
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index a826133..c74e0db 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -96,7 +96,7 @@
 #define VMSTATE_BIT (UINT64_C(1) << 62)
 #define VDI_ATTR_BIT (UINT64_C(1) << 61)
 #define VDI_BTREE_BIT (UINT64_C(1) << 60)
-#define MAX_DATA_OBJS (1ULL << 20)
+#define MAX_DATA_OBJS (1ULL << 32)
 #define MAX_CHILDREN (1024U - 1)
 #define SD_MAX_VDI_LEN 256U
 #define SD_MAX_VDI_TAG_LEN 256U
@@ -108,7 +108,8 @@
 #define SD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * MAX_DATA_OBJS)
 
 #define SD_INODE_SIZE (sizeof(struct sd_inode))
-#define SD_INODE_INDEX_SIZE (sizeof(uint32_t) * MAX_DATA_OBJS)
+#define SD_INODE_META_SIZE (1ULL << 20)
+#define SD_INODE_INDEX_SIZE (sizeof(uint32_t) * SD_INODE_META_SIZE)
 #define SD_INODE_HEADER_SIZE (sizeof(struct sd_inode) - SD_INODE_INDEX_SIZE)
 #define SD_ATTR_OBJ_SIZE (sizeof(struct sheepdog_vdi_attr))
 #define CURRENT_VDI_ID 0
@@ -225,7 +226,7 @@ struct sd_inode {
 	uint32_t parent_vdi_id;
 	uint32_t btree_counter;
 	uint32_t child_vdi_id[MAX_CHILDREN];
-	uint32_t data_vdi_id[MAX_DATA_OBJS];
+	uint32_t data_vdi_id[SD_INODE_META_SIZE];
 };
 
 struct sd_extent {
diff --git a/lib/option.c b/lib/option.c
index d12c205..a74049b 100644
--- a/lib/option.c
+++ b/lib/option.c
@@ -71,6 +71,9 @@ int option_parse_size(const char *value, uint64_t *ret)
 		goto err;
 
 	switch (*postfix) {
+	case 'P':
+	case 'p':
+		sizef *= 1024;
 	case 'T':
 	case 't':
 		sizef *= 1024;
diff --git a/sheep/ops.c b/sheep/ops.c
index 886a734..e9f43b0 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -819,7 +819,7 @@ static int local_discard_obj(struct request *req)
 
 	ret = write_object(vid_to_vdi_oid(vid),
 			   (char *)inode + SD_INODE_HEADER_SIZE,
-			   sizeof(uint32_t) * MAX_DATA_OBJS,
+			   SD_INODE_INDEX_SIZE,
 			   SD_INODE_HEADER_SIZE, false);
 	if (inode)
 		free(inode);
diff --git a/sheepfs/volume.c b/sheepfs/volume.c
index 786ce0d..aa0ddbd 100644
--- a/sheepfs/volume.c
+++ b/sheepfs/volume.c
@@ -197,7 +197,7 @@ static int volume_rw_object(char *buf, uint64_t oid, size_t size,
 		if (volume_rw_object((char *)(vdi->inode)
 					+ SD_INODE_HEADER_SIZE,
 				     vid_to_vdi_oid(vid),
-				     sizeof(uint32_t) * MAX_DATA_OBJS,
+				     SD_INODE_INDEX_SIZE,
 				     SD_INODE_HEADER_SIZE,
 				     VOLUME_WRITE) < 0)
 			return -1;
-- 
1.7.1




More information about the sheepdog mailing list