]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: remove exported caps when handling cap import message
authorYan, Zheng <zheng.z.yan@intel.com>
Fri, 21 Feb 2014 02:13:00 +0000 (10:13 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Sat, 1 Mar 2014 05:04:07 +0000 (13:04 +0800)
Version 3 cap import message includes the ID of the exported
caps. It allow us to remove the exported caps if we still haven't
received the corresponding cap export message.

We remove the exported caps because they are stale, keeping them
can compromise consistence.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/client/Client.cc

index 21e1eea42aaeaaf60fad7cb200dfac5d768587da..9ff6d016d85c5ae7821a314fe65f9f57a9331133 100644 (file)
@@ -3496,11 +3496,22 @@ void Client::handle_cap_import(MetaSession *session, Inode *in, MClientCaps *m)
 {
   int mds = session->mds_num;
 
+  ldout(cct, 5) << "handle_cap_import ino " << m->get_ino() << " mseq " << m->get_mseq()
+               << " IMPORT from mds." << mds << dendl;
+
   // add/update it
   update_snap_trace(m->snapbl);
   add_update_cap(in, session, m->get_cap_id(),
                 m->get_caps(), m->get_seq(), m->get_mseq(), m->get_realm(),
                 CEPH_CAP_FLAG_AUTH);
+
+  if (m->peer.cap_id) {
+    Cap *cap = in->caps[m->peer.mds];
+    if (cap && cap->cap_id == m->peer.cap_id) {
+      in->exporting_issued = cap->issued;
+      remove_cap(cap, (m->peer.flags & CEPH_CAP_FLAG_RELEASE));
+    }
+  }
   
   if (in->auth_cap && in->auth_cap->session->mds_num == mds) {
     // reflush any/all caps (if we are now the auth_cap)
@@ -3509,21 +3520,6 @@ void Client::handle_cap_import(MetaSession *session, Inode *in, MClientCaps *m)
     if (in->flushing_caps)
       flush_caps(in, session);
   }
-
-  if (m->get_mseq() > in->exporting_mseq) {
-    ldout(cct, 5) << "handle_cap_import ino " << m->get_ino() << " mseq " << m->get_mseq()
-           << " IMPORT from mds." << mds
-           << ", clearing exporting_issued " << ccap_string(in->exporting_issued) 
-           << " mseq " << in->exporting_mseq << dendl;
-    in->exporting_issued = 0;
-    in->exporting_mseq = 0;
-    in->exporting_mds = -1;
-  } else {
-    ldout(cct, 5) << "handle_cap_import ino " << m->get_ino() << " mseq " << m->get_mseq()
-           << " IMPORT from mds." << mds 
-           << ", keeping exporting_issued " << ccap_string(in->exporting_issued) 
-           << " mseq " << in->exporting_mseq << " by mds." << in->exporting_mds << dendl;
-  }
 }
 
 void Client::handle_cap_export(MetaSession *session, Inode *in, MClientCaps *m)