]> git.apps.os.sepia.ceph.com Git - ceph.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>
Tue, 30 Jul 2024 21:05:51 +0000 (23:05 +0200)
commitcacf7ca941876f64f9a04867ffc6cdcb484d89b9
treeccf55e277fc66805abf1de53107e87368101bbeb
parent3bbf1f5ddbaa4a8c252d70a384e23852f0c537c1
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>
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