1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_IO_COPYUP_REQUEST_H
5 #define CEPH_LIBRBD_IO_COPYUP_REQUEST_H
7 #include "include/int_types.h"
8 #include "include/rados/librados.hpp"
9 #include "include/buffer.h"
10 #include "common/zipkin_trace.h"
11 #include "librbd/io/AsyncOperation.h"
12 #include "librbd/io/Types.h"
18 namespace ZTracer { struct Trace; }
27 template <typename I> class ObjectRequest;
31 CopyupRequest(ImageCtx *ictx, const std::string &oid, uint64_t objectno,
32 Extents &&image_extents, const ZTracer::Trace &parent_trace);
35 void append_request(ObjectRequest<ImageCtx> *req);
43 * Copyup requests go through the following state machine to read from the
44 * parent image, update the object map, and copyup the object:
52 * . . .STATE_READ_FROM_PARENT. . .
55 * . . STATE_OBJECT_MAP_HEAD v (copy on read /
56 * . . | . no HEAD rev. update)
58 * . . STATE_OBJECT_MAP. . . . .
61 * . . . . > STATE_COPYUP
68 * The _OBJECT_MAP state is skipped if the object map isn't enabled or if
69 * an object map update isn't required. The _COPYUP state is skipped if
70 * no data was read from the parent *and* there are no additional ops.
73 STATE_READ_FROM_PARENT,
74 STATE_OBJECT_MAP_HEAD, // only update the HEAD revision
75 STATE_OBJECT_MAP, // update HEAD+snaps (if any)
82 Extents m_image_extents;
83 ZTracer::Trace m_trace;
86 ceph::bufferlist m_copyup_data;
87 std::vector<ObjectRequest<ImageCtx> *> m_pending_requests;
88 std::atomic<unsigned> m_pending_copyups { 0 };
90 AsyncOperation m_async_op;
92 std::vector<uint64_t> m_snap_ids;
93 librados::IoCtx m_data_ctx; // for empty SnapContext
95 void complete_requests(int r);
97 bool should_complete(int r);
99 void remove_from_list();
101 bool send_object_map_head();
102 bool send_object_map();
104 bool is_copyup_required();
108 } // namespace librbd
110 #endif // CEPH_LIBRBD_IO_COPYUP_REQUEST_H