[sheepdog] [PATCH] sheep: handle older version client correctly
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Mon Oct 8 18:35:21 CEST 2012
SD_PROTO_VER is a protocol version between sheep and client, so the
check of SD_PROTO_VER_TRIM_ZERO_SECTORS must be in gateway_read_obj,
not peer_read_obj.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
sheep/gateway.c | 18 +++++++++++++++---
sheep/ops.c | 8 ++------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/sheep/gateway.c b/sheep/gateway.c
index eea6d41..55b1370 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -39,8 +39,11 @@ int gateway_read_obj(struct request *req)
uint64_t oid = req->rq.obj.oid;
int nr_copies, j;
- if (is_object_cache_enabled() && !req->local && !bypass_object_cache(req))
- return object_cache_handle_request(req);
+ if (is_object_cache_enabled() && !req->local &&
+ !bypass_object_cache(req)) {
+ ret = object_cache_handle_request(req);
+ goto out;
+ }
nr_copies = get_req_copy_number(req);
oid_to_vnodes(req->vinfo->vnodes, req->vinfo->nr_vnodes, oid,
@@ -51,7 +54,7 @@ int gateway_read_obj(struct request *req)
continue;
ret = peer_read_obj(req);
if (ret == SD_RES_SUCCESS)
- return ret;
+ goto out;
eprintf("local read fail %x\n", ret);
break;
@@ -84,6 +87,15 @@ int gateway_read_obj(struct request *req)
memcpy(&req->rp, rsp, sizeof(*rsp));
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 */
+ set_trimmed_sectors(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 a2a795e..df4831b 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -775,12 +775,8 @@ int peer_read_obj(struct request *req)
goto out;
rsp->data_length = hdr->data_length;
-
- if (hdr->proto_ver >= SD_PROTO_VER_TRIM_ZERO_SECTORS) {
- rsp->obj.offset = 0;
- trim_zero_sectors(req->data, &rsp->obj.offset,
- &rsp->data_length);
- }
+ rsp->obj.offset = 0;
+ trim_zero_sectors(req->data, &rsp->obj.offset, &rsp->data_length);
if (hdr->obj.copies)
rsp->obj.copies = hdr->obj.copies;
--
1.7.2.5
More information about the sheepdog
mailing list