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_FLATTEN_REQUEST_H
4 #define CEPH_LIBRBD_OPERATION_FLATTEN_REQUEST_H
6 #include "librbd/operation/Request.h"
7 #include "common/snap_types.h"
8 #include "librbd/Types.h"
13 class ProgressContext;
17 template <typename ImageCtxT = ImageCtx>
18 class FlattenRequest : public Request<ImageCtxT>
21 FlattenRequest(ImageCtxT &image_ctx, Context *on_finish,
22 uint64_t object_size, uint64_t overlap_objects,
23 const ::SnapContext &snapc, ProgressContext &prog_ctx)
24 : Request<ImageCtxT>(image_ctx, on_finish), m_object_size(object_size),
25 m_overlap_objects(overlap_objects), m_snapc(snapc), m_prog_ctx(prog_ctx),
26 m_ignore_enoent(false)
31 void send_op() override;
32 bool should_complete(int r) override;
34 journal::Event create_event(uint64_t op_tid) const override {
35 return journal::FlattenEvent(op_tid);
40 * Flatten goes through the following state machine to copyup objects
41 * from the parent image:
48 * STATE_FLATTEN_OBJECTS ---> STATE_UPDATE_HEADER . . . . .
52 * . STATE_UPDATE_CHILDREN .
55 * . \---> <finish> < . .
58 * . . . . . . . . . . . . . . . . . . .
62 * The _UPDATE_CHILDREN state will be skipped if the image has one or
63 * more snapshots. The _UPDATE_HEADER state will be skipped if the
64 * image was concurrently flattened by another client.
67 STATE_FLATTEN_OBJECTS,
72 uint64_t m_object_size;
73 uint64_t m_overlap_objects;
74 ::SnapContext m_snapc;
75 ProgressContext &m_prog_ctx;
78 ParentSpec m_parent_spec;
81 bool send_update_header();
82 bool send_update_children();
85 } // namespace operation
88 extern template class librbd::operation::FlattenRequest<librbd::ImageCtx>;
90 #endif // CEPH_LIBRBD_OPERATION_FLATTEN_REQUEST_H