From: Adam Emerson Date: Tue, 28 Nov 2023 17:28:41 +0000 (-0500) Subject: neorados: Remove broken out duplicates of calls X-Git-Tag: v19.3.0~349^2~41 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b19e15cb238b41d38c81fd00063906baf7816fdc;p=ceph.git neorados: Remove broken out duplicates of calls Make everything use IOContext rather than duplicating everything with versions taking a separate pool, namespace, and key. Signed-off-by: Adam Emerson --- diff --git a/src/include/neorados/RADOS.hpp b/src/include/neorados/RADOS.hpp index b4f48d12ffc..258a2ead5ff 100644 --- a/src/include/neorados/RADOS.hpp +++ b/src/include/neorados/RADOS.hpp @@ -575,36 +575,6 @@ public: return init.result.get(); } - template - auto execute(const Object& o, std::int64_t pool, - ReadOp&& op, - ceph::buffer::list* bl, - CompletionToken&& token, - std::optional ns = {}, - std::optional key = {}, - uint64_t* objver = nullptr) { - boost::asio::async_completion 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 - auto execute(const Object& o, std::int64_t pool, WriteOp&& op, - CompletionToken&& token, - std::optional ns = {}, - std::optional key = {}, - uint64_t* objver = nullptr) { - boost::asio::async_completion 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 - auto watch(const Object& o, std::int64_t pool, - std::optional timeout, - WatchCB&& cb, CompletionToken&& token, - std::optional ns = {}, - std::optional key = {}) { - boost::asio::async_completion 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 auto notify_ack(const Object& o, const IOContext& ioc, @@ -784,23 +740,6 @@ public: return init.result.get(); } - template - 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 ns = {}, - std::optional key = {}) { - boost::asio::async_completion 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 auto unwatch(uint64_t cookie, const IOContext& ioc, CompletionToken&& token) { @@ -811,19 +750,6 @@ public: return init.result.get(); } - template - auto unwatch(uint64_t cookie, std::int64_t pool, - CompletionToken&& token, - std::optional ns = {}, - std::optional key = {}) { - boost::asio::async_completion 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 - auto notify(const Object& oid, std::int64_t pool, ceph::buffer::list&& bl, - std::optional timeout, - CompletionToken&& token, - std::optional ns = {}, - std::optional key = {}) { - boost::asio::async_completion 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 - 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 ns = {}, - std::optional key = {}) { - boost::asio::async_completion 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; @@ -984,18 +880,6 @@ private: std::unique_ptr 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 c, - std::optional ns, - std::optional key, - uint64_t* objver); - - void execute(const Object& o, std::int64_t pool, WriteOp&& op, - std::unique_ptr c, - std::optional ns, - std::optional key, - uint64_t* objver); - void lookup_pool(std::string_view name, std::unique_ptr c); void list_pools(std::unique_ptr 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 timeout, WatchCB&& cb, std::unique_ptr c); - void watch(const Object& o, std::int64_t pool, - std::optional timeout, - WatchCB&& cb, std::unique_ptr c, - std::optional ns, - std::optional key); tl::expected 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); - void notify_ack(const Object& o, - std::int64_t pool, - uint64_t notify_id, - uint64_t cookie, - ceph::buffer::list&& bl, - std::unique_ptr, - std::optional ns, - std::optional key); void unwatch(uint64_t cookie, const IOContext& ioc, std::unique_ptr); - void unwatch(uint64_t cookie, std::int64_t pool, - std::unique_ptr, - std::optional ns, - std::optional key); void notify(const Object& oid, const IOContext& ioctx, ceph::buffer::list&& bl, std::optional timeout, std::unique_ptr c); - void notify(const Object& oid, std::int64_t pool, - ceph::buffer::list&& bl, - std::optional timeout, - std::unique_ptr c, - std::optional ns, - std::optional key); void flush_watch(std::unique_ptr); void enumerate_objects(const IOContext& ioc, const Cursor& begin, @@ -1064,24 +925,10 @@ private: std::vector* ls, Cursor* cursor, std::unique_ptr 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* ls, - Cursor* cursor, - std::unique_ptr c, - std::optional ns, - std::optional 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 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 c, - std::optional ns, - std::optional key); void osd_command(int osd, std::vector&& cmd, ceph::buffer::list&& in, std::unique_ptr c); void pg_command(PG pg, std::vector&& cmd, diff --git a/src/neorados/RADOS.cc b/src/neorados/RADOS.cc index 93f02b1ae70..667127d1125 100644 --- a/src/neorados/RADOS.cc +++ b/src/neorados/RADOS.cc @@ -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 c, - std::optional ns, - std::optional key, - version_t* objver) { - auto oid = reinterpret_cast(&o.impl); - auto op = reinterpret_cast(&_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 c, - std::optional ns, - std::optional key, - version_t* objver) { - auto oid = reinterpret_cast(&o.impl); - auto op = reinterpret_cast(&_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 timeout, WatchCB&& cb, - std::unique_ptr c, - std::optional ns, - std::optional key) { - auto oid = reinterpret_cast(&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 c, - std::optional ns, - std::optional key) { - auto oid = reinterpret_cast(&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 RADOS::watch_check(uint64_t cookie) { Objecter::LingerOp *linger_op = reinterpret_cast(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 c, - std::optional ns, - std::optional key) -{ - object_locator_t oloc; - oloc.pool = pool; - if (ns) - oloc.nspace = *ns; - if (key) - oloc.key = *key; - - Objecter::LingerOp *linger_op = reinterpret_cast(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 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 timeout, - std::unique_ptr c, - std::optional ns, - std::optional key) -{ - auto oid = reinterpret_cast(&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(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 c, - std::optional ns, - std::optional key) { - impl->objecter->enumerate_objects( - pool, - ns ? *ns : std::string_view{}, - *reinterpret_cast(&begin.impl), - *reinterpret_cast(&end.impl), - max, - filter, - [c = std::move(c)] - (bs::error_code ec, std::vector&& v, - hobject_t&& n) mutable { - ca::dispatch(std::move(c), ec, std::move(v), - Cursor(static_cast(&n))); - }); -} - - void RADOS::osd_command(int osd, std::vector&& cmd, ceph::bufferlist&& in, std::unique_ptr c) { impl->objecter->osd_command(osd, std::move(cmd), std::move(in), nullptr, diff --git a/src/test/neorados/list_pool.cc b/src/test/neorados/list_pool.cc index ae36c36e655..4a1dc9cb7b1 100644 --- a/src/test/neorados/list_pool.cc +++ b/src/test/neorados/list_pool.cc @@ -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; diff --git a/src/test/neorados/test_neorados.cc b/src/test/neorados/test_neorados.cc index 953e772e115..84bb5d96d4a 100644 --- a/src/test/neorados/test_neorados.cc +++ b/src/test/neorados/test_neorados.cc @@ -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::max(), + rados.execute({"dummy-obj"}, IOContext{std::numeric_limits::max()}, std::move(op), nullptr, ceph::async::use_blocked), boost::system::system_error); } diff --git a/src/tools/neorados.cc b/src/tools/neorados.cc index 4c5f8475d39..097dedb6e49 100644 --- a/src/tools/neorados.cc +++ b/src/tools/neorados.cc @@ -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&, void ls(R::RADOS& r, const std::vector& 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 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& 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);