]>
git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/operation/TrimRequest.h
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_TRIM_REQUEST_H
4 #define CEPH_LIBRBD_OPERATION_TRIM_REQUEST_H
6 #include "librbd/AsyncRequest.h"
12 class ProgressContext
;
16 template <typename ImageCtxT
= ImageCtx
>
17 class TrimRequest
: public AsyncRequest
<ImageCtxT
>
20 static TrimRequest
*create(ImageCtxT
&image_ctx
, Context
*on_finish
,
21 uint64_t original_size
, uint64_t new_size
,
22 ProgressContext
&prog_ctx
) {
23 return new TrimRequest(image_ctx
, on_finish
, original_size
, new_size
,
31 * Trim goes through the following state machine to remove whole objects,
32 * clean partially trimmed objects, and update the object map:
36 * <start> . . . . > STATE_FINISHED . . . . . . . . .
37 * | . . . . . . . . . . > . . . . . . . . . .
39 * STATE_PRE_COPYUP ---> STATE_COPYUP_OBJECTS . .
41 * /-----------------------/ v .
44 * STATE_POST_COPYUP. . . > . . .
45 * | . . . . . . . . . . < . . . . . . . . . .
48 * STATE_PRE_REMOVE ---> STATE_REMOVE_OBJECTS .
50 * /-----------------------/ . . . . . . . .
53 * STATE_POST_REMOVE --> STATE_CLEAN_BOUNDARY ---> <finish>
56 * . . . . . . . . . . . . . . . . . . . . . . .
60 * The _COPYUP_OBJECTS state is skipped if there is no parent overlap
61 * within the new image size and the image does not have any snapshots.
62 * The _PRE_REMOVE/_POST_REMOVE states are skipped if the object map
63 * isn't enabled. The _REMOVE_OBJECTS state is skipped if no whole objects
64 * are removed. The _CLEAN_BOUNDARY state is skipped if no boundary
65 * objects are cleaned. The state machine will immediately transition
66 * to _FINISHED state if there are no bytes to trim.
80 bool should_complete(int r
) override
;
85 uint64_t m_delete_start
;
86 uint64_t m_num_objects
;
87 uint64_t m_delete_off
;
89 ProgressContext
&m_prog_ctx
;
91 uint64_t m_copyup_start
;
92 uint64_t m_copyup_end
;
94 TrimRequest(ImageCtxT
&image_ctx
, Context
*on_finish
,
95 uint64_t original_size
, uint64_t new_size
,
96 ProgressContext
&prog_ctx
);
98 void send_pre_copyup();
99 void send_copyup_objects();
100 void send_post_copyup();
102 void send_pre_remove();
103 void send_remove_objects();
104 void send_post_remove();
106 void send_clean_boundary();
107 void send_finish(int r
);
110 } // namespace operation
111 } // namespace librbd
113 extern template class librbd::operation::TrimRequest
<librbd::ImageCtx
>;
115 #endif // CEPH_LIBRBD_OPERATION_TRIM_REQUEST_H