diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2012-11-29 13:39:22 -0800 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2012-12-03 16:02:33 -0800 |
commit | 0639cd9c479d69b077175f0385eb569ebb839349 (patch) | |
tree | 094a54525ef564dcc2db7d5c4db53efb84becb45 | |
parent | 84983387a220a29540aca64af774bbe7bc6b5ee6 (diff) | |
download | ceph-0639cd9c479d69b077175f0385eb569ebb839349.tar.gz |
rgw: fix rgw_tools get_obj()
The original implementation broke whenever data exceeded
the chunk size. Also don't keep cache for objects that
exceed the chunk size as cache is not designed for
it. Increased chunk size to 512k.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_cache.h | 5 | ||||
-rw-r--r-- | src/rgw/rgw_tools.cc | 19 |
2 files changed, 14 insertions, 10 deletions
diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index 1cc319b1fa3..71f139c1541 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -262,6 +262,11 @@ int RGWCache<T>::get_obj(void *ctx, void **handle, rgw_obj& obj, bufferlist& obl return r; } + if (obl.length() == end + 1) { + /* in this case, most likely object contains more data, we can't cache it */ + return r; + } + bufferptr p(r); bufferlist& bl = info.data; bl.clear(); diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index 3b8264058fb..14f984bcf36 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -10,7 +10,7 @@ #define dout_subsys ceph_subsys_rgw -#define READ_CHUNK_LEN (16 * 1024) +#define READ_CHUNK_LEN (512 * 1024) static map<string, string> ext_mime_map; @@ -41,25 +41,24 @@ int rgw_get_obj(void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl, map< bufferlist::iterator iter; int request_len = READ_CHUNK_LEN; rgw_obj obj(bucket, key); - ret = rgwstore->prepare_get_obj(ctx, obj, NULL, NULL, pattrs, NULL, + do { + ret = rgwstore->prepare_get_obj(ctx, obj, NULL, NULL, pattrs, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &handle, &err); - if (ret < 0) - return ret; + if (ret < 0) + return ret; - do { ret = rgwstore->get_obj(ctx, &handle, obj, bl, 0, request_len - 1); + rgwstore->finish_get_obj(&handle); if (ret < 0) - goto done; + return ret; + if (ret < request_len) break; bl.clear(); request_len *= 2; } while (true); - ret = 0; -done: - rgwstore->finish_get_obj(&handle); - return ret; + return 0; } void parse_mime_map_line(const char *start, const char *end) |