]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
neorados: Remove broken out duplicates of calls
authorAdam Emerson <aemerson@redhat.com>
Tue, 28 Nov 2023 17:28:41 +0000 (12:28 -0500)
committerAdam Emerson <aemerson@redhat.com>
Wed, 6 Dec 2023 20:39:35 +0000 (15:39 -0500)
Make everything use IOContext rather than duplicating everything with
versions taking a separate pool, namespace, and key.

Signed-off-by: Adam Emerson <aemerson@redhat.com>
src/include/neorados/RADOS.hpp
src/neorados/RADOS.cc
src/test/neorados/list_pool.cc
src/test/neorados/test_neorados.cc
src/tools/neorados.cc

index b4f48d12ffc1855395e872c240d4754f46d9d2aa..258a2ead5ffd17df12521344ca36b227a93cd5c5 100644 (file)
@@ -575,36 +575,6 @@ public:
     return init.result.get();
   }
 
-  template<typename CompletionToken>
-  auto execute(const Object& o, std::int64_t pool,
-              ReadOp&& op,
-              ceph::buffer::list* bl,
-              CompletionToken&& token,
-              std::optional<std::string_view> ns = {},
-              std::optional<std::string_view> key = {},
-              uint64_t* objver = nullptr) {
-    boost::asio::async_completion<CompletionToken, Op::Signature> init(token);
-    execute(o, pool, std::move(op), bl,
-           ReadOp::Completion::create(get_executor(),
-                                      std::move(init.completion_handler)),
-           ns, key, objver);
-    return init.result.get();
-  }
-
-  template<typename CompletionToken>
-  auto execute(const Object& o, std::int64_t pool, WriteOp&& op,
-              CompletionToken&& token,
-              std::optional<std::string_view> ns = {},
-              std::optional<std::string_view> key = {},
-              uint64_t* objver = nullptr) {
-    boost::asio::async_completion<CompletionToken, Op::Signature> init(token);
-    execute(o, pool, std::move(op),
-           Op::Completion::create(get_executor(),
-                                  std::move(init.completion_handler)),
-           ns, key, objver);
-    return init.result.get();
-  }
-
   boost::uuids::uuid get_fsid() const noexcept;
 
   using LookupPoolSig = void(boost::system::error_code,
@@ -756,20 +726,6 @@ public:
     return init.result.get();
   }
 
-  template<typename CompletionToken>
-  auto watch(const Object& o, std::int64_t pool,
-            std::optional<std::chrono::seconds> timeout,
-            WatchCB&& cb, CompletionToken&& token,
-            std::optional<std::string_view> ns = {},
-            std::optional<std::string_view> key = {}) {
-    boost::asio::async_completion<CompletionToken, WatchSig> init(token);
-    watch(o, pool, timeout, std::move(cb),
-         WatchComp::create(get_executor(),
-                           std::move(init.completion_handler)),
-         ns, key);
-    return init.result.get();
-  }
-
   template<typename CompletionToken>
   auto notify_ack(const Object& o,
                  const IOContext& ioc,
@@ -784,23 +740,6 @@ public:
     return init.result.get();
   }
 
-  template<typename CompletionToken>
-  auto notify_ack(const Object& o,
-                 std::int64_t pool,
-                 uint64_t notify_id,
-                 uint64_t cookie,
-                 ceph::buffer::list&& bl,
-                 CompletionToken&& token,
-                 std::optional<std::string_view> ns = {},
-                 std::optional<std::string_view> key = {}) {
-    boost::asio::async_completion<CompletionToken, WatchSig> init(token);
-    notify_ack(o, pool, notify_id, cookie, std::move(bl),
-              SimpleOpComp::create(get_executor(),
-                                   std::move(init.completion_handler)),
-              ns, key);
-    return init.result.get();
-  }
-
   template<typename CompletionToken>
   auto unwatch(uint64_t cookie, const IOContext& ioc,
               CompletionToken&& token) {
@@ -811,19 +750,6 @@ public:
     return init.result.get();
   }
 
