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_RENAME_REQUEST_H
5 #define CEPH_LIBRBD_RENAME_REQUEST_H
7 #include "librbd/operation/Request.h"
18 template <typename ImageCtxT
= ImageCtx
>
19 class RenameRequest
: public Request
<ImageCtxT
>
23 * Rename goes through the following state machine:
30 * STATE_READ_SOURCE_HEADER
33 * STATE_WRITE_DEST_HEADER
36 * STATE_UPDATE_DIRECTORY
39 * STATE_REMOVE_SOURCE_HEADER
48 STATE_READ_SOURCE_HEADER
,
49 STATE_WRITE_DEST_HEADER
,
50 STATE_UPDATE_DIRECTORY
,
51 STATE_REMOVE_SOURCE_HEADER
54 RenameRequest(ImageCtxT
&image_ctx
, Context
*on_finish
,
55 const std::string
&dest_name
);
58 void send_op() override
;
59 bool should_complete(int r
) override
;
60 int filter_return_code(int r
) const override
;
62 journal::Event
create_event(uint64_t op_tid
) const override
{
63 return journal::RenameEvent(op_tid
, m_dest_name
);
67 std::string m_dest_name
;
69 std::string m_source_oid
;
70 std::string m_dest_oid
;
74 bufferlist m_header_bl
;
76 void send_read_source_header();
77 void send_write_destination_header();
78 void send_update_directory();
79 void send_remove_source_header();
84 } // namespace operation
87 extern template class librbd::operation::RenameRequest
<librbd::ImageCtx
>;
89 #endif // CEPH_LIBRBD_RENAME_REQUEST_H