Skip to content

Commit

Permalink
Merge pull request ceph#5258 from zhouyuan/rgw_skip_first_chunk
Browse files Browse the repository at this point in the history
rgw: skip prefetch first chunk if range get falls to shadow objects

Reviewed-by: Yehuda Sadeh <[email protected]>
  • Loading branch information
yehudasa committed Jul 31, 2015
2 parents 3fbcf5e + 9574555 commit c8653b1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
36 changes: 33 additions & 3 deletions src/rgw/rgw_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -960,9 +987,12 @@ void RGWGetObj::execute()
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)
Expand Down
4 changes: 3 additions & 1 deletion src/rgw/rgw_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class RGWGetObj : public RGWOp {
int ret;
bool get_data;
bool partial_content;
bool range_parsed;
rgw_obj obj;
utime_t gc_invalidate_time;

Expand All @@ -156,10 +157,11 @@ class RGWGetObj : public RGWOp {
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;
Expand Down

0 comments on commit c8653b1

Please sign in to comment.