-  template<typename CompletionToken>
-  auto unwatch(uint64_t cookie, std::int64_t pool,
-              CompletionToken&& token,
-              std::optional<std::string_view> ns = {},
-              std::optional<std::string_view> key = {}) {
-    boost::asio::async_completion<CompletionToken, SimpleOpSig> init(token);
-    unwatch(cookie, pool,
-           SimpleOpComp::create(get_executor(),
-                                std::move(init.completion_handler)),
-           ns, key);
-    return init.result.get();
-  }
-
   // This is one of those places where having to force everything into
   // a .cc file is really infuriating. If we had modules, that would
   // let us separate out the implementation details without
@@ -852,21 +778,6 @@ public:
     return init.result.get();
   }
 
-  template<typename CompletionToken>
-  auto notify(const Object& oid, std::int64_t pool, ceph::buffer::list&& bl,
-             std::optional<std::chrono::milliseconds> timeout,
-             CompletionToken&& token,
-             std::optional<std::string_view> ns = {},
-             std::optional<std::string_view> key = {}) {
-    boost::asio::async_completion<CompletionToken, NotifySig> init(token);
-    notify(oid, pool, bl, timeout,
-          NotifyComp::create(get_executor(),
-                             std::move(init.completion_handler)),
-          ns, key);
-
-    return init.result.get();
-  }
-
   // The versions with pointers are fine for coroutines, but
   // extraordinarily unappealing for callback-oriented programming.
   using EnumerateSig = void(boost::system::error_code,
@@ -885,21 +796,6 @@ public:
     return init.result.get();
   }
 
-  template<typename CompletionToken>
-  auto enumerate_objects(std::int64_t pool, const Cursor& begin,
-                        const Cursor& end, const std::uint32_t max,
-                        const ceph::buffer::list& filter,
-                        CompletionToken&& token,
-                        std::optional<std::string_view> ns = {},
-                        std::optional<std::string_view> key = {}) {
-    boost::asio::async_completion<CompletionToken, EnumerateSig> init(token);
-    enumerate_objects(pool, begin, end, max, filter,
-                     EnumerateComp::create(get_executor(),
-                                           std::move(init.completion_handler)),
-                     ns, key);
-    return init.result.get();
-  }
-
   using CommandSig = void(boost::system::error_code,
                          std::string, ceph::buffer::list);
   using CommandComp = ceph::async::Completion<CommandSig>;
@@ -984,18 +880,6 @@ private:
               std::unique_ptr<Op::Completion> c, uint64_t* objver,
               const blkin_trace_info* trace_info);
 
