]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: lookup_ino command
authorSage Weil <sage.weil@dreamhost.com>
Fri, 1 Apr 2011 17:46:07 +0000 (10:46 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Fri, 1 Apr 2011 18:24:14 +0000 (11:24 -0700)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/client/Client.cc
src/client/Client.h
src/client/SyntheticClient.cc
src/client/SyntheticClient.h

index 314d44ee61832c0472c1b9ae8ab904bdd11f97df..ca6fdc11db66a064ab83e3f6c5b9eb9c022fb2ea 100644 (file)
@@ -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
index 900d21cbc167eb4e4112c4a8bf3fde61fb52cc60..e31237e2e3e1ebebf05652b4ee9ce9088ca1cd09 100644 (file)
@@ -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);
index e96560232ca26d0fe7bddba2e537b2bf24634d70..4cd14b41e0ef21a7bdafbd175d43eccfa794300c 100644 (file)
@@ -243,6 +243,9 @@ void parse_syn_options(vector<const char*>& 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);
index 475ea7c43becd59c0b9144ddeb6ce24b6c4c464f..e3fcc136bebe2a15924b42c435f7c23dbc56d628 100644 (file)
@@ -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);