]>
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
,
27 TrimRequest(ImageCtxT
&image_ctx
, Context
*on_finish
,
28 uint64_t original_size
, uint64_t new_size
,
29 ProgressContext
&prog_ctx
);
35 * Trim goes through the following state machine to remove whole objects,
36 * clean partially trimmed objects, and update the object map:
40 * <start> . . . . . . . . . . . . . . . . .
42 * v (skip if not needed) .
45 * v (skip if not needed) .
46 * STATE_COPYUP_OBJECTS .
48 * v (skip if not needed) .
49 * STATE_REMOVE_OBJECTS .
51 * v (skip if not needed) .
54 * v (skip if not needed) .
55 * STATE_CLEAN_BOUNDARY .
58 * STATE_FINISHED < . . . . . . . . . . . . . . .
63 * The _COPYUP_OBJECTS state is skipped if there is no parent overlap
64 * within the new image size and the image does not have any snapshots.
65 * The _PRE_TRIM/_POST_TRIM states are skipped if the object map
66 * isn't enabled. The _REMOVE_OBJECTS state is skipped if no whole objects
67 * are removed. The _CLEAN_BOUNDARY state is skipped if no boundary
68 * objects are cleaned. The state machine will immediately transition
69 * to _FINISHED state if there are no bytes to trim.
81 bool should_complete(int r
) override
;
83 State m_state
= STATE_PRE_TRIM
;
86 uint64_t m_delete_start
;
87 uint64_t m_delete_start_min
= 0;
88 uint64_t m_num_objects
;
89 uint64_t m_delete_off
;
91 ProgressContext
&m_prog_ctx
;
94 void send_copyup_objects();
95 void send_remove_objects();
96 void send_post_trim();
98 void send_clean_boundary();
99 void send_finish(int r
);
102 } // namespace operation
103 } // namespace librbd
105 extern template class librbd::operation::TrimRequest
<librbd::ImageCtx
>;
107 #endif // CEPH_LIBRBD_OPERATION_TRIM_REQUEST_H