-  void execute(const Object& o, std::int64_t pool, ReadOp&& op,
-              ceph::buffer::list* bl, std::unique_ptr<Op::Completion> c,
-              std::optional<std::string_view> ns,
-              std::optional<std::string_view> key,
-              uint64_t* objver);
-
-  void execute(const Object& o, std::int64_t pool, WriteOp&& op,
-              std::unique_ptr<Op::Completion> c,
-              std::optional<std::string_view> ns,
-              std::optional<std::string_view> key,
-              uint64_t* objver);
-
   void lookup_pool(std::string_view name, std::unique_ptr<LookupPoolComp> c);
   void list_pools(std::unique_ptr<LSPoolsComp> c);
   void create_pool_snap(int64_t pool, std::string_view snapName,
@@ -1019,11 +903,6 @@ private:
   void watch(const Object& o, const IOContext& ioc,
             std::optional<std::chrono::seconds> timeout,
             WatchCB&& cb, std::unique_ptr<WatchComp> c);
-  void watch(const Object& o, std::int64_t pool,
-            std::optional<std::chrono::seconds> timeout,
-            WatchCB&& cb, std::unique_ptr<WatchComp> c,
-            std::optional<std::string_view> ns,
-            std::optional<std::string_view> key);
   tl::expected<ceph::timespan, boost::system::error_code>
   watch_check(uint64_t cookie);
   void notify_ack(const Object& o,
@@ -1032,30 +911,12 @@ private:
                  uint64_t cookie,
                  ceph::buffer::list&& bl,
                  std::unique_ptr<SimpleOpComp>);
-  void notify_ack(const Object& o,
-                 std::int64_t pool,
-                 uint64_t notify_id,
-                 uint64_t cookie,
-                 ceph::buffer::list&& bl,
-                 std::unique_ptr<SimpleOpComp>,
-                 std::optional<std::string_view> ns,
-                 std::optional<std::string_view> key);
   void unwatch(uint64_t cookie, const IOContext& ioc,
               std::unique_ptr<SimpleOpComp>);
-  void unwatch(uint64_t cookie, std::int64_t pool,
-              std::unique_ptr<SimpleOpComp>,
-              std::optional<std::string_view> ns,
-              std::optional<std::string_view> key);
   void notify(const Object& oid, const IOContext& ioctx,
              ceph::buffer::list&& bl,
              std::optional<std::chrono::milliseconds> timeout,
              std::unique_ptr<NotifyComp> c);
-  void notify(const Object& oid, std::int64_t pool,
-             ceph::buffer::list&& bl,
-             std::optional<std::chrono::milliseconds> timeout,
-             std::unique_ptr<NotifyComp> c,
-             std::optional<std::string_view> ns,
-             std::optional<std::string_view> key);
   void flush_watch(std::unique_ptr<VoidOpComp>);
 
   void enumerate_objects(const IOContext& ioc, const Cursor& begin,
@@ -1064,24 +925,10 @@ private:
                         std::vector<Entry>* ls,
                         Cursor* cursor,
                         std::unique_ptr<SimpleOpComp> c);
-  void enumerate_objects(std::int64_t pool, const Cursor& begin,
-                        const Cursor& end, const std::uint32_t max,
-                        const ceph::buffer::list& filter,
-                        std::vector<Entry>* ls,
-                        Cursor* cursor,
-                        std::unique_ptr<SimpleOpComp> c,
-                        std::optional<std::string_view> ns,
-                        std::optional<std::string_view> key);
   void enumerate_objects(const IOContext& ioc, const Cursor& begin,
                         const Cursor& end, const std::uint32_t max,
                         const ceph::buffer::list& filter,
                         std::unique_ptr<EnumerateComp> c);
-  void enumerate_objects(std::int64_t pool, const Cursor& begin,
-                        const Cursor& end, const std::uint32_t max,
-                        const ceph::buffer::list& filter,
-                        std::unique_ptr<EnumerateComp> c,
-                        std::optional<std::string_view> ns,
-                        std::optional<std::string_view> key);
   void osd_command(int osd, std::vector<std::string>&& cmd,
                   ceph::buffer::list&& in, std::unique_ptr<CommandComp> c);
   void pg_command(PG pg, std::vector<std::string>&& cmd,
index 93f02b1ae702757a1854174a03e056f783a286e0..667127d112535c579845e4bf838705aaf5016c2b 100644 (file)
@@ -849,54 +849,6 @@ void RADOS::execute(const Object& o, const IOContext& _ioc, WriteOp&& _op,
   trace.event("submitted");
 }
 
-void RADOS::execute(const Object& o, std::int64_t pool, ReadOp&& _op,
-                   cb::list* bl,
-                   std::unique_ptr<ReadOp::Completion> c,
-                   std::optional<std::string_view> ns,
-                   std::optional<std::string_view> key,
-                   version_t* objver) {
-  auto oid = reinterpret_cast<const object_t*>(&o.impl);
-  auto op = reinterpret_cast<OpImpl*>(&_op.impl);
-  auto flags = op->op.flags;
-  object_locator_t oloc;
-  oloc.pool = pool;
-  if (ns)
-    oloc.nspace = *ns;
-  if (key)
-    oloc.key = *key;
-
-  impl->objecter->read(
-    *oid, oloc, std::move(op->op), CEPH_NOSNAP, bl, flags,
-    std::move(c), objver);
-}
-
-void RADOS::execute(const Object& o, std::int64_t pool, WriteOp&& _op,
-                   std::unique_ptr<WriteOp::Completion> c,
-                   std::optional<std::string_view> ns,
-                   std::optional<std::string_view> key,
-                   version_t* objver) {
-  auto oid = reinterpret_cast<const object_t*>(&o.impl);
-  auto op = reinterpret_cast<OpImpl*>(&_op.impl);
-  auto flags = op->op.flags;
-  object_locator_t oloc;
-  oloc.pool = pool;
-  if (ns)
-    oloc.nspace = *ns;
-  if (key)
-    oloc.key = *key;
-
-  ceph::real_time mtime;
-  if (op->mtime)
-    mtime = *op->mtime;
-  else
-    mtime = ceph::real_clock::now();
-
-  impl->objecter->mutate(
-    *oid, oloc, std::move(op->op), {},
-    mtime, flags,
-    std::move(c), objver);
-}
-
 boost::uuids::uuid RADOS::get_fsid() const noexcept {
   return impl->monclient.get_fsid().uuid;
 }
@@ -1130,35 +1082,6 @@ void RADOS::watch(const Object& o, const IOContext& _ioc,
       }), nullptr);
 }
 
