1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef RBD_MIRROR_IMAGE_REPLAYER_OPEN_LOCAL_IMAGE_REQUEST_H
5 #define RBD_MIRROR_IMAGE_REPLAYER_OPEN_LOCAL_IMAGE_REQUEST_H
7 #include "include/int_types.h"
8 #include "librbd/ImageCtx.h"
13 namespace librbd { class ImageCtx; }
17 namespace image_replayer {
19 template <typename ImageCtxT = librbd::ImageCtx>
20 class OpenLocalImageRequest {
22 static OpenLocalImageRequest* create(librados::IoCtx &local_io_ctx,
23 ImageCtxT **local_image_ctx,
24 const std::string &local_image_id,
25 ContextWQ *work_queue,
27 return new OpenLocalImageRequest(local_io_ctx, local_image_ctx,
28 local_image_id, work_queue, on_finish);
31 OpenLocalImageRequest(librados::IoCtx &local_io_ctx,
32 ImageCtxT **local_image_ctx,
33 const std::string &local_image_id,
34 ContextWQ *m_work_queue,
46 * OPEN_IMAGE * * * * * * * *
49 * IS_PRIMARY * * * * * * * *
51 * v (skip if primary) v
52 * LOCK_IMAGE * * * > CLOSE_IMAGE
55 * <finish> <---------------/
59 librados::IoCtx &m_local_io_ctx;
60 ImageCtxT **m_local_image_ctx;
61 std::string m_local_image_id;
62 ContextWQ *m_work_queue;
65 bool m_primary = false;
68 void send_open_image();
69 void handle_open_image(int r);
71 void send_is_primary();
72 void handle_is_primary(int r);
74 void send_lock_image();
75 void handle_lock_image(int r);
77 void send_close_image(int r);
78 void handle_close_image(int r);
84 } // namespace image_replayer
88 extern template class rbd::mirror::image_replayer::OpenLocalImageRequest<librbd::ImageCtx>;
90 #endif // RBD_MIRROR_IMAGE_REPLAYER_OPEN_LOCAL_IMAGE_REQUEST_H