From 578c0510dd48c39f77ede558a83311cb75746c1c Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 2 Mar 2012 10:10:54 -0800 Subject: [PATCH] rgw: manifest object contains source offset info Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_access.h | 5 +++++ src/rgw/rgw_op.cc | 2 ++ src/rgw/rgw_rados.cc | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_access.h b/src/rgw/rgw_access.h index b33741feb4bf6..d22114fc93e7c 100644 --- a/src/rgw/rgw_access.h +++ b/src/rgw/rgw_access.h @@ -26,12 +26,16 @@ struct RGWCloneRangeInfo { struct RGWObjManifestPart { rgw_obj loc; + uint64_t loc_ofs; uint64_t size; + RGWObjManifestPart() : loc_ofs(0), size(0) {} + void encode(bufferlist& bl) const { __u32 ver = 1; ::encode(ver, bl); ::encode(loc, bl); + ::encode(loc_ofs, bl); ::encode(size, bl); } @@ -39,6 +43,7 @@ struct RGWObjManifestPart { __u32 ver; ::decode(ver, bl); ::decode(loc, bl); + ::decode(loc_ofs, bl); ::decode(size, bl); } }; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 3424433fd3b15..b75acd4149e10 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -796,9 +796,11 @@ int RGWPutObjProcessor_Atomic::complete(string& etag, map& a uint64_t head_chunk_len = first_chunk.length(); RGWObjManifest manifest; manifest.objs[0].loc = head_obj; + manifest.objs[0].loc_ofs = 0; manifest.objs[0].size = head_chunk_len; if (obj_len > RGW_MAX_CHUNK_SIZE) { manifest.objs[RGW_MAX_CHUNK_SIZE].loc = obj; + manifest.objs[RGW_MAX_CHUNK_SIZE].loc_ofs = RGW_MAX_CHUNK_SIZE; manifest.objs[RGW_MAX_CHUNK_SIZE].size = obj_len - head_chunk_len; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 24534581d874f..6b9a21df0b030 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1817,6 +1817,7 @@ int RGWRados::get_obj(void *ctx, void **handle, rgw_obj& obj, rgw_bucket bucket; std::string oid, key; rgw_obj read_obj = obj; + uint64_t read_ofs = ofs; uint64_t len; bufferlist bl; RGWRadosCtx *rctx = (RGWRadosCtx *)ctx; @@ -1852,6 +1853,7 @@ int RGWRados::get_obj(void *ctx, void **handle, rgw_obj& obj, uint64_t part_ofs = iter->first; read_obj = part.loc; len = min(len, part.size - (ofs - part_ofs)); + read_ofs = part.loc_ofs + (ofs - part_ofs); reading_from_head = (read_obj == obj); if (!reading_from_head) @@ -1876,8 +1878,8 @@ int RGWRados::get_obj(void *ctx, void **handle, rgw_obj& obj, goto done; } - dout(20) << "rados->read ofs=" << ofs << " len=" << len << dendl; - op.read(ofs, len, &bl, NULL); + dout(20) << "rados->read obj-ofs=" << ofs << " read_ofs=" << read_ofs << " read_len=" << len << dendl; + op.read(read_ofs, len, &bl, NULL); r = state->io_ctx.operate(oid, &op, NULL); dout(20) << "rados->read r=" << r << " bl.length=" << bl.length() << dendl; -- 2.39.5