-void RADOS::watch(const Object& o, std::int64_t pool,
-                 std::optional<std::chrono::seconds> timeout, WatchCB&& cb,
-                 std::unique_ptr<WatchComp> c,
-                 std::optional<std::string_view> ns,
-                 std::optional<std::string_view> key) {
-  auto oid = reinterpret_cast<const object_t*>(&o.impl);
-  object_locator_t oloc;
-  oloc.pool = pool;
-  if (ns)
-    oloc.nspace = *ns;
-  if (key)
-    oloc.key = *key;
-
-  ObjectOperation op;
-
-  Objecter::LingerOp *linger_op = impl->objecter->linger_register(*oid, oloc, 0);
-  uint64_t cookie = linger_op->get_cookie();
-  linger_op->handle = std::move(cb);
-  op.watch(cookie, CEPH_OSD_WATCH_OP_WATCH, timeout.value_or(0s).count());
-  bufferlist bl;
-  impl->objecter->linger_watch(
-    linger_op, op, {}, ceph::real_clock::now(), bl,
-    Objecter::LingerOp::OpComp::create(
-      get_executor(),
-      [c = std::move(c), cookie](bs::error_code e, bufferlist) mutable {
-       ca::dispatch(std::move(c), e, cookie);
-      }), nullptr);
-}
-
 void RADOS::notify_ack(const Object& o,
                       const IOContext& _ioc,
                       uint64_t notify_id,
@@ -1176,28 +1099,6 @@ void RADOS::notify_ack(const Object& o,
                       nullptr, ioc->extra_op_flags, std::move(c));
 }
 
-void RADOS::notify_ack(const Object& o,
-                      std::int64_t pool,
-                      uint64_t notify_id,
-                      uint64_t cookie,
-                      bufferlist&& bl,
-                      std::unique_ptr<SimpleOpComp> c,
-                      std::optional<std::string_view> ns,
-                      std::optional<std::string_view> key) {
-  auto oid = reinterpret_cast<const object_t*>(&o.impl);
-  object_locator_t oloc;
-  oloc.pool = pool;
-  if (ns)
-    oloc.nspace = *ns;
-  if (key)
-    oloc.key = *key;
-
-  ObjectOperation op;
-  op.notify_ack(notify_id, cookie, bl);
-  impl->objecter->read(*oid, oloc, std::move(op), CEPH_NOSNAP, nullptr, 0,
-                      std::move(c));
-}
-
 tl::expected<ceph::timespan, bs::error_code> RADOS::watch_check(uint64_t cookie)
 {
   Objecter::LingerOp *linger_op = reinterpret_cast<Objecter::LingerOp*>(cookie);
@@ -1225,34 +1126,6 @@ void RADOS::unwatch(uint64_t cookie, const IOContext& _ioc,
                           }));
 }
 
