Skip to content

Commit

Permalink
Merge pull request ceph#1336 from ceph/wip-nfs-export
Browse files Browse the repository at this point in the history
Wip nfs export

Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
Sage Weil committed Mar 2, 2014
2 parents 84ba4cf + 8d6b25a commit 4bf32c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 36 deletions.
50 changes: 16 additions & 34 deletions src/mds/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,10 @@ void Server::dispatch_client_request(MDRequest *mdr)
switch (req->get_op()) {
case CEPH_MDS_OP_LOOKUPHASH:
case CEPH_MDS_OP_LOOKUPINO:
handle_client_lookup_ino(mdr);
handle_client_lookup_ino(mdr, false);
break;
case CEPH_MDS_OP_LOOKUPPARENT:
handle_client_lookup_ino(mdr, true);
break;

// inodes ops.
Expand All @@ -1204,10 +1207,6 @@ void Server::dispatch_client_request(MDRequest *mdr)
handle_client_getattr(mdr, false);
break;

case CEPH_MDS_OP_LOOKUPPARENT:
handle_client_lookup_parent(mdr);
break;

case CEPH_MDS_OP_SETATTR:
handle_client_setattr(mdr);
break;
Expand Down Expand Up @@ -2360,31 +2359,6 @@ void Server::handle_client_getattr(MDRequest *mdr, bool is_lookup)
is_lookup ? mdr->dn[0].back() : 0);
}

/* This function will clean up the passed mdr*/
void Server::handle_client_lookup_parent(MDRequest *mdr)
{
MClientRequest *req = mdr->client_request;

CInode *in = mdcache->get_inode(req->get_filepath().get_ino());
if (!in) {
reply_request(mdr, -ESTALE);
return;
}
if (in->is_base()) {
reply_request(mdr, -EINVAL);
return;
}

CDentry *dn = in->get_projected_parent_dn();

set<SimpleLock*> rdlocks, wrlocks, xlocks;
rdlocks.insert(&dn->lock);
if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
return;

reply_request(mdr, 0, in, dn); // reply
}

struct C_MDS_LookupIno2 : public Context {
Server *server;
MDRequest *mdr;
Expand All @@ -2398,7 +2372,7 @@ struct C_MDS_LookupIno2 : public Context {
/*
* filepath: ino
*/
void Server::handle_client_lookup_ino(MDRequest *mdr)
void Server::handle_client_lookup_ino(MDRequest *mdr, bool want_parent)
{
MClientRequest *req = mdr->client_request;

Expand All @@ -2413,9 +2387,17 @@ void Server::handle_client_lookup_ino(MDRequest *mdr)
return;
}

dout(10) << "reply to lookup_ino " << *in << dendl;
MClientReply *reply = new MClientReply(req, 0);
reply_request(mdr, reply, in, NULL);
if (want_parent) {
CInode *pin = in->get_parent_inode();
if (pin && !pin->is_stray()) {
dout(10) << "reply to lookup_parent " << *in << dendl;
reply_request(mdr, 0, pin);
} else
reply_request(mdr, -ESTALE);
} else {
dout(10) << "reply to lookup_ino " << *in << dendl;
reply_request(mdr, 0, in);
}
}

void Server::_lookup_ino_2(MDRequest *mdr, int r)
Expand Down
3 changes: 1 addition & 2 deletions src/mds/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ class Server {

// requests on existing inodes.
void handle_client_getattr(MDRequest *mdr, bool is_lookup);
void handle_client_lookup_parent(MDRequest *mdr);
void handle_client_lookup_ino(MDRequest *mdr);
void handle_client_lookup_ino(MDRequest *mdr, bool want_parent);
void _lookup_ino_2(MDRequest *mdr, int r);
void handle_client_readdir(MDRequest *mdr);
void handle_client_file_setlock(MDRequest *mdr);
Expand Down

0 comments on commit 4bf32c6

Please sign in to comment.