]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mds/Mutation.cc
Import ceph 15.2.8
[ceph.git] / ceph / src / mds / Mutation.cc
index d9f3f7cadcc60b049014a2096d964b0027d5f56f..10b211ecabe6ff07e6ec0f36511d2a623106a92f 100644 (file)
@@ -418,12 +418,31 @@ bool MDRequestImpl::is_queued_for_replay() const
   return client_request ? client_request->is_queued_for_replay() : false;
 }
 
-bool MDRequestImpl::is_batch_op()
+bool MDRequestImpl::can_batch()
 {
-  return (client_request->get_op() == CEPH_MDS_OP_LOOKUP &&
-      client_request->get_filepath().depth() == 1) ||
-    (client_request->get_op() == CEPH_MDS_OP_GETATTR &&
-     client_request->get_filepath().depth() == 0);
+  if (num_auth_pins || num_remote_auth_pins || lock_cache || !locks.empty())
+    return false;
+
+  auto op = client_request->get_op();
+  auto& path = client_request->get_filepath();
+  if (op == CEPH_MDS_OP_GETATTR) {
+    if (path.depth() == 0)
+      return true;
+  } else if (op == CEPH_MDS_OP_LOOKUP) {
+    if (path.depth() == 1 && !path.is_last_snap())
+      return true;
+  }
+
+  return false;
+}
+
+std::unique_ptr<BatchOp> MDRequestImpl::release_batch_op()
+{
+  int mask = client_request->head.args.getattr.mask;
+  auto it = batch_op_map->find(mask);
+  std::unique_ptr<BatchOp> bop = std::move(it->second);
+  batch_op_map->erase(it);
+  return bop;
 }
 
 int MDRequestImpl::compare_paths()
@@ -444,6 +463,7 @@ cref_t<MClientRequest> MDRequestImpl::release_client_request()
   msg_lock.lock();
   cref_t<MClientRequest> req;
   req.swap(client_request);
+  client_request = req;
   msg_lock.unlock();
   return req;
 }