Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librbd: send FLUSH_SOURCE_INTERNAL when do copy/deep_copy. #43659

Merged
merged 1 commit into from Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/librbd/api/Image.cc
Expand Up @@ -26,6 +26,8 @@
#include "librbd/image/PreRemoveRequest.h"
#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/io/ObjectDispatcherInterface.h"
#include "librbd/io/AioCompletion.h"
#include "librbd/io/ImageDispatchSpec.h"
#include <boost/scope_exit.hpp>

#define dout_subsys ceph_subsys_rbd
Expand Down Expand Up @@ -680,6 +682,22 @@ int Image<I>::deep_copy(I *src, librados::IoCtx& dest_md_ctx,
template <typename I>
int Image<I>::deep_copy(I *src, I *dest, bool flatten,
ProgressContext &prog_ctx) {
// ensure previous writes are visible to dest
C_SaferCond flush_ctx;
{
std::shared_lock owner_locker{src->owner_lock};
auto aio_comp = io::AioCompletion::create_and_start(&flush_ctx, src,
io::AIO_TYPE_FLUSH);
auto req = io::ImageDispatchSpec::create_flush(
*src, io::IMAGE_DISPATCH_LAYER_INTERNAL_START,
aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
req->send();
}
int r = flush_ctx.wait();
if (r < 0) {
return r;
}

librados::snap_t snap_id_start = 0;
librados::snap_t snap_id_end;
{
Expand All @@ -696,7 +714,7 @@ int Image<I>::deep_copy(I *src, I *dest, bool flatten,
src, dest, snap_id_start, snap_id_end, 0U, flatten, boost::none,
asio_engine.get_work_queue(), &snap_seqs, &progress_handler, &cond);
req->send();
int r = cond.wait();
r = cond.wait();
if (r < 0) {
return r;
}
Expand Down
17 changes: 16 additions & 1 deletion src/librbd/internal.cc
Expand Up @@ -1281,12 +1281,27 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
return -EINVAL;
}

// ensure previous writes are visible to dest
C_SaferCond flush_ctx;
{
auto aio_comp = io::AioCompletion::create_and_start(&flush_ctx, src,
io::AIO_TYPE_FLUSH);
auto req = io::ImageDispatchSpec::create_flush(
*src, io::IMAGE_DISPATCH_LAYER_INTERNAL_START,
aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
req->send();
}
int r = flush_ctx.wait();
if (r < 0) {
return r;
}

C_SaferCond ctx;
auto req = deep_copy::MetadataCopyRequest<>::create(
src, dest, &ctx);
req->send();

int r = ctx.wait();
r = ctx.wait();
if (r < 0) {
lderr(cct) << "failed to copy metadata: " << cpp_strerror(r) << dendl;
return r;
Expand Down