]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: use DentryRef for ref counting in MetaRequest
authorPatrick Donnelly <pdonnell@ibm.com>
Thu, 31 Oct 2024 00:38:36 +0000 (20:38 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Mon, 17 Mar 2025 19:43:16 +0000 (15:43 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
Fixes: https://tracker.ceph.com/issues/66373
(cherry picked from commit ff42d8603704756c23e629bd9940e4969929e2ab)

src/client/MetaRequest.cc
src/client/MetaRequest.h

index 6d709db5831d20319dc03dfd79937f6f166ed320..eaff2e0603b2f7d3e6485e1f59f336047479f881 100644 (file)
@@ -56,28 +56,18 @@ void MetaRequest::dump(Formatter *f) const
   f->dump_unsigned("owner_gid", head.owner_gid);
 }
 
-MetaRequest::~MetaRequest()
-{
-  if (_dentry)
-    _dentry->put();
-  if (_old_dentry)
-    _old_dentry->put();
-}
-
-void MetaRequest::set_dentry(Dentry *d) {
-  ceph_assert(_dentry == NULL);
-  _dentry = d;
-  _dentry->get();
+void MetaRequest::set_dentry(DentryRef dn) {
+  ceph_assert(_dentry.get() == NULL);
+  _dentry = std::move(dn);
 }
 Dentry *MetaRequest::dentry() {
-  return _dentry;
+  return _dentry.get();
 }
 
-void MetaRequest::set_old_dentry(Dentry *d) {
-  ceph_assert(_old_dentry == NULL);
-  _old_dentry = d;
-  _old_dentry->get();
+void MetaRequest::set_old_dentry(DentryRef dn) {
+  ceph_assert(_old_dentry.get() == NULL);
+  _old_dentry = std::move(dn);
 }
 Dentry *MetaRequest::old_dentry() {
-  return _old_dentry;
+  return _old_dentry.get();
 }
index 240c0cd02a39578abdcee6dfc8c6619041d9550f..172a916b6669877a6733b33b30b7ad2740c09384 100644 (file)
@@ -9,20 +9,20 @@
 #include "include/xlist.h"
 #include "include/filepath.h"
 #include "mds/mdstypes.h"
+#include "DentryRef.h"
 #include "InodeRef.h"
 #include "UserPerm.h"
 
 #include "messages/MClientRequest.h"
 #include "messages/MClientReply.h"
 
-class Dentry;
 class dir_result_t;
 
 struct MetaRequest {
 private:
   InodeRef _inode, _old_inode, _other_inode;
-  Dentry *_dentry = NULL;     //associated with path
-  Dentry *_old_dentry = NULL; //associated with path2
+  DentryRef _dentry;     //associated with path
+  DentryRef _old_dentry; //associated with path2
   int abort_rc = 0;
 public:
   ceph::coarse_mono_time created = ceph::coarse_mono_clock::zero();
@@ -83,7 +83,7 @@ public:
     head.owner_uid = -1;
     head.owner_gid = -1;
   }
-  ~MetaRequest();
+  ~MetaRequest() = default;
 
   /**
    * Prematurely terminate the request, such that callers
@@ -115,14 +115,17 @@ public:
   void set_inode(Inode *in) {
     _inode = in;
   }
+  void set_inode(InodeRef in) {
+    _inode = std::move(in);
+  }
   Inode *inode() {
     return _inode.get();
   }
   void take_inode(InodeRef *out) {
     out->swap(_inode);
   }
-  void set_old_inode(Inode *in) {
-    _old_inode = in;
+  void set_old_inode(InodeRef in) {
+    _old_inode = std::move(in);
   }
   Inode *old_inode() {
     return _old_inode.get();
@@ -130,8 +133,8 @@ public:
   void take_old_inode(InodeRef *out) {
     out->swap(_old_inode);
   }
-  void set_other_inode(Inode *in) {
-    _other_inode = in;
+  void set_other_inode(InodeRef in) {
+    _other_inode = std::move(in);
   }
   Inode *other_inode() {
     return _other_inode.get();
@@ -139,9 +142,9 @@ public:
   void take_other_inode(InodeRef *out) {
     out->swap(_other_inode);
   }
-  void set_dentry(Dentry *d);
+  void set_dentry(DentryRef d);
   Dentry *dentry();
-  void set_old_dentry(Dentry *d);
+  void set_old_dentry(DentryRef d);
   Dentry *old_dentry();
 
   MetaRequest* get() {