mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
Merge pull request #5258 from zhouyuan/rgw_skip_first_chunk
rgw: skip prefetch first chunk if range get falls to shadow objects Reviewed-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
commit
c8653b11a8
@ -879,6 +879,33 @@ int RGWGetObj::get_data_cb(bufferlist& bl, off_t bl_ofs, off_t bl_len)
|
||||
return send_response_data(bl, bl_ofs, bl_len);
|
||||
}
|
||||
|
||||
bool RGWGetObj::prefetch_data()
|
||||
{
|
||||
/* HEAD request, stop prefetch*/
|
||||
if (!get_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool prefetch_first_chunk = true;
|
||||
range_str = s->info.env->get("HTTP_RANGE");
|
||||
|
||||
if(range_str) {
|
||||
int r = parse_range(range_str, ofs, end, &partial_content);
|
||||
/* error on parsing the range, stop prefetch and will fail in execte() */
|
||||
if (r < 0) {
|
||||
range_parsed = false;
|
||||
return false;
|
||||
} else {
|
||||
range_parsed = true;
|
||||
}
|
||||
/* range get goes to shadown objects, stop prefetch */
|
||||
if (ofs >= s->cct->_conf->rgw_max_chunk_size) {
|
||||
prefetch_first_chunk = false;
|
||||
}
|
||||
}
|
||||
|
||||
return get_data && prefetch_first_chunk;
|
||||
}
|
||||
void RGWGetObj::pre_exec()
|
||||
{
|
||||
rgw_bucket_object_pre_exec(s);
|
||||
@ -960,9 +987,12 @@ done_err:
|
||||
int RGWGetObj::init_common()
|
||||
{
|
||||
if (range_str) {
|
||||
int r = parse_range(range_str, ofs, end, &partial_content);
|
||||
if (r < 0)
|
||||
return r;
|
||||
/* range parsed error when prefetch*/
|
||||
if (!range_parsed) {
|
||||
int r = parse_range(range_str, ofs, end, &partial_content);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
if (if_mod) {
|
||||
if (parse_time(if_mod, &mod_time) < 0)
|
||||
|
@ -134,6 +134,7 @@ protected:
|
||||
int ret;
|
||||
bool get_data;
|
||||
bool partial_content;
|
||||
bool range_parsed;
|
||||
rgw_obj obj;
|
||||
utime_t gc_invalidate_time;
|
||||
|
||||
@ -156,10 +157,11 @@ public:
|
||||
unmod_ptr = NULL;
|
||||
get_data = false;
|
||||
partial_content = false;
|
||||
range_parsed = false;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
virtual bool prefetch_data() { return get_data; }
|
||||
bool prefetch_data();
|
||||
|
||||
void set_get_data(bool get_data) {
|
||||
this->get_data = get_data;
|
||||
|
Loading…
Reference in New Issue
Block a user