]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
librbd/migration: don't instantiate NativeFormat, handle it via dispatch
authorIlya Dryomov <idryomov@gmail.com>
Thu, 18 Jul 2024 16:11:18 +0000 (18:11 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 11 Aug 2024 17:14:03 +0000 (19:14 +0200)
commite3e6e9c0858d68525778dc55e3327c2374e4d098
tree74f04d7f7df314dd8b38d4038aa872ec1eb1489e
parent0d80b6a14f08a2bb19fb714a44a0e8b898bfb7b5
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>
(cherry picked from commit cacf7ca941876f64f9a04867ffc6cdcb484d89b9)
src/librbd/migration/ImageDispatch.cc
src/librbd/migration/ImageDispatch.h
src/librbd/migration/NativeFormat.cc
src/librbd/migration/NativeFormat.h
src/librbd/migration/OpenSourceImageRequest.cc
src/librbd/migration/OpenSourceImageRequest.h
src/librbd/migration/SourceSpecBuilder.cc
src/librbd/migration/SourceSpecBuilder.h