Skip to content

Commit

Permalink
mds: introduce LOOKUPNAME MDS request
Browse files Browse the repository at this point in the history
The new MDS request is used for connecting a given inode to its
parent inode. It allows client to have efficient implementation of
get_rename() NFS export callback.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
  • Loading branch information
Yan, Zheng committed Mar 7, 2014
1 parent 9d387d3 commit 617ce67
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/common/ceph_strings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const char *ceph_mds_op_name(int op)
case CEPH_MDS_OP_LOOKUPHASH: return "lookuphash";
case CEPH_MDS_OP_LOOKUPPARENT: return "lookupparent";
case CEPH_MDS_OP_LOOKUPINO: return "lookupino";
case CEPH_MDS_OP_LOOKUPNAME: return "lookupname";
case CEPH_MDS_OP_GETATTR: return "getattr";
case CEPH_MDS_OP_SETXATTR: return "setxattr";
case CEPH_MDS_OP_SETATTR: return "setattr";
Expand Down
1 change: 1 addition & 0 deletions src/include/ceph_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ enum {
CEPH_MDS_OP_LOOKUPHASH = 0x00102,
CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
CEPH_MDS_OP_LOOKUPINO = 0x00104,
CEPH_MDS_OP_LOOKUPNAME = 0x00105,

CEPH_MDS_OP_SETXATTR = 0x01105,
CEPH_MDS_OP_RMXATTR = 0x01106,
Expand Down
42 changes: 32 additions & 10 deletions src/mds/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1190,10 +1190,13 @@ 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, false);
handle_client_lookup_ino(mdr, false, false);
break;
case CEPH_MDS_OP_LOOKUPPARENT:
handle_client_lookup_ino(mdr, true);
handle_client_lookup_ino(mdr, true, false);
break;
case CEPH_MDS_OP_LOOKUPNAME:
handle_client_lookup_ino(mdr, false, true);
break;

// inodes ops.
Expand Down Expand Up @@ -2372,7 +2375,7 @@ struct C_MDS_LookupIno2 : public Context {
/*
* filepath: ino
*/
void Server::handle_client_lookup_ino(MDRequest *mdr, bool want_parent)
void Server::handle_client_lookup_ino(MDRequest *mdr, bool want_parent, bool want_dentry)
{
MClientRequest *req = mdr->client_request;

Expand All @@ -2387,16 +2390,35 @@ void Server::handle_client_lookup_ino(MDRequest *mdr, bool want_parent)
return;
}

CDentry *dn = in->get_projected_parent_dn();
CInode *diri = dn ? dn->get_dir()->inode : NULL;
if (dn && (want_parent || want_dentry)) {
mdr->pin(dn);
set<SimpleLock*> rdlocks, wrlocks, xlocks;
rdlocks.insert(&dn->lock);
if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
return;
}

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
if (!diri || diri->is_stray()) {
reply_request(mdr, -ESTALE);
return;
}
dout(10) << "reply to lookup_parent " << *in << dendl;
reply_request(mdr, 0, diri);
} else {
dout(10) << "reply to lookup_ino " << *in << dendl;
reply_request(mdr, 0, in);
if (want_dentry) {
inodeno_t dirino = req->get_filepath2().get_ino();
if (!diri || (dirino != inodeno_t() && diri->ino() != dirino)) {
reply_request(mdr, -ENOENT);
return;
}
dout(10) << "reply to lookup_name " << *in << dendl;
} else
dout(10) << "reply to lookup_ino " << *in << dendl;

reply_request(mdr, 0, in, want_dentry ? dn : NULL);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mds/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Server {

// requests on existing inodes.
void handle_client_getattr(MDRequest *mdr, bool is_lookup);
void handle_client_lookup_ino(MDRequest *mdr, bool want_parent);
void handle_client_lookup_ino(MDRequest *mdr, bool want_parent, bool want_dentry);
void _lookup_ino_2(MDRequest *mdr, int r);
void handle_client_readdir(MDRequest *mdr);
void handle_client_file_setlock(MDRequest *mdr);
Expand Down
1 change: 1 addition & 0 deletions wireshark/ceph/ceph_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ enum {
CEPH_MDS_OP_LOOKUPHASH = 0x00102,
CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
CEPH_MDS_OP_LOOKUPINO = 0x00104,
CEPH_MDS_OP_LOOKUPNAME = 0x00105,

CEPH_MDS_OP_SETXATTR = 0x01105,
CEPH_MDS_OP_RMXATTR = 0x01106,
Expand Down
1 change: 1 addition & 0 deletions wireshark/ceph/packet-ceph.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ const char *ceph_mds_op_name(int op)
case CEPH_MDS_OP_LOOKUPHASH: return "lookuphash";
case CEPH_MDS_OP_LOOKUPPARENT: return "lookupparent";
case CEPH_MDS_OP_LOOKUPINO: return "lookupino";
case CEPH_MDS_OP_LOOKUPNAME: return "lookupname";
case CEPH_MDS_OP_GETATTR: return "getattr";
case CEPH_MDS_OP_SETXATTR: return "setxattr";
case CEPH_MDS_OP_SETATTR: return "setattr";
Expand Down

0 comments on commit 617ce67

Please sign in to comment.