[sheepdog] [PATCH 1/3] sheep, dog: add vid space variables to the structs

Takafumi Fujieda fujieda.takafumi at lab.ntt.co.jp
Mon Feb 2 06:58:19 CET 2015


This patch adds new variables to some structs (cluster_info,
system_info, etc...) to store the vid space size.

Signed-off-by: Takafumi Fujieda <fujieda.takafumi at lab.ntt.co.jp>
---
 dog/cluster.c            |    1 +
 dog/farm/farm.h          |    3 ++-
 include/internal_proto.h |    6 ++++--
 include/sheepdog_proto.h |   10 ++++++----
 sheep/config.c           |    4 +++-
 sheep/sheep_priv.h       |    2 ++
 6 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/dog/cluster.c b/dog/cluster.c
index 6a2db6e..2b6864a 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -37,6 +37,7 @@ static struct cluster_cmd_data {
 	uint8_t copy_policy;
 	uint8_t multithread;
 	uint8_t block_size_shift;
+	uint8_t vid_space;
 	bool force;
 	bool strict;
 	char name[STORE_LEN];
diff --git a/dog/farm/farm.h b/dog/farm/farm.h
index 6b96c5e..ca25e6f 100644
--- a/dog/farm/farm.h
+++ b/dog/farm/farm.h
@@ -41,7 +41,8 @@ struct snap_log_hdr {
 	uint8_t copy_number;
 	uint8_t copy_policy;
 	uint8_t block_size_shift;
-	uint8_t reserved[21];
+	uint8_t vid_space;
+	uint8_t reserved[20];
 };
 
 struct snap_log {
diff --git a/include/internal_proto.h b/include/internal_proto.h
index 6b24b5c..6637568 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -219,7 +219,8 @@ struct cluster_info {
 	uint8_t copy_policy;
 	enum sd_status status : 8;
 	uint8_t block_size_shift;
-	uint8_t __pad[3];
+	uint8_t vid_space;
+	uint8_t __pad[2];
 	uint8_t store[STORE_LEN];
 
 	/* Node list at cluster_info->epoch */
@@ -234,7 +235,8 @@ struct epoch_log {
 	uint8_t  disable_recovery;
 	uint8_t  nr_copies;
 	uint8_t  copy_policy;
-	uint8_t  __pad[3];
+	uint8_t  vid_space;
+	uint8_t  __pad[2];
 	uint16_t flags;
 	char drv_name[STORE_LEN];
 	struct sd_node nodes[0];
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index bf3e9df..5db2394 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -101,6 +101,7 @@
  * 60 - 63 ( 4 bits): object type identifier space
  */
 
+#define SD_VID_SPACE 24
 #define VDI_SPACE_SHIFT   32
 #define SD_VDI_MASK 0x00FFFFFF00000000
 #define VDI_BIT (UINT64_C(1) << 63)
@@ -115,7 +116,7 @@
 #define SD_MAX_VDI_ATTR_KEY_LEN 256U
 #define SD_MAX_VDI_ATTR_VALUE_LEN 65536U
 #define SD_MAX_SNAPSHOT_TAG_LEN 256U
-#define SD_NR_VDIS   (1U << 24)
+#define SD_NR_VDIS   (1U << SD_VID_SPACE)
 #define SD_DATA_OBJ_SIZE (UINT64_C(1) << 22)
 #define SD_OLD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * OLD_MAX_DATA_OBJS)
 #define SD_MAX_VDI_SIZE (SD_DATA_OBJ_SIZE * MAX_DATA_OBJS)
@@ -180,7 +181,8 @@ struct sd_req {
 			uint32_t	tag;
 			uint32_t	nodes_nr;
 			uint8_t		block_size_shift;
-			uint8_t		reserved[3];
+			uint8_t 	vid_space;
+			uint8_t		reserved[2];
 		} cluster;
 		struct {
 			uint32_t	old_vid;
@@ -258,11 +260,11 @@ struct sd_rsp {
 			uint8_t		digest[20];
 		} hash;
 		struct {
-			uint32_t	__pad1;
+			uint32_t	__pad;
 			uint8_t		nr_copies;
 			uint8_t		copy_policy;
 			uint8_t		block_size_shift;
-			uint8_t		__pad2;
+			uint8_t		vid_space;
 		} cluster_default;
 
 		uint32_t		__pad[8];
diff --git a/sheep/config.c b/sheep/config.c
index 9518109..548a1e8 100644
--- a/sheep/config.c
+++ b/sheep/config.c
@@ -12,7 +12,7 @@
 #include "sheep_priv.h"
 
 #define SD_FORMAT_VERSION 0x0006
-#define SD_CONFIG_SIZE 40
+#define SD_CONFIG_SIZE 48
 
 static struct sheepdog_config {
 	uint64_t ctime;
@@ -24,6 +24,8 @@ static struct sheepdog_config {
 	uint8_t block_size_shift;
 	uint16_t version;
 	uint64_t space;
+	uint8_t vid_space;
+	uint8_t _pad[7];
 } config;
 
 char *config_path;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 3399a36..5608cbc 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -130,6 +130,8 @@ struct system_info {
 
 	uint64_t disk_space;
 
+	uint32_t nr_vdis;
+	uint64_t vdi_mask;
 	DECLARE_BITMAP(vdi_inuse, SD_NR_VDIS);
 	DECLARE_BITMAP(vdi_deleted, SD_NR_VDIS);
 
-- 
1.7.1




More information about the sheepdog mailing list