Skip to contentSkip to conversation

mds: fixes for mds

PATCH New Yan, Zheng 1 participant 6 messages Nov 30, 2012

lore
Share & tools
lore

Yan, Zheng

author
#0 lore raw

cover mds: fixes for mds

From: "Yan, Zheng" <[email protected]>

Hi,

The 1st patch fixes a rstat accounting bug. The 5th patch fixes journal replay bug, the fix requires a minor disk format change.

These patches are also in:
git://github.com/ukernel/ceph.git wip-mds

Regards
Yan, Zheng

author
#1 lore raw

PATCH 1/5 mds: fix journaling issue regarding rstat accounting

From: "Yan, Zheng" <[email protected]>

Rename operation can call predirty_journal_parents() twice. So directory fragment's rstat can be modified twice. But only the first modification is journaled because EMetaBlob::add_dir() does not update existing dirlump.

---
 src/mds/events/EMetaBlob.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
src/mds/events/EMetaBlob.h +4 -4
index 9c281e9..116b704 100644
@@ -635,12 +635,12 @@ private:
 		   dirty, complete, isnew);
   }
   dirlump& add_dir(dirfrag_t df, fnode_t *pf, version_t pv, bool dirty, bool complete=false, bool isnew=false) {
-    if (lump_map.count(df) == 0) {
+    if (lump_map.count(df) == 0)
       lump_order.push_back(df);
-      lump_map[df].fnode = *pf;
-      lump_map[df].fnode.version = pv;
-    }
+
     dirlump& l = lump_map[df];
+    l.fnode = *pf;
+    l.fnode.version = pv;
     if (complete) l.mark_complete();
     if (dirty) l.mark_dirty();
     if (isnew) l.mark_new();
Signature · 1 line
1.7.11.7
author
#2 lore raw

PATCH 2/5 mds: fix handle_client_openc() hang

In reply to Yan, Zheng

From: "Yan, Zheng" <[email protected]>

handle_client_openc() calls handle_client_open() if the linkage isn't null. handle_client_open() calls rdlock_path_pin_ref() which returns mdr->in[0] directly because mdr->done_locking is true. the problem here is that mdr->in[0] can be NULL if the linkage is remote.

---
 src/mds/Server.cc | 6 ++++++
 1 file changed, 6 insertions(+)
src/mds/Server.cc +6 -0
index 4c66f4a..59d7d3c 100644
@@ -2637,6 +2637,12 @@ void Server::handle_client_openc(MDRequest *mdr)
       reply_request(mdr, -EEXIST, dnl->get_inode(), dn);
       return;
     } 
+
+    mdcache->request_drop_non_rdlocks(mdr);
+
+    // remote link, avoid rdlock_path_pin_ref() returning null
+    if (!mdr->in[0])
+      mdr->done_locking = false;
     
     handle_client_open(mdr);
     return;
Signature · 1 line
1.7.11.7
author
#3 lore raw

PATCH 3/5 mds: alllow handle_client_readdir() fetching freezing dir.

In reply to Yan, Zheng

From: "Yan, Zheng" <[email protected]>

At that point, the request already auth pins some objects. So CDir::fetch() should ignore can_auth_pin check.

---
 src/mds/Server.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/mds/Server.cc +6 -1
index 59d7d3c..2c59f25 100644
@@ -2741,9 +2741,14 @@ void Server::handle_client_readdir(MDRequest *mdr)
   assert(dir->is_auth());
 
   if (!dir->is_complete()) {
+    if (dir->is_frozen()) {
+      dout(7) << "dir is frozen " << *dir << dendl;
+      dir->add_waiter(CDir::WAIT_UNFREEZE, new C_MDS_RetryRequest(mdcache, mdr));
+      return;
+    }
     // fetch
     dout(10) << " incomplete dir contents for readdir on " << *dir << ", fetching" << dendl;
-    dir->fetch(new C_MDS_RetryRequest(mdcache, mdr));
+    dir->fetch(new C_MDS_RetryRequest(mdcache, mdr), true);
     return;
   }
 
Signature · 1 line
1.7.11.7
author
#4 lore raw

PATCH 4/5 mds: call eval() after cap is imported

In reply to Yan, Zheng

From: "Yan, Zheng" <[email protected]>

The migrator calls eval() for imported caps after importing a directory tree. We should do the same thing after importing a inode.

---
 src/mds/Migrator.cc | 1 +
 1 file changed, 1 insertion(+)
