From: Sage Weil Date: Fri, 1 Apr 2011 17:46:07 +0000 (-0700) Subject: client: lookup_ino command X-Git-Tag: v0.27~181^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8408f83ceed8f63f2cb7722d563cc802d8e6b58c;p=ceph.git client: lookup_ino command Signed-off-by: Sage Weil --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 314d44ee6183..ca6fdc11db66 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -4540,6 +4540,20 @@ int Client::lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name) return r; } +int Client::lookup_ino(inodeno_t ino) +{ + Mutex::Locker lock(client_lock); + dout(3) << "lookup_ino enter(" << ino << ") = " << dendl; + + MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPINO); + filepath path(ino); + req->set_filepath(path); + + int r = make_request(req, -1, -1, NULL, rand() % mdsmap->get_num_mds()); + dout(3) << "lookup_ino exit(" << ino << ") = " << r << dendl; + return r; +} + Fh *Client::_create_fh(Inode *in, int flags, int cmode) { // yay diff --git a/src/client/Client.h b/src/client/Client.h index 900d21cbc167..e31237e2e3e1 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1283,6 +1283,7 @@ public: int mknod(const char *path, mode_t mode, dev_t rdev=0); int open(const char *path, int flags, mode_t mode=0); int lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name); + int lookup_ino(inodeno_t ino); int close(int fd); loff_t lseek(int fd, loff_t offset, int whence); int read(int fd, char *buf, loff_t size, loff_t offset=-1); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index e96560232ca2..4cd14b41e0ef 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -243,6 +243,9 @@ void parse_syn_options(vector& args) syn_sargs.push_back(args[++i]); syn_sargs.push_back(args[++i]); syn_sargs.push_back(args[++i]); + } else if (strcmp(args[i], "lookupino") == 0) { + syn_modes.push_back(SYNCLIENT_MODE_LOOKUPINO); + syn_sargs.push_back(args[++i]); } else if (strcmp(args[i], "chunkfile") == 0) { syn_modes.push_back(SYNCLIENT_MODE_CHUNK); @@ -881,6 +884,16 @@ int SyntheticClient::run() } } break; + case SYNCLIENT_MODE_LOOKUPINO: + { + inodeno_t ino; + string iname = get_sarg(0); + sscanf(iname.c_str(), "%llx", (long long unsigned*)&ino.val); + if (run_me()) { + lookup_ino(ino); + } + } + break; case SYNCLIENT_MODE_MKSNAP: { @@ -3341,6 +3354,13 @@ int SyntheticClient::lookup_hash(inodeno_t ino, inodeno_t dirino, const char *na return r; } +int SyntheticClient::lookup_ino(inodeno_t ino) +{ + int r = client->lookup_ino(ino); + dout(0) << "lookup_ino(" << ino << ") = " << r << dendl; + return r; +} + int SyntheticClient::chunk_file(string &filename) { int fd = client->open(filename.c_str(), O_RDONLY); diff --git a/src/client/SyntheticClient.h b/src/client/SyntheticClient.h index 475ea7c43bec..e3fcc136bebe 100644 --- a/src/client/SyntheticClient.h +++ b/src/client/SyntheticClient.h @@ -74,6 +74,7 @@ #define SYNCLIENT_MODE_DUMP 63 #define SYNCLIENT_MODE_LOOKUPHASH 70 +#define SYNCLIENT_MODE_LOOKUPINO 71 #define SYNCLIENT_MODE_TRUNCATE 200 @@ -263,6 +264,7 @@ class SyntheticClient { void import_find(const char *basedir, const char *find, bool writedata); int lookup_hash(inodeno_t ino, inodeno_t dirino, const char *name); + int lookup_ino(inodeno_t ino); int chunk_file(string &filename);