[Sheepdog] [PATCH] support vdi creation with non-zero tag number
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Sat Jan 9 15:02:33 CET 2010
This patch is for the master branch, and depends on the client patches
I'll send later.
==
>From ce2950333457dc3d0b508645de91c16c6f7b4f75 Mon Sep 17 00:00:00 2001
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Date: Sat, 9 Jan 2010 15:39:11 +0900
Subject: [PATCH] support vdi creation with non-zero tag number
The tag number of images created from `qemu-img create` must be zero
but it is confusing. This patch introduces SD_FLAG_CMD_CREATE_VDI and
resolves the problem.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
collie/collie.h | 2 +-
collie/group.c | 2 +-
collie/store.c | 4 +---
collie/vdi.c | 3 ++-
include/sheepdog_proto.h | 1 +
lib/net.c | 7 ++++---
shepherd/shepherd.c | 4 ++--
7 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/collie/collie.h b/collie/collie.h
index 3b2d871..e3b2ec6 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -76,7 +76,7 @@ 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);
+ uint64_t base_oid, uint32_t tag, 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 ac8ea7e..9acf4db 100644
--- a/collie/group.c
+++ b/collie/group.c
@@ -335,7 +335,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->base_oid, hdr->tag, 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 aa785b4..26a8b0e 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -560,9 +560,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)
- ;
- else {
+ if (hdr->flags & SD_FLAG_CMD_CREATE_VDI) {
ret = mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
S_IWGRP | S_IXGRP);
if (ret) {
diff --git a/collie/vdi.c b/collie/vdi.c
index f2acc9d..3337a73 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -81,7 +81,7 @@ 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)
+ uint64_t *added_oid, uint64_t base_oid, uint32_t tag, uint16_t flags)
{
struct sheepdog_node_list_entry entries[SD_MAX_NODES];
int nr_nodes, nr_reqs;
@@ -115,6 +115,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 9557cd8..c8d931d 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -54,6 +54,7 @@
#define SD_FLAG_CMD_WRITE 0x01
#define SD_FLAG_CMD_COW 0x02
+#define SD_FLAG_CMD_CREATE_VDI 0x08
#define SD_RES_SUCCESS 0x00 /* Success */
#define SD_RES_UNKNOWN 0x01 /* Unknown error */
diff --git a/lib/net.c b/lib/net.c
index 5e26f46..969d598 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 8c4aa9e..983ad80 100644
--- a/shepherd/shepherd.c
+++ b/shepherd/shepherd.c
@@ -572,11 +572,11 @@ static void print_vdi_tree(uint64_t oid, char *name, uint32_t tag,
localtime_r(&ti, &tm);
strftime(buf, sizeof(buf),
- "[%y-%m-%d %H:%M:%S]", &tm);
+ "[%y-%m-%d %H:%M]", &tm);
}
add_proc(name, buf, oid,
- tag == 0 ? 0 : i->parent_oid,
+ i->parent_oid,
info->highlight && (flags & FLAG_CURRENT));
}
--
1.5.6.5
More information about the sheepdog
mailing list