From: Casey Bodley Date: Wed, 26 Mar 2025 23:19:36 +0000 (-0400) Subject: rgw: rgw_rados_ref::watch/unwatch take optional_yield X-Git-Tag: v20.3.0~135^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d0499aed4a606e5efab60c2a33563a2fb3827135;p=ceph.git rgw: rgw_rados_ref::watch/unwatch take optional_yield Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/rados/rgw_tools.cc b/src/rgw/driver/rados/rgw_tools.cc index 2a12b583508..c1db14d9912 100644 --- a/src/rgw/driver/rados/rgw_tools.cc +++ b/src/rgw/driver/rados/rgw_tools.cc @@ -116,6 +116,34 @@ int rgw_get_rados_ref(const DoutPrefixProvider* dpp, librados::Rados* rados, return 0; } +int rgw_rados_ref::watch(const DoutPrefixProvider* dpp, uint64_t* handle, + librados::WatchCtx2* ctx, optional_yield y) +{ + if (y) { + auto& yield = y.get_yield_context(); + boost::system::error_code ec; + librados::async_watch(yield.get_executor(), ioctx, obj.oid, + handle, ctx, 0, yield[ec]); + return ceph::from_error_code(ec); + } else { + maybe_warn_about_blocking(dpp); + return ioctx.watch2(obj.oid, handle, ctx); + } +} + +int rgw_rados_ref::unwatch(const DoutPrefixProvider* dpp, uint64_t handle, + optional_yield y) +{ + if (y) { + auto& yield = y.get_yield_context(); + boost::system::error_code ec; + librados::async_unwatch(yield.get_executor(), ioctx, handle, yield[ec]); + return ceph::from_error_code(ec); + } else { + maybe_warn_about_blocking(dpp); + return ioctx.unwatch2(handle); + } +} map* no_change_attrs() { static map no_change; diff --git a/src/rgw/driver/rados/rgw_tools.h b/src/rgw/driver/rados/rgw_tools.h index 43470a0c718..fb070ebe62e 100644 --- a/src/rgw/driver/rados/rgw_tools.h +++ b/src/rgw/driver/rados/rgw_tools.h @@ -128,18 +128,10 @@ struct rgw_rados_ref { return ioctx.aio_operate(obj.oid, c, op, pbl); } - int watch(uint64_t* handle, librados::WatchCtx2* ctx) { - return ioctx.watch2(obj.oid, handle, ctx); - } - - int aio_watch(librados::AioCompletion* c, uint64_t* handle, - librados::WatchCtx2 *ctx) { - return ioctx.aio_watch(obj.oid, c, handle, ctx); - } + int watch(const DoutPrefixProvider* dpp, uint64_t* handle, + librados::WatchCtx2* ctx, optional_yield y); - int unwatch(uint64_t handle) { - return ioctx.unwatch2(handle); - } + int unwatch(const DoutPrefixProvider* dpp, uint64_t handle, optional_yield y); int notify(const DoutPrefixProvider* dpp, bufferlist& bl, uint64_t timeout_ms, bufferlist* pbl, optional_yield y) {