]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/LibrbdWriteback.h
update sources to 12.2.7
[ceph.git] / ceph / src / librbd / LibrbdWriteback.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #ifndef CEPH_LIBRBD_LIBRBDWRITEBACKHANDLER_H
4 #define CEPH_LIBRBD_LIBRBDWRITEBACKHANDLER_H
5
6 #include <queue>
7
8 #include "common/snap_types.h"
9 #include "osd/osd_types.h"
10 #include "osdc/WritebackHandler.h"
11
12 class Mutex;
13 class Context;
14
15 namespace librbd {
16
17 struct ImageCtx;
18
19 class LibrbdWriteback : public WritebackHandler {
20 public:
21 LibrbdWriteback(ImageCtx *ictx, Mutex& lock);
22
23 // Note that oloc, trunc_size, and trunc_seq are ignored
24 void read(const object_t& oid, uint64_t object_no,
25 const object_locator_t& oloc, uint64_t off, uint64_t len,
26 snapid_t snapid, bufferlist *pbl, uint64_t trunc_size,
27 __u32 trunc_seq, int op_flags,
28 const ZTracer::Trace &parent_trace, Context *onfinish) override;
29
30 // Determine whether a read to this extent could be affected by a
31 // write-triggered copy-on-write
32 bool may_copy_on_write(const object_t& oid, uint64_t read_off,
33 uint64_t read_len, snapid_t snapid) override;
34
35 // Note that oloc, trunc_size, and trunc_seq are ignored
36 ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
37 uint64_t off, uint64_t len,
38 const SnapContext& snapc, const bufferlist &bl,
39 ceph::real_time mtime, uint64_t trunc_size,
40 __u32 trunc_seq, ceph_tid_t journal_tid,
41 const ZTracer::Trace &parent_trace,
42 Context *oncommit) override;
43 using WritebackHandler::write;
44
45 void overwrite_extent(const object_t& oid, uint64_t off,
46 uint64_t len, ceph_tid_t original_journal_tid,
47 ceph_tid_t new_journal_tid) override;
48
49 struct write_result_d {
50 bool done;
51 int ret;
52 std::string oid;
53 Context *oncommit;
54 write_result_d(const std::string& oid, Context *oncommit) :
55 done(false), ret(0), oid(oid), oncommit(oncommit) {}
56 private:
57 write_result_d(const write_result_d& rhs);
58 const write_result_d& operator=(const write_result_d& rhs);
59 };
60
61 private:
62 void complete_writes(const std::string& oid);
63
64 ceph_tid_t m_tid;
65 Mutex& m_lock;
66 librbd::ImageCtx *m_ictx;
67 ceph::unordered_map<std::string, std::queue<write_result_d*> > m_writes;
68 friend class C_OrderedWrite;
69 };
70 }
71
72 #endif