]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix cap revoke race 19920/head
authorYan, Zheng <zyan@redhat.com>
Thu, 11 Jan 2018 09:50:22 +0000 (17:50 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 11 Jan 2018 09:50:22 +0000 (17:50 +0800)
If caps are been revoking by the auth MDS, don't consider them as
issued even they are still issued by non-auth MDS. The non-auth
MDS should also be revoking/exporting these caps, the client just
hasn't received the cap revoke/export message.

The race I encountered is: When caps are exporting to new MDS, the
client receives cap import message and cap revoke message from the
new MDS, then receives cap export message from the old MDS. When
the client receives cap revoke message from the new MDS, the revoking
caps are still issued by the old MDS, so the client does nothing.
Later when the cap export message is received, the client removes
the caps issued by the old MDS. (Another way to fix the race is
calling ceph_check_caps() in handle_cap_export())

copid from kernel commit b1530f57

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/client/Inode.cc

index faf5cda885fe754de866924efff04aaac265aafe..3f2502b4c9cca3ea1857a452bb6a95a7498d0b4a 100644 (file)
@@ -52,7 +52,7 @@ ostream& operator<<(ostream &out, const Inode &in)
     out << "(";
     bool first = true;
     for (const auto &pair : in.caps) {
-      if (first)
+      if (!first)
         out << ',';
       out << pair.first << '=' << ccap_string(pair.second.issued);
       first = false;
@@ -200,6 +200,12 @@ int Inode::caps_issued(int *implemented) const
       i |= cap.implemented;
     }
   }
+  // exclude caps issued by non-auth MDS, but are been revoking by
+  // the auth MDS. The non-auth MDS should be revoking/exporting
+  // these caps, but the message is delayed.
+  if (auth_cap)
+    c &= ~auth_cap->implemented | auth_cap->issued;
+
   if (implemented)
     *implemented = i;
   return c;