]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rgw_rados_ref::watch/unwatch take optional_yield
authorCasey Bodley <cbodley@redhat.com>
Wed, 26 Mar 2025 23:19:36 +0000 (19:19 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 27 Mar 2025 13:59:04 +0000 (09:59 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_tools.cc
src/rgw/driver/rados/rgw_tools.h

index 2a12b583508c4444452e2bc571b8384ef7d7d654..c1db14d99127ea80e37d95623c7d9989599866a3 100644 (file)
@@ -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<string, bufferlist>* no_change_attrs() {
   static map<string, bufferlist> no_change;
index 43470a0c718160875c4c588f41938ff13eee0920..fb070ebe62e4e30585251fd36bf4f75fda1601c0 100644 (file)
@@ -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) {