]>
git.proxmox.com Git - ceph.git/blob - ceph/src/osd/OpRequest.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2012 New Dream Network/Sage Weil <sage@newdream.net>
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.
20 #include <include/utime.h>
21 #include "common/Mutex.h"
22 #include "include/xlist.h"
23 #include "msg/Message.h"
24 #include "include/memory.h"
25 #include "osd/osd_types.h"
26 #include "common/TrackedOp.h"
29 * The OpRequest takes in a Message* and takes over a single reference
30 * to it, which it puts() when destroyed.
32 struct OpRequest
: public TrackedOp
{
33 friend class OpTracker
;
38 bool check_rmw(int flag
);
42 bool rwordered_forced();
44 bool includes_pg_op();
46 bool need_write_cap();
48 bool need_skip_handle_cache();
49 bool need_skip_promote();
53 void set_class_read();
54 void set_class_write();
57 void set_skip_handle_cache();
58 void set_skip_promote();
59 void set_force_rwordered();
62 ClassInfo(const std::string
& name
, bool read
, bool write
,
64 name(name
), read(read
), write(write
), whitelisted(whitelisted
)
66 const std::string name
;
67 const bool read
, write
, whitelisted
;
70 void add_class(const std::string
& name
, bool read
, bool write
,
72 classes_
.emplace_back(name
, read
, write
, whitelisted
);
75 std::vector
<ClassInfo
> classes() const {
79 void _dump(Formatter
*f
) const override
;
81 bool has_feature(uint64_t f
) const {
82 return request
->get_connection()->has_feature(f
);
86 Message
*request
; /// the logical request we are tracking
88 uint8_t hit_flag_points
;
89 uint8_t latest_flag_point
;
90 utime_t dequeued_time
;
91 static const uint8_t flag_queued_for_pg
=1 << 0;
92 static const uint8_t flag_reached_pg
= 1 << 1;
93 static const uint8_t flag_delayed
= 1 << 2;
94 static const uint8_t flag_started
= 1 << 3;
95 static const uint8_t flag_sub_op_sent
= 1 << 4;
96 static const uint8_t flag_commit_sent
= 1 << 5;
98 std::vector
<ClassInfo
> classes_
;
100 OpRequest(Message
*req
, OpTracker
*tracker
);
103 void _dump_op_descriptor_unlocked(ostream
& stream
) const override
;
104 void _unregistered() override
;
107 ~OpRequest() override
{
111 bool check_send_map
= true; ///< true until we check if sender needs a map
112 epoch_t sent_epoch
= 0; ///< client's map epoch
113 epoch_t min_epoch
= 0; ///< min epoch needed to handle this msg
115 bool hitset_inserted
;
116 const Message
*get_req() const { return request
; }
117 Message
*get_nonconst_req() { return request
; }
119 entity_name_t
get_source() {
121 return request
->get_source();
123 return entity_name_t();
127 const char *state_string() const override
{
128 switch(latest_flag_point
) {
129 case flag_queued_for_pg
: return "queued for pg";
130 case flag_reached_pg
: return "reached pg";
131 case flag_delayed
: return "delayed";
132 case flag_started
: return "started";
133 case flag_sub_op_sent
: return "waiting for sub ops";
134 case flag_commit_sent
: return "commit sent; apply or cleanup";
137 return "no flag points reached";
140 void mark_queued_for_pg() {
141 mark_flag_point(flag_queued_for_pg
, "queued_for_pg");
143 void mark_reached_pg() {
144 mark_flag_point(flag_reached_pg
, "reached_pg");
146 void mark_delayed(const string
& s
) {
147 mark_flag_point_string(flag_delayed
, s
);
149 void mark_started() {
150 mark_flag_point(flag_started
, "started");
152 void mark_sub_op_sent(const string
& s
) {
153 mark_flag_point_string(flag_sub_op_sent
, s
);
155 void mark_commit_sent() {
156 mark_flag_point(flag_commit_sent
, "commit_sent");
159 utime_t
get_dequeued_time() const {
160 return dequeued_time
;
162 void set_dequeued_time(utime_t deq_time
) {
163 dequeued_time
= deq_time
;
166 osd_reqid_t
get_reqid() const {
170 typedef boost::intrusive_ptr
<OpRequest
> Ref
;
173 void set_rmw_flags(int flags
);
174 void mark_flag_point(uint8_t flag
, const char *s
);
175 void mark_flag_point_string(uint8_t flag
, const string
& s
);
178 typedef OpRequest::Ref OpRequestRef
;
180 ostream
& operator<<(ostream
& out
, const OpRequest::ClassInfo
& i
);
182 #endif /* OPREQUEST_H_ */