rgw: data obj synchronous read, use correct ioctx

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
Yehuda Sadeh 2018-10-09 17:25:28 -07:00
parent 1a3733fc77
commit 053a765876
3 changed files with 26 additions and 6 deletions

View File

@ -6168,7 +6168,10 @@ int RGWRados::Object::Read::prepare()
state.obj = astate->obj;
store->obj_to_raw(bucket_info.placement_rule, state.obj, &state.head_obj);
r = store->get_obj_head_ioctx(bucket_info, state.obj, &state.io_ctx);
state.cur_pool = state.head_obj.pool;
state.cur_ioctx = &state.io_ctxs[state.cur_pool];
r = store->get_obj_head_ioctx(bucket_info, state.obj, state.cur_ioctx);
if (r < 0) {
return r;
}
@ -6492,8 +6495,6 @@ int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl)
len = max_chunk_size;
state.io_ctx.locator_set_key(read_obj.loc);
read_len = len;
if (reading_from_head) {
@ -6525,7 +6526,24 @@ int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl)
ldout(cct, 20) << "rados->read obj-ofs=" << ofs << " read_ofs=" << read_ofs << " read_len=" << read_len << dendl;
op.read(read_ofs, read_len, pbl, NULL);
r = state.io_ctx.operate(read_obj.oid, &op, NULL);
if (state.cur_pool != read_obj.pool) {
auto iter = state.io_ctxs.find(read_obj.pool);
if (iter == state.io_ctxs.end()) {
state.cur_ioctx = &state.io_ctxs[read_obj.pool];
r = store->open_pool_ctx(read_obj.pool, *state.cur_ioctx);
if (r < 0) {
ldout(cct, 20) << "ERROR: failed to open pool context for pool=" << read_obj.pool << " r=" << r << dendl;
return r;
}
} else {
state.cur_ioctx = &iter->second;
}
state.cur_pool = read_obj.pool;
}
state.cur_ioctx->locator_set_key(read_obj.loc);
r = state.cur_ioctx->operate(read_obj.oid, &op, NULL);
ldout(cct, 20) << "rados->read r=" << r << " bl.length=" << bl.length() << dendl;
if (r < 0) {

View File

@ -1548,7 +1548,9 @@ public:
RGWRados::Object *source;
struct GetObjState {
librados::IoCtx io_ctx;
map<rgw_pool, librados::IoCtx> io_ctxs;
rgw_pool cur_pool;
librados::IoCtx *cur_ioctx{nullptr};
rgw_obj obj;
rgw_raw_obj head_obj;
} state;

View File

@ -68,7 +68,7 @@ int seed::get_torrent_file(RGWRados::Object::Read &read_op,
const set<string> obj_key{RGW_OBJ_TORRENT};
map<string, bufferlist> m;
const int r = read_op.state.io_ctx.omap_get_vals_by_keys(oid, obj_key, &m);
const int r = read_op.state.cur_ioctx->omap_get_vals_by_keys(oid, obj_key, &m);
if (r < 0) {
ldout(s->cct, 0) << "ERROR: omap_get_vals_by_keys failed: " << r << dendl;
return r;