]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MMDSSlaveRequest.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / messages / MMDSSlaveRequest.h
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 public:
24 static const int OP_XLOCK = 1;
25 static const int OP_XLOCKACK = -1;
26 static const int OP_UNXLOCK = 2;
27 static const int OP_AUTHPIN = 3;
28 static const int OP_AUTHPINACK = -3;
29
30 static const int OP_LINKPREP = 4;
31 static const int OP_UNLINKPREP = 5;
32 static const int OP_LINKPREPACK = -4;
33
34 static const int OP_RENAMEPREP = 7;
35 static const int OP_RENAMEPREPACK = -7;
36
37 static const int OP_WRLOCK = 8;
38 static const int OP_WRLOCKACK = -8;
39 static const int OP_UNWRLOCK = 9;
40
41 static const int OP_RMDIRPREP = 10;
42 static const int OP_RMDIRPREPACK = -10;
43
44 static const int OP_DROPLOCKS = 11;
45
46 static const int OP_RENAMENOTIFY = 12;
47 static const int OP_RENAMENOTIFYACK = -12;
48
49 static const int OP_FINISH = 17;
50 static const int OP_COMMITTED = -18;
51
52 static const int OP_ABORT = 20; // used for recovery only
53 //static const int OP_COMMIT = 21; // used for recovery only
54
55
56 const static char *get_opname(int o) {
57 switch (o) {
58 case OP_XLOCK: return "xlock";
59 case OP_XLOCKACK: return "xlock_ack";
60 case OP_UNXLOCK: return "unxlock";
61 case OP_AUTHPIN: return "authpin";
62 case OP_AUTHPINACK: return "authpin_ack";
63
64 case OP_LINKPREP: return "link_prep";
65 case OP_LINKPREPACK: return "link_prep_ack";
66 case OP_UNLINKPREP: return "unlink_prep";
67
68 case OP_RENAMEPREP: return "rename_prep";
69 case OP_RENAMEPREPACK: return "rename_prep_ack";
70
71 case OP_FINISH: return "finish"; // commit
72 case OP_COMMITTED: return "committed";
73
74 case OP_WRLOCK: return "wrlock";
75 case OP_WRLOCKACK: return "wrlock_ack";
76 case OP_UNWRLOCK: return "unwrlock";
77
78 case OP_RMDIRPREP: return "rmdir_prep";
79 case OP_RMDIRPREPACK: return "rmdir_prep_ack";
80
81 case OP_DROPLOCKS: return "drop_locks";
82
83 case OP_RENAMENOTIFY: return "rename_notify";
84 case OP_RENAMENOTIFYACK: return "rename_notify_ack";
85
86 case OP_ABORT: return "abort";
87 //case OP_COMMIT: return "commit";
88
89 default: ceph_abort(); return 0;
90 }
91 }
92
93 private:
94 metareqid_t reqid;
95 __u32 attempt;
96 __s16 op;
97 __u16 flags;
98
99 static const unsigned FLAG_NONBLOCK = 1<<0;
100 static const unsigned FLAG_WOULDBLOCK = 1<<1;
101 static const unsigned FLAG_NOTJOURNALED = 1<<2;
102 static const unsigned FLAG_EROFS = 1<<3;
103 static const unsigned FLAG_ABORT = 1<<4;
104
105 // for locking
106 __u16 lock_type; // lock object type
107 MDSCacheObjectInfo object_info;
108
109 // for authpins
110 vector<MDSCacheObjectInfo> authpins;
111
112 public:
113 // for rename prep
114 filepath srcdnpath;
115 filepath destdnpath;
116 set<mds_rank_t> witnesses;
117 bufferlist inode_export;
118 version_t inode_export_v;
119 bufferlist srci_replica;
120 utime_t op_stamp;
121
122 bufferlist stray; // stray dir + dentry
123
124 public:
125 metareqid_t get_reqid() { return reqid; }
126 __u32 get_attempt() const { return attempt; }
127 int get_op() { return op; }
128 bool is_reply() { return op < 0; }
129
130 int get_lock_type() { return lock_type; }
131 MDSCacheObjectInfo &get_object_info() { return object_info; }
132 MDSCacheObjectInfo &get_authpin_freeze() { return object_info; }
133
134 vector<MDSCacheObjectInfo>& get_authpins() { return authpins; }
135 void mark_nonblock() { flags |= FLAG_NONBLOCK; }
136 bool is_nonblock() { return (flags & FLAG_NONBLOCK); }
137 void mark_error_wouldblock() { flags |= FLAG_WOULDBLOCK; }
138 bool is_error_wouldblock() { return (flags & FLAG_WOULDBLOCK); }
139 void mark_not_journaled() { flags |= FLAG_NOTJOURNALED; }
140 bool is_not_journaled() { return (flags & FLAG_NOTJOURNALED); }
141 void mark_error_rofs() { flags |= FLAG_EROFS; }
142 bool is_error_rofs() { return (flags & FLAG_EROFS); }
143 bool is_abort() { return (flags & FLAG_ABORT); }
144 void mark_abort() { flags |= FLAG_ABORT; }
145
146 void set_lock_type(int t) { lock_type = t; }
147
148
149 // ----
150 MMDSSlaveRequest() : Message(MSG_MDS_SLAVE_REQUEST) { }
151 MMDSSlaveRequest(metareqid_t ri, __u32 att, int o) :
152 Message(MSG_MDS_SLAVE_REQUEST),
153 reqid(ri), attempt(att), op(o), flags(0), lock_type(0),
154 inode_export_v(0) { }
155 private:
156 ~MMDSSlaveRequest() override {}
157
158 public:
159 void encode_payload(uint64_t features) override {
160 ::encode(reqid, payload);
161 ::encode(attempt, payload);
162 ::encode(op, payload);
163 ::encode(flags, payload);
164 ::encode(lock_type, payload);
165 ::encode(object_info, payload);
166 ::encode(authpins, payload);
167 ::encode(srcdnpath, payload);
168 ::encode(destdnpath, payload);
169 ::encode(witnesses, payload);
170 ::encode(op_stamp, payload);
171 ::encode(inode_export, payload);
172 ::encode(inode_export_v, payload);
173 ::encode(srci_replica, payload);
174 ::encode(stray, payload);
175 }
176 void decode_payload() override {
177 bufferlist::iterator p = payload.begin();
178 ::decode(reqid, p);
179 ::decode(attempt, p);
180 ::decode(op, p);
181 ::decode(flags, p);
182 ::decode(lock_type, p);
183 ::decode(object_info, p);
184 ::decode(authpins, p);
185 ::decode(srcdnpath, p);
186 ::decode(destdnpath, p);
187 ::decode(witnesses, p);
188 ::decode(op_stamp, p);
189 ::decode(inode_export, p);
190 ::decode(inode_export_v, p);
191 ::decode(srci_replica, p);
192 ::decode(stray, p);
193 }
194
195 const char *get_type_name() const override { return "slave_request"; }
196 void print(ostream& out) const override {
197 out << "slave_request(" << reqid
198 << "." << attempt
199 << " " << get_opname(op)
200 << ")";
201 }
202
203 };
204
205 #endif