From 2f9a5beb9a903220b70a780b30564d9741e9f0e5 Mon Sep 17 00:00:00 2001 From: Marcus Watts Date: Thu, 13 Oct 2016 21:12:36 -0400 Subject: [PATCH] Don't loop forever when reading data from 0 sized segment. The 0 sized segment can arise depending on how the client uploads the object in the first place. The cpu loop then happens during a swift `GET'. Signed-off-by: Marcus Watts (cherry picked from commit 46c5f9773246522e66bb2cca49345d0b62a16c42) --- src/rgw/rgw_op.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 4f69c7879dc1..5382f6abfd7f 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -726,6 +726,10 @@ int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket, return -EPERM; } + if (ent.size == 0) { + return 0; + } + perfcounter->inc(l_rgw_get_b, cur_end - cur_ofs); while (cur_ofs <= cur_end) { bufferlist bl; @@ -735,6 +739,12 @@ int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket, off_t len = bl.length(); cur_ofs += len; + if (!len) { + ldout(s->cct, 0) << "ERROR: read 0 bytes; ofs=" << cur_ofs + << " end=" << cur_end << " from obj=" << ent.key.name + << "[" << ent.key.instance << "]" << dendl; + return -EIO; + } op_ret = 0; /* XXX redundant? */ perfcounter->tinc(l_rgw_get_lat, (ceph_clock_now(s->cct) - start_time)); @@ -1004,6 +1014,11 @@ int RGWGetObj::handle_user_manifest(const char *prefix) return r; } + if (!total_len) { + bufferlist bl; + send_response_data(bl, 0, 0); + } + return 0; } -- 2.47.3