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
8 #include "common/snap_types.h"
9 #include "osd/osd_types.h"
10 #include "osdc/WritebackHandler.h"
19 class LibrbdWriteback
: public WritebackHandler
{
21 LibrbdWriteback(ImageCtx
*ictx
, Mutex
& lock
);
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
;
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
;
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
;
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
;
49 struct write_result_d
{
54 write_result_d(const std::string
& oid
, Context
*oncommit
) :
55 done(false), ret(0), oid(oid
), oncommit(oncommit
) {}
57 write_result_d(const write_result_d
& rhs
);
58 const write_result_d
& operator=(const write_result_d
& rhs
);
62 void complete_writes(const std::string
& oid
);
66 librbd::ImageCtx
*m_ictx
;
67 ceph::unordered_map
<std::string
, std::queue
<write_result_d
*> > m_writes
;
68 friend class C_OrderedWrite
;