[Sheepdog] [PATCH 01/10] add SD_FLAG_CMD_SNAPSHOT to specify the creation of snapshots
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Tue Jan 26 05:34:47 CET 2010
SD_OP_NEW_VDI uses the tag value to specify the creation of a normal
vdi or snapshot. We'll change the tag to a string to obey the qemu
logic. This introduces SD_FLAG_CMD_SNAPSHOT to specify the creation of
snapshots.
Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
collie/collie.h | 6 +++---
collie/group.c | 2 +-
collie/store.c | 2 +-
collie/vdi.c | 4 +++-
include/sheepdog_proto.h | 2 ++
lib/net.c | 7 ++++---
shepherd/shepherd.c | 3 +--
7 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/collie/collie.h b/collie/collie.h
index 053e988..05ee029 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -76,9 +76,9 @@ int create_listen_port(int port, void *data);
int init_store(char *dir);
-int add_vdi(struct cluster_info *cluster,
- char *name, int len, uint64_t size, uint64_t * added_oid,
- uint64_t base_oid, uint32_t tag, int copies);
+int add_vdi(struct cluster_info *ci, char *name, int len, uint64_t size,
+ uint64_t *added_oid, uint64_t base_oid, uint32_t tag, int copies,
+ uint16_t flags);
int lookup_vdi(struct cluster_info *cluster, char *filename, uint64_t * oid,
uint32_t tag, int do_lock, int *current);
diff --git a/collie/group.c b/collie/group.c
index cbb4761..b58f60e 100644
--- a/collie/group.c
+++ b/collie/group.c
@@ -365,7 +365,7 @@ static void vdi_op(struct cluster_info *ci, struct vdi_op_message *msg)
switch (hdr->opcode) {
case SD_OP_NEW_VDI:
ret = add_vdi(ci, data, strlen(data), hdr->vdi_size, &oid,
- hdr->base_oid, hdr->tag, hdr->copies);
+ hdr->base_oid, hdr->tag, hdr->copies, hdr->flags);
break;
case SD_OP_LOCK_VDI:
case SD_OP_GET_VDI_INFO:
diff --git a/collie/store.c b/collie/store.c
index 2272350..5d1cb43 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -804,7 +804,7 @@ void so_queue_request(struct work *work, int idx)
strncpy(path + strlen(path), "/", 1);
strncpy(path + strlen(path), (char *)req->data, hdr->data_length);
- if (hdr->tag)
+ if (hdr->flags & SD_FLAG_CMD_SNAPSHOT)
;
else {
ret = mkdir(path, def_dmode);
diff --git a/collie/vdi.c b/collie/vdi.c
index 45b3544..503b29b 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -81,7 +81,8 @@ static int create_inode_obj(struct sheepdog_node_list_entry *entries,
* TODO: handle larger buffer
*/
int add_vdi(struct cluster_info *ci, char *name, int len, uint64_t size,
- uint64_t *added_oid, uint64_t base_oid, uint32_t tag, int copies)
+ uint64_t *added_oid, uint64_t base_oid, uint32_t tag, int copies,
+ uint16_t flags)
{
struct sheepdog_node_list_entry entries[SD_MAX_NODES];
int nr_nodes, nr_reqs;
@@ -111,6 +112,7 @@ int add_vdi(struct cluster_info *ci, char *name, int len, uint64_t size,
req.opcode = SD_OP_SO_NEW_VDI;
req.copies = copies;
req.tag = tag;
+ req.flags |= flags;
ret = exec_reqs(entries, nr_nodes, ci->epoch,
SD_DIR_OID, (struct sd_req *)&req, name, len, 0,
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index e016a2a..2d14abc 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -58,6 +58,8 @@
#define SD_FLAG_CMD_COW 0x02
#define SD_FLAG_CMD_FORWARD 0x04
+#define SD_FLAG_CMD_SNAPSHOT (1U << 8)
+
#define SD_RES_SUCCESS 0x00 /* Success */
#define SD_RES_UNKNOWN 0x01 /* Unknown error */
#define SD_RES_NO_OBJ 0x02 /* No object found */
diff --git a/lib/net.c b/lib/net.c
index 1ea1afe..cc625f0 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -463,11 +463,12 @@ int exec_reqs(struct sheepdog_node_list_entry *e,
hdr->epoch = node_version;
if (wdatalen) {
- hdr->flags = SD_FLAG_CMD_WRITE;
+ hdr->flags |= SD_FLAG_CMD_WRITE;
hdr->data_length = wdatalen;
- } else if (rdatalen)
+ } else if (rdatalen) {
+ hdr->flags &= ~SD_FLAG_CMD_WRITE;
hdr->data_length = rdatalen;
- else
+ } else
hdr->data_length = 0;
memcpy(&tmp, hdr, sizeof(tmp));
diff --git a/shepherd/shepherd.c b/shepherd/shepherd.c
index c38e0d6..a13bed7 100644
--- a/shepherd/shepherd.c
+++ b/shepherd/shepherd.c
@@ -522,8 +522,7 @@ static void print_vdi_tree(uint64_t oid, char *name, uint32_t tag,
"[%y-%m-%d %H:%M:%S]", &tm);
}
- add_proc(name, buf, oid,
- tag == 0 ? 0 : i->parent_oid,
+ add_proc(name, buf, oid, i->parent_oid,
info->highlight && (flags & FLAG_CURRENT));
}
--
1.5.6.5
More information about the sheepdog
mailing list