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;
61 journal::Event create_event(uint64_t op_tid) const override {
62 return journal::RenameEvent(op_tid, m_dest_name);
66 std::string m_dest_name;
68 std::string m_source_oid;
69 std::string m_dest_oid;
73 bufferlist m_header_bl;
75 int filter_state_return_code(int r);
77 void send_read_source_header();
78 void send_write_destination_header();
79 void send_update_directory();
80 void send_remove_source_header();
85 } // namespace operation
88 extern template class librbd::operation::RenameRequest<librbd::ImageCtx>;
90 #endif // CEPH_LIBRBD_RENAME_REQUEST_H