]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: find_ino_dir
authorSage Weil <sage.weil@dreamhost.com>
Fri, 1 Apr 2011 01:07:04 +0000 (18:07 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Fri, 1 Apr 2011 01:07:04 +0000 (18:07 -0700)
Search for a dir ino by checking the ondisk directory object path xattr.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/mds/MDCache.cc
src/mds/MDCache.h

index 832c578476c869822b726abae53671e4d3792171..2d596768a078c3aa4b8c360b2e7aa582673244c6 100644 (file)
@@ -6997,6 +6997,54 @@ void MDCache::kick_find_ino_peers(int who)
   }
 }
 
+/* ---------------------------- */
+
+struct C_MDS_FindInoDir : public Context {
+  MDCache *mdcache;
+  inodeno_t ino;
+  Context *fin;
+  bufferlist bl;
+  C_MDS_FindInoDir(MDCache *m, inodeno_t i, Context *f) : mdcache(m), ino(i), fin(f) {}
+  void finish(int r) {
+    mdcache->_find_ino_dir(ino, fin, bl, r);
+  }
+};
+
+void MDCache::find_ino_dir(inodeno_t ino, Context *fin)
+{
+  dout(10) << "find_ino_dir " << ino << dendl;
+  assert(!have_inode(ino));
+
+  // get the backtrace from the dir
+  object_t oid = CInode::get_object_name(ino, frag_t(), "");
+  object_locator_t oloc(mds->mdsmap->get_metadata_pg_pool());
+  
+  C_MDS_FindInoDir *c = new C_MDS_FindInoDir(this, ino, fin);
+  mds->objecter->getxattr(oid, oloc, "path", CEPH_NOSNAP, &c->bl, 0, c);
+}
+
+void MDCache::_find_ino_dir(inodeno_t ino, Context *fin, bufferlist& bl, int r)
+{
+  dout(10) << "_find_ino_dir " << ino << " got " << r << " " << bl.length() << " bytes" << dendl;
+  if (r < 0) {
+    fin->finish(r);
+    delete fin;
+    return;
+  }
+
+  string s(bl.c_str(), bl.length());
+  filepath path(s.c_str());
+  vector<CDentry*> trace;
+
+  Context *c = new C_MDS_FindInoDir(this, ino, fin);
+  r = path_traverse(NULL, NULL, c, path, &trace, NULL, MDS_TRAVERSE_DISCOVER);
+  if (r > 0)
+    return; 
+  delete c;  // path_traverse doesn't clean it up for us.
+  
+  fin->finish(r);
+  delete fin;
+}
 
 
 /* ---------------------------- */
index a128f1b7366a193d5bbf68a6ae86c1a5e56ebe97..c378b421ba888fd294f5da70baab01f072e63b17 100644 (file)
@@ -1013,6 +1013,7 @@ public:
 
   void make_trace(vector<CDentry*>& trace, CInode *in);
   
+  // -- find_ino_peer --
   struct find_ino_peer_info_t {
     inodeno_t ino;
     tid_t tid;
@@ -1033,6 +1034,15 @@ public:
   void handle_find_ino_reply(MMDSFindInoReply *m);
   void kick_find_ino_peers(int who);
 
+  // -- find_ino_dir --
+  struct find_ino_dir_info_t {
+    inodeno_t ino;
+    Context *fin;
+  };
+
+  void find_ino_dir(inodeno_t ino, Context *c);
+  void _find_ino_dir(inodeno_t ino, Context *c, bufferlist& bl, int r);
+
   // -- anchors --
 public:
   void anchor_create_prep_locks(MDRequest *mdr, CInode *in, set<SimpleLock*>& rdlocks,