Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jewel: mds: fix getattr starve setattr #9560

Merged
1 commit merged into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/mds/MDSRank.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ void MDSRankDispatcher::shutdown()
/**
* Helper for simple callbacks that call a void fn with no args.
*/
class C_VoidFn : public MDSInternalContext
class C_MDS_VoidFn : public MDSInternalContext
{
typedef void (MDSRank::*fn_ptr)();
protected:
fn_ptr fn;
public:
C_VoidFn(MDSRank *mds_, fn_ptr fn_)
C_MDS_VoidFn(MDSRank *mds_, fn_ptr fn_)
: MDSInternalContext(mds_), fn(fn_)
{
assert(mds_);
Expand Down Expand Up @@ -1160,7 +1160,7 @@ void MDSRank::resolve_start()

reopen_log();

mdcache->resolve_start(new C_VoidFn(this, &MDSRank::resolve_done));
mdcache->resolve_start(new C_MDS_VoidFn(this, &MDSRank::resolve_done));
finish_contexts(g_ceph_context, waiting_for_resolve);
}
void MDSRank::resolve_done()
Expand All @@ -1177,7 +1177,7 @@ void MDSRank::reconnect_start()
reopen_log();
}

server->reconnect_clients(new C_VoidFn(this, &MDSRank::reconnect_done));
server->reconnect_clients(new C_MDS_VoidFn(this, &MDSRank::reconnect_done));
finish_contexts(g_ceph_context, waiting_for_reconnect);
}
void MDSRank::reconnect_done()
Expand All @@ -1194,7 +1194,7 @@ void MDSRank::rejoin_joint_start()
void MDSRank::rejoin_start()
{
dout(1) << "rejoin_start" << dendl;
mdcache->rejoin_start(new C_VoidFn(this, &MDSRank::rejoin_done));
mdcache->rejoin_start(new C_MDS_VoidFn(this, &MDSRank::rejoin_done));
}
void MDSRank::rejoin_done()
{
Expand Down Expand Up @@ -1299,7 +1299,7 @@ void MDSRank::boot_create()
{
dout(3) << "boot_create" << dendl;

MDSGatherBuilder fin(g_ceph_context, new C_VoidFn(this, &MDSRank::creating_done));
MDSGatherBuilder fin(g_ceph_context, new C_MDS_VoidFn(this, &MDSRank::creating_done));

mdcache->init_layouts();

Expand Down
2 changes: 1 addition & 1 deletion src/mds/SimpleLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class SimpleLock {
parent->take_waiting(mask << get_wait_shift(), ls);
}
void add_waiter(uint64_t mask, MDSInternalContextBase *c) {
parent->add_waiter(mask << get_wait_shift(), c);
parent->add_waiter((mask << get_wait_shift()) | MDSCacheObject::WAIT_ORDERED, c);
}
bool is_waiter_for(uint64_t mask) const {
return parent->is_waiter_for(mask << get_wait_shift());
Expand Down
2 changes: 2 additions & 0 deletions src/mds/mdstypes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,8 @@ void cap_reconnect_t::generate_test_instances(list<cap_reconnect_t*>& ls)
ls.back()->capinfo.cap_id = 1;
}

uint64_t MDSCacheObject::last_wait_seq = 0;

void MDSCacheObject::dump(Formatter *f) const
{
f->dump_bool("is_auth", is_auth());
Expand Down
35 changes: 29 additions & 6 deletions src/mds/mdstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@ class MDSCacheObject {


// -- wait --
const static uint64_t WAIT_ORDERED = (1ull<<61);
const static uint64_t WAIT_SINGLEAUTH = (1ull<<60);
const static uint64_t WAIT_UNFREEZE = (1ull<<59); // pka AUTHPINNABLE

Expand Down Expand Up @@ -1544,7 +1545,8 @@ class MDSCacheObject {
// ---------------------------------------------
// waiting
protected:
compact_multimap<uint64_t, MDSInternalContextBase*> waiting;
compact_multimap<uint64_t, pair<uint64_t, MDSInternalContextBase*> > waiting;
static uint64_t last_wait_seq;

public:
bool is_waiter_for(uint64_t mask, uint64_t min=0) {
Expand All @@ -1553,7 +1555,7 @@ class MDSCacheObject {
while (min & (min-1)) // if more than one bit is set
min &= min-1; // clear LSB
}
for (compact_multimap<uint64_t,MDSInternalContextBase*>::iterator p = waiting.lower_bound(min);
for (auto p = waiting.lower_bound(min);
p != waiting.end();
++p) {
if (p->first & mask) return true;
Expand All @@ -1564,7 +1566,15 @@ class MDSCacheObject {
virtual void add_waiter(uint64_t mask, MDSInternalContextBase *c) {
if (waiting.empty())
get(PIN_WAITER);
waiting.insert(pair<uint64_t,MDSInternalContextBase*>(mask, c));

uint64_t seq = 0;
if (mask & WAIT_ORDERED) {
seq = ++last_wait_seq;
mask &= ~WAIT_ORDERED;
}
waiting.insert(pair<uint64_t, pair<uint64_t, MDSInternalContextBase*> >(
mask,
pair<uint64_t, MDSInternalContextBase*>(seq, c)));
// pdout(10,g_conf->debug_mds) << (mdsco_db_line_prefix(this))
// << "add_waiter " << hex << mask << dec << " " << c
// << " on " << *this
Expand All @@ -1573,10 +1583,18 @@ class MDSCacheObject {
}
virtual void take_waiting(uint64_t mask, list<MDSInternalContextBase*>& ls) {
if (waiting.empty()) return;
compact_multimap<uint64_t,MDSInternalContextBase*>::iterator it = waiting.begin();
while (it != waiting.end()) {

// process ordered waiters in the same order that they were added.
std::map<uint64_t, MDSInternalContextBase*> ordered_waiters;

for (auto it = waiting.begin();
it != waiting.end(); ) {
if (it->first & mask) {
ls.push_back(it->second);

if (it->second.first > 0)
ordered_waiters.insert(it->second);
else
ls.push_back(it->second.second);
// pdout(10,g_conf->debug_mds) << (mdsco_db_line_prefix(this))
// << "take_waiting mask " << hex << mask << dec << " took " << it->second
// << " tag " << hex << it->first << dec
Expand All @@ -1591,6 +1609,11 @@ class MDSCacheObject {
++it;
}
}
for (auto it = ordered_waiters.begin();
it != ordered_waiters.end();
++it) {
ls.push_back(it->second);
}
if (waiting.empty())
put(PIN_WAITER);
}
Expand Down