[sheepdog] [PATCH 4/6] sheep: pass vdi_iocb for vdi deletion
Liu Yuan
namei.unix at gmail.com
Mon Apr 22 17:34:13 CEST 2013
From: Liu Yuan <tailai.ly at taobao.com>
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/ops.c | 14 +++++++++-----
sheep/sheep_priv.h | 4 +---
sheep/vdi.c | 20 ++++++++++----------
3 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/sheep/ops.c b/sheep/ops.c
index c266a9f..3e0a9d3 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -129,11 +129,14 @@ static int post_cluster_new_vdi(const struct sd_req *req, struct sd_rsp *rsp,
static int cluster_del_vdi(struct request *req)
{
- const struct sd_req *hdr = &req->rq;
- uint32_t vid;
+ struct sd_req *hdr = &req->rq;
+ struct vdi_iocb iocb;
- return del_vdi(req, req->data, hdr->data_length,
- &vid, hdr->vdi.snapid);
+ iocb.name = req->data;
+ iocb.data_len = hdr->data_length;
+ iocb.snapid = hdr->vdi.snapid;
+
+ return del_vdi(&iocb, req);
}
struct cache_deletion_work {
@@ -620,7 +623,8 @@ static int cluster_delete_cache(const struct sd_req *req, struct sd_rsp *rsp,
{
uint32_t vid = oid_to_vid(req->obj.oid);
- object_cache_delete(vid);
+ if (sys->enable_object_cache)
+ object_cache_delete(vid);
return SD_RES_SUCCESS;
}
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 04ce8e6..85339df 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -252,9 +252,7 @@ int get_req_copy_number(struct request *req);
int add_vdi_copy_number(uint32_t vid, int nr_copies);
int vdi_exist(uint32_t vid);
int add_vdi(struct vdi_iocb *iocb, uint32_t *new_vid);
-
-int del_vdi(struct request *req, char *data, int data_len, uint32_t *vid,
- uint32_t snapid);
+int del_vdi(struct vdi_iocb *iocb, struct request *req);
int lookup_vdi(const char *name, const char *tag, uint32_t *vid,
uint32_t snapid, uint64_t *ctime);
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 0bb12e2..33a5943 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -497,30 +497,30 @@ int add_vdi(struct vdi_iocb *iocb, uint32_t *new_vid)
static int start_deletion(struct request *req, uint32_t vid);
-int del_vdi(struct request *req, char *data, int data_len,
- uint32_t *vid, uint32_t snapid)
+int del_vdi(struct vdi_iocb *iocb, struct request *req)
{
- const char *name = data, *tag;
+ const char *name = iocb->name, *tag;
uint32_t dummy0;
unsigned long dummy1, dummy2;
int ret;
+ uint32_t vid, data_len = iocb->data_len;
- if (data_len == SD_MAX_VDI_LEN + SD_MAX_VDI_TAG_LEN)
- tag = data + SD_MAX_VDI_LEN;
- else if (data_len == SD_MAX_VDI_LEN)
+ if (data_len == SD_MAX_VDI_LEN + SD_MAX_VDI_TAG_LEN) {
+ tag = (char *)req->data + SD_MAX_VDI_LEN;
+ } else if (data_len == SD_MAX_VDI_LEN) {
tag = NULL;
- else {
+ } else {
ret = SD_RES_INVALID_PARMS;
goto out;
}
- ret = do_lookup_vdi(name, strlen(name), vid, tag,
- snapid, &dummy0, &dummy1, &dummy2,
+ ret = do_lookup_vdi(name, strlen(name), &vid, tag,
+ iocb->snapid, &dummy0, &dummy1, &dummy2,
NULL);
if (ret != SD_RES_SUCCESS)
goto out;
- ret = start_deletion(req, *vid);
+ ret = start_deletion(req, vid);
out:
return ret;
}
--
1.7.9.5
More information about the sheepdog
mailing list