Skip to content

Commit 72b2c44

Browse files
authored
Merge pull request ceph#58882 from idryomov/wip-native-format-dispatch
librbd/migration: don't instantiate NativeFormat, handle it via dispatch Reviewed-by: Ramana Raja <[email protected]> Reviewed-by: N Balachandran <[email protected]>
2 parents cbe442d + b6c7f69 commit 72b2c44

19 files changed

+321
-403
lines changed

src/librbd/api/Migration.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ int Migration<I>::prepare_import(
540540
return r;
541541
}
542542

543-
auto asio_engine = src_image_ctx->asio_engine;
544543
BOOST_SCOPE_EXIT_TPL(src_image_ctx) {
545544
src_image_ctx->state->close();
546545
} BOOST_SCOPE_EXIT_END;
@@ -581,11 +580,6 @@ int Migration<I>::prepare_import(
581580
Migration migration(src_image_ctx, dst_image_ctx, dst_migration_spec,
582581
opts, nullptr);
583582
return migration.prepare_import();
584-
if (r < 0) {
585-
return r;
586-
}
587-
588-
return 0;
589583
}
590584

591585
template <typename I>

src/librbd/migration/FileStream.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct FileStream<I>::ReadRequest {
7474
auto offset = lseek64(file_stream->m_file_no, byte_extent.first, SEEK_SET);
7575
if (offset == -1) {
7676
r = -errno;
77-
lderr(cct) << "failed to seek file stream: " << cpp_strerror(r) << dendl;
77+
lderr(cct) << "failed to seek file: " << cpp_strerror(r) << dendl;
7878
finish(r);
7979
return;
8080
}
@@ -149,7 +149,7 @@ void FileStream<I>::open(Context* on_finish) {
149149
m_file_no = ::open(file_path.c_str(), O_RDONLY);
150150
if (m_file_no < 0) {
151151
int r = -errno;
152-
lderr(m_cct) << "failed to open file stream '" << file_path << "': "
152+
lderr(m_cct) << "failed to open file '" << file_path << "': "
153153
<< cpp_strerror(r) << dendl;
154154
on_finish->complete(r);
155155
return;

src/librbd/migration/FormatInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct FormatInterface {
3535
virtual void get_image_size(uint64_t snap_id, uint64_t* size,
3636
Context* on_finish) = 0;
3737

38-
virtual bool read(io::AioCompletion* aio_comp, uint64_t snap_id,
38+
virtual void read(io::AioCompletion* aio_comp, uint64_t snap_id,
3939
io::Extents&& image_extents, io::ReadResult&& read_result,
4040
int op_flags, int read_flags,
4141
const ZTracer::Trace &parent_trace) = 0;

src/librbd/migration/HttpClient.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class HttpClient<I>::HttpSession : public HttpSessionInterface {
283283
ldout(cct, 15) << "r=" << r << dendl;
284284

285285
if (r < 0) {
286-
lderr(cct) << "failed to disconnect stream: '" << cpp_strerror(r)
286+
lderr(cct) << "failed to disconnect stream: " << cpp_strerror(r)
287287
<< dendl;
288288
}
289289

@@ -350,7 +350,7 @@ class HttpClient<I>::HttpSession : public HttpSessionInterface {
350350
ldout(cct, 15) << "r=" << r << dendl;
351351

352352
if (r < 0) {
353-
lderr(cct) << "failed to disconnect stream: '" << cpp_strerror(r)
353+
lderr(cct) << "failed to disconnect stream: " << cpp_strerror(r)
354354
<< dendl;
355355
}
356356

src/librbd/migration/ImageDispatch.cc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,17 @@ bool ImageDispatch<I>::read(
4343
auto cct = m_image_ctx->cct;
4444
ldout(cct, 20) << dendl;
4545

46+
// let io::ImageDispatch layer (IMAGE_DISPATCH_LAYER_CORE) handle
47+
// native format
48+
if (!m_format) {
49+
return false;
50+
}
51+
4652
*dispatch_result = io::DISPATCH_RESULT_COMPLETE;
47-
return m_format->read(aio_comp, io_context->get_read_snap(),
48-
std::move(image_extents), std::move(read_result),
49-
op_flags, read_flags, parent_trace);
53+
m_format->read(aio_comp, io_context->get_read_snap(),
54+
std::move(image_extents), std::move(read_result),
55+
op_flags, read_flags, parent_trace);
56+
return true;
5057
}
5158

5259
template <typename I>
@@ -132,6 +139,12 @@ bool ImageDispatch<I>::list_snaps(
132139
auto cct = m_image_ctx->cct;
133140
ldout(cct, 20) << dendl;
134141

142+
// let io::ImageDispatch layer (IMAGE_DISPATCH_LAYER_CORE) handle
143+
// native format
144+
if (!m_format) {
145+
return false;
146+
}
147+
135148
*dispatch_result = io::DISPATCH_RESULT_COMPLETE;
136149

137150
aio_comp->set_request_count(1);

src/librbd/migration/ImageDispatch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class ImageDispatch : public io::ImageDispatchInterface {
8686

8787
private:
8888
ImageCtxT* m_image_ctx;
89+
90+
// empty (nullptr) for native format
8991
std::unique_ptr<FormatInterface> m_format;
9092

9193
void fail_io(int r, io::AioCompletion* aio_comp,

0 commit comments

Comments
 (0)