src/mds/Migrator.cc +1 -0
index 41d97e9..fcc06cd 100644
@@ -2613,6 +2613,7 @@ void Migrator::logged_import_caps(CInode *in,
 
   assert(cap_imports.count(in));
   finish_import_inode_caps(in, from, cap_imports[in]);  
+  mds->locker->eval(in, CEPH_CAP_LOCKS);
 
   mds->send_message_mds(new MExportCapsAck(in->ino()), from);
 }
Signature · 1 line
1.7.11.7
author
#5 lore raw

PATCH 5/5 mds: compare sessionmap version before replaying imported sessions

In reply to Yan, Zheng

From: "Yan, Zheng" <[email protected]>

Otherwise we may wrongly increase mds->sessionmap.version, which will confuse future journal replays that involving sessionmap.

---
 src/mds/Server.cc        |  2 ++
 src/mds/events/EUpdate.h |  8 ++++++--
 src/mds/journal.cc       | 24 +++++++++++++++++-------
 3 files changed, 25 insertions(+), 9 deletions(-)
src/mds/Server.cc +2 -0
index 2c59f25..a10c503 100644
@@ -5425,6 +5425,8 @@ void Server::handle_client_rename(MDRequest *mdr)
   }
   
   _rename_prepare(mdr, &le->metablob, &le->client_map, srcdn, destdn, straydn);
+  if (le->client_map.length())
+    le->cmapv = mds->sessionmap.projected;
 
   // -- commit locally --
   C_MDS_rename_finish *fin = new C_MDS_rename_finish(mds, mdr, srcdn, destdn, straydn);
src/mds/events/EUpdate.h +6 -2
index 6ce18fe..a302a5a 100644
@@ -23,13 +23,14 @@ public:
   EMetaBlob metablob;
   string type;
   bufferlist client_map;
+  version_t cmapv;
   metareqid_t reqid;
   bool had_slaves;
 
   EUpdate() : LogEvent(EVENT_UPDATE) { }
   EUpdate(MDLog *mdlog, const char *s) : 
     LogEvent(EVENT_UPDATE), metablob(mdlog),
-    type(s), had_slaves(false) { }
+    type(s), cmapv(0), had_slaves(false) { }
   
   void print(ostream& out) {
     if (type.length())
@@ -38,12 +39,13 @@ public:
   }
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 2;
+    __u8 struct_v = 3;
     ::encode(struct_v, bl);
     ::encode(stamp, bl);
     ::encode(type, bl);
     ::encode(metablob, bl);
     ::encode(client_map, bl);
+    ::encode(cmapv, bl);
     ::encode(reqid, bl);
     ::encode(had_slaves, bl);
   } 
@@ -55,6 +57,8 @@ public:
     ::decode(type, bl);
     ::decode(metablob, bl);
     ::decode(client_map, bl);
+    if (struct_v >= 3)
+      ::decode(cmapv, bl);
     ::decode(reqid, bl);
     ::decode(had_slaves, bl);
   }
src/mds/journal.cc +17 -7
index 04b1a92..3f6d5eb 100644
@@ -999,14 +999,24 @@ void EUpdate::replay(MDS *mds)
     mds->mdcache->add_uncommitted_master(reqid, _segment, slaves);
   }
   
-  // open client sessions?
-  map<client_t,entity_inst_t> cm;
-  map<client_t, uint64_t> seqm;
   if (client_map.length()) {
-    bufferlist::iterator blp = client_map.begin();
-    ::decode(cm, blp);
-    mds->server->prepare_force_open_sessions(cm, seqm);
-    mds->server->finish_force_open_sessions(cm, seqm);
+    if (mds->sessionmap.version >= cmapv) {
+      dout(10) << "EUpdate.replay sessionmap v " << cmapv
+	       << " <= table " << mds->sessionmap.version << dendl;
+    } else {
+      dout(10) << "EUpdate.replay sessionmap " << mds->sessionmap.version
+	       << " < " << cmapv << dendl;
+      // open client sessions?
+      map<client_t,entity_inst_t> cm;
+      map<client_t, uint64_t> seqm;
+      bufferlist::iterator blp = client_map.begin();
+      ::decode(cm, blp);
+      mds->server->prepare_force_open_sessions(cm, seqm);
+      mds->server->finish_force_open_sessions(cm, seqm);
+
+      assert(mds->sessionmap.version = cmapv);
+      mds->sessionmap.projected = mds->sessionmap.version;
+    }
   }
 }
 
Signature · 1 line
1.7.11.7