]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mds/Capability.cc
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / mds / Capability.cc
index b6258e466df38b6013edb1950b01ffcb4a95dff2..de2a16e1ab19870bdcb7dc9d4a94dcfae6cb4168 100644 (file)
 
 #include "common/Formatter.h"
 
+#define dout_context g_ceph_context
+#define dout_subsys ceph_subsys_mds
+#undef dout_prefix
+#define dout_prefix *_dout << "Capability "
+
 
 /*
  * Capability::Export
@@ -176,6 +181,46 @@ client_t Capability::get_client() const
   return session ? session->get_client() : client_t(-1);
 }
 
+int Capability::confirm_receipt(ceph_seq_t seq, unsigned caps) {
+  int was_revoking = (_issued & ~_pending);
+  if (seq == last_sent) {
+    _revokes.clear();
+    _issued = caps;
+    // don't add bits
+    _pending &= caps;
+
+    // if the revoking is not totally finished just add the
+    // new revoking caps back.
+    if (was_revoking && revoking()) {
+      CInode *in = get_inode();
+      dout(10) << "revocation is not totally finished yet on " << *in
+               << ", the session " << *session << dendl;
+      _revokes.emplace_back(_pending, last_sent, last_issue);
+      if (!is_notable())
+        mark_notable();
+    }
+  } else {
+    // can i forget any revocations?
+    while (!_revokes.empty() && _revokes.front().seq < seq)
+      _revokes.pop_front();
+    if (!_revokes.empty()) {
+      if (_revokes.front().seq == seq)
+        _revokes.begin()->before = caps;
+      calc_issued();
+    } else {
+      // seq < last_sent
+      _issued = caps | _pending;
+    }
+  }
+
+  if (was_revoking && _issued == _pending) {
+    item_revoking_caps.remove_myself();
+    item_client_revoking_caps.remove_myself();
+    maybe_clear_notable();
+  }
+  return was_revoking & ~_issued; // return revoked
+}
+
 bool Capability::is_stale() const
 {
   return session ? session->is_stale() : false;