1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #ifndef CEPH_LIBRBD_OPERATION_REBUILD_OBJECT_MAP_REQUEST_H
4 #define CEPH_LIBRBD_OPERATION_REBUILD_OBJECT_MAP_REQUEST_H
6 #include "include/int_types.h"
7 #include "librbd/AsyncRequest.h"
12 class ProgressContext;
16 template <typename ImageCtxT = ImageCtx>
17 class RebuildObjectMapRequest : public AsyncRequest<ImageCtxT> {
20 RebuildObjectMapRequest(ImageCtxT &image_ctx, Context *on_finish,
21 ProgressContext &prog_ctx)
22 : AsyncRequest<ImageCtxT>(image_ctx, on_finish), m_image_ctx(image_ctx),
23 m_prog_ctx(prog_ctx), m_attempted_trim(false)
30 bool should_complete(int r) override;
34 * Rebuild object map goes through the following state machine to
35 * verify per-object state:
38 * . | . . . . . . . . . .
41 * . STATE_RESIZE_OBJECT_MAP . . . > STATE_TRIM_IMAGE
44 * . . . > STATE_VERIFY_OBJECTS
47 * STATE_SAVE_OBJECT_MAP
52 * The _RESIZE_OBJECT_MAP state will be skipped if the object map
53 * is appropriately sized for the image. The _TRIM_IMAGE state will
54 * only be hit if the resize failed due to an in-use object.
57 STATE_RESIZE_OBJECT_MAP,
60 STATE_SAVE_OBJECT_MAP,
64 ImageCtxT &m_image_ctx;
65 ProgressContext &m_prog_ctx;
67 bool m_attempted_trim;
69 void send_resize_object_map();
70 void send_trim_image();
71 void send_verify_objects();
72 void send_save_object_map();
73 void send_update_header();
75 uint64_t get_image_size() const;
79 } // namespace operation
82 extern template class librbd::operation::RebuildObjectMapRequest<librbd::ImageCtx>;
84 #endif // CEPH_LIBRBD_OPERATION_REBUILD_OBJECT_MAP_REQUEST_H