- ObjectRemoveRequest(ImageCtx *ictx, const std::string &oid,
- uint64_t object_no, const ::SnapContext &snapc,
- const ZTracer::Trace &parent_trace, Context *completion)
- : AbstractObjectWriteRequest(ictx, oid, object_no, 0, 0, snapc, true,
- "remote", parent_trace, completion),
- m_object_state(OBJECT_NONEXISTENT) {
- }
-
- const char* get_op_type() const override {
- if (has_parent()) {
- return "remove (trunc)";
- }
- return "remove";
- }
-
- bool pre_object_map_update(uint8_t *new_state) override {
- if (has_parent()) {
- m_object_state = OBJECT_EXISTS;
+ ObjectDiscardRequest(ImageCtxT *ictx, const std::string &oid,
+ uint64_t object_no, uint64_t object_off,
+ uint64_t object_len, const ::SnapContext &snapc,
+ bool disable_clone_remove, bool update_object_map,
+ const ZTracer::Trace &parent_trace, Context *completion)
+ : AbstractObjectWriteRequest<ImageCtxT>(ictx, oid, object_no, object_off,
+ object_len, snapc, "discard",
+ parent_trace, completion),
+ m_update_object_map(update_object_map) {
+ if (this->m_full_object) {
+ if (disable_clone_remove && this->has_parent()) {
+ // need to hide the parent object instead of child object
+ m_discard_action = DISCARD_ACTION_REMOVE_TRUNCATE;
+ this->m_object_len = 0;
+ } else {
+ m_discard_action = DISCARD_ACTION_REMOVE;
+ }
+ } else if (object_off + object_len == ictx->layout.object_size) {
+ m_discard_action = DISCARD_ACTION_TRUNCATE;