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 "librbd/AsyncOperation.h"
8 #include "include/int_types.h"
9 #include "include/rados/librados.hpp"
10 #include "include/buffer.h"
11 #include "librbd/io/Types.h"
24 template <typename I
> class ObjectRequest
;
28 CopyupRequest(ImageCtx
*ictx
, const std::string
&oid
, uint64_t objectno
,
29 Extents
&&image_extents
);
32 void append_request(ObjectRequest
<ImageCtx
> *req
);
40 * Copyup requests go through the following state machine to read from the
41 * parent image, update the object map, and copyup the object:
49 * . . .STATE_READ_FROM_PARENT. . .
52 * . . STATE_OBJECT_MAP_HEAD v (copy on read /
53 * . . | . no HEAD rev. update)
55 * . . STATE_OBJECT_MAP. . . . .
58 * . . . . > STATE_COPYUP
65 * The _OBJECT_MAP state is skipped if the object map isn't enabled or if
66 * an object map update isn't required. The _COPYUP state is skipped if
67 * no data was read from the parent *and* there are no additional ops.
70 STATE_READ_FROM_PARENT
,
71 STATE_OBJECT_MAP_HEAD
, // only update the HEAD revision
72 STATE_OBJECT_MAP
, // update HEAD+snaps (if any)
79 Extents m_image_extents
;
81 ceph::bufferlist m_copyup_data
;
82 std::vector
<ObjectRequest
<ImageCtx
> *> m_pending_requests
;
83 std::atomic
<unsigned> m_pending_copyups
{ 0 };
85 AsyncOperation m_async_op
;
87 std::vector
<uint64_t> m_snap_ids
;
88 librados::IoCtx m_data_ctx
; // for empty SnapContext
90 void complete_requests(int r
);
92 bool should_complete(int r
);
94 void remove_from_list();
96 bool send_object_map_head();
97 bool send_object_map();
99 bool is_copyup_required();
103 } // namespace librbd
105 #endif // CEPH_LIBRBD_IO_COPYUP_REQUEST_H