summaryrefslogtreecommitdiffstats
path: root/src/librbd/migration/SourceSpecBuilder.h
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2024-07-18 18:11:18 +0200
committerIlya Dryomov <idryomov@gmail.com>2024-07-30 23:05:51 +0200
commitcacf7ca941876f64f9a04867ffc6cdcb484d89b9 (patch)
treeccf55e277fc66805abf1de53107e87368101bbeb /src/librbd/migration/SourceSpecBuilder.h
parentlibrbd/migration/NativeFormat: refactor source spec parsing (diff)
downloadceph-cacf7ca941876f64f9a04867ffc6cdcb484d89b9.tar.xz
ceph-cacf7ca941876f64f9a04867ffc6cdcb484d89b9.zip
librbd/migration: don't instantiate NativeFormat, handle it via dispatch
Trying to shoehorn NativeFormat under FormatInterface doesn't really work. It fundamentally doesn't fit in: - Unlike for RawFormat and QCOWFormat, src_image_ctx for NativeFormat is not dummy -- it's an ImageCtx for a real RBD image. Pre-creating it in OpenSourceImageRequest with the expectation that placeholder values would be overridden later forces NativeFormat to reach into ImageCtx guts, duplicating the logic in the constructor. This also necessitates calling snap_set() in a separate step, since snap_id isn't known at the time ImageCtx is created. - Unlike for RawFormat and QCOWFormat, get_image_size() and get_snapshots() implementations for NativeFormat are dummy. - read() and list_snaps() implementations for NativeFormat are inconsistent: read() passes through io::ImageDispatch layer, but list_snaps() doesn't. Both can be passing through, meaning that in essence these are also dummy. All of this is with today's code. Additional complications arise with planned support for migrating from external clusters where src_image_ctx would require more invasive patching to "move" to an IoCtx belonging to an external cluster's CephContext and also with other work. With the above in mind, NativeFormat actually consists of: 1. Code that parses the "type: native" source spec 2. Code that patches ImageCtx, working around the fact that it's pre-created in OpenSourceImageRequest 3. A bunch of dummy implementations for FormatInterface With this change, (1) is wrapped into a static method that also creates ImageCtx after all required parameters are known and (2) and (3) go away entirely. NativeFormat no longer implements FormatInterface and doesn't get instantiated at all. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'src/librbd/migration/SourceSpecBuilder.h')
-rw-r--r--src/librbd/migration/SourceSpecBuilder.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librbd/migration/SourceSpecBuilder.h b/src/librbd/migration/SourceSpecBuilder.h
index 58f83139476..1dd069cfdab 100644
--- a/src/librbd/migration/SourceSpecBuilder.h
+++ b/src/librbd/migration/SourceSpecBuilder.h
@@ -30,7 +30,7 @@ public:
SourceSpecBuilder(ImageCtxT* image_ctx) : m_image_ctx(image_ctx) {
}
- int build_format(const json_spirit::mObject& format_object, bool import_only,
+ int build_format(const json_spirit::mObject& format_object,
std::unique_ptr<FormatInterface>* format) const;
int build_snapshot(const json_spirit::mObject& source_spec_object,