]> git.proxmox.com Git - ceph.git/blame - ceph/src/osd/mClockOpClassSupport.cc
update download target update for octopus release
[ceph.git] / ceph / src / osd / mClockOpClassSupport.cc
CommitLineData
11fdf7f2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2017 Red Hat Inc.
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15
16#include "common/dout.h"
17#include "osd/mClockOpClassSupport.h"
18#include "osd/OpQueueItem.h"
19
20#include "include/ceph_assert.h"
21
22namespace ceph {
23
24 namespace mclock {
25
26 OpClassClientInfoMgr::OpClassClientInfoMgr(CephContext *cct) :
27 client_op(cct->_conf->osd_op_queue_mclock_client_op_res,
28 cct->_conf->osd_op_queue_mclock_client_op_wgt,
29 cct->_conf->osd_op_queue_mclock_client_op_lim),
30 osd_rep_op(cct->_conf->osd_op_queue_mclock_osd_rep_op_res,
31 cct->_conf->osd_op_queue_mclock_osd_rep_op_wgt,
32 cct->_conf->osd_op_queue_mclock_osd_rep_op_lim),
33 snaptrim(cct->_conf->osd_op_queue_mclock_snap_res,
34 cct->_conf->osd_op_queue_mclock_snap_wgt,
35 cct->_conf->osd_op_queue_mclock_snap_lim),
36 recov(cct->_conf->osd_op_queue_mclock_recov_res,
37 cct->_conf->osd_op_queue_mclock_recov_wgt,
38 cct->_conf->osd_op_queue_mclock_recov_lim),
39 scrub(cct->_conf->osd_op_queue_mclock_scrub_res,
40 cct->_conf->osd_op_queue_mclock_scrub_wgt,
41 cct->_conf->osd_op_queue_mclock_scrub_lim),
42 pg_delete(cct->_conf->osd_op_queue_mclock_pg_delete_res,
43 cct->_conf->osd_op_queue_mclock_pg_delete_wgt,
44 cct->_conf->osd_op_queue_mclock_pg_delete_lim),
45 peering_event(cct->_conf->osd_op_queue_mclock_peering_event_res,
46 cct->_conf->osd_op_queue_mclock_peering_event_wgt,
47 cct->_conf->osd_op_queue_mclock_peering_event_lim)
48 {
49 constexpr int rep_ops[] = {
50 MSG_OSD_REPOP,
51 MSG_OSD_REPOPREPLY,
52 MSG_OSD_PG_UPDATE_LOG_MISSING,
53 MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY,
54 MSG_OSD_EC_WRITE,
55 MSG_OSD_EC_WRITE_REPLY,
56 MSG_OSD_EC_READ,
57 MSG_OSD_EC_READ_REPLY
58 };
59 for (auto op : rep_ops) {
60 add_rep_op_msg(op);
61 }
62
63 lgeneric_subdout(cct, osd, 20) <<
64 "mClock OpClass settings:: " <<
65 "client_op:" << client_op <<
66 "; osd_rep_op:" << osd_rep_op <<
67 "; snaptrim:" << snaptrim <<
68 "; recov:" << recov <<
69 "; scrub:" << scrub <<
70 dendl;
71
72 lgeneric_subdout(cct, osd, 30) <<
73 "mClock OpClass message bit set:: " <<
74 rep_op_msg_bitset.to_string() << dendl;
75 }
76
77 void OpClassClientInfoMgr::add_rep_op_msg(int message_code) {
78 ceph_assert(message_code >= 0 && message_code < int(rep_op_msg_bitset_size));
79 rep_op_msg_bitset.set(message_code);
80 }
81
82 osd_op_type_t
83 OpClassClientInfoMgr::osd_op_type(const OpQueueItem& op) const {
84 osd_op_type_t type = convert_op_type(op.get_op_type());
85 if (osd_op_type_t::client_op != type) {
86 return type;
87 } else {
88 // get_header returns ceph_msg_header type, ceph_msg_header
89 // stores type as unsigned little endian, so be sure to
90 // convert to CPU byte ordering
91 boost::optional<OpRequestRef> op_ref_maybe = op.maybe_get_op();
92 ceph_assert(op_ref_maybe);
93 __le16 mtype_le = (*op_ref_maybe)->get_req()->get_header().type;
94 __u16 mtype = le16_to_cpu(mtype_le);
95 if (rep_op_msg_bitset.test(mtype)) {
96 return osd_op_type_t::osd_rep_op;
97 } else {
98 return osd_op_type_t::client_op;
99 }
100 }
101 }
102
103 // used for debugging since faster implementation can be done
104 // with rep_op_msg_bitmap
105 bool OpClassClientInfoMgr::is_rep_op(uint16_t mtype) {
106 return
107 MSG_OSD_REPOP == mtype ||
108 MSG_OSD_REPOPREPLY == mtype ||
109 MSG_OSD_PG_UPDATE_LOG_MISSING == mtype ||
110 MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY == mtype ||
111 MSG_OSD_EC_WRITE == mtype ||
112 MSG_OSD_EC_WRITE_REPLY == mtype ||
113 MSG_OSD_EC_READ == mtype ||
114 MSG_OSD_EC_READ_REPLY == mtype;
115 }
116 } // namespace mclock
117} // namespace ceph