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,
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,
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) {
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
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,
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>;
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,
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,
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,
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,
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;
}
}), 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,
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);
}));
}
-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 {
}), 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() {
});
}
-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,