]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Don't loop forever when reading data from 0 sized segment. 11628/head
authorMarcus Watts <mwatts@redhat.com>
Fri, 14 Oct 2016 01:12:36 +0000 (21:12 -0400)
committerOrit Wasserman <owasserm@redhat.com>
Thu, 24 Nov 2016 07:36:07 +0000 (08:36 +0100)
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 <mwatts@redhat.com>
(cherry picked from commit 46c5f9773246522e66bb2cca49345d0b62a16c42)

src/rgw/rgw_op.cc

index b1d1d368f0ded7377002f848da7961701ef71dd4..de580e6bff386b2cd58d0f665553d6d87035aaf3 100644 (file)
@@ -722,6 +722,10 @@ int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket, RGWObjEnt& ent, RGWAc
     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;
@@ -731,6 +735,12 @@ int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket, RGWObjEnt& ent, RGWAc
 
     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;
+    }
     ret = 0;
     perfcounter->tinc(l_rgw_get_lat,
                       (ceph_clock_now(s->cct) - start_time));
@@ -881,6 +891,11 @@ int RGWGetObj::handle_user_manifest(const char *prefix)
   if (r < 0)
     return r;
 
+  if (!total_len) {
+    bufferlist bl;
+    send_response_data(bl, 0, 0);
+  }
+
   return 0;
 }