-void RADOS::unwatch(uint64_t cookie, std::int64_t pool,
-                   std::unique_ptr<SimpleOpComp> c,
-                   std::optional<std::string_view> ns,
-                   std::optional<std::string_view> key)
-{
-  object_locator_t oloc;
-  oloc.pool = pool;
-  if (ns)
-    oloc.nspace = *ns;
-  if (key)
-    oloc.key = *key;
-
-  Objecter::LingerOp *linger_op = reinterpret_cast<Objecter::LingerOp*>(cookie);
-
-  ObjectOperation op;
-  op.watch(cookie, CEPH_OSD_WATCH_OP_UNWATCH);
-  impl->objecter->mutate(linger_op->target.base_oid, oloc, std::move(op),
-                        {}, ceph::real_clock::now(), 0,
-                        Objecter::Op::OpComp::create(
-                          get_executor(),
-                          [objecter = impl->objecter,
-                           linger_op, c = std::move(c)]
-                          (bs::error_code ec) mutable {
-                            objecter->linger_cancel(linger_op);
-                            ca::dispatch(std::move(c), ec);
-                          }));
-}
-
 void RADOS::flush_watch(std::unique_ptr<VoidOpComp> c)
 {
   impl->objecter->linger_callback_flush([c = std::move(c)]() mutable {
@@ -1346,45 +1219,6 @@ void RADOS::notify(const Object& o, const IOContext& _ioc, bufferlist&& bl,
       }), nullptr);
 }
 
-void RADOS::notify(const Object& o, std::int64_t pool, bufferlist&& bl,
-                  std::optional<std::chrono::milliseconds> timeout,
-                  std::unique_ptr<NotifyComp> c,
-                  std::optional<std::string_view> ns,
-                  std::optional<std::string_view> key)
-{
-  auto oid = reinterpret_cast<const object_t*>(&o.impl);
-  object_locator_t oloc;
-  oloc.pool = pool;
-  if (ns)
-    oloc.nspace = *ns;
-  if (key)
-    oloc.key = *key;
-  auto linger_op = impl->objecter->linger_register(*oid, oloc, 0);
-
-  auto cb = std::make_shared<NotifyHandler>(impl->ioctx, impl->objecter,
-                                            linger_op, std::move(c));
-  linger_op->on_notify_finish =
-    Objecter::LingerOp::OpComp::create(
-      get_executor(),
-      [cb](bs::error_code ec, ceph::bufferlist&& bl) mutable {
-       (*cb)(ec, std::move(bl));
-      });
-  ObjectOperation rd;
-  bufferlist inbl;
-  rd.notify(
-    linger_op->get_cookie(), 1,
-    timeout ? timeout->count() : impl->cct->_conf->client_notify_timeout,
-    bl, &inbl);
-
-  impl->objecter->linger_notify(
-    linger_op, rd, CEPH_NOSNAP, inbl,
-    Objecter::LingerOp::OpComp::create(
-      get_executor(),
-      [cb](bs::error_code ec, bufferlist&& bl) mutable {
-       cb->handle_ack(ec, std::move(bl));
-      }), nullptr);
-}
-
 // Enumeration
 
 Cursor::Cursor() {
@@ -1509,30 +1343,6 @@ void RADOS::enumerate_objects(const IOContext& _ioc,
     });
 }
 
