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
, Context
*onfinish
) override
;
29 // Determine whether a read to this extent could be affected by a
30 // write-triggered copy-on-write
31 bool may_copy_on_write(const object_t
& oid
, uint64_t read_off
,
32 uint64_t read_len
, snapid_t snapid
) override
;
34 // Note that oloc, trunc_size, and trunc_seq are ignored
35 ceph_tid_t
write(const object_t
& oid
, const object_locator_t
& oloc
,
36 uint64_t off
, uint64_t len
,
37 const SnapContext
& snapc
, const bufferlist
&bl
,
38 ceph::real_time mtime
, uint64_t trunc_size
,
39 __u32 trunc_seq
, ceph_tid_t journal_tid
,
40 Context
*oncommit
) override
;
41 using WritebackHandler::write
;
43 void overwrite_extent(const object_t
& oid
, uint64_t off
,
44 uint64_t len
, ceph_tid_t original_journal_tid
,
45 ceph_tid_t new_journal_tid
) override
;
47 struct write_result_d
{
52 write_result_d(const std::string
& oid
, Context
*oncommit
) :
53 done(false), ret(0), oid(oid
), oncommit(oncommit
) {}
55 write_result_d(const write_result_d
& rhs
);
56 const write_result_d
& operator=(const write_result_d
& rhs
);
60 void complete_writes(const std::string
& oid
);
64 librbd::ImageCtx
*m_ictx
;
65 ceph::unordered_map
<std::string
, std::queue
<write_result_d
*> > m_writes
;
66 friend class C_OrderedWrite
;