]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/RecoveryQueue: add method to prioritize a file recovery; fix logging
authorSage Weil <sage@redhat.com>
Thu, 14 Aug 2014 21:52:40 +0000 (14:52 -0700)
committerSage Weil <sage@redhat.com>
Thu, 28 Aug 2014 20:09:25 +0000 (13:09 -0700)
Add a prioritize() method to make file recovery start immediately for the
given inode.  Note that this doesn't respect the max recovery limit: if
someone stats it, they are blocking, and we start the recovery immediately.

Also fix up the dout logging a bit so that everything is prefixed
consistently.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mds/RecoveryQueue.cc
src/mds/RecoveryQueue.h

index d4a5b264086eeeb1372c80479ec8cd2bce5d3d2c..90ae65edf8e8c40f253234b5f7d2a447c2eb7836 100644 (file)
@@ -22,7 +22,8 @@
 
 
 #define dout_subsys ceph_subsys_mds
-
+#undef dout_prefix
+#define dout_prefix *_dout << "mds." << mds->get_nodeid() << " RecoveryQueue::" << __func__ << " "
 
 class C_MDC_Recover : public MDSIOContextBase {
 protected:
@@ -52,39 +53,58 @@ public:
  */
 void RecoveryQueue::advance()
 {
-  dout(10) << "RecoveryQueue::advance " << file_recover_queue.size() << " queued, "
+  dout(10) << file_recover_queue.size() << " queued, "
           << file_recovering.size() << " recovering" << dendl;
 
   while (file_recovering.size() < g_conf->mds_max_file_recover &&
         !file_recover_queue.empty()) {
-    CInode *in = *file_recover_queue.begin();
-    file_recover_queue.erase(in);
+    _start(*file_recover_queue.begin());
+  }
+}
 
-    inode_t *pi = in->get_projected_inode();
+void RecoveryQueue::_start(CInode *in)
+{
+  file_recover_queue.erase(in);
 
-    // blech
-    if (pi->client_ranges.size() && !pi->get_max_size()) {
-      mds->clog.warn() << "bad client_range " << pi->client_ranges
-         << " on ino " << pi->ino << "\n";
-    }
+  inode_t *pi = in->get_projected_inode();
 
-    if (pi->client_ranges.size() && pi->get_max_size()) {
-      dout(10) << "do_file_recover starting " << in->inode.size << " " << pi->client_ranges
-              << " " << *in << dendl;
-      file_recovering.insert(in);
-
-      C_MDC_Recover *fin = new C_MDC_Recover(this, in);
-      mds->filer->probe(in->inode.ino, &in->inode.layout, in->last,
-                       pi->get_max_size(), &fin->size, &fin->mtime, false,
-                       0, fin);
-    } else {
-      dout(10) << "do_file_recover skipping " << in->inode.size
-              << " " << *in << dendl;
-      in->state_clear(CInode::STATE_RECOVERING);
-      mds->locker->eval(in, CEPH_LOCK_IFILE);
-      in->auth_unpin(this);
-    }
+  // blech
+  if (pi->client_ranges.size() && !pi->get_max_size()) {
+    mds->clog.warn() << "bad client_range " << pi->client_ranges
+                    << " on ino " << pi->ino << "\n";
   }
+
+  if (pi->client_ranges.size() && pi->get_max_size()) {
+    dout(10) << "starting " << in->inode.size << " " << pi->client_ranges
+            << " " << *in << dendl;
+    file_recovering.insert(in);
+
+    C_MDC_Recover *fin = new C_MDC_Recover(this, in);
+    mds->filer->probe(in->inode.ino, &in->inode.layout, in->last,
+                     pi->get_max_size(), &fin->size, &fin->mtime, false,
+                     0, fin);
+  } else {
+    dout(10) << "skipping " << in->inode.size << " " << *in << dendl;
+    in->state_clear(CInode::STATE_RECOVERING);
+    mds->locker->eval(in, CEPH_LOCK_IFILE);
+    in->auth_unpin(this);
+  }
+}
+
+void RecoveryQueue::prioritize(CInode *in)
+{
+  if (file_recovering.count(in)) {
+    dout(10) << "already working on " << *in << dendl;
+    return;
+  }
+
+  if (file_recover_queue.count(in)) {
+    dout(20) << *in << dendl;
+    _start(in);
+    return;
+  }
+
+  dout(10) << "not queued " << *in << dendl;
 }
 
 
index 72d94acabaf3784259f0b224ef001661e0ff6fd9..41b2dcf0fedbf03d8865de14bd3f9f28d944f198 100644 (file)
@@ -23,12 +23,15 @@ class CInode;
 class MDS;
 
 class RecoveryQueue {
-  public:
+public:
   void enqueue(CInode *in);
   void advance();
+  void prioritize(CInode *in);   ///< do this inode now/soon
   RecoveryQueue(MDS *mds_) : mds(mds_) {}
 
-  private:
+private:
+  void _start(CInode *in);  ///< start recovering this file
+
   std::set<CInode*> file_recover_queue;
   std::set<CInode*> file_recovering;
   void _recovered(CInode *in, int r, uint64_t size, utime_t mtime);