[sheepdog] [PATCH v2 1/5] sheep: kill is_erasure_obj()
Liu Yuan
namei.unix at gmail.com
Fri Feb 28 08:52:15 CET 2014
Since we already register vdi for 'cluster snapshot load', we don't need
ugly is_erasure_obj() any more. Now we can use is_erasure_oid() to reliably
check if oid is ec object.
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
sheep/gateway.c | 28 ++--------------------------
sheep/plain_store.c | 2 +-
sheep/sheep_priv.h | 1 -
3 files changed, 3 insertions(+), 28 deletions(-)
diff --git a/sheep/gateway.c b/sheep/gateway.c
index f0f716a..aea4495 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -179,30 +179,6 @@ out:
return reqs;
}
-/*
- * We have two kinds of requests that might go for erasured object:
- * 1. requests without setting copy_policy but expect vdi's copy policy is
- * registered in vdi states, e.g, normal requests from QEMU
- * 2. requests with copy_policy explicitly set because vdi's copy policy is
- * not registered, e.g, requests from 'cluster snapshot load'.
- *
- * So we have to firstly check copy_policy from heaher directly and then call
- * get_vdi_copy_policy(oid).
- */
-bool is_erasure_obj(uint64_t oid, uint8_t copy_policy)
-{
- if (is_vdi_obj(oid))
- return false;
-
- if (is_vdi_btree_obj(oid))
- return false;
-
- if (copy_policy > 0)
- return true;
-
- return get_vdi_copy_policy(oid_to_vid(oid)) > 0;
-}
-
bool is_erasure_oid(uint64_t oid)
{
return !is_vdi_obj(oid) && !is_vdi_btree_obj(oid) &&
@@ -212,7 +188,7 @@ bool is_erasure_oid(uint64_t oid)
/* Prepare request iterator and buffer for each replica */
static struct req_iter *prepare_requests(struct request *req, int *nr)
{
- if (is_erasure_obj(req->rq.obj.oid, req->rq.obj.copy_policy))
+ if (is_erasure_oid(req->rq.obj.oid))
return prepare_erasure_requests(req, nr);
else
return prepare_replication_requests(req, nr);
@@ -229,7 +205,7 @@ static void finish_requests(struct request *req, struct req_iter *reqs,
int end = DIV_ROUND_UP(off + len, SD_EC_DATA_STRIPE_SIZE), i, j;
int nr_stripe = end - start;
- if (!is_erasure_obj(oid, req->rq.obj.copy_policy))
+ if (!is_erasure_oid(oid))
goto out;
sd_debug("start %d, end %d, send %d, off %"PRIu64 ", len %"PRIu32,
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 754a25a..716de33 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -374,7 +374,7 @@ int default_create_and_write(uint64_t oid, const struct siocb *iocb)
int flags = prepare_iocb(oid, iocb, true);
int ret, fd;
uint32_t len = iocb->length;
- bool ec = is_erasure_obj(oid, iocb->copy_policy);
+ bool ec = is_erasure_oid(oid);
size_t obj_size;
sd_debug("%"PRIx64, oid);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index b498c45..72599ed 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -434,7 +434,6 @@ int gateway_write_obj(struct request *req);
int gateway_create_and_write_obj(struct request *req);
int gateway_remove_obj(struct request *req);
bool is_erasure_oid(uint64_t oid);
-bool is_erasure_obj(uint64_t oid, uint8_t copy_policy);
/* object_cache */
--
1.8.1.2
More information about the sheepdog
mailing list