-void RADOS::enumerate_objects(std::int64_t pool,
-                             const Cursor& begin,
-                             const Cursor& end,
-                             const std::uint32_t max,
-                             const bufferlist& filter,
-                             std::unique_ptr<EnumerateComp> c,
-                             std::optional<std::string_view> ns,
-                             std::optional<std::string_view> key) {
-  impl->objecter->enumerate_objects<Entry>(
-    pool,
-    ns ? *ns : std::string_view{},
-    *reinterpret_cast<const hobject_t*>(&begin.impl),
-    *reinterpret_cast<const hobject_t*>(&end.impl),
-    max,
-    filter,
-    [c = std::move(c)]
-    (bs::error_code ec, std::vector<Entry>&& v,
-     hobject_t&& n) mutable {
-      ca::dispatch(std::move(c), ec, std::move(v),
-                  Cursor(static_cast<void*>(&n)));
-    });
-}
-
-
 void RADOS::osd_command(int osd, std::vector<std::string>&& cmd,
                        ceph::bufferlist&& in, std::unique_ptr<CommandComp> c) {
   impl->objecter->osd_command(osd, std::move(cmd), std::move(in), nullptr,
index ae36c36e65523b16e7d278033a5c16f89e8f9cd6..4a1dc9cb7b1b39dc54c57285031a87fb05974f39 100644 (file)
@@ -83,9 +83,9 @@ bs::error_code noisy_list(R::RADOS& r, int64_t p)
 
   std::cout << "begin = " << b.to_str() << std::endl;
   std::cout << "end = " << e.to_str() << std::endl;
+  R::IOContext pool{p, R::all_nspaces};
   try {
-    auto [v, next] = r.enumerate_objects(p, b, e, 1000, {}, ca::use_blocked,
-                                        R::all_nspaces);
+    auto [v, next] = r.enumerate_objects(pool, b, e, 1000, {}, ca::use_blocked);
 
     std::cout << "Got " << v.size() << " entries." << std::endl;
     std::cout << "next cursor = " << next.to_str() << std::endl;
index 953e772e115b454a223190dbc35f2e1caf673a94..84bb5d96d4ac2461f677c71608aa43d7a990488a 100644 (file)
@@ -29,7 +29,7 @@ TEST_F(TestNeoRADOS, MakeWithLibRADOS) {
 
   // provide pool that doesn't exists -- just testing round-trip
   ASSERT_THROW(
-    rados.execute({"dummy-obj"}, std::numeric_limits<int64_t>::max(),
+    rados.execute({"dummy-obj"}, IOContext{std::numeric_limits<int64_t>::max()},
                   std::move(op), nullptr, ceph::async::use_blocked),
     boost::system::system_error);
 }
index 4c5f8475d394d9d37a86e3a57920a7e402ffabd8..097dedb6e4990c17b379d047f9990f1e000dbcd1 100644 (file)
@@ -67,7 +67,7 @@ void printseq(const V& v, std::ostream& m, F&& f)
                });
 }
 
-std::int64_t lookup_pool(R::RADOS& r, const std::string& pname,
+R::IOContext lookup_pool(R::RADOS& r, const std::string& pname,
                         s::yield_context y)
 {
   bs::error_code ec;
@@ -75,7 +75,7 @@ std::int64_t lookup_pool(R::RADOS& r, const std::string& pname,
   if (ec)
     throw bs::system_error(
       ec, fmt::format("when looking up '{}'", pname));
-  return p;
+  return R::IOContext{p};
 }
 
 
@@ -92,14 +92,15 @@ void lspools(R::RADOS& r, const std::vector<std::string>&,
 void ls(R::RADOS& r, const std::vector<std::string>& p, s::yield_context y)
 {
   const auto& pname = p[0];
-  const auto pool = lookup_pool(r, pname, y);
+  auto pool = lookup_pool(r, pname, y);
+  pool.ns(R::all_nspaces);
 
   std::vector<R::Entry> ls;
   R::Cursor next = R::Cursor::begin();
   bs::error_code ec;
   do {
     std::tie(ls, next) = r.enumerate_objects(pool, next, R::Cursor::end(),
-                                            1000, {}, y[ec], R::all_nspaces);
+                                            1000, {}, y[ec]);
     if (ec)
       throw bs::system_error(ec, fmt::format("when listing {}", pname));
     printseq(ls, std::cout);
@@ -212,7 +213,7 @@ void read(R::RADOS& r, const std::vector<std::string>& p, s::yield_context y)
       throw bs::system_error(
        ec,
        fmt::format("when reading from object '{}' in pool '{}'",
-                   obj, pool));
+                   obj, pool.pool()));
 
     off += bl.length();
     bl.write_stream(std::cout);