1    	// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
2    	// vim: ts=8 sw=2 smarttab
3    	/*
4    	 * Ceph - scalable distributed file system
5    	 *
6    	 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7    	 *
8    	 * This is free software; you can redistribute it and/or
9    	 * modify it under the terms of the GNU Lesser General Public
10   	 * License version 2.1, as published by the Free Software 
11   	 * Foundation.  See file COPYING.
12   	 * 
13   	 */
14   	
15   	
16   	#ifndef CEPH_MMDSSLAVEREQUEST_H
17   	#define CEPH_MMDSSLAVEREQUEST_H
18   	
19   	#include "msg/Message.h"
20   	#include "mds/mdstypes.h"
21   	
22   	class MMDSSlaveRequest : public Message {
23   	  static constexpr int HEAD_VERSION = 1;
24   	  static constexpr int COMPAT_VERSION = 1;
25   	public:
26   	  static constexpr int OP_XLOCK =       1;
27   	  static constexpr int OP_XLOCKACK =   -1;
28   	  static constexpr int OP_UNXLOCK =     2;
29   	  static constexpr int OP_AUTHPIN =     3;
30   	  static constexpr int OP_AUTHPINACK = -3;
31   	
32   	  static constexpr int OP_LINKPREP =     4;
33   	  static constexpr int OP_UNLINKPREP =   5;
34   	  static constexpr int OP_LINKPREPACK = -4;
35   	
36   	  static constexpr int OP_RENAMEPREP =     7;
37   	  static constexpr int OP_RENAMEPREPACK = -7;
38   	
39   	  static constexpr int OP_WRLOCK = 8;
40   	  static constexpr int OP_WRLOCKACK = -8;
41   	  static constexpr int OP_UNWRLOCK = 9;
42   	
43   	  static constexpr int OP_RMDIRPREP = 10;
44   	  static constexpr int OP_RMDIRPREPACK = -10;
45   	
46   	  static constexpr int OP_DROPLOCKS	= 11;
47   	
48   	  static constexpr int OP_RENAMENOTIFY = 12;
49   	  static constexpr int OP_RENAMENOTIFYACK = -12;
50   	
51   	  static constexpr int OP_FINISH = 17;
52   	  static constexpr int OP_COMMITTED = -18;
53   	
54   	  static constexpr int OP_ABORT =  20;  // used for recovery only
55   	  //static constexpr int OP_COMMIT = 21;  // used for recovery only
56   	
57   	
58   	  static const char *get_opname(int o) {
59   	    switch (o) { 
60   	    case OP_XLOCK: return "xlock";
61   	    case OP_XLOCKACK: return "xlock_ack";
62   	    case OP_UNXLOCK: return "unxlock";
63   	    case OP_AUTHPIN: return "authpin";
64   	    case OP_AUTHPINACK: return "authpin_ack";
65   	
66   	    case OP_LINKPREP: return "link_prep";
67   	    case OP_LINKPREPACK: return "link_prep_ack";
68   	    case OP_UNLINKPREP: return "unlink_prep";
69   	
70   	    case OP_RENAMEPREP: return "rename_prep";
71   	    case OP_RENAMEPREPACK: return "rename_prep_ack";
72   	
73   	    case OP_FINISH: return "finish"; // commit
74   	    case OP_COMMITTED: return "committed";
75   	
76   	    case OP_WRLOCK: return "wrlock";
77   	    case OP_WRLOCKACK: return "wrlock_ack";
78   	    case OP_UNWRLOCK: return "unwrlock";
79   	
80   	    case OP_RMDIRPREP: return "rmdir_prep";
81   	    case OP_RMDIRPREPACK: return "rmdir_prep_ack";
82   	
83   	    case OP_DROPLOCKS: return "drop_locks";
84   	
85   	    case OP_RENAMENOTIFY: return "rename_notify";
86   	    case OP_RENAMENOTIFYACK: return "rename_notify_ack";
87   	
88   	    case OP_ABORT: return "abort";
89   	      //case OP_COMMIT: return "commit";
90   	
91   	    default: ceph_abort(); return 0;
92   	    }
93   	  }
94   	
95   	 private:
96   	  metareqid_t reqid;
(1) Event member_decl: Class member declaration for "attempt".
Also see events: [uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member]
97   	  __u32 attempt;
(3) Event member_decl: Class member declaration for "op".
Also see events: [member_decl][uninit_member][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member]
98   	  __s16 op;
(5) Event member_decl: Class member declaration for "flags".
Also see events: [member_decl][uninit_member][member_decl][uninit_member][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member]
99   	  mutable __u16 flags; /* XXX HACK for mark_interrupted */
100  	
101  	  static constexpr unsigned FLAG_NONBLOCK       =	1<<0;
102  	  static constexpr unsigned FLAG_WOULDBLOCK     =	1<<1;
103  	  static constexpr unsigned FLAG_NOTJOURNALED   =	1<<2;
104  	  static constexpr unsigned FLAG_EROFS          =	1<<3;
105  	  static constexpr unsigned FLAG_ABORT          =	1<<4;
106  	  static constexpr unsigned FLAG_INTERRUPTED    =	1<<5;
107  	
108  	  // for locking
(7) Event member_decl: Class member declaration for "lock_type".
Also see events: [member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][uninit_member][member_decl][uninit_member][member_decl][uninit_member]
109  	  __u16 lock_type;  // lock object type
110  	  MDSCacheObjectInfo object_info;
111  	  
112  	  // for authpins
113  	  vector<MDSCacheObjectInfo> authpins;
114  	
115  	 public:
116  	  // for rename prep
117  	  filepath srcdnpath;
118  	  filepath destdnpath;
119  	  set<mds_rank_t> witnesses;
120  	  bufferlist inode_export;
(9) Event member_decl: Class member declaration for "inode_export_v".
Also see events: [member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][uninit_member][member_decl][uninit_member]
121  	  version_t inode_export_v;
(11) Event member_decl: Class member declaration for "srcdn_auth".
Also see events: [member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][member_decl][uninit_member][uninit_member]
122  	  mds_rank_t srcdn_auth;
123  	  utime_t op_stamp;
124  	
125  	  mutable bufferlist straybl;  // stray dir + dentry
126  	  bufferlist srci_snapbl;
127  	  bufferlist desti_snapbl;
128  	
129  	public:
130  	  metareqid_t get_reqid() const { return reqid; }
131  	  __u32 get_attempt() const { return attempt; }
132  	  int get_op() const { return op; }
133  	  bool is_reply() const { return op < 0; }
134  	
135  	  int get_lock_type() const { return lock_type; }
136  	  const MDSCacheObjectInfo &get_object_info() const { return object_info; }
137  	  MDSCacheObjectInfo &get_object_info() { return object_info; }
138  	  const MDSCacheObjectInfo &get_authpin_freeze() const { return object_info; }
139  	  MDSCacheObjectInfo &get_authpin_freeze() { return object_info; }
140  	
141  	  const vector<MDSCacheObjectInfo>& get_authpins() const { return authpins; }
142  	  vector<MDSCacheObjectInfo>& get_authpins() { return authpins; }
143  	  void mark_nonblock() { flags |= FLAG_NONBLOCK; }
144  	  bool is_nonblock() const { return (flags & FLAG_NONBLOCK); }
145  	  void mark_error_wouldblock() { flags |= FLAG_WOULDBLOCK; }
146  	  bool is_error_wouldblock() const { return (flags & FLAG_WOULDBLOCK); }
147  	  void mark_not_journaled() { flags |= FLAG_NOTJOURNALED; }
148  	  bool is_not_journaled() const { return (flags & FLAG_NOTJOURNALED); }
149  	  void mark_error_rofs() { flags |= FLAG_EROFS; }
150  	  bool is_error_rofs() const { return (flags & FLAG_EROFS); }
151  	  bool is_abort() const { return (flags & FLAG_ABORT); }
152  	  void mark_abort() { flags |= FLAG_ABORT; }
153  	  bool is_interrupted() const { return (flags & FLAG_INTERRUPTED); }
154  	  void mark_interrupted() const { flags |= FLAG_INTERRUPTED; }
155  	
156  	  void set_lock_type(int t) { lock_type = t; }
157  	  const bufferlist& get_lock_data() const { return inode_export; }
158  	  bufferlist& get_lock_data() { return inode_export; }
159  	
160  	protected:
(2) Event uninit_member: Non-static class member "attempt" is not initialized in this constructor nor in any functions that it calls.
(4) Event uninit_member: Non-static class member "op" is not initialized in this constructor nor in any functions that it calls.
(6) Event uninit_member: Non-static class member "flags" is not initialized in this constructor nor in any functions that it calls.
(8) Event uninit_member: Non-static class member "lock_type" is not initialized in this constructor nor in any functions that it calls.
(10) Event uninit_member: Non-static class member "inode_export_v" is not initialized in this constructor nor in any functions that it calls.
(12) Event uninit_member: Non-static class member "srcdn_auth" is not initialized in this constructor nor in any functions that it calls.
Also see events: [member_decl][member_decl][member_decl][member_decl][member_decl][member_decl]
161  	  MMDSSlaveRequest() : Message{MSG_MDS_SLAVE_REQUEST, HEAD_VERSION, COMPAT_VERSION} { }
162  	  MMDSSlaveRequest(metareqid_t ri, __u32 att, int o) : 
163  	    Message{MSG_MDS_SLAVE_REQUEST, HEAD_VERSION, COMPAT_VERSION},
164  	    reqid(ri), attempt(att), op(o), flags(0), lock_type(0),
165  	    inode_export_v(0), srcdn_auth(MDS_RANK_NONE) { }
166  	  ~MMDSSlaveRequest() override {}
167  	
168  	public:
169  	  void encode_payload(uint64_t features) override {
170  	    using ceph::encode;
171  	    encode(reqid, payload);
172  	    encode(attempt, payload);
173  	    encode(op, payload);
174  	    encode(flags, payload);
175  	    encode(lock_type, payload);
176  	    encode(object_info, payload);
177  	    encode(authpins, payload);
178  	    encode(srcdnpath, payload);
179  	    encode(destdnpath, payload);
180  	    encode(witnesses, payload);
181  	    encode(op_stamp, payload);
182  	    encode(inode_export, payload);
183  	    encode(inode_export_v, payload);
184  	    encode(srcdn_auth, payload);
185  	    encode(straybl, payload);
186  	    encode(srci_snapbl, payload);
187  	    encode(desti_snapbl, payload);
188  	  }
189  	  void decode_payload() override {
190  	    auto p = payload.cbegin();
191  	    decode(reqid, p);
192  	    decode(attempt, p);
193  	    decode(op, p);
194  	    decode(flags, p);
195  	    decode(lock_type, p);
196  	    decode(object_info, p);
197  	    decode(authpins, p);
198  	    decode(srcdnpath, p);
199  	    decode(destdnpath, p);
200  	    decode(witnesses, p);
201  	    decode(op_stamp, p);
202  	    decode(inode_export, p);
203  	    decode(inode_export_v, p);
204  	    decode(srcdn_auth, p);
205  	    decode(straybl, p);
206  	    decode(srci_snapbl, p);
207  	    decode(desti_snapbl, p);
208  	  }
209  	
210  	  std::string_view get_type_name() const override { return "slave_request"; }
211  	  void print(ostream& out) const override {
212  	    out << "slave_request(" << reqid
213  		<< "." << attempt
214  		<< " " << get_opname(op) 
215  		<< ")";
216  	  }  
217  	private:
218  	  template<class T, typename... Args>
219  	  friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);	
220  	};
221  	
222  	#endif
223