]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix range dump
authorYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 18 Jul 2011 17:06:59 +0000 (10:06 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Mon, 18 Jul 2011 17:07:27 +0000 (10:07 -0700)
12 files changed:
src/rgw/rgw_access.h
src/rgw/rgw_fs.cc
src/rgw/rgw_fs.h
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h
src/rgw/rgw_rest_os.cc
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_user.cc

index 05a1b1be26ee116726f2f1405cdd1eb315e4b5c5..8cc32ab4a1eeb0b1f27c45be12f17e60a0db9cb5 100644 (file)
@@ -161,6 +161,7 @@ public:
             const char *if_match,
             const char *if_nomatch,
             size_t *total_size,
+            size_t *obj_size,
             void **handle,
             struct rgw_err *err) = 0;
 
index 801bfd662c3dbfc090e7e1686ba140f6b9a48a20..bba8b9903220aa7afd1ab96f0c807d88640e2259 100644 (file)
@@ -305,12 +305,12 @@ int RGWFS::copy_obj(std::string& id, rgw_obj& dest_obj,
   char *data;
   void *handle;
   off_t ofs = 0, end = -1;
-  size_t total_len;
+  size_t total_len, obj_size;
   time_t lastmod;
 
   map<string, bufferlist> attrset;
   ret = prepare_get_obj(src_obj, 0, &end, &attrset, mod_ptr, unmod_ptr, &lastmod,
-                        if_match, if_nomatch, &total_len, &handle, err);
+                        if_match, if_nomatch, &total_len, &obj_size, &handle, err);
   if (ret < 0)
     return ret;
  
@@ -462,6 +462,7 @@ int RGWFS::prepare_get_obj(rgw_obj& obj,
             const char *if_match,
             const char *if_nomatch,
             size_t *total_size,
+            size_t *obj_size,
             void **handle,
             struct rgw_err *err)
 {
@@ -546,7 +547,10 @@ int RGWFS::prepare_get_obj(rgw_obj& obj,
 
   free(etag);
 
-  *total_size = (max_len > 0 ? max_len : 0);
+  if (total_size)
+    *total_size = (max_len > 0 ? max_len : 0);
+  if (obj_size)
+    *obj_size = size;
   r = 0;
   return r;
 
index 28a28a870817019f806e94aa835ec10e8cec1b0e..ca5a9876082d765ce6e6fbfe74cdf5d2a8d2c328 100644 (file)
@@ -51,6 +51,7 @@ public:
             const char *if_match,
             const char *if_nomatch,
             size_t *size,
+            size_t *obj_size,
             void **handle,
             struct rgw_err *err);
 
index 755a5494525aa5f22ebebdbb9518839988e257fc..a9f196fdaaaa93371a495068f41ae95dedde708d 100644 (file)
@@ -252,12 +252,10 @@ void RGWGetObj::execute()
 
   obj.init(s->bucket_str, s->object_str);
   ret = rgwstore->prepare_get_obj(obj, ofs, &end, &attrs, mod_ptr,
-                                  unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &handle, &s->err);
+                                  unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &s->obj_size, &handle, &s->err);
   if (ret < 0)
     goto done;
 
-  s->obj_size = total_len;
-
   if (!get_data || ofs > end)
     goto done;
 
@@ -288,6 +286,7 @@ int RGWGetObj::init_common()
     int r = parse_range(range_str, ofs, end);
     if (r < 0)
       return r;
