[sheepdog] [PATCH] remove trim/untrim functions
Liu Yuan
namei.unix at gmail.com
Thu Sep 19 14:05:44 CEST 2013
Why?
1. it makes code very complicated because trim/untrim is scattered everywhere in
the code
2 it is hard to pass correct parameters to them
3. only deleted inode can benefit from it for the recovery code, but deleted
inodes are relatively small group compared to data objects
We need a more lower level and transparent mechanism to reduce io network
because sheepdog data management shouldn't be aware of it thus greatly simplify
the code for read.
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
- this is on top of erasure code path and with it, erasure code can work
without any problems.
dog/common.c | 2 --
dog/vdi.c | 5 -----
sheep/gateway.c | 8 --------
sheep/ops.c | 16 +---------------
sheep/store.c | 4 ----
5 files changed, 1 insertion(+), 34 deletions(-)
diff --git a/dog/common.c b/dog/common.c
index 83777af..c79f20e 100644
--- a/dog/common.c
+++ b/dog/common.c
@@ -81,8 +81,6 @@ int sd_read_object(uint64_t oid, void *data, unsigned int datalen,
return rsp->result;
}
- untrim_zero_blocks(data, rsp->obj.offset, rsp->data_length, datalen);
-
return SD_RES_SUCCESS;
}
diff --git a/dog/vdi.c b/dog/vdi.c
index b101d43..9004b08 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -341,9 +341,6 @@ static void parse_objs(uint64_t oid, obj_parser_func_t func, void *data, unsigne
continue;
}
- untrim_zero_blocks(buf, rsp->obj.offset, rsp->data_length,
- size);
-
cb_ret = func(addr_to_str(n->nid.addr, n->nid.port),
oid, rsp, buf, data);
if (cb_ret)
@@ -1366,8 +1363,6 @@ static void *read_object_from(const struct sd_vnode *vnode, uint64_t oid)
switch (rsp->result) {
case SD_RES_SUCCESS:
- untrim_zero_blocks(buf, rsp->obj.offset, rsp->data_length,
- size);
break;
case SD_RES_NO_OBJ:
free(buf);
diff --git a/sheep/gateway.c b/sheep/gateway.c
index 968e7cb..384eed0 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -283,14 +283,6 @@ static int gateway_replication_read(struct request *req)
break;
}
out:
- if (ret == SD_RES_SUCCESS &&
- req->rq.proto_ver < SD_PROTO_VER_TRIM_ZERO_SECTORS) {
- /* the client doesn't support trimming zero bytes */
- untrim_zero_blocks(req->data, req->rp.obj.offset,
- req->rp.data_length, req->rq.data_length);
- req->rp.data_length = req->rq.data_length;
- req->rp.obj.offset = 0;
- }
return ret;
}
diff --git a/sheep/ops.c b/sheep/ops.c
index f433289..5206faf 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -876,8 +876,6 @@ static int read_copy_from_replica(struct request *req, uint32_t epoch,
{
struct request read_req = { };
struct sd_req *hdr = &read_req.rq;
- struct sd_rsp *rsp = &read_req.rp;
- int ret;
/* Create a fake gateway read request */
sd_init_req(hdr, SD_OP_READ_OBJ);
@@ -892,13 +890,7 @@ static int read_copy_from_replica(struct request *req, uint32_t epoch,
read_req.op = get_sd_op(hdr->opcode);
read_req.vinfo = req->vinfo;
- ret = gateway_read_obj(&read_req);
-
- if (ret == SD_RES_SUCCESS)
- untrim_zero_blocks(buf, rsp->obj.offset, rsp->data_length,
- SD_DATA_OBJ_SIZE);
-
- return ret;
+ return gateway_read_obj(&read_req);
}
static int peer_remove_obj(struct request *req)
@@ -931,9 +923,6 @@ int peer_read_obj(struct request *req)
goto out;
rsp->data_length = hdr->data_length;
- rsp->obj.offset = 0;
- trim_zero_blocks(req->data, &rsp->obj.offset, &rsp->data_length);
-
if (hdr->obj.copies)
rsp->obj.copies = hdr->obj.copies;
else
@@ -997,9 +986,6 @@ static int peer_create_and_write_obj(struct request *req)
memcpy(&cow_hdr, hdr, sizeof(cow_hdr));
cow_hdr.data_length = SD_DATA_OBJ_SIZE;
cow_hdr.obj.offset = 0;
- trim_zero_blocks(buf, &cow_hdr.obj.offset,
- &cow_hdr.data_length);
-
ret = do_create_and_write_obj(&iocb, &cow_hdr, epoch, buf);
} else
ret = do_create_and_write_obj(&iocb, hdr, epoch, req->data);
diff --git a/sheep/store.c b/sheep/store.c
index a5239d5..b0af526 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -389,7 +389,6 @@ int read_backend_object(uint64_t oid, char *data, unsigned int datalen,
uint64_t offset)
{
struct sd_req hdr;
- struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
int ret;
sd_init_req(&hdr, SD_OP_READ_OBJ);
@@ -402,9 +401,6 @@ int read_backend_object(uint64_t oid, char *data, unsigned int datalen,
if (ret != SD_RES_SUCCESS)
sd_err("failed to read object %" PRIx64 ", %s", oid,
sd_strerror(ret));
-
- untrim_zero_blocks(data, rsp->obj.offset, rsp->data_length, datalen);
-
return ret;
}
--
1.7.9.5
More information about the sheepdog
mailing list