]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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; | |
31f18b77 | 104 | static const unsigned FLAG_INTERRUPTED = 1<<5; |
7c673cae FG |
105 | |
106 | // for locking | |
107 | __u16 lock_type; // lock object type | |
108 | MDSCacheObjectInfo object_info; | |
109 | ||
110 | // for authpins | |
111 | vector<MDSCacheObjectInfo> authpins; | |
112 | ||
113 | public: | |
114 | // for rename prep | |
115 | filepath srcdnpath; | |
116 | filepath destdnpath; | |
117 | set<mds_rank_t> witnesses; | |
118 | bufferlist inode_export; | |
119 | version_t inode_export_v; | |
120 | bufferlist srci_replica; | |
31f18b77 | 121 | mds_rank_t srcdn_auth; |
7c673cae FG |
122 | utime_t op_stamp; |
123 | ||
124 | bufferlist stray; // stray dir + dentry | |
125 | ||
126 | public: | |
127 | metareqid_t get_reqid() { return reqid; } | |
128 | __u32 get_attempt() const { return attempt; } | |
129 | int get_op() { return op; } | |
130 | bool is_reply() { return op < 0; } | |
131 | ||
132 | int get_lock_type() { return lock_type; } | |
133 | MDSCacheObjectInfo &get_object_info() { return object_info; } | |
134 | MDSCacheObjectInfo &get_authpin_freeze() { return object_info; } | |
135 | ||
136 | vector<MDSCacheObjectInfo>& get_authpins() { return authpins; } | |
137 | void mark_nonblock() { flags |= FLAG_NONBLOCK; } | |
138 | bool is_nonblock() { return (flags & FLAG_NONBLOCK); } | |
139 | void mark_error_wouldblock() { flags |= FLAG_WOULDBLOCK; } | |
140 | bool is_error_wouldblock() { return (flags & FLAG_WOULDBLOCK); } | |
141 | void mark_not_journaled() { flags |= FLAG_NOTJOURNALED; } | |
142 | bool is_not_journaled() { return (flags & FLAG_NOTJOURNALED); } | |
143 | void mark_error_rofs() { flags |= FLAG_EROFS; } | |
144 | bool is_error_rofs() { return (flags & FLAG_EROFS); } | |
145 | bool is_abort() { return (flags & FLAG_ABORT); } | |
146 | void mark_abort() { flags |= FLAG_ABORT; } | |
31f18b77 FG |
147 | bool is_interrupted() { return (flags & FLAG_INTERRUPTED); } |
148 | void mark_interrupted() { flags |= FLAG_INTERRUPTED; } | |
7c673cae FG |
149 | |
150 | void set_lock_type(int t) { lock_type = t; } | |
151 | ||
152 | ||
153 | // ---- | |
154 | MMDSSlaveRequest() : Message(MSG_MDS_SLAVE_REQUEST) { } | |
155 | MMDSSlaveRequest(metareqid_t ri, __u32 att, int o) : | |
156 | Message(MSG_MDS_SLAVE_REQUEST), | |
157 | reqid(ri), attempt(att), op(o), flags(0), lock_type(0), | |
31f18b77 | 158 | inode_export_v(0), srcdn_auth(MDS_RANK_NONE) { } |
7c673cae FG |
159 | private: |
160 | ~MMDSSlaveRequest() override {} | |
161 | ||
162 | public: | |
163 | void encode_payload(uint64_t features) override { | |
164 | ::encode(reqid, payload); | |
165 | ::encode(attempt, payload); | |
166 | ::encode(op, payload); | |
167 | ::encode(flags, payload); | |
168 | ::encode(lock_type, payload); | |
169 | ::encode(object_info, payload); | |
170 | ::encode(authpins, payload); | |
171 | ::encode(srcdnpath, payload); | |
172 | ::encode(destdnpath, payload); | |
173 | ::encode(witnesses, payload); | |
174 | ::encode(op_stamp, payload); | |
175 | ::encode(inode_export, payload); | |
176 | ::encode(inode_export_v, payload); | |
31f18b77 | 177 | ::encode(srcdn_auth, payload); |
7c673cae FG |
178 | ::encode(srci_replica, payload); |
179 | ::encode(stray, payload); | |
180 | } | |
181 | void decode_payload() override { | |
182 | bufferlist::iterator p = payload.begin(); | |
183 | ::decode(reqid, p); | |
184 | ::decode(attempt, p); | |
185 | ::decode(op, p); | |
186 | ::decode(flags, p); | |
187 | ::decode(lock_type, p); | |
188 | ::decode(object_info, p); | |
189 | ::decode(authpins, p); | |
190 | ::decode(srcdnpath, p); | |
191 | ::decode(destdnpath, p); | |
192 | ::decode(witnesses, p); | |
193 | ::decode(op_stamp, p); | |
194 | ::decode(inode_export, p); | |
195 | ::decode(inode_export_v, p); | |
31f18b77 | 196 | ::decode(srcdn_auth, p); |
7c673cae FG |
197 | ::decode(srci_replica, p); |
198 | ::decode(stray, p); | |
199 | } | |
200 | ||
201 | const char *get_type_name() const override { return "slave_request"; } | |
202 | void print(ostream& out) const override { | |
203 | out << "slave_request(" << reqid | |
204 | << "." << attempt | |
205 | << " " << get_opname(op) | |
206 | << ")"; | |
207 | } | |
208 | ||
209 | }; | |
210 | ||
211 | #endif |