]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/io/Utils.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / librbd / io / Utils.h
index 13237435a1569e980a9388f5af68142c81b951aa..9f7e0b94668bad13062cfbd88119a6a7c5b3978d 100644 (file)
@@ -8,12 +8,14 @@
 #include "include/buffer_fwd.h"
 #include "include/rados/rados_types.hpp"
 #include "common/zipkin_trace.h"
+#include "librbd/Types.h"
 #include "librbd/io/Types.h"
 #include <map>
 
-class Context;
 class ObjectExtent;
 
+namespace neorados { struct Op; }
+
 namespace librbd {
 
 struct ImageCtx;
@@ -21,16 +23,54 @@ struct ImageCtx;
 namespace io {
 namespace util {
 
+void apply_op_flags(uint32_t op_flags, uint32_t flags, neorados::Op* op);
+
 bool assemble_write_same_extent(const LightweightObjectExtent &object_extent,
                                 const ceph::bufferlist& data,
                                 ceph::bufferlist *ws_data,
                                 bool force_write);
 
 template <typename ImageCtxT = librbd::ImageCtx>
-void read_parent(ImageCtxT *image_ctx, uint64_t object_no, uint64_t off,
-                 uint64_t len, librados::snap_t snap_id,
-                 const ZTracer::Trace &trace, ceph::bufferlist* data,
-                 Context* on_finish);
+void read_parent(ImageCtxT *image_ctx, uint64_t object_no,
+                 ReadExtents* extents, librados::snap_t snap_id,
+                 const ZTracer::Trace &trace, Context* on_finish);
+
+template <typename ImageCtxT = librbd::ImageCtx>
+int clip_request(ImageCtxT *image_ctx, Extents *image_extents);
+
+inline uint64_t get_extents_length(const Extents &extents) {
+  uint64_t total_bytes = 0;
+  for (auto [_, extent_length] : extents) {
+    total_bytes += extent_length;
+  }
+  return total_bytes;
+}
+
+void unsparsify(CephContext* cct, ceph::bufferlist* bl,
+                const Extents& extent_map, uint64_t bl_off,
+                uint64_t out_bl_len);
+
+template <typename ImageCtxT = librbd::ImageCtx>
+bool trigger_copyup(ImageCtxT *image_ctx, uint64_t object_no,
+                    IOContext io_context, Context* on_finish);
+                
+template <typename ImageCtxT = librbd::ImageCtx>
+void file_to_extents(ImageCtxT *image_ctx, uint64_t offset, uint64_t length,
+                     uint64_t buffer_offset,
+                     striper::LightweightObjectExtents* object_extents);
+
+template <typename ImageCtxT = librbd::ImageCtx>
+void extent_to_file(ImageCtxT *image_ctx, uint64_t object_no, uint64_t offset,
+                    uint64_t length,
+                    std::vector<std::pair<uint64_t, uint64_t> >& extents);
+
+template <typename ImageCtxT = librbd::ImageCtx>
+uint64_t get_file_offset(ImageCtxT *image_ctx, uint64_t object_no,
+                         uint64_t offset);
+
+inline ObjectDispatchLayer get_previous_layer(ObjectDispatchLayer layer) {
+  return (ObjectDispatchLayer)(((int)layer) - 1);
+}
 
 } // namespace util
 } // namespace io