+    start = ofs;
   }
   if (if_mod) {
     if (parse_time(if_mod, &mod_time) < 0)
@@ -1122,7 +1121,7 @@ static int get_multiparts_info(struct req_state *s, string& meta_oid, map<uint32
   rgw_obj obj(s->bucket_str, meta_oid, s->object_str, mp_ns);
 
   int ret = rgwstore->prepare_get_obj(obj, 0, NULL, &attrs, NULL,
-                                      NULL, NULL, NULL, NULL, NULL, &handle, &s->err);
+                                      NULL, NULL, NULL, NULL, NULL, NULL, &handle, &s->err);
   rgwstore->finish_get_obj(&handle);
 
   if (ret < 0)
index 324d90d9f0ce1ba72ec79db883b1de8f13325605..33bace813f43ef6e4726eb3a398c2be53e01c5c7 100644 (file)
@@ -57,6 +57,7 @@ protected:
   off_t ofs;
   size_t len;
   size_t total_len;
+  off_t start;
   off_t end;
   time_t mod_time;
   time_t lastmod;
@@ -79,6 +80,7 @@ public:
     if_unmod = NULL;
     if_match = NULL;
     if_nomatch = NULL;
+    start = 0;
     ofs = 0;
     len = 0;
     total_len = 0;
index 03cd09b9ab32cc69a106788cc0ca18f96de51ba3..ddb6045887d5a3cd4b46152df1629116409f3c46 100644 (file)
@@ -471,7 +471,7 @@ int RGWRados::copy_obj(std::string& id, rgw_obj& dest_obj,
   int ret, r;
   char *data;
   off_t end = -1;
-  size_t total_len;
+  size_t total_len, obj_size;
   time_t lastmod;
   map<string, bufferlist>::iterator iter;
   rgw_obj tmp_obj = dest_obj;
@@ -489,7 +489,7 @@ int RGWRados::copy_obj(std::string& id, rgw_obj& dest_obj,
 
   map<string, bufferlist> attrset;
   ret = prepare_get_obj(src_obj, 0, &end, &attrset,
-                mod_ptr, unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &handle, err);
+                mod_ptr, unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &obj_size, &handle, err);
 
   if (ret < 0)
     return ret;
@@ -792,6 +792,7 @@ int RGWRados::prepare_get_obj(rgw_obj& obj,
             const char *if_match,
             const char *if_nomatch,
             size_t *total_size,
+            size_t *obj_size,
             void **handle,
             struct rgw_err *err)
 {
@@ -888,6 +889,8 @@ int RGWRados::prepare_get_obj(rgw_obj& obj,
 
   if (total_size)
     *total_size = (ofs <= *end ? *end + 1 - ofs : 0);
+  if (obj_size)
+    *obj_size = size;
   if (lastmod)
     *lastmod = mtime;
 
index 804d8c58e042ead31ae384d6df47151cac59281c..249e72013cf45da7a8264c5001a7c839194eaa2a 100644 (file)
@@ -104,6 +104,7 @@ public:
             const char *if_match,
             const char *if_nomatch,
             size_t *total_size,
+            size_t *obj_size,
             void **handle,
             struct rgw_err *err);
 
index c690051f27d416957ffba838000eedb60af73a66..85fda35f1732cef8304605d41433e33822e18fa4 100644 (file)
@@ -202,9 +202,9 @@ void dump_continue(struct req_state *s)
   FCGX_FFlush(s->fcgx->out);
 }
 
-void dump_range(struct req_state *s, off_t ofs, off_t end)
+void dump_range(struct req_state *s, off_t ofs, off_t end, size_t total)
 {
-    CGI_PRINTF(s,"Content-Range: bytes %d-%d/%d\n", (int)ofs, (int)end, (int)end + 1);
+    CGI_PRINTF(s,"Content-Range: bytes %d-%d/%d\n", (int)ofs, (int)end, (int)total);
 }
 
 int RGWGetObj_REST::get_params()
index 4d35d5ede67d671137ec8eace1c0f33fe46548f3..1658363e3908a2f0c0256e38854553232365b665 100644 (file)
@@ -160,7 +160,7 @@ extern void dump_content_length(struct req_state *s, size_t len);
 extern void dump_etag(struct req_state *s, const char *etag);
 extern void dump_last_modified(struct req_state *s, time_t t);
 extern void abort_early(struct req_state *s, int err);
-extern void dump_range(struct req_state *s, off_t ofs, off_t end);
+extern void dump_range(struct req_state *s, off_t ofs, off_t end, size_t total_size);
 extern void dump_continue(struct req_state *s);
 extern void list_all_buckets_end(struct req_state *s);
 extern void dump_time(struct req_state *s, const char *name, time_t *t);
index 2853024be2b84dcf97658ef643fc1e88a9f25d62..8e28be6c37c834c51f59c465a604ecabc443b08d 100644 (file)
@@ -184,7 +184,7 @@ int RGWGetObj_REST_OS::send_response(void *handle)
     goto send_data;
 
   if (range_str)
-    dump_range(s, ofs, end);
+    dump_range(s, ofs, start, s->obj_size);
 
   dump_content_length(s, total_len);
   dump_last_modified(s, lastmod);
index 4acdc3f75ca7043929a1a18ed2fad7cc87c12a8f..8bfa10c82fc85efcbb0b898f95d10be175437048 100644 (file)
@@ -42,7 +42,7 @@ int RGWGetObj_REST_S3::send_response(void *handle)
     goto send_data;
 
   if (range_str)
-    dump_range(s, ofs, end);
+    dump_range(s, start, end, s->obj_size);
 
   dump_content_length(s, total_len);
   dump_last_modified(s, lastmod);
index 93e1580e07bdb0afe751b45bf73ef7187d152c7f..f9835c6457b128a4e2d94145e44f1910b5328460 100644 (file)
@@ -66,7 +66,7 @@ static int get_obj(string& bucket, string& key, bufferlist& bl)
   int request_len = READ_CHUNK_LEN;
   rgw_obj obj(bucket, key);
   ret = rgwstore->prepare_get_obj(obj, 0, NULL, NULL, NULL,
-                                  NULL, NULL, NULL, NULL, NULL, &handle, &err);
+                                  NULL, NULL, NULL, NULL, NULL, NULL, &handle, &err);
   if (ret < 0)
     return ret;