]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: minor cleanup to MetaRequest class
authorXiubo Li <xiubli@redhat.com>
Fri, 14 Aug 2020 03:38:03 +0000 (11:38 +0800)
committerXiubo Li <xiubli@redhat.com>
Mon, 16 Aug 2021 05:25:35 +0000 (13:25 +0800)
To make the code more readable and there is no need to care about
the members order when initlizeing them.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/client/MetaRequest.h

index fa97bf0f31626b729a218081625c827c27e762ee..630f5ee15bc879ba5c039a441aa2057a6de508c7 100644 (file)
@@ -21,73 +21,60 @@ class dir_result_t;
 struct MetaRequest {
 private:
   InodeRef _inode, _old_inode, _other_inode;
-  Dentry *_dentry; //associated with path
-  Dentry *_old_dentry; //associated with path2
-  int abort_rc;
+  Dentry *_dentry = NULL;     //associated with path
+  Dentry *_old_dentry = NULL; //associated with path2
+  int abort_rc = 0;
 public:
-  uint64_t tid;
+  uint64_t tid = 0;
   utime_t  op_stamp;
   ceph_mds_request_head head;
   filepath path, path2;
   std::string alternate_name;
   bufferlist data;
-  int inode_drop; //the inode caps this operation will drop
-  int inode_unless; //unless we have these caps already
-  int old_inode_drop, old_inode_unless;
-  int dentry_drop, dentry_unless;
-  int old_dentry_drop, old_dentry_unless;
-  int other_inode_drop, other_inode_unless;
+  int inode_drop = 0;   //the inode caps this operation will drop
+  int inode_unless = 0; //unless we have these caps already
+  int old_inode_drop = 0, old_inode_unless = 0;
+  int dentry_drop = 0, dentry_unless = 0;
+  int old_dentry_drop = 0, old_dentry_unless = 0;
+  int other_inode_drop = 0, other_inode_unless = 0;
   std::vector<MClientRequest::Release> cap_releases;
 
-  int regetattr_mask;          // getattr mask if i need to re-stat after a traceless reply
+  int regetattr_mask = 0;          // getattr mask if i need to re-stat after a traceless reply
  
   utime_t  sent_stamp;
-  mds_rank_t mds;                // who i am asking
-  mds_rank_t resend_mds;         // someone wants you to (re)send the request here
-  bool     send_to_auth;       // must send to auth mds
-  __u32    sent_on_mseq;       // mseq at last submission of this request
-  int      num_fwd;            // # of times i've been forwarded
-  int      retry_attempt;
+  mds_rank_t mds = -1;             // who i am asking
+  mds_rank_t resend_mds = -1;      // someone wants you to (re)send the request here
+  bool     send_to_auth = false;   // must send to auth mds
+  __u32    sent_on_mseq = 0;       // mseq at last submission of this request
+  int      num_fwd = 0;            // # of times i've been forwarded
+  int      retry_attempt = 0;
   std::atomic<uint64_t> ref = { 1 };
   
-  ceph::cref_t<MClientReply> reply;         // the reply
-  bool kick;
-  bool success;
-  
+  ceph::cref_t<MClientReply> reply = NULL;  // the reply
+  bool kick = false;
+  bool success = false;
+
   // readdir result
-  dir_result_t *dirp;
+  dir_result_t *dirp = NULL;
 
   //possible responses
-  bool got_unsafe;
+  bool got_unsafe = false;
 
   xlist<MetaRequest*>::item item;
   xlist<MetaRequest*>::item unsafe_item;
   xlist<MetaRequest*>::item unsafe_dir_item;
   xlist<MetaRequest*>::item unsafe_target_item;
 
-  ceph::condition_variable *caller_cond;          // who to take up
-  ceph::condition_variable *dispatch_cond;        // who to kick back
+  ceph::condition_variable *caller_cond = NULL;   // who to take up
+  ceph::condition_variable *dispatch_cond = NULL; // who to kick back
   std::list<ceph::condition_variable*> waitfor_safe;
 
   InodeRef target;
   UserPerm perms;
 
   explicit MetaRequest(int op) :
-    _dentry(NULL), _old_dentry(NULL), abort_rc(0),
-    tid(0),
-    inode_drop(0), inode_unless(0),
-    old_inode_drop(0), old_inode_unless(0),
-    dentry_drop(0), dentry_unless(0),
-    old_dentry_drop(0), old_dentry_unless(0),
-    other_inode_drop(0), other_inode_unless(0),
-    regetattr_mask(0),
-    mds(-1), resend_mds(-1), send_to_auth(false), sent_on_mseq(0),
-    num_fwd(0), retry_attempt(0),
-    reply(0),
-    kick(false), success(false), dirp(NULL),
-    got_unsafe(false), item(this), unsafe_item(this),
-    unsafe_dir_item(this), unsafe_target_item(this),
-    caller_cond(0), dispatch_cond(0) {
+    item(this), unsafe_item(this), unsafe_dir_item(this),
+    unsafe_target_item(this) {
     memset(&head, 0, sizeof(head));
     head.op = op;
   }