Skip to content

Commit

Permalink
Merge pull request ceph#4743 from ceph/wip-client-oldest-tid
Browse files Browse the repository at this point in the history
Wip client oldest tid

Reviewed-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo committed Jun 5, 2015
2 parents 3673c8b + 2517ea9 commit 7dc602a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
41 changes: 28 additions & 13 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Client::Client(Messenger *m, MonClient *mc)
tick_event(NULL),
monclient(mc), messenger(m), whoami(m->get_myname().num()),
cap_epoch_barrier(0),
last_tid(0), oldest_tid(0), last_flush_seq(0),
initialized(false), authenticated(false),
mounted(false), unmounting(false),
local_osd(-1), local_osd_epoch(0),
Expand All @@ -182,9 +183,6 @@ Client::Client(Messenger *m, MonClient *mc)
{
monclient->set_messenger(m);

last_tid = 0;
last_flush_seq = 0;

cwd = NULL;

//
Expand Down Expand Up @@ -1477,6 +1475,9 @@ int Client::make_request(MetaRequest *request,

// make note
mds_requests[tid] = request->get();
if (oldest_tid == 0 && request->get_op() != CEPH_MDS_OP_SETFILELOCK)\
oldest_tid = tid;

if (uid < 0) {
uid = geteuid();
gid = getegid();
Expand All @@ -1488,10 +1489,7 @@ int Client::make_request(MetaRequest *request,
ldout(cct, 20) << __func__ << " injecting fixed oldest_client_tid(1)" << dendl;
request->set_oldest_client_tid(1);
} else {
if (!mds_requests.empty())
request->set_oldest_client_tid(mds_requests.begin()->first);
else
request->set_oldest_client_tid(tid); // this one is the oldest.
request->set_oldest_client_tid(oldest_tid);
}

// hack target mds?
Expand Down Expand Up @@ -1564,8 +1562,7 @@ int Client::make_request(MetaRequest *request,
assert(request->aborted);
assert(!request->got_unsafe);
request->item.remove_myself();
mds_requests.erase(tid);
put_request(request); // request map's
unregister_request(request);
put_request(request); // ours
return -ETIMEDOUT;
}
Expand Down Expand Up @@ -1602,6 +1599,26 @@ int Client::make_request(MetaRequest *request,
return r;
}

void Client::unregister_request(MetaRequest *req)
{
mds_requests.erase(req->tid);
if (req->tid == oldest_tid) {
map<ceph_tid_t, MetaRequest*>::iterator p = mds_requests.upper_bound(oldest_tid);
while (true) {
if (p == mds_requests.end()) {
oldest_tid = 0;
break;
}
if (p->second->get_op() != CEPH_MDS_OP_SETFILELOCK) {
oldest_tid = p->first;
break;
}
++p;
}
}
put_request(req);
}

void Client::put_request(MetaRequest *request)
{
if (request->_put()) {
Expand Down Expand Up @@ -2097,8 +2114,7 @@ void Client::handle_client_reply(MClientReply *reply)
request->unsafe_item.remove_myself();
}
request->item.remove_myself();
mds_requests.erase(tid);
put_request(request);
unregister_request(request);
}
if (unmounting)
mount_cond.Signal();
Expand Down Expand Up @@ -2468,8 +2484,7 @@ void Client::kick_requests_closed(MetaSession *session)
if (req->got_unsafe) {
lderr(cct) << "kick_requests_closed removing unsafe request " << req->get_tid() << dendl;
req->unsafe_item.remove_myself();
mds_requests.erase(req->get_tid());
put_request(req);
unregister_request(req);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ class Client : public Dispatcher, public md_config_obs_t {
void resend_unsafe_requests(MetaSession *s);

// mds requests
ceph_tid_t last_tid, last_flush_seq;
ceph_tid_t last_tid;
ceph_tid_t oldest_tid; // oldest incomplete mds request, excluding setfilelock requests
ceph_tid_t last_flush_seq;
map<ceph_tid_t, MetaRequest*> mds_requests;

void dump_mds_requests(Formatter *f);
Expand All @@ -301,6 +303,7 @@ class Client : public Dispatcher, public md_config_obs_t {
Inode **ptarget = 0, bool *pcreated = 0,
int use_mds=-1, bufferlist *pdirbl=0);
void put_request(MetaRequest *request);
void unregister_request(MetaRequest *request);

int verify_reply_trace(int r, MetaRequest *request, MClientReply *reply,
Inode **ptarget, bool *pcreated, int uid, int gid);
Expand Down
8 changes: 7 additions & 1 deletion src/mds/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,13 @@ void Server::reply_client_request(MDRequestRef& mdr, MClientReply *reply)
mdr->mark_event("replying");

// note successful request in session map?
if (req->may_write() && mdr->session && reply->get_result() == 0) {
//
// setfilelock requests are special, they only modify states in MDS memory.
// The states get lost when MDS fails. If Client re-send a completed
// setfilelock request, it means that client did not receive corresponding
// setfilelock reply. So MDS should re-execute the setfilelock request.
if (req->may_write() && req->get_op() != CEPH_MDS_OP_SETFILELOCK &&
reply->get_result() == 0 && mdr->session) {
inodeno_t created = mdr->alloc_ino ? mdr->alloc_ino : mdr->used_prealloc_ino;
mdr->session->add_completed_request(mdr->reqid.tid, created);
if (mdr->ls) {
Expand Down

0 comments on commit 7dc602a

Please sign in to comment.