#include "cls/journal/cls_journal_types.h"
#include "cls/journal/cls_journal_client.h"
+#include "librbd/AsioEngine.h"
#include "librbd/ExclusiveLock.h"
#include "librbd/ImageCtx.h"
#include "librbd/ImageState.h"
#include "librbd/Journal.h"
#include "librbd/ObjectMap.h"
#include "librbd/Operations.h"
+#include "librbd/PluginRegistry.h"
#include "librbd/Types.h"
#include "librbd/Utils.h"
#include "librbd/api/Config.h"
#include "librbd/api/Image.h"
+#include "librbd/api/Io.h"
+#include "librbd/cache/Utils.h"
#include "librbd/exclusive_lock/AutomaticPolicy.h"
#include "librbd/exclusive_lock/StandardPolicy.h"
#include "librbd/deep_copy/MetadataCopyRequest.h"
#include "librbd/image/GetMetadataRequest.h"
#include "librbd/image/Types.h"
#include "librbd/io/AioCompletion.h"
-#include "librbd/io/ImageRequest.h"
-#include "librbd/io/ImageRequestWQ.h"
-#include "librbd/io/ObjectDispatcher.h"
+#include "librbd/io/ImageDispatchSpec.h"
+#include "librbd/io/ImageDispatcherInterface.h"
+#include "librbd/io/ObjectDispatcherInterface.h"
#include "librbd/io/ObjectRequest.h"
#include "librbd/io/ReadResult.h"
#include "librbd/journal/Types.h"
int obj_order = ictx->order;
{
std::shared_lock locker{ictx->image_lock};
- info.size = ictx->get_image_size(ictx->snap_id);
+ info.size = ictx->get_effective_image_size(ictx->snap_id);
}
info.obj_size = 1ULL << obj_order;
info.num_objs = Striper::get_num_objects(ictx->layout, info.size);
lderr(cct) << "Forced V1 image creation. " << dendl;
r = create_v1(io_ctx, image_name.c_str(), size, order);
} else {
- ThreadPool *thread_pool;
- ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ AsioEngine asio_engine(io_ctx);
ConfigProxy config{cct->_conf};
api::Config<>::apply_pool_overrides(io_ctx, &config);
image::CreateRequest<> *req = image::CreateRequest<>::create(
config, io_ctx, image_name, id, size, opts, create_flags,
static_cast<cls::rbd::MirrorImageMode>(mirror_image_mode),
- non_primary_global_image_id, primary_mirror_uuid, op_work_queue, &cond);
+ non_primary_global_image_id, primary_mirror_uuid,
+ asio_engine.get_work_queue(), &cond);
req->send();
r = cond.wait();
ConfigProxy config{reinterpret_cast<CephContext *>(c_ioctx.cct())->_conf};
api::Config<>::apply_pool_overrides(c_ioctx, &config);
- ThreadPool *thread_pool;
- ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+ AsioEngine asio_engine(p_ioctx);
C_SaferCond cond;
auto *req = image::CloneRequest<>::create(
config, p_ioctx, parent_id, p_snap_name,
{cls::rbd::UserSnapshotNamespace{}}, CEPH_NOSNAP, c_ioctx, c_name,
clone_id, c_opts, cls::rbd::MIRROR_IMAGE_MODE_JOURNAL,
- non_primary_global_image_id, primary_mirror_uuid, op_work_queue, &cond);
+ non_primary_global_image_id, primary_mirror_uuid,
+ asio_engine.get_work_queue(), &cond);
req->send();
r = cond.wait();
if (r < 0)
return r;
std::shared_lock l2{ictx->image_lock};
- *size = ictx->get_image_size(ictx->snap_id);
+ *size = ictx->get_effective_image_size(ictx->snap_id);
return 0;
}
return 0;
}
- // might have been blacklisted by peer -- ensure we still own
+ // might have been blocklisted by peer -- ensure we still own
// the lock by pinging the OSD
int r = ictx->exclusive_lock->assert_header_locked();
if (r == -EBUSY || r == -ENOENT) {
auto comp = io::AioCompletion::create(ctx);
// coordinate through AIO WQ to ensure lock is acquired if needed
- m_dest->io_work_queue->aio_write(comp, m_offset + write_offset,
- write_length,
- std::move(*write_bl),
- LIBRADOS_OP_FLAG_FADVISE_DONTNEED,
- std::move(read_trace));
+ api::Io<>::aio_write(*m_dest, comp, m_offset + write_offset,
+ write_length, std::move(*write_bl),
+ LIBRADOS_OP_FLAG_FADVISE_DONTNEED,
+ std::move(read_trace));
write_offset = offset;
write_length = 0;
}
trace.init("copy", &src->trace_endpoint);
}
- std::shared_lock owner_lock{src->owner_lock};
SimpleThrottle throttle(src->config.get_val<uint64_t>("rbd_concurrent_management_ops"), false);
uint64_t period = src->get_stripe_period();
unsigned fadvise_flags = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL |
auto ctx = new C_CopyRead(&throttle, dest, offset, bl, sparse_size);
auto comp = io::AioCompletion::create_and_start<Context>(
ctx, src, io::AIO_TYPE_READ);
+ auto req = io::ImageDispatchSpec::create_read(
+ *src, io::IMAGE_DISPATCH_LAYER_NONE, comp,
+ {{offset, len}}, io::ReadResult{bl},
+ src->get_data_io_context(), fadvise_flags, 0, trace);
- io::ImageReadRequest<> req(*src, comp, {{offset, len}},
- io::ReadResult{bl}, fadvise_flags,
- std::move(trace));
- ctx->read_trace = req.get_trace();
+ ctx->read_trace = trace;
+ req->send();
- req.send();
prog_ctx.update_progress(offset, src_size);
}
{
std::shared_lock locker{ictx->image_lock};
r = rados::cls::lock::lock(&ictx->md_ctx, ictx->header_oid, RBD_LOCK_NAME,
- exclusive ? LOCK_EXCLUSIVE : LOCK_SHARED,
+ exclusive ? ClsLockType::EXCLUSIVE : ClsLockType::SHARED,
cookie, tag, "", utime_t(), 0);
if (r < 0) {
return r;
return -EINVAL;
}
- if (ictx->config.get_val<bool>("rbd_blacklist_on_break_lock")) {
+ if (ictx->config.get_val<bool>("rbd_blocklist_on_break_lock")) {
typedef std::map<rados::cls::lock::locker_id_t,
rados::cls::lock::locker_info_t> Lockers;
Lockers lockers;
}
librados::Rados rados(ictx->md_ctx);
- r = rados.blacklist_add(
+ r = rados.blocklist_add(
client_address,
- ictx->config.get_val<uint64_t>("rbd_blacklist_expire_seconds"));
+ ictx->config.get_val<uint64_t>("rbd_blocklist_expire_seconds"));
if (r < 0) {
- lderr(ictx->cct) << "unable to blacklist client: " << cpp_strerror(r)
+ lderr(ictx->cct) << "unable to blocklist client: " << cpp_strerror(r)
<< dendl;
return r;
}
C_SaferCond ctx;
auto c = io::AioCompletion::create_and_start(&ctx, ictx,
io::AIO_TYPE_READ);
- io::ImageRequest<>::aio_read(ictx, c, {{off, read_len}},
- io::ReadResult{&bl}, 0, std::move(trace));
+ auto req = io::ImageDispatchSpec::create_read(
+ *ictx, io::IMAGE_DISPATCH_LAYER_NONE, c,
+ {{off, read_len}}, io::ReadResult{&bl},
+ ictx->get_data_io_context(), 0, 0, trace);
+ req->send();
int ret = ctx.wait();
if (ret < 0) {
int clip_io(ImageCtx *ictx, uint64_t off, uint64_t *len)
{
ceph_assert(ceph_mutex_is_locked(ictx->image_lock));
- uint64_t image_size = ictx->get_image_size(ictx->snap_id);
- bool snap_exists = ictx->snap_exists;
- if (!snap_exists)
+ if (ictx->snap_id != CEPH_NOSNAP &&
+ ictx->get_snap_info(ictx->snap_id) == nullptr) {
return -ENOENT;
+ }
+ uint64_t image_size = ictx->get_effective_image_size(ictx->snap_id);
// special-case "len == 0" requests: always valid
if (*len == 0)
C_SaferCond ctx;
{
- std::shared_lock owner_locker{ictx->owner_lock};
- ictx->io_object_dispatcher->invalidate_cache(&ctx);
+ ictx->io_image_dispatcher->invalidate_cache(&ctx);
}
r = ctx.wait();
+
+ if (r < 0) {
+ ldout(cct, 20) << "failed to invalidate image cache" << dendl;
+ return r;
+ }
+
ictx->perfcounter->inc(l_librbd_invalidate_cache);
+
+ // Delete writeback cache if it is not initialized
+ if ((!ictx->exclusive_lock ||
+ !ictx->exclusive_lock->is_lock_owner()) &&
+ ictx->test_features(RBD_FEATURE_DIRTY_CACHE)) {
+ C_SaferCond ctx3;
+ ictx->plugin_registry->discard(&ctx3);
+ r = ctx3.wait();
+ }
return r;
}