summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-05-30 12:58:11 -0700
committerGreg Farnum <greg@inktank.com>2013-05-31 10:30:42 -0700
commit34733bdc3b9da13195dfac8a25f98c6de64070d7 (patch)
treef2c708a4f2307d0fe364c44bf4d55d8a741cac21
parent3d91301e5d788f9f9f52ba4067006f39a89e1531 (diff)
downloadceph-34733bdc3b9da13195dfac8a25f98c6de64070d7.tar.gz
rgw: only append prefetched data if reading from head
Fixes: #5209 Backport: bobtail, cuttlefish If the head object wrongfully contains data, but according to the manifest we don't read from the head, we shouldn't copy the prefetched data. Also fix the length calculation for that data. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com> Reviewed-by: Greg Farnum <greg@inktank.com> (cherry picked from commit c5fc52ae0fc851444226abd54a202af227d7cf17)
-rw-r--r--src/rgw/rgw_rados.cc34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index b663ed2d41f..d31e2a5a48e 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -2694,31 +2694,31 @@ int RGWRados::get_obj(void *ctx, void **handle, rgw_obj& obj,
state->io_ctx.locator_set_key(key);
+ read_len = len;
+
if (reading_from_head) {
/* only when reading from the head object do we need to do the atomic test */
r = append_atomic_test(rctx, read_obj, op, &astate);
if (r < 0)
goto done_ret;
- }
-
- read_len = len;
- if (astate) {
- if (!ofs && astate->data.length() >= len) {
- bl = astate->data;
- goto done;
- }
+ if (astate) {
+ if (!ofs && astate->data.length() >= len) {
+ bl = astate->data;
+ goto done;
+ }
- if (ofs < astate->data.length()) {
- unsigned copy_len = min((uint64_t)astate->data.length(), len);
- astate->data.copy(ofs, copy_len, bl);
- read_len -= copy_len;
- read_ofs += copy_len;
- if (!read_len)
- goto done;
+ if (ofs < astate->data.length()) {
+ unsigned copy_len = min((uint64_t)astate->data.length() - ofs, len);
+ astate->data.copy(ofs, copy_len, bl);
+ read_len -= copy_len;
+ read_ofs += copy_len;
+ if (!read_len)
+ goto done;
- merge_bl = true;
- pbl = &read_bl;
+ merge_bl = true;
+ pbl = &read_bl;
+ }
}
}