]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: remove capless inodes from logsegment open_file lists after reconnect
authorSage Weil <sage@newdream.net>
Sun, 23 Nov 2008 18:57:28 +0000 (10:57 -0800)
committerSage Weil <sage@newdream.net>
Sun, 23 Nov 2008 18:57:28 +0000 (10:57 -0800)
Inodes get added during replay of EOpen events.  We remove capless inodes
after reconnect restores from clients.

We only want inodes with caps on those lists.  Add an assertion to
enforce constraint.

Also, remove ourselves explicitly in remove_inode(), since that may happen
during replay when an inode is destroyed.

src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDS.cc
src/mds/journal.cc

index 576d6aa31bc9bb36f319c33b959127b84288399e..059705fe47bd12c019da306cdb9293f25bad89d6 100644 (file)
@@ -196,6 +196,8 @@ void MDCache::remove_inode(CInode *o)
   if (o->is_dirty())
     o->mark_clean();
 
+  o->xlist_open_file.remove_myself();
+
   // remove from inode map
   inode_map.erase(o->vino());    
 
@@ -3600,6 +3602,33 @@ void MDCache::send_snaps(map<int,MClientSnap*>& splits)
 }
 
 
+/*
+ * remove any items from logsegment open_file lists that don't have
+ * any caps
+ */
+void MDCache::reconnect_clean_open_file_lists()
+{
+  dout(10) << "reconnect_clean_open_file_lists" << dendl;
+  
+  for (map<loff_t,LogSegment*>::iterator p = mds->mdlog->segments.begin();
+       p != mds->mdlog->segments.end();
+       p++) {
+    LogSegment *ls = p->second;
+    
+    xlist<CInode*>::iterator q = ls->open_files.begin();
+    while (!q.end()) {
+      CInode *in = *q;
+      ++q;
+      if (!in->is_any_caps()) {
+       dout(10) << " unlisting capless inode " << *in << dendl;
+       in->xlist_open_file.remove_myself();
+      }
+    }
+  }
+}
+
+
+
 void MDCache::rejoin_import_cap(CInode *in, int client, ceph_mds_cap_reconnect& icr, int frommds)
 {
   dout(10) << "rejoin_import_cap for client" << client << " from mds" << frommds
index eb81f5575beacaacaf4c07eef6f468596f0ec0ca..7363ac06c9a4e3e77543d959ec5d4e889e175979 100644 (file)
@@ -615,6 +615,9 @@ public:
   ESubtreeMap *create_subtree_map();
 
 
+  // [reconnect]
+  void reconnect_clean_open_file_lists();
+
 protected:
   // [rejoin]
   set<int> rejoin_gather;      // nodes from whom i need a rejoin
index d9957b4c6237e6ee844338495e5ee1903c72e66d..8de5ba624c8253edd3fb532792f92ec0d0f1b391 100644 (file)
@@ -960,6 +960,8 @@ void MDS::reconnect_done()
   dout(1) << "reconnect_done" << dendl;
   request_state(MDSMap::STATE_REJOIN);    // move to rejoin state
 
+  mdcache->reconnect_clean_open_file_lists();
+
   /*
   if (mdsmap->get_num_in_mds() == 1 &&
       mdsmap->get_num_mds(MDSMap::STATE_FAILED) == 0) { // just me!
index f5dd5f64098e3511215f53316be4f552163ac2b3..01e2a24bf186fc6659588378527bcbe0454796ca 100644 (file)
@@ -158,6 +158,7 @@ C_Gather *LogSegment::try_to_expire(MDS *mds)
     for (xlist<CInode*>::iterator p = open_files.begin(); !p.end(); ++p) {
       CInode *in = *p;
       dout(20) << "try_to_expire requeueing open file " << *in << dendl;
+      assert(in->is_any_caps());
       if (!le) le = new EOpen(mds->mdlog);
       le->add_clean_inode(in);
       ls->open_files.push_back(&in->xlist_open_file);