]>
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 | #include "Capability.h" | |
16 | ||
17 | #include "common/Formatter.h" | |
18 | ||
19 | ||
20 | /* | |
21 | * Capability::Export | |
22 | */ | |
23 | ||
24 | void Capability::Export::encode(bufferlist &bl) const | |
25 | { | |
26 | ENCODE_START(2, 2, bl); | |
27 | ::encode(cap_id, bl); | |
28 | ::encode(wanted, bl); | |
29 | ::encode(issued, bl); | |
30 | ::encode(pending, bl); | |
31 | ::encode(client_follows, bl); | |
32 | ::encode(seq, bl); | |
33 | ::encode(mseq, bl); | |
34 | ::encode(last_issue_stamp, bl); | |
35 | ENCODE_FINISH(bl); | |
36 | } | |
37 | ||
38 | void Capability::Export::decode(bufferlist::iterator &p) | |
39 | { | |
40 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, p); | |
41 | ::decode(cap_id, p); | |
42 | ::decode(wanted, p); | |
43 | ::decode(issued, p); | |
44 | ::decode(pending, p); | |
45 | ::decode(client_follows, p); | |
46 | ::decode(seq, p); | |
47 | ::decode(mseq, p); | |
48 | ::decode(last_issue_stamp, p); | |
49 | DECODE_FINISH(p); | |
50 | } | |
51 | ||
52 | void Capability::Export::dump(Formatter *f) const | |
53 | { | |
54 | f->dump_unsigned("cap_id", cap_id); | |
55 | f->dump_unsigned("wanted", wanted); | |
56 | f->dump_unsigned("issued", issued); | |
57 | f->dump_unsigned("pending", pending); | |
58 | f->dump_unsigned("client_follows", client_follows); | |
59 | f->dump_unsigned("seq", seq); | |
60 | f->dump_unsigned("migrate_seq", mseq); | |
61 | f->dump_stream("last_issue_stamp") << last_issue_stamp; | |
62 | } | |
63 | ||
64 | void Capability::Export::generate_test_instances(list<Capability::Export*>& ls) | |
65 | { | |
66 | ls.push_back(new Export); | |
67 | ls.push_back(new Export); | |
68 | ls.back()->wanted = 1; | |
69 | ls.back()->issued = 2; | |
70 | ls.back()->pending = 3; | |
71 | ls.back()->client_follows = 4; | |
72 | ls.back()->mseq = 5; | |
73 | ls.back()->last_issue_stamp = utime_t(6, 7); | |
74 | } | |
75 | ||
76 | void Capability::Import::encode(bufferlist &bl) const | |
77 | { | |
78 | ENCODE_START(1, 1, bl); | |
79 | ::encode(cap_id, bl); | |
80 | ::encode(issue_seq, bl); | |
81 | ::encode(mseq, bl); | |
82 | ENCODE_FINISH(bl); | |
83 | } | |
84 | ||
85 | void Capability::Import::decode(bufferlist::iterator &bl) | |
86 | { | |
87 | DECODE_START(1, bl); | |
88 | ::decode(cap_id, bl); | |
89 | ::decode(issue_seq, bl); | |
90 | ::decode(mseq, bl); | |
91 | DECODE_FINISH(bl); | |
92 | } | |
93 | ||
94 | void Capability::Import::dump(Formatter *f) const | |
95 | { | |
96 | f->dump_unsigned("cap_id", cap_id); | |
97 | f->dump_unsigned("issue_seq", issue_seq); | |
98 | f->dump_unsigned("migrate_seq", mseq); | |
99 | } | |
100 | ||
101 | /* | |
102 | * Capability::revoke_info | |
103 | */ | |
104 | ||
105 | void Capability::revoke_info::encode(bufferlist& bl) const | |
106 | { | |
107 | ENCODE_START(2, 2, bl) | |
108 | ::encode(before, bl); | |
109 | ::encode(seq, bl); | |
110 | ::encode(last_issue, bl); | |
111 | ENCODE_FINISH(bl); | |
112 | } | |
113 | ||
114 | void Capability::revoke_info::decode(bufferlist::iterator& bl) | |
115 | { | |
116 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); | |
117 | ::decode(before, bl); | |
118 | ::decode(seq, bl); | |
119 | ::decode(last_issue, bl); | |
120 | DECODE_FINISH(bl); | |
121 | } | |
122 | ||
123 | void Capability::revoke_info::dump(Formatter *f) const | |
124 | { | |
125 | f->dump_unsigned("before", before); | |
126 | f->dump_unsigned("seq", seq); | |
127 | f->dump_unsigned("last_issue", last_issue); | |
128 | } | |
129 | ||
130 | void Capability::revoke_info::generate_test_instances(list<Capability::revoke_info*>& ls) | |
131 | { | |
132 | ls.push_back(new revoke_info); | |
133 | ls.push_back(new revoke_info); | |
134 | ls.back()->before = 1; | |
135 | ls.back()->seq = 2; | |
136 | ls.back()->last_issue = 3; | |
137 | } | |
138 | ||
139 | ||
140 | /* | |
141 | * Capability | |
142 | */ | |
143 | ||
144 | void Capability::encode(bufferlist& bl) const | |
145 | { | |
146 | ENCODE_START(2, 2, bl) | |
147 | ::encode(last_sent, bl); | |
148 | ::encode(last_issue_stamp, bl); | |
149 | ||
150 | ::encode(_wanted, bl); | |
151 | ::encode(_pending, bl); | |
152 | ::encode(_revokes, bl); | |
153 | ENCODE_FINISH(bl); | |
154 | } | |
155 | ||
156 | void Capability::decode(bufferlist::iterator &bl) | |
157 | { | |
158 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl) | |
159 | ::decode(last_sent, bl); | |
160 | ::decode(last_issue_stamp, bl); | |
161 | ||
162 | ::decode(_wanted, bl); | |
163 | ::decode(_pending, bl); | |
164 | ::decode(_revokes, bl); | |
165 | DECODE_FINISH(bl); | |
166 | ||
167 | _calc_issued(); | |
168 | } | |
169 | ||
170 | void Capability::dump(Formatter *f) const | |
171 | { | |
172 | f->dump_unsigned("last_sent", last_sent); | |
173 | f->dump_unsigned("last_issue_stamp", last_issue_stamp); | |
174 | f->dump_unsigned("wanted", _wanted); | |
175 | f->dump_unsigned("pending", _pending); | |
176 | ||
177 | f->open_array_section("revokes"); | |
94b18763 | 178 | for (const auto &r : _revokes) { |
7c673cae | 179 | f->open_object_section("revoke"); |
94b18763 | 180 | r.dump(f); |
7c673cae FG |
181 | f->close_section(); |
182 | } | |
183 | f->close_section(); | |
184 | } | |
185 | ||
186 | void Capability::generate_test_instances(list<Capability*>& ls) | |
187 | { | |
188 | ls.push_back(new Capability); | |
189 | ls.push_back(new Capability); | |
190 | ls.back()->last_sent = 11; | |
191 | ls.back()->last_issue_stamp = utime_t(12, 13); | |
192 | ls.back()->_wanted = 14; | |
193 | ls.back()->_pending = 15; | |
94b18763 FG |
194 | { |
195 | ls.back()->_revokes.emplace_back(); | |
196 | auto &r = ls.back()->_revokes.back(); | |
197 | r.before = 16; | |
198 | r.seq = 17; | |
199 | r.last_issue = 18; | |
200 | } | |
201 | { | |
202 | ls.back()->_revokes.emplace_back(); | |
203 | auto &r = ls.back()->_revokes.back(); | |
204 | r.before = 19; | |
205 | r.seq = 20; | |
206 | r.last_issue = 21; | |
207 | } | |
7c673cae | 208 | } |
94b18763 FG |
209 | |
210 | MEMPOOL_DEFINE_OBJECT_FACTORY(Capability, co_cap, mds_co); |