From: Casey Bodley Date: Tue, 4 Sep 2018 20:14:18 +0000 (-0400) Subject: rgw: RGWAsyncGetSystemObj does not access coroutine memory X-Git-Tag: v12.2.9~73^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=85935f088a1886f982c0510d93bf570f15b8a87a;p=ceph.git rgw: RGWAsyncGetSystemObj does not access coroutine memory now reads the buffer/attrs into local memory, and calling coroutines copy out the result during request_complete() Fixes: http://tracker.ceph.com/issues/35543 Signed-off-by: Casey Bodley (cherry picked from commit 089db9f74266073eb1d45900d982f1831c72fe59) Conflicts: src/rgw/rgw_cr_rados.h : Resolved in request_complete --- diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 5fd8403178ad..6deaffb8cdc2 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -87,32 +87,36 @@ void RGWAsyncRadosProcessor::queue(RGWAsyncRadosRequest *req) { int RGWAsyncGetSystemObj::_send_request() { - return store->get_system_obj(*obj_ctx, read_state, objv_tracker, obj, *pbl, ofs, end, pattrs, NULL); + map *pattrs = want_attrs ? &attrs : nullptr; + + return store->get_system_obj(obj_ctx, read_state, &objv_tracker, + obj, bl, ofs, end, pattrs, nullptr); } -RGWAsyncGetSystemObj::RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjectCtx *_obj_ctx, +RGWAsyncGetSystemObj::RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, - bufferlist *_pbl, off_t _ofs, off_t _end) : RGWAsyncRadosRequest(caller, cn), store(_store), obj_ctx(_obj_ctx), - objv_tracker(_objv_tracker), obj(_obj), pbl(_pbl), pattrs(NULL), - ofs(_ofs), end(_end) + off_t _ofs, off_t _end, bool want_attrs) + : RGWAsyncRadosRequest(caller, cn), store(_store), obj_ctx(_store), + obj(_obj), ofs(_ofs), end(_end), want_attrs(want_attrs) { + if (_objv_tracker) { + objv_tracker = *_objv_tracker; + } } int RGWSimpleRadosReadAttrsCR::send_request() { req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(), - store, &obj_ctx, NULL, - obj, - &bl, 0, -1); - if (pattrs) { - req->set_read_attrs(pattrs); - } + store, nullptr, obj, 0, -1, true); async_rados->queue(req); return 0; } int RGWSimpleRadosReadAttrsCR::request_complete() { + if (pattrs) { + *pattrs = std::move(req->attrs); + } return req->get_ret_status(); } diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index e30646f6e1c3..441381d94eac 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -102,21 +102,22 @@ public: class RGWAsyncGetSystemObj : public RGWAsyncRadosRequest { RGWRados *store; - RGWObjectCtx *obj_ctx; + RGWObjectCtx obj_ctx; RGWRados::SystemObject::Read::GetObjState read_state; - RGWObjVersionTracker *objv_tracker; + RGWObjVersionTracker objv_tracker; rgw_raw_obj obj; - bufferlist *pbl; - map *pattrs; off_t ofs; off_t end; + const bool want_attrs; protected: int _send_request() override; public: - RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjectCtx *_obj_ctx, + RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, - bufferlist *_pbl, off_t _ofs, off_t _end); - void set_read_attrs(map *_pattrs) { pattrs = _pattrs; } + off_t _ofs, off_t _end, bool want_attrs); + + bufferlist bl; + map attrs; }; class RGWAsyncPutSystemObj : public RGWAsyncRadosRequest { @@ -181,18 +182,11 @@ template class RGWSimpleRadosReadCR : public RGWSimpleCoroutine { RGWAsyncRadosProcessor *async_rados; RGWRados *store; - RGWObjectCtx obj_ctx; - bufferlist bl; - rgw_raw_obj obj; - - map *pattrs{nullptr}; - T *result; /// on ENOENT, call handle_data() with an empty object instead of failing const bool empty_on_enoent; RGWObjVersionTracker *objv_tracker; - RGWAsyncGetSystemObj *req{nullptr}; public: @@ -201,7 +195,7 @@ public: T *_result, bool empty_on_enoent = true, RGWObjVersionTracker *objv_tracker = nullptr) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), - obj_ctx(store), obj(_obj), result(_result), + obj(_obj), result(_result), empty_on_enoent(empty_on_enoent), objv_tracker(objv_tracker) {} ~RGWSimpleRadosReadCR() override { request_cleanup(); @@ -226,12 +220,7 @@ template int RGWSimpleRadosReadCR::send_request() { req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(), - store, &obj_ctx, objv_tracker, - obj, - &bl, 0, -1); - if (pattrs) { - req->set_read_attrs(pattrs); - } + store, objv_tracker, obj, 0, -1, false); async_rados->queue(req); return 0; } @@ -248,7 +237,7 @@ int RGWSimpleRadosReadCR::request_complete() return ret; } try { - bufferlist::iterator iter = bl.begin(); + bufferlist::iterator iter = req->bl.begin(); if (iter.end()) { // allow successful reads with empty buffers. ReadSyncStatus coroutines // depend on this to be able to read without locking, because the @@ -269,13 +258,8 @@ int RGWSimpleRadosReadCR::request_complete() class RGWSimpleRadosReadAttrsCR : public RGWSimpleCoroutine { RGWAsyncRadosProcessor *async_rados; RGWRados *store; - RGWObjectCtx obj_ctx; - bufferlist bl; - rgw_raw_obj obj; - map *pattrs; - RGWAsyncGetSystemObj *req; public: @@ -283,7 +267,6 @@ public: const rgw_raw_obj& _obj, map *_pattrs) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), - obj_ctx(store), obj(_obj), pattrs(_pattrs), req(NULL) { }