From: fang yuxiang Date: Thu, 1 Feb 2018 09:36:46 +0000 (+0800) Subject: rgw: can't download object with range when compression enabled X-Git-Tag: v12.2.5~136^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c71f1e39907e7044d7013bf50cc5904e921e6ca4;p=ceph.git rgw: can't download object with range when compression enabled Fixes: http://tracker.ceph.com/issues/22852 Signed-off-by: fang yuxiang (cherry picked from commit 1e3af175359d633c3728524396a22f9f33873ff2) --- diff --git a/src/rgw/rgw_compression.cc b/src/rgw/rgw_compression.cc index b9637d01d09b..b1ffa04e15a9 100644 --- a/src/rgw/rgw_compression.cc +++ b/src/rgw/rgw_compression.cc @@ -121,15 +121,17 @@ int RGWGetObj_Decompress::handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len } cur_ofs += bl_len; - off_t ch_len = std::min(out_bl.length() - q_ofs, q_len); - r = next->handle_data(out_bl, q_ofs, ch_len); - if (r < 0) { - lderr(cct) << "handle_data failed with exit code " << r << dendl; - return r; + if (ch_len > 0) { + r = next->handle_data(out_bl, q_ofs, ch_len); + if (r < 0) { + lderr(cct) << "handle_data failed with exit code " << r << dendl; + return r; + } + out_bl.splice(0, q_ofs + ch_len); + q_len -= ch_len; + q_ofs = 0; } - q_len -= ch_len; - q_ofs = 0; return r; }