1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "ReadRequest.h"
6 #define dout_subsys ceph_subsys_rbd_pwl
8 #define dout_prefix *_dout << "librbd::cache::pwl::rwl::ReadRequest: " << this << " " \
16 void C_ReadRequest::finish(int r
) {
17 ldout(m_cct
, 20) << "(" << get_name() << "): r=" << r
<< dendl
;
24 * At this point the miss read has completed. We'll iterate through
25 * read_extents and produce *m_out_bl by assembling pieces of miss_bl
26 * and the individual hit extent bufs in the read extents that represent
29 uint64_t miss_bl_offset
= 0;
30 for (auto extent
: read_extents
) {
31 if (extent
->m_bl
.length()) {
33 ceph_assert(extent
->second
== extent
->m_bl
.length());
35 hit_bytes
+= extent
->second
;
36 m_out_bl
->claim_append(extent
->m_bl
);
38 /* This was a miss. */
40 miss_bytes
+= extent
->second
;
41 bufferlist miss_extent_bl
;
42 miss_extent_bl
.substr_of(miss_bl
, miss_bl_offset
, extent
->second
);
43 /* Add this read miss bufferlist to the output bufferlist */
44 m_out_bl
->claim_append(miss_extent_bl
);
45 /* Consume these bytes in the read miss bufferlist */
46 miss_bl_offset
+= extent
->second
;
50 ldout(m_cct
, 20) << "(" << get_name() << "): r=" << r
<< " bl=" << *m_out_bl
<< dendl
;
51 utime_t now
= ceph_clock_now();
52 ceph_assert((int)m_out_bl
->length() == hit_bytes
+ miss_bytes
);
53 m_on_finish
->complete(r
);
54 m_perfcounter
->inc(l_librbd_pwl_rd_bytes
, hit_bytes
+ miss_bytes
);
55 m_perfcounter
->inc(l_librbd_pwl_rd_hit_bytes
, hit_bytes
);
56 m_perfcounter
->tinc(l_librbd_pwl_rd_latency
, now
- m_arrived_time
);
58 m_perfcounter
->inc(l_librbd_pwl_rd_hit_req
, 1);
59 m_perfcounter
->tinc(l_librbd_pwl_rd_hit_latency
, now
- m_arrived_time
);
62 m_perfcounter
->inc(l_librbd_pwl_rd_part_hit_req
, 1);