1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
16 #ifndef CEPH_MMDSSLAVEREQUEST_H
17 #define CEPH_MMDSSLAVEREQUEST_H
19 #include "msg/Message.h"
20 #include "mds/mdstypes.h"
22 class MMDSSlaveRequest
: public Message
{
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;
30 static const int OP_LINKPREP
= 4;
31 static const int OP_UNLINKPREP
= 5;
32 static const int OP_LINKPREPACK
= -4;
34 static const int OP_RENAMEPREP
= 7;
35 static const int OP_RENAMEPREPACK
= -7;
37 static const int OP_WRLOCK
= 8;
38 static const int OP_WRLOCKACK
= -8;
39 static const int OP_UNWRLOCK
= 9;
41 static const int OP_RMDIRPREP
= 10;
42 static const int OP_RMDIRPREPACK
= -10;
44 static const int OP_DROPLOCKS
= 11;
46 static const int OP_RENAMENOTIFY
= 12;
47 static const int OP_RENAMENOTIFYACK
= -12;
49 static const int OP_FINISH
= 17;
50 static const int OP_COMMITTED
= -18;
52 static const int OP_ABORT
= 20; // used for recovery only
53 //static const int OP_COMMIT = 21; // used for recovery only
56 const static char *get_opname(int 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";
64 case OP_LINKPREP
: return "link_prep";
65 case OP_LINKPREPACK
: return "link_prep_ack";
66 case OP_UNLINKPREP
: return "unlink_prep";
68 case OP_RENAMEPREP
: return "rename_prep";
69 case OP_RENAMEPREPACK
: return "rename_prep_ack";
71 case OP_FINISH
: return "finish"; // commit
72 case OP_COMMITTED
: return "committed";
74 case OP_WRLOCK
: return "wrlock";
75 case OP_WRLOCKACK
: return "wrlock_ack";
76 case OP_UNWRLOCK
: return "unwrlock";
78 case OP_RMDIRPREP
: return "rmdir_prep";
79 case OP_RMDIRPREPACK
: return "rmdir_prep_ack";
81 case OP_DROPLOCKS
: return "drop_locks";
83 case OP_RENAMENOTIFY
: return "rename_notify";
84 case OP_RENAMENOTIFYACK
: return "rename_notify_ack";
86 case OP_ABORT
: return "abort";
87 //case OP_COMMIT: return "commit";
89 default: ceph_abort(); return 0;
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;
106 __u16 lock_type
; // lock object type
107 MDSCacheObjectInfo object_info
;
110 vector
<MDSCacheObjectInfo
> authpins
;
116 set
<mds_rank_t
> witnesses
;
117 bufferlist inode_export
;
118 version_t inode_export_v
;
119 bufferlist srci_replica
;
122 bufferlist stray
; // stray dir + dentry
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; }
130 int get_lock_type() { return lock_type
; }
131 MDSCacheObjectInfo
&get_object_info() { return object_info
; }
132 MDSCacheObjectInfo
&get_authpin_freeze() { return object_info
; }
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
; }
146 void set_lock_type(int t
) { lock_type
= t
; }
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) { }
156 ~MMDSSlaveRequest() override
{}
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
);
176 void decode_payload() override
{
177 bufferlist::iterator p
= payload
.begin();
179 ::decode(attempt
, 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
);
195 const char *get_type_name() const override
{ return "slave_request"; }
196 void print(ostream
& out
) const override
{
197 out
<< "slave_request(" << reqid
199 << " " << get_opname(op
)