]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MDSContext.cc
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 Red Hat
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.
18 #include "MDSContext.h"
20 #include "common/dout.h"
21 #define dout_context g_ceph_context
22 #define dout_subsys ceph_subsys_mds
24 void MDSInternalContextBase::complete(int r
) {
25 MDSRank
*mds
= get_mds();
27 dout(10) << "MDSInternalContextBase::complete: " << typeid(*this).name() << dendl
;
29 assert(mds
->mds_lock
.is_locked_by_me());
30 MDSContext::complete(r
);
34 MDSRank
*MDSInternalContext::get_mds() {
38 MDSRank
*MDSInternalContextWrapper::get_mds()
43 void MDSInternalContextWrapper::finish(int r
)
48 elist
<MDSIOContextBase
*> MDSIOContextBase::ctx_list(member_offset(MDSIOContextBase
, list_item
));
49 std::atomic_flag
MDSIOContextBase::ctx_list_lock
= ATOMIC_FLAG_INIT
;
51 MDSIOContextBase::MDSIOContextBase(bool track
)
53 created_at
= ceph::coarse_mono_clock::now();
55 simple_spin_lock(&ctx_list_lock
);
56 ctx_list
.push_back(&list_item
);
57 simple_spin_unlock(&ctx_list_lock
);
61 MDSIOContextBase::~MDSIOContextBase()
63 simple_spin_lock(&ctx_list_lock
);
64 list_item
.remove_myself();
65 simple_spin_unlock(&ctx_list_lock
);
68 bool MDSIOContextBase::check_ios_in_flight(ceph::coarse_mono_time cutoff
,
69 std::string
& slow_count
,
70 ceph::coarse_mono_time
& oldest
)
72 static const unsigned MAX_COUNT
= 100;
75 simple_spin_lock(&ctx_list_lock
);
76 for (elist
<MDSIOContextBase
*>::iterator p
= ctx_list
.begin(); !p
.end(); ++p
) {
77 MDSIOContextBase
*c
= *p
;
78 if (c
->created_at
>= cutoff
)
84 oldest
= c
->created_at
;
86 simple_spin_unlock(&ctx_list_lock
);
90 slow_count
= std::to_string(MAX_COUNT
) + "+";
92 slow_count
= std::to_string(slow
);
99 void MDSIOContextBase::complete(int r
) {
100 MDSRank
*mds
= get_mds();
102 dout(10) << "MDSIOContextBase::complete: " << typeid(*this).name() << dendl
;
104 Mutex::Locker
l(mds
->mds_lock
);
106 if (mds
->is_daemon_stopping()) {
107 dout(4) << "MDSIOContextBase::complete: dropping for stopping "
108 << typeid(*this).name() << dendl
;
112 if (r
== -EBLACKLISTED
) {
113 derr
<< "MDSIOContextBase: blacklisted! Restarting..." << dendl
;
116 MDSContext::complete(r
);
120 void MDSLogContextBase::complete(int r
) {
121 MDLog
*mdlog
= get_mds()->mdlog
;
122 uint64_t safe_pos
= write_pos
;
124 // MDSContextBase::complete() free this
125 MDSIOContextBase::complete(r
);
126 mdlog
->set_safe_pos(safe_pos
);
129 MDSRank
*MDSIOContext::get_mds() {
133 MDSRank
*MDSIOContextWrapper::get_mds() {
137 void MDSIOContextWrapper::finish(int r
)
142 void C_IO_Wrapper::complete(int r
)
146 get_mds()->finisher
->queue(this, r
);
148 MDSIOContext::complete(r
);
152 MDSRank
*MDSInternalContextGather::get_mds()
154 derr
<< "Forbidden call to MDSInternalContextGather::get_mds by " << typeid(*this).name() << dendl
;