]> git.proxmox.com Git - ceph.git/blame - ceph/src/osd/Session.cc
buildsys: switch source download to quincy
[ceph.git] / ceph / src / osd / Session.cc
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#include "PG.h"
5#include "Session.h"
6
7#include "common/debug.h"
8
9#define dout_context cct
10#define dout_subsys ceph_subsys_osd
11
f67539c2
TL
12using std::map;
13using std::set;
14
7c673cae
FG
15void Session::clear_backoffs()
16{
9f95a23c 17 map<spg_t,map<hobject_t,set<ceph::ref_t<Backoff>>>> ls;
7c673cae 18 {
11fdf7f2 19 std::lock_guard l(backoff_lock);
7c673cae
FG
20 ls.swap(backoffs);
21 backoff_count = 0;
22 }
23 for (auto& i : ls) {
24 for (auto& p : i.second) {
25 for (auto& b : p.second) {
11fdf7f2 26 std::lock_guard l(b->lock);
7c673cae 27 if (b->pg) {
11fdf7f2
TL
28 ceph_assert(b->session == this);
29 ceph_assert(b->is_new() || b->is_acked());
7c673cae
FG
30 b->pg->rm_backoff(b);
31 b->pg.reset();
32 b->session.reset();
33 } else if (b->session) {
11fdf7f2
TL
34 ceph_assert(b->session == this);
35 ceph_assert(b->is_deleting());
7c673cae
FG
36 b->session.reset();
37 }
38 }
39 }
40 }
41}
42
43void Session::ack_backoff(
44 CephContext *cct,
45 spg_t pgid,
46 uint64_t id,
47 const hobject_t& begin,
48 const hobject_t& end)
49{
11fdf7f2 50 std::lock_guard l(backoff_lock);
7c673cae
FG
51 auto p = backoffs.find(pgid);
52 if (p == backoffs.end()) {
53 dout(20) << __func__ << " " << pgid << " " << id << " [" << begin << ","
54 << end << ") pg not found" << dendl;
55 return;
56 }
57 auto q = p->second.find(begin);
58 if (q == p->second.end()) {
59 dout(20) << __func__ << " " << pgid << " " << id << " [" << begin << ","
60 << end << ") begin not found" << dendl;
61 return;
62 }
63 for (auto i = q->second.begin(); i != q->second.end(); ++i) {
64 Backoff *b = (*i).get();
65 if (b->id == id) {
66 if (b->is_new()) {
67 b->state = Backoff::STATE_ACKED;
68 dout(20) << __func__ << " now " << *b << dendl;
69 } else if (b->is_deleting()) {
70 dout(20) << __func__ << " deleting " << *b << dendl;
71 q->second.erase(i);
72 --backoff_count;
73 }
74 break;
75 }
76 }
77 if (q->second.empty()) {
78 dout(20) << __func__ << " clearing begin bin " << q->first << dendl;
79 p->second.erase(q);
80 if (p->second.empty()) {
81 dout(20) << __func__ << " clearing pg bin " << p->first << dendl;
82 backoffs.erase(p);
83 }
84 }
11fdf7f2 85 ceph_assert(!backoff_count == backoffs.empty());
7c673cae
FG
86}
87
88bool Session::check_backoff(
89 CephContext *cct, spg_t pgid, const hobject_t& oid, const Message *m)
90{
9f95a23c 91 auto b = have_backoff(pgid, oid);
7c673cae
FG
92 if (b) {
93 dout(10) << __func__ << " session " << this << " has backoff " << *b
94 << " for " << *m << dendl;
11fdf7f2 95 ceph_assert(!b->is_acked() || !g_conf()->osd_debug_crash_on_ignored_backoff);
7c673cae
FG
96 return true;
97 }
98 // we may race with ms_handle_reset. it clears session->con before removing
99 // backoffs, so if we see con is cleared here we have to abort this
100 // request.
101 if (!con) {
102 dout(10) << __func__ << " session " << this << " disconnected" << dendl;
103 return true;
104 }
105 return false;
106}