]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
MDS: add a flush_dentry() function, and wire it up to the admin socket
authorGreg Farnum <greg@inktank.com>
Tue, 9 Sep 2014 21:55:42 +0000 (14:55 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Fri, 7 Nov 2014 20:53:03 +0000 (12:53 -0800)
Signed-off-by: Greg Farnum <greg@inktank.com>
src/include/ceph_fs.h
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDS.cc
src/mds/MDS.h

index cf6148eee9497dc778341345db2aee5858669625..06d8f745d76c6fb3bfc1dbc21783e7a59a66604b 100644 (file)
@@ -340,7 +340,8 @@ enum {
        // internal op
        CEPH_MDS_OP_FRAGMENTDIR= 0x01500,
        CEPH_MDS_OP_EXPORTDIR  = 0x01501,
-       CEPH_MDS_OP_VALIDATE   = 0x01502
+       CEPH_MDS_OP_VALIDATE   = 0x01502,
+       CEPH_MDS_OP_FLUSH      = 0x01503
 };
 
 extern const char *ceph_mds_op_name(int op);
index c296fd4c05952d443eea2e485c81e8516693c99c..40de91d3ee9dde1f3b1b5a6ef2326299f30391f5 100644 (file)
@@ -8485,6 +8485,9 @@ void MDCache::dispatch_request(MDRequestRef& mdr)
     case CEPH_MDS_OP_VALIDATE:
       scrub_dentry_work(mdr);
       break;
+    case CEPH_MDS_OP_FLUSH:
+      flush_dentry_work(mdr);
+      break;
     default:
       assert(0);
     }
@@ -11556,3 +11559,28 @@ void MDCache::scrub_dentry_work(MDRequestRef& mdr)
   in->validate_disk_state(vr, mdr->internal_op_finish);
   return;
 }
+
+void MDCache::flush_dentry(const string& path, Context *fin)
+{
+  dout(10) << "flush_dentry " << path << dendl;
+  MDRequestRef mdr = request_start_internal(CEPH_MDS_OP_FLUSH);
+  filepath fp(path.c_str());
+  mdr->set_filepath(fp);
+  mdr->internal_op_finish = fin;
+  flush_dentry_work(mdr);
+}
+
+void MDCache::flush_dentry_work(MDRequestRef& mdr)
+{
+  set<SimpleLock*> rdlocks, wrlocks, xlocks;
+  CInode *in = mds->server->rdlock_path_pin_ref(mdr, 0, rdlocks, true);
+  if (NULL == in)
+    return;
+
+  // TODO: Is this necessary? Fix it if so
+  assert(in->is_auth());
+  bool locked = mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks);
+  if (!locked)
+    return;
+  in->flush(new MDSInternalContextWrapper(mds,mdr->internal_op_finish));
+}
index d83b5aa8deebedad231c0599e062fc3cce7e61d0..604708611ad72b202487993b48cb872756ded4aa 100644 (file)
@@ -1034,6 +1034,8 @@ public:
   }
   void scrub_dentry(const string& path, Formatter *f, Context *fin);
   void scrub_dentry_work(MDRequestRef& mdr);
+  void flush_dentry(const string& path, Context *fin);
+  void flush_dentry_work(MDRequestRef& mdr);
 };
 
 class C_MDS_RetryRequest : public MDSInternalContext {
index 74d81f1df44d37f998608ab099b5252e6d941049..a0b7725fd017bbdc030581ab5e1ad3ba0789ff24 100644 (file)
@@ -290,6 +290,10 @@ bool MDS::asok_command(string command, cmdmap_t& cmdmap, string format,
     string path;
     cmd_getval(g_ceph_context, cmdmap, "path", path);
     command_scrub_path(f, path);
+  } else if (command == "flush_path") {
+    string path;
+    cmd_getval(g_ceph_context, cmdmap, "path", path);
+    command_flush_path(f, path);
   }
   f->flush(ss);
   delete f;
@@ -307,6 +311,19 @@ void MDS::command_scrub_path(Formatter *f, const string& path)
   // scrub_dentry() finishers will dump the data for us; we're done!
 }
 
+void MDS::command_flush_path(Formatter *f, const string& path)
+{
+  C_SaferCond scond;
+  {
+    Mutex::Locker l(mds_lock);
+    mdcache->flush_dentry(path, &scond);
+  }
+  int r = scond.wait();
+  f->open_object_section("results");
+  f->dump_int("return_code", r);
+  f->close_section(); // results
+}
+
 void MDS::set_up_admin_socket()
 {
   int r;
@@ -326,6 +343,10 @@ void MDS::set_up_admin_socket()
                                      "scrub_path name=path,type=CephString",
                                      asok_hook,
                                      "scrub an inode and output results");
+  r = admin_socket->register_command("flush_path",
+                                     "flush_path name=path,type=CephString",
+                                     asok_hook,
+                                     "flush an inode (and its dirfrags)");
   assert(0 == r);
   r = admin_socket->register_command("session evict",
                                     "session evict name=client_id,type=CephString",
index aac6e6760a947e774289db866e50e70b701b2c11..67b6591e610e092336afbd6bfe4b75d678cbb6d2 100644 (file)
@@ -376,6 +376,7 @@ private:
   void clean_up_admin_socket();
   void check_ops_in_flight(); // send off any slow ops to monitor
   void command_scrub_path(Formatter *f, const string& path);
+  void command_flush_path(Formatter *f, const string& path);
     // config observer bits
   virtual const char** get_tracked_conf_keys() const;
   virtual void handle_conf_change(const struct md_config_t *conf,