]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MMDSSlaveRequest.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / messages / MMDSSlaveRequest.h
CommitLineData
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
11fdf7f2
TL
22class MMDSSlaveRequest : public MessageInstance<MMDSSlaveRequest> {
23public:
24 friend factory;
7c673cae 25
11fdf7f2
TL
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;
7c673cae 31
11fdf7f2
TL
32 static constexpr int OP_LINKPREP = 4;
33 static constexpr int OP_UNLINKPREP = 5;
34 static constexpr int OP_LINKPREPACK = -4;
7c673cae 35
11fdf7f2
TL
36 static constexpr int OP_RENAMEPREP = 7;
37 static constexpr int OP_RENAMEPREPACK = -7;
7c673cae 38
11fdf7f2
TL
39 static constexpr int OP_WRLOCK = 8;
40 static constexpr int OP_WRLOCKACK = -8;
41 static constexpr int OP_UNWRLOCK = 9;
7c673cae 42
11fdf7f2
TL
43 static constexpr int OP_RMDIRPREP = 10;
44 static constexpr int OP_RMDIRPREPACK = -10;
7c673cae 45
11fdf7f2 46 static constexpr int OP_DROPLOCKS = 11;
7c673cae 47
11fdf7f2
TL
48 static constexpr int OP_RENAMENOTIFY = 12;
49 static constexpr int OP_RENAMENOTIFYACK = -12;
7c673cae 50
11fdf7f2
TL
51 static constexpr int OP_FINISH = 17;
52 static constexpr int OP_COMMITTED = -18;
7c673cae 53
11fdf7f2
TL
54 static constexpr int OP_ABORT = 20; // used for recovery only
55 //static constexpr int OP_COMMIT = 21; // used for recovery only
7c673cae 56
11fdf7f2
TL
57
58 static const char *get_opname(int o) {
7c673cae
FG
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;
97 __u32 attempt;
98 __s16 op;
11fdf7f2 99 mutable __u16 flags; /* XXX HACK for mark_interrupted */
7c673cae 100
11fdf7f2
TL
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;
7c673cae
FG
107
108 // for locking
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;
121 version_t inode_export_v;
31f18b77 122 mds_rank_t srcdn_auth;
7c673cae
FG
123 utime_t op_stamp;
124
11fdf7f2
TL
125 mutable bufferlist straybl; // stray dir + dentry
126 bufferlist srci_snapbl;
127 bufferlist desti_snapbl;
7c673cae
FG
128
129public:
11fdf7f2 130 metareqid_t get_reqid() const { return reqid; }
7c673cae 131 __u32 get_attempt() const { return attempt; }
11fdf7f2
TL
132 int get_op() const { return op; }
133 bool is_reply() const { return op < 0; }
7c673cae 134
11fdf7f2
TL
135 int get_lock_type() const { return lock_type; }
136 const MDSCacheObjectInfo &get_object_info() const { return object_info; }
7c673cae 137 MDSCacheObjectInfo &get_object_info() { return object_info; }
11fdf7f2 138 const MDSCacheObjectInfo &get_authpin_freeze() const { return object_info; }
7c673cae
FG
139 MDSCacheObjectInfo &get_authpin_freeze() { return object_info; }
140
11fdf7f2 141 const vector<MDSCacheObjectInfo>& get_authpins() const { return authpins; }
7c673cae
FG
142 vector<MDSCacheObjectInfo>& get_authpins() { return authpins; }
143 void mark_nonblock() { flags |= FLAG_NONBLOCK; }
11fdf7f2 144 bool is_nonblock() const { return (flags & FLAG_NONBLOCK); }
7c673cae 145 void mark_error_wouldblock() { flags |= FLAG_WOULDBLOCK; }
11fdf7f2 146 bool is_error_wouldblock() const { return (flags & FLAG_WOULDBLOCK); }
7c673cae 147 void mark_not_journaled() { flags |= FLAG_NOTJOURNALED; }
11fdf7f2 148 bool is_not_journaled() const { return (flags & FLAG_NOTJOURNALED); }
7c673cae 149 void mark_error_rofs() { flags |= FLAG_EROFS; }
11fdf7f2
TL
150 bool is_error_rofs() const { return (flags & FLAG_EROFS); }
151 bool is_abort() const { return (flags & FLAG_ABORT); }
7c673cae 152 void mark_abort() { flags |= FLAG_ABORT; }
11fdf7f2
TL
153 bool is_interrupted() const { return (flags & FLAG_INTERRUPTED); }
154 void mark_interrupted() const { flags |= FLAG_INTERRUPTED; }
7c673cae
FG
155
156 void set_lock_type(int t) { lock_type = t; }
11fdf7f2
TL
157 const bufferlist& get_lock_data() const { return inode_export; }
158 bufferlist& get_lock_data() { return inode_export; }
7c673cae 159
11fdf7f2
TL
160protected:
161 MMDSSlaveRequest() : MessageInstance(MSG_MDS_SLAVE_REQUEST) { }
7c673cae 162 MMDSSlaveRequest(metareqid_t ri, __u32 att, int o) :
11fdf7f2 163 MessageInstance(MSG_MDS_SLAVE_REQUEST),
7c673cae 164 reqid(ri), attempt(att), op(o), flags(0), lock_type(0),
31f18b77 165 inode_export_v(0), srcdn_auth(MDS_RANK_NONE) { }
7c673cae
FG
166 ~MMDSSlaveRequest() override {}
167
168public:
169 void encode_payload(uint64_t features) override {
11fdf7f2
TL
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);
7c673cae
FG
188 }
189 void decode_payload() override {
11fdf7f2
TL
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);
7c673cae
FG
208 }
209
11fdf7f2 210 std::string_view get_type_name() const override { return "slave_request"; }
7c673cae
FG
211 void print(ostream& out) const override {
212 out << "slave_request(" << reqid
213 << "." << attempt
214 << " " << get_opname(op)
215 << ")";
216 }
217
218};
219
220#endif