]>
Commit | Line | Data |
---|---|---|
d7e09d03 PT |
1 | /* |
2 | * GPL HEADER START | |
3 | * | |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 only, | |
8 | * as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License version 2 for more details (a copy is included | |
14 | * in the LICENSE file that accompanied this code). | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * version 2 along with this program; If not, see | |
6a5b99a4 | 18 | * http://www.gnu.org/licenses/gpl-2.0.html |
d7e09d03 | 19 | * |
d7e09d03 PT |
20 | * GPL HEADER END |
21 | */ | |
22 | /* | |
23 | * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | |
24 | * Use is subject to license terms. | |
25 | * | |
26 | * Copyright (c) 2011, 2012, Intel Corporation. | |
27 | */ | |
28 | /* | |
29 | * This file is part of Lustre, http://www.lustre.org/ | |
30 | * Lustre is a trademark of Sun Microsystems, Inc. | |
31 | * | |
32 | * lustre/ptlrpc/pack_generic.c | |
33 | * | |
34 | * (Un)packing of OST requests | |
35 | * | |
36 | * Author: Peter J. Braam <braam@clusterfs.com> | |
37 | * Author: Phil Schwan <phil@clusterfs.com> | |
38 | * Author: Eric Barton <eeb@clusterfs.com> | |
39 | */ | |
40 | ||
41 | #define DEBUG_SUBSYSTEM S_RPC | |
42 | ||
9fdaf8c0 | 43 | #include "../../include/linux/libcfs/libcfs.h" |
d7e09d03 | 44 | |
884a1369 BE |
45 | #include "../include/lustre/ll_fiemap.h" |
46 | ||
36dc51cc | 47 | #include "../include/llog_swab.h" |
e27db149 | 48 | #include "../include/lustre_net.h" |
36dc51cc | 49 | #include "../include/lustre_swab.h" |
e27db149 | 50 | #include "../include/obd_cksum.h" |
884a1369 BE |
51 | #include "../include/obd_support.h" |
52 | #include "../include/obd_class.h" | |
d7e09d03 | 53 | |
f157d807 IAR |
54 | #include "ptlrpc_internal.h" |
55 | ||
26ad0dc3 | 56 | static inline u32 lustre_msg_hdr_size_v2(u32 count) |
d7e09d03 PT |
57 | { |
58 | return cfs_size_round(offsetof(struct lustre_msg_v2, | |
59 | lm_buflens[count])); | |
60 | } | |
61 | ||
26ad0dc3 | 62 | u32 lustre_msg_hdr_size(__u32 magic, u32 count) |
d7e09d03 PT |
63 | { |
64 | switch (magic) { | |
65 | case LUSTRE_MSG_MAGIC_V2: | |
66 | return lustre_msg_hdr_size_v2(count); | |
67 | default: | |
68 | LASSERTF(0, "incorrect message magic: %08x\n", magic); | |
26ad0dc3 | 69 | return 0; |
d7e09d03 PT |
70 | } |
71 | } | |
d7e09d03 PT |
72 | |
73 | void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout, | |
26ad0dc3 | 74 | u32 index) |
d7e09d03 PT |
75 | { |
76 | if (inout) | |
77 | lustre_set_req_swabbed(req, index); | |
78 | else | |
79 | lustre_set_rep_swabbed(req, index); | |
80 | } | |
d7e09d03 PT |
81 | |
82 | int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout, | |
26ad0dc3 | 83 | u32 index) |
d7e09d03 PT |
84 | { |
85 | if (inout) | |
86 | return (ptlrpc_req_need_swab(req) && | |
87 | !lustre_req_swabbed(req, index)); | |
88 | else | |
89 | return (ptlrpc_rep_need_swab(req) && | |
90 | !lustre_rep_swabbed(req, index)); | |
91 | } | |
d7e09d03 | 92 | |
d7e09d03 | 93 | /* early reply size */ |
26ad0dc3 | 94 | u32 lustre_msg_early_size(void) |
d7e09d03 | 95 | { |
26ad0dc3 | 96 | static u32 size; |
50ffcb7e | 97 | |
d7e09d03 | 98 | if (!size) { |
dfc16973 | 99 | /* Always reply old ptlrpc_body_v2 to keep interoperability |
d7e09d03 PT |
100 | * with the old client (< 2.3) which doesn't have pb_jobid |
101 | * in the ptlrpc_body. | |
102 | * | |
dfc16973 | 103 | * XXX Remove this whenever we drop interoperability with such |
d7e09d03 PT |
104 | * client. |
105 | */ | |
106 | __u32 pblen = sizeof(struct ptlrpc_body_v2); | |
50ffcb7e | 107 | |
d7e09d03 PT |
108 | size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, &pblen); |
109 | } | |
110 | return size; | |
111 | } | |
112 | EXPORT_SYMBOL(lustre_msg_early_size); | |
113 | ||
26ad0dc3 | 114 | u32 lustre_msg_size_v2(int count, __u32 *lengths) |
d7e09d03 | 115 | { |
26ad0dc3 | 116 | u32 size; |
d7e09d03 PT |
117 | int i; |
118 | ||
119 | size = lustre_msg_hdr_size_v2(count); | |
120 | for (i = 0; i < count; i++) | |
121 | size += cfs_size_round(lengths[i]); | |
122 | ||
123 | return size; | |
124 | } | |
125 | EXPORT_SYMBOL(lustre_msg_size_v2); | |
126 | ||
127 | /* This returns the size of the buffer that is required to hold a lustre_msg | |
128 | * with the given sub-buffer lengths. | |
129 | * NOTE: this should only be used for NEW requests, and should always be | |
130 | * in the form of a v2 request. If this is a connection to a v1 | |
131 | * target then the first buffer will be stripped because the ptlrpc | |
dadfcdab OD |
132 | * data is part of the lustre_msg_v1 header. b=14043 |
133 | */ | |
26ad0dc3 | 134 | u32 lustre_msg_size(__u32 magic, int count, __u32 *lens) |
d7e09d03 PT |
135 | { |
136 | __u32 size[] = { sizeof(struct ptlrpc_body) }; | |
137 | ||
138 | if (!lens) { | |
139 | LASSERT(count == 1); | |
140 | lens = size; | |
141 | } | |
142 | ||
143 | LASSERT(count > 0); | |
144 | LASSERT(lens[MSG_PTLRPC_BODY_OFF] >= sizeof(struct ptlrpc_body_v2)); | |
145 | ||
146 | switch (magic) { | |
147 | case LUSTRE_MSG_MAGIC_V2: | |
148 | return lustre_msg_size_v2(count, lens); | |
149 | default: | |
150 | LASSERTF(0, "incorrect message magic: %08x\n", magic); | |
26ad0dc3 | 151 | return 0; |
d7e09d03 PT |
152 | } |
153 | } | |
d7e09d03 PT |
154 | |
155 | /* This is used to determine the size of a buffer that was already packed | |
dadfcdab OD |
156 | * and will correctly handle the different message formats. |
157 | */ | |
26ad0dc3 | 158 | u32 lustre_packed_msg_size(struct lustre_msg *msg) |
d7e09d03 PT |
159 | { |
160 | switch (msg->lm_magic) { | |
161 | case LUSTRE_MSG_MAGIC_V2: | |
162 | return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens); | |
163 | default: | |
164 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
165 | return 0; | |
166 | } | |
167 | } | |
d7e09d03 PT |
168 | |
169 | void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens, | |
170 | char **bufs) | |
171 | { | |
172 | char *ptr; | |
173 | int i; | |
174 | ||
175 | msg->lm_bufcount = count; | |
176 | /* XXX: lm_secflvr uninitialized here */ | |
177 | msg->lm_magic = LUSTRE_MSG_MAGIC_V2; | |
178 | ||
179 | for (i = 0; i < count; i++) | |
180 | msg->lm_buflens[i] = lens[i]; | |
181 | ||
8b382089 | 182 | if (!bufs) |
d7e09d03 PT |
183 | return; |
184 | ||
185 | ptr = (char *)msg + lustre_msg_hdr_size_v2(count); | |
186 | for (i = 0; i < count; i++) { | |
187 | char *tmp = bufs[i]; | |
50ffcb7e | 188 | |
d7e09d03 PT |
189 | LOGL(tmp, lens[i], ptr); |
190 | } | |
191 | } | |
192 | EXPORT_SYMBOL(lustre_init_msg_v2); | |
193 | ||
194 | static int lustre_pack_request_v2(struct ptlrpc_request *req, | |
195 | int count, __u32 *lens, char **bufs) | |
196 | { | |
197 | int reqlen, rc; | |
198 | ||
199 | reqlen = lustre_msg_size_v2(count, lens); | |
200 | ||
201 | rc = sptlrpc_cli_alloc_reqbuf(req, reqlen); | |
202 | if (rc) | |
203 | return rc; | |
204 | ||
205 | req->rq_reqlen = reqlen; | |
206 | ||
207 | lustre_init_msg_v2(req->rq_reqmsg, count, lens, bufs); | |
208 | lustre_msg_add_version(req->rq_reqmsg, PTLRPC_MSG_VERSION); | |
209 | return 0; | |
210 | } | |
211 | ||
212 | int lustre_pack_request(struct ptlrpc_request *req, __u32 magic, int count, | |
213 | __u32 *lens, char **bufs) | |
214 | { | |
215 | __u32 size[] = { sizeof(struct ptlrpc_body) }; | |
216 | ||
217 | if (!lens) { | |
218 | LASSERT(count == 1); | |
219 | lens = size; | |
220 | } | |
221 | ||
222 | LASSERT(count > 0); | |
223 | LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body)); | |
224 | ||
225 | /* only use new format, we don't need to be compatible with 1.4 */ | |
de636b38 | 226 | return lustre_pack_request_v2(req, count, lens, bufs); |
d7e09d03 | 227 | } |
d7e09d03 PT |
228 | |
229 | #if RS_DEBUG | |
230 | LIST_HEAD(ptlrpc_rs_debug_lru); | |
231 | spinlock_t ptlrpc_rs_debug_lock; | |
232 | ||
233 | #define PTLRPC_RS_DEBUG_LRU_ADD(rs) \ | |
234 | do { \ | |
235 | spin_lock(&ptlrpc_rs_debug_lock); \ | |
236 | list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru); \ | |
237 | spin_unlock(&ptlrpc_rs_debug_lock); \ | |
238 | } while (0) | |
239 | ||
240 | #define PTLRPC_RS_DEBUG_LRU_DEL(rs) \ | |
241 | do { \ | |
242 | spin_lock(&ptlrpc_rs_debug_lock); \ | |
243 | list_del(&(rs)->rs_debug_list); \ | |
244 | spin_unlock(&ptlrpc_rs_debug_lock); \ | |
245 | } while (0) | |
246 | #else | |
0d100bfc KM |
247 | # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while (0) |
248 | # define PTLRPC_RS_DEBUG_LRU_DEL(rs) do {} while (0) | |
d7e09d03 PT |
249 | #endif |
250 | ||
251 | struct ptlrpc_reply_state * | |
252 | lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) | |
253 | { | |
254 | struct ptlrpc_reply_state *rs = NULL; | |
255 | ||
256 | spin_lock(&svcpt->scp_rep_lock); | |
257 | ||
258 | /* See if we have anything in a pool, and wait if nothing */ | |
259 | while (list_empty(&svcpt->scp_rep_idle)) { | |
d0bfef31 CH |
260 | struct l_wait_info lwi; |
261 | int rc; | |
d7e09d03 PT |
262 | |
263 | spin_unlock(&svcpt->scp_rep_lock); | |
264 | /* If we cannot get anything for some long time, we better | |
dadfcdab OD |
265 | * bail out instead of waiting infinitely |
266 | */ | |
d7e09d03 PT |
267 | lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL); |
268 | rc = l_wait_event(svcpt->scp_rep_waitq, | |
269 | !list_empty(&svcpt->scp_rep_idle), &lwi); | |
270 | if (rc != 0) | |
271 | goto out; | |
272 | spin_lock(&svcpt->scp_rep_lock); | |
273 | } | |
274 | ||
275 | rs = list_entry(svcpt->scp_rep_idle.next, | |
30c0aa39 | 276 | struct ptlrpc_reply_state, rs_list); |
d7e09d03 PT |
277 | list_del(&rs->rs_list); |
278 | ||
279 | spin_unlock(&svcpt->scp_rep_lock); | |
280 | ||
281 | memset(rs, 0, svcpt->scp_service->srv_max_reply_size); | |
a34041af | 282 | rs->rs_size = svcpt->scp_service->srv_max_reply_size; |
d7e09d03 PT |
283 | rs->rs_svcpt = svcpt; |
284 | rs->rs_prealloc = 1; | |
285 | out: | |
286 | return rs; | |
287 | } | |
288 | ||
289 | void lustre_put_emerg_rs(struct ptlrpc_reply_state *rs) | |
290 | { | |
291 | struct ptlrpc_service_part *svcpt = rs->rs_svcpt; | |
292 | ||
293 | spin_lock(&svcpt->scp_rep_lock); | |
294 | list_add(&rs->rs_list, &svcpt->scp_rep_idle); | |
295 | spin_unlock(&svcpt->scp_rep_lock); | |
296 | wake_up(&svcpt->scp_rep_waitq); | |
297 | } | |
298 | ||
299 | int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, | |
300 | __u32 *lens, char **bufs, int flags) | |
301 | { | |
302 | struct ptlrpc_reply_state *rs; | |
d0bfef31 | 303 | int msg_len, rc; |
d7e09d03 | 304 | |
8b382089 | 305 | LASSERT(!req->rq_reply_state); |
d7e09d03 PT |
306 | |
307 | if ((flags & LPRFL_EARLY_REPLY) == 0) { | |
308 | spin_lock(&req->rq_lock); | |
309 | req->rq_packed_final = 1; | |
310 | spin_unlock(&req->rq_lock); | |
311 | } | |
312 | ||
313 | msg_len = lustre_msg_size_v2(count, lens); | |
314 | rc = sptlrpc_svc_alloc_rs(req, msg_len); | |
315 | if (rc) | |
0a3bdb00 | 316 | return rc; |
d7e09d03 PT |
317 | |
318 | rs = req->rq_reply_state; | |
319 | atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */ | |
320 | rs->rs_cb_id.cbid_fn = reply_out_callback; | |
321 | rs->rs_cb_id.cbid_arg = rs; | |
322 | rs->rs_svcpt = req->rq_rqbd->rqbd_svcpt; | |
323 | INIT_LIST_HEAD(&rs->rs_exp_list); | |
324 | INIT_LIST_HEAD(&rs->rs_obd_list); | |
325 | INIT_LIST_HEAD(&rs->rs_list); | |
326 | spin_lock_init(&rs->rs_lock); | |
327 | ||
328 | req->rq_replen = msg_len; | |
329 | req->rq_reply_state = rs; | |
330 | req->rq_repmsg = rs->rs_msg; | |
331 | ||
332 | lustre_init_msg_v2(rs->rs_msg, count, lens, bufs); | |
333 | lustre_msg_add_version(rs->rs_msg, PTLRPC_MSG_VERSION); | |
334 | ||
335 | PTLRPC_RS_DEBUG_LRU_ADD(rs); | |
336 | ||
0a3bdb00 | 337 | return 0; |
d7e09d03 PT |
338 | } |
339 | EXPORT_SYMBOL(lustre_pack_reply_v2); | |
340 | ||
341 | int lustre_pack_reply_flags(struct ptlrpc_request *req, int count, __u32 *lens, | |
342 | char **bufs, int flags) | |
343 | { | |
344 | int rc = 0; | |
345 | __u32 size[] = { sizeof(struct ptlrpc_body) }; | |
346 | ||
347 | if (!lens) { | |
348 | LASSERT(count == 1); | |
349 | lens = size; | |
350 | } | |
351 | ||
352 | LASSERT(count > 0); | |
353 | LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body)); | |
354 | ||
355 | switch (req->rq_reqmsg->lm_magic) { | |
356 | case LUSTRE_MSG_MAGIC_V2: | |
357 | rc = lustre_pack_reply_v2(req, count, lens, bufs, flags); | |
358 | break; | |
359 | default: | |
360 | LASSERTF(0, "incorrect message magic: %08x\n", | |
361 | req->rq_reqmsg->lm_magic); | |
362 | rc = -EINVAL; | |
363 | } | |
364 | if (rc != 0) | |
365 | CERROR("lustre_pack_reply failed: rc=%d size=%d\n", rc, | |
366 | lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens)); | |
367 | return rc; | |
368 | } | |
d7e09d03 PT |
369 | |
370 | int lustre_pack_reply(struct ptlrpc_request *req, int count, __u32 *lens, | |
371 | char **bufs) | |
372 | { | |
373 | return lustre_pack_reply_flags(req, count, lens, bufs, 0); | |
374 | } | |
375 | EXPORT_SYMBOL(lustre_pack_reply); | |
376 | ||
26ad0dc3 | 377 | void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, u32 n, u32 min_size) |
d7e09d03 | 378 | { |
26ad0dc3 | 379 | u32 i, offset, buflen, bufcount; |
d7e09d03 PT |
380 | |
381 | bufcount = m->lm_bufcount; | |
382 | if (unlikely(n >= bufcount)) { | |
383 | CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n", | |
384 | m, n, bufcount); | |
385 | return NULL; | |
386 | } | |
387 | ||
388 | buflen = m->lm_buflens[n]; | |
389 | if (unlikely(buflen < min_size)) { | |
2d00bd17 JP |
390 | CERROR("msg %p buffer[%d] size %d too small (required %d, opc=%d)\n", |
391 | m, n, buflen, min_size, | |
d7e09d03 PT |
392 | n == MSG_PTLRPC_BODY_OFF ? -1 : lustre_msg_get_opc(m)); |
393 | return NULL; | |
394 | } | |
395 | ||
396 | offset = lustre_msg_hdr_size_v2(bufcount); | |
397 | for (i = 0; i < n; i++) | |
398 | offset += cfs_size_round(m->lm_buflens[i]); | |
399 | ||
400 | return (char *)m + offset; | |
401 | } | |
402 | ||
26ad0dc3 | 403 | void *lustre_msg_buf(struct lustre_msg *m, u32 n, u32 min_size) |
d7e09d03 PT |
404 | { |
405 | switch (m->lm_magic) { | |
406 | case LUSTRE_MSG_MAGIC_V2: | |
407 | return lustre_msg_buf_v2(m, n, min_size); | |
408 | default: | |
2e4fe2bd AD |
409 | LASSERTF(0, "incorrect message magic: %08x (msg:%p)\n", |
410 | m->lm_magic, m); | |
d7e09d03 PT |
411 | return NULL; |
412 | } | |
413 | } | |
414 | EXPORT_SYMBOL(lustre_msg_buf); | |
415 | ||
26ad0dc3 | 416 | static int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, u32 segment, |
2adf5e87 | 417 | unsigned int newlen, int move_data) |
d7e09d03 | 418 | { |
d0bfef31 CH |
419 | char *tail = NULL, *newpos; |
420 | int tail_len = 0, n; | |
d7e09d03 PT |
421 | |
422 | LASSERT(msg); | |
423 | LASSERT(msg->lm_bufcount > segment); | |
424 | LASSERT(msg->lm_buflens[segment] >= newlen); | |
425 | ||
426 | if (msg->lm_buflens[segment] == newlen) | |
427 | goto out; | |
428 | ||
429 | if (move_data && msg->lm_bufcount > segment + 1) { | |
430 | tail = lustre_msg_buf_v2(msg, segment + 1, 0); | |
431 | for (n = segment + 1; n < msg->lm_bufcount; n++) | |
432 | tail_len += cfs_size_round(msg->lm_buflens[n]); | |
433 | } | |
434 | ||
435 | msg->lm_buflens[segment] = newlen; | |
436 | ||
437 | if (tail && tail_len) { | |
438 | newpos = lustre_msg_buf_v2(msg, segment + 1, 0); | |
439 | LASSERT(newpos <= tail); | |
440 | if (newpos != tail) | |
441 | memmove(newpos, tail, tail_len); | |
442 | } | |
443 | out: | |
444 | return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens); | |
445 | } | |
446 | ||
447 | /* | |
448 | * for @msg, shrink @segment to size @newlen. if @move_data is non-zero, | |
449 | * we also move data forward from @segment + 1. | |
450 | * | |
451 | * if @newlen == 0, we remove the segment completely, but we still keep the | |
452 | * totally bufcount the same to save possible data moving. this will leave a | |
453 | * unused segment with size 0 at the tail, but that's ok. | |
454 | * | |
455 | * return new msg size after shrinking. | |
456 | * | |
457 | * CAUTION: | |
458 | * + if any buffers higher than @segment has been filled in, must call shrink | |
459 | * with non-zero @move_data. | |
460 | * + caller should NOT keep pointers to msg buffers which higher than @segment | |
461 | * after call shrink. | |
462 | */ | |
463 | int lustre_shrink_msg(struct lustre_msg *msg, int segment, | |
464 | unsigned int newlen, int move_data) | |
465 | { | |
466 | switch (msg->lm_magic) { | |
467 | case LUSTRE_MSG_MAGIC_V2: | |
468 | return lustre_shrink_msg_v2(msg, segment, newlen, move_data); | |
469 | default: | |
470 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
471 | } | |
74e3bb75 | 472 | return 0; |
d7e09d03 PT |
473 | } |
474 | EXPORT_SYMBOL(lustre_shrink_msg); | |
475 | ||
476 | void lustre_free_reply_state(struct ptlrpc_reply_state *rs) | |
477 | { | |
478 | PTLRPC_RS_DEBUG_LRU_DEL(rs); | |
479 | ||
0d100bfc KM |
480 | LASSERT(atomic_read(&rs->rs_refcount) == 0); |
481 | LASSERT(!rs->rs_difficult || rs->rs_handled); | |
482 | LASSERT(!rs->rs_on_net); | |
483 | LASSERT(!rs->rs_scheduled); | |
8b382089 | 484 | LASSERT(!rs->rs_export); |
0d100bfc KM |
485 | LASSERT(rs->rs_nlocks == 0); |
486 | LASSERT(list_empty(&rs->rs_exp_list)); | |
487 | LASSERT(list_empty(&rs->rs_obd_list)); | |
d7e09d03 PT |
488 | |
489 | sptlrpc_svc_free_rs(rs); | |
490 | } | |
d7e09d03 PT |
491 | |
492 | static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len) | |
493 | { | |
494 | int swabbed, required_len, i; | |
495 | ||
496 | /* Now we know the sender speaks my language. */ | |
497 | required_len = lustre_msg_hdr_size_v2(0); | |
498 | if (len < required_len) { | |
499 | /* can't even look inside the message */ | |
500 | CERROR("message length %d too small for lustre_msg\n", len); | |
501 | return -EINVAL; | |
502 | } | |
503 | ||
504 | swabbed = (m->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED); | |
505 | ||
506 | if (swabbed) { | |
507 | __swab32s(&m->lm_magic); | |
508 | __swab32s(&m->lm_bufcount); | |
509 | __swab32s(&m->lm_secflvr); | |
510 | __swab32s(&m->lm_repsize); | |
511 | __swab32s(&m->lm_cksum); | |
512 | __swab32s(&m->lm_flags); | |
f440d909 AB |
513 | BUILD_BUG_ON(offsetof(typeof(*m), lm_padding_2) == 0); |
514 | BUILD_BUG_ON(offsetof(typeof(*m), lm_padding_3) == 0); | |
d7e09d03 PT |
515 | } |
516 | ||
517 | required_len = lustre_msg_hdr_size_v2(m->lm_bufcount); | |
518 | if (len < required_len) { | |
519 | /* didn't receive all the buffer lengths */ | |
0d100bfc KM |
520 | CERROR("message length %d too small for %d buflens\n", |
521 | len, m->lm_bufcount); | |
d7e09d03 PT |
522 | return -EINVAL; |
523 | } | |
524 | ||
525 | for (i = 0; i < m->lm_bufcount; i++) { | |
526 | if (swabbed) | |
527 | __swab32s(&m->lm_buflens[i]); | |
528 | required_len += cfs_size_round(m->lm_buflens[i]); | |
529 | } | |
530 | ||
531 | if (len < required_len) { | |
532 | CERROR("len: %d, required_len %d\n", len, required_len); | |
533 | CERROR("bufcount: %d\n", m->lm_bufcount); | |
534 | for (i = 0; i < m->lm_bufcount; i++) | |
535 | CERROR("buffer %d length %d\n", i, m->lm_buflens[i]); | |
536 | return -EINVAL; | |
537 | } | |
538 | ||
539 | return swabbed; | |
540 | } | |
541 | ||
542 | int __lustre_unpack_msg(struct lustre_msg *m, int len) | |
543 | { | |
544 | int required_len, rc; | |
d7e09d03 PT |
545 | |
546 | /* We can provide a slightly better error log, if we check the | |
547 | * message magic and version first. In the future, struct | |
548 | * lustre_msg may grow, and we'd like to log a version mismatch, | |
549 | * rather than a short message. | |
550 | * | |
551 | */ | |
552 | required_len = offsetof(struct lustre_msg, lm_magic) + | |
553 | sizeof(m->lm_magic); | |
554 | if (len < required_len) { | |
555 | /* can't even look inside the message */ | |
556 | CERROR("message length %d too small for magic/version check\n", | |
557 | len); | |
0a3bdb00 | 558 | return -EINVAL; |
d7e09d03 PT |
559 | } |
560 | ||
561 | rc = lustre_unpack_msg_v2(m, len); | |
562 | ||
0a3bdb00 | 563 | return rc; |
d7e09d03 PT |
564 | } |
565 | EXPORT_SYMBOL(__lustre_unpack_msg); | |
566 | ||
567 | int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len) | |
568 | { | |
569 | int rc; | |
50ffcb7e | 570 | |
d7e09d03 PT |
571 | rc = __lustre_unpack_msg(req->rq_reqmsg, len); |
572 | if (rc == 1) { | |
573 | lustre_set_req_swabbed(req, MSG_PTLRPC_HEADER_OFF); | |
574 | rc = 0; | |
575 | } | |
576 | return rc; | |
577 | } | |
d7e09d03 PT |
578 | |
579 | int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len) | |
580 | { | |
581 | int rc; | |
50ffcb7e | 582 | |
d7e09d03 PT |
583 | rc = __lustre_unpack_msg(req->rq_repmsg, len); |
584 | if (rc == 1) { | |
585 | lustre_set_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF); | |
586 | rc = 0; | |
587 | } | |
588 | return rc; | |
589 | } | |
d7e09d03 PT |
590 | |
591 | static inline int lustre_unpack_ptlrpc_body_v2(struct ptlrpc_request *req, | |
592 | const int inout, int offset) | |
593 | { | |
594 | struct ptlrpc_body *pb; | |
595 | struct lustre_msg_v2 *m = inout ? req->rq_reqmsg : req->rq_repmsg; | |
596 | ||
597 | pb = lustre_msg_buf_v2(m, offset, sizeof(struct ptlrpc_body_v2)); | |
598 | if (!pb) { | |
599 | CERROR("error unpacking ptlrpc body\n"); | |
600 | return -EFAULT; | |
601 | } | |
602 | if (ptlrpc_buf_need_swab(req, inout, offset)) { | |
603 | lustre_swab_ptlrpc_body(pb); | |
604 | ptlrpc_buf_set_swabbed(req, inout, offset); | |
605 | } | |
606 | ||
607 | if ((pb->pb_version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) { | |
532118c0 KM |
608 | CERROR("wrong lustre_msg version %08x\n", pb->pb_version); |
609 | return -EINVAL; | |
d7e09d03 PT |
610 | } |
611 | ||
2d58de78 LW |
612 | if (!inout) |
613 | pb->pb_status = ptlrpc_status_ntoh(pb->pb_status); | |
614 | ||
d7e09d03 PT |
615 | return 0; |
616 | } | |
617 | ||
618 | int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset) | |
619 | { | |
620 | switch (req->rq_reqmsg->lm_magic) { | |
621 | case LUSTRE_MSG_MAGIC_V2: | |
622 | return lustre_unpack_ptlrpc_body_v2(req, 1, offset); | |
623 | default: | |
624 | CERROR("bad lustre msg magic: %08x\n", | |
625 | req->rq_reqmsg->lm_magic); | |
626 | return -EINVAL; | |
627 | } | |
628 | } | |
629 | ||
630 | int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset) | |
631 | { | |
632 | switch (req->rq_repmsg->lm_magic) { | |
633 | case LUSTRE_MSG_MAGIC_V2: | |
634 | return lustre_unpack_ptlrpc_body_v2(req, 0, offset); | |
635 | default: | |
636 | CERROR("bad lustre msg magic: %08x\n", | |
637 | req->rq_repmsg->lm_magic); | |
638 | return -EINVAL; | |
639 | } | |
640 | } | |
641 | ||
26ad0dc3 | 642 | static inline u32 lustre_msg_buflen_v2(struct lustre_msg_v2 *m, u32 n) |
d7e09d03 PT |
643 | { |
644 | if (n >= m->lm_bufcount) | |
645 | return 0; | |
646 | ||
647 | return m->lm_buflens[n]; | |
648 | } | |
649 | ||
650 | /** | |
651 | * lustre_msg_buflen - return the length of buffer \a n in message \a m | |
652 | * \param m lustre_msg (request or reply) to look at | |
653 | * \param n message index (base 0) | |
654 | * | |
655 | * returns zero for non-existent message indices | |
656 | */ | |
26ad0dc3 | 657 | u32 lustre_msg_buflen(struct lustre_msg *m, u32 n) |
d7e09d03 PT |
658 | { |
659 | switch (m->lm_magic) { | |
660 | case LUSTRE_MSG_MAGIC_V2: | |
661 | return lustre_msg_buflen_v2(m, n); | |
662 | default: | |
663 | CERROR("incorrect message magic: %08x\n", m->lm_magic); | |
26ad0dc3 | 664 | return 0; |
d7e09d03 PT |
665 | } |
666 | } | |
667 | EXPORT_SYMBOL(lustre_msg_buflen); | |
668 | ||
d7e09d03 | 669 | /* NB return the bufcount for lustre_msg_v2 format, so if message is packed |
dadfcdab OD |
670 | * in V1 format, the result is one bigger. (add struct ptlrpc_body). |
671 | */ | |
26ad0dc3 | 672 | u32 lustre_msg_bufcount(struct lustre_msg *m) |
d7e09d03 PT |
673 | { |
674 | switch (m->lm_magic) { | |
675 | case LUSTRE_MSG_MAGIC_V2: | |
676 | return m->lm_bufcount; | |
677 | default: | |
678 | CERROR("incorrect message magic: %08x\n", m->lm_magic); | |
26ad0dc3 | 679 | return 0; |
d7e09d03 PT |
680 | } |
681 | } | |
d7e09d03 | 682 | |
26ad0dc3 | 683 | char *lustre_msg_string(struct lustre_msg *m, u32 index, u32 max_len) |
d7e09d03 PT |
684 | { |
685 | /* max_len == 0 means the string should fill the buffer */ | |
686 | char *str; | |
26ad0dc3 | 687 | u32 slen, blen; |
d7e09d03 PT |
688 | |
689 | switch (m->lm_magic) { | |
690 | case LUSTRE_MSG_MAGIC_V2: | |
691 | str = lustre_msg_buf_v2(m, index, 0); | |
692 | blen = lustre_msg_buflen_v2(m, index); | |
693 | break; | |
694 | default: | |
695 | LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic); | |
696 | } | |
697 | ||
8b382089 | 698 | if (!str) { |
0d100bfc | 699 | CERROR("can't unpack string in msg %p buffer[%d]\n", m, index); |
d7e09d03 PT |
700 | return NULL; |
701 | } | |
702 | ||
703 | slen = strnlen(str, blen); | |
704 | ||
705 | if (slen == blen) { /* not NULL terminated */ | |
2d00bd17 JP |
706 | CERROR("can't unpack non-NULL terminated string in msg %p buffer[%d] len %d\n", |
707 | m, index, blen); | |
d7e09d03 PT |
708 | return NULL; |
709 | } | |
710 | ||
711 | if (max_len == 0) { | |
712 | if (slen != blen - 1) { | |
2d00bd17 | 713 | CERROR("can't unpack short string in msg %p buffer[%d] len %d: strlen %d\n", |
d7e09d03 PT |
714 | m, index, blen, slen); |
715 | return NULL; | |
716 | } | |
717 | } else if (slen > max_len) { | |
2d00bd17 | 718 | CERROR("can't unpack oversized string in msg %p buffer[%d] len %d strlen %d: max %d expected\n", |
d7e09d03 PT |
719 | m, index, blen, slen, max_len); |
720 | return NULL; | |
721 | } | |
722 | ||
723 | return str; | |
724 | } | |
d7e09d03 PT |
725 | |
726 | /* Wrap up the normal fixed length cases */ | |
26ad0dc3 DE |
727 | static inline void *__lustre_swab_buf(struct lustre_msg *msg, u32 index, |
728 | u32 min_size, void *swabber) | |
d7e09d03 PT |
729 | { |
730 | void *ptr = NULL; | |
731 | ||
d7e09d03 PT |
732 | switch (msg->lm_magic) { |
733 | case LUSTRE_MSG_MAGIC_V2: | |
734 | ptr = lustre_msg_buf_v2(msg, index, min_size); | |
735 | break; | |
736 | default: | |
737 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
738 | } | |
739 | ||
740 | if (ptr && swabber) | |
741 | ((void (*)(void *))swabber)(ptr); | |
742 | ||
743 | return ptr; | |
744 | } | |
745 | ||
746 | static inline struct ptlrpc_body *lustre_msg_ptlrpc_body(struct lustre_msg *msg) | |
747 | { | |
748 | return lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, | |
749 | sizeof(struct ptlrpc_body_v2)); | |
750 | } | |
751 | ||
752 | __u32 lustre_msghdr_get_flags(struct lustre_msg *msg) | |
753 | { | |
754 | switch (msg->lm_magic) { | |
d7e09d03 PT |
755 | case LUSTRE_MSG_MAGIC_V2: |
756 | /* already in host endian */ | |
757 | return msg->lm_flags; | |
758 | default: | |
2e4fe2bd | 759 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); |
d7e09d03 PT |
760 | return 0; |
761 | } | |
762 | } | |
763 | EXPORT_SYMBOL(lustre_msghdr_get_flags); | |
764 | ||
765 | void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags) | |
766 | { | |
767 | switch (msg->lm_magic) { | |
d7e09d03 PT |
768 | case LUSTRE_MSG_MAGIC_V2: |
769 | msg->lm_flags = flags; | |
770 | return; | |
771 | default: | |
772 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
773 | } | |
774 | } | |
775 | ||
776 | __u32 lustre_msg_get_flags(struct lustre_msg *msg) | |
777 | { | |
778 | switch (msg->lm_magic) { | |
779 | case LUSTRE_MSG_MAGIC_V2: { | |
780 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 781 | |
2e4fe2bd AD |
782 | if (pb) |
783 | return pb->pb_flags; | |
784 | ||
785 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
d7e09d03 | 786 | } |
2e4fe2bd | 787 | /* no break */ |
d7e09d03 PT |
788 | default: |
789 | /* flags might be printed in debug code while message | |
dadfcdab OD |
790 | * uninitialized |
791 | */ | |
d7e09d03 PT |
792 | return 0; |
793 | } | |
794 | } | |
795 | EXPORT_SYMBOL(lustre_msg_get_flags); | |
796 | ||
26ad0dc3 | 797 | void lustre_msg_add_flags(struct lustre_msg *msg, u32 flags) |
d7e09d03 PT |
798 | { |
799 | switch (msg->lm_magic) { | |
800 | case LUSTRE_MSG_MAGIC_V2: { | |
801 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 802 | |
d7e09d03 PT |
803 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
804 | pb->pb_flags |= flags; | |
805 | return; | |
806 | } | |
807 | default: | |
808 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
809 | } | |
810 | } | |
811 | EXPORT_SYMBOL(lustre_msg_add_flags); | |
812 | ||
26ad0dc3 | 813 | void lustre_msg_set_flags(struct lustre_msg *msg, u32 flags) |
d7e09d03 PT |
814 | { |
815 | switch (msg->lm_magic) { | |
816 | case LUSTRE_MSG_MAGIC_V2: { | |
817 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 818 | |
d7e09d03 PT |
819 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
820 | pb->pb_flags = flags; | |
821 | return; | |
822 | } | |
823 | default: | |
824 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
825 | } | |
826 | } | |
d7e09d03 | 827 | |
26ad0dc3 | 828 | void lustre_msg_clear_flags(struct lustre_msg *msg, u32 flags) |
d7e09d03 PT |
829 | { |
830 | switch (msg->lm_magic) { | |
831 | case LUSTRE_MSG_MAGIC_V2: { | |
832 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 833 | |
d7e09d03 | 834 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
2b241d31 | 835 | pb->pb_flags &= ~(flags & MSG_GEN_FLAG_MASK); |
d7e09d03 PT |
836 | return; |
837 | } | |
838 | default: | |
839 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
840 | } | |
841 | } | |
842 | EXPORT_SYMBOL(lustre_msg_clear_flags); | |
843 | ||
844 | __u32 lustre_msg_get_op_flags(struct lustre_msg *msg) | |
845 | { | |
846 | switch (msg->lm_magic) { | |
847 | case LUSTRE_MSG_MAGIC_V2: { | |
848 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 849 | |
2e4fe2bd AD |
850 | if (pb) |
851 | return pb->pb_op_flags; | |
852 | ||
853 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
d7e09d03 | 854 | } |
2e4fe2bd | 855 | /* no break */ |
d7e09d03 PT |
856 | default: |
857 | return 0; | |
858 | } | |
859 | } | |
d7e09d03 | 860 | |
26ad0dc3 | 861 | void lustre_msg_add_op_flags(struct lustre_msg *msg, u32 flags) |
d7e09d03 PT |
862 | { |
863 | switch (msg->lm_magic) { | |
864 | case LUSTRE_MSG_MAGIC_V2: { | |
865 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 866 | |
d7e09d03 PT |
867 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
868 | pb->pb_op_flags |= flags; | |
869 | return; | |
870 | } | |
871 | default: | |
872 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
873 | } | |
874 | } | |
875 | EXPORT_SYMBOL(lustre_msg_add_op_flags); | |
876 | ||
d7e09d03 PT |
877 | struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg) |
878 | { | |
879 | switch (msg->lm_magic) { | |
880 | case LUSTRE_MSG_MAGIC_V2: { | |
881 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 882 | |
d7e09d03 PT |
883 | if (!pb) { |
884 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
885 | return NULL; | |
886 | } | |
887 | return &pb->pb_handle; | |
888 | } | |
889 | default: | |
890 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
891 | return NULL; | |
892 | } | |
893 | } | |
d7e09d03 PT |
894 | |
895 | __u32 lustre_msg_get_type(struct lustre_msg *msg) | |
896 | { | |
897 | switch (msg->lm_magic) { | |
898 | case LUSTRE_MSG_MAGIC_V2: { | |
899 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 900 | |
d7e09d03 PT |
901 | if (!pb) { |
902 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
903 | return PTL_RPC_MSG_ERR; | |
904 | } | |
905 | return pb->pb_type; | |
906 | } | |
907 | default: | |
908 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
909 | return PTL_RPC_MSG_ERR; | |
910 | } | |
911 | } | |
912 | EXPORT_SYMBOL(lustre_msg_get_type); | |
913 | ||
26ad0dc3 | 914 | void lustre_msg_add_version(struct lustre_msg *msg, u32 version) |
d7e09d03 PT |
915 | { |
916 | switch (msg->lm_magic) { | |
917 | case LUSTRE_MSG_MAGIC_V2: { | |
918 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 919 | |
d7e09d03 PT |
920 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
921 | pb->pb_version |= version; | |
922 | return; | |
923 | } | |
924 | default: | |
925 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
926 | } | |
927 | } | |
d7e09d03 PT |
928 | |
929 | __u32 lustre_msg_get_opc(struct lustre_msg *msg) | |
930 | { | |
931 | switch (msg->lm_magic) { | |
932 | case LUSTRE_MSG_MAGIC_V2: { | |
933 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 934 | |
d7e09d03 PT |
935 | if (!pb) { |
936 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
937 | return 0; | |
938 | } | |
939 | return pb->pb_opc; | |
940 | } | |
941 | default: | |
2e4fe2bd AD |
942 | CERROR("incorrect message magic: %08x (msg:%p)\n", |
943 | msg->lm_magic, msg); | |
d7e09d03 PT |
944 | return 0; |
945 | } | |
946 | } | |
947 | EXPORT_SYMBOL(lustre_msg_get_opc); | |
948 | ||
e33115e3 GP |
949 | __u16 lustre_msg_get_tag(struct lustre_msg *msg) |
950 | { | |
951 | switch (msg->lm_magic) { | |
952 | case LUSTRE_MSG_MAGIC_V2: { | |
953 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
954 | ||
955 | if (!pb) { | |
956 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
957 | return 0; | |
958 | } | |
959 | return pb->pb_tag; | |
960 | } | |
961 | default: | |
962 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
963 | return 0; | |
964 | } | |
965 | } | |
966 | EXPORT_SYMBOL(lustre_msg_get_tag); | |
967 | ||
d7e09d03 PT |
968 | __u64 lustre_msg_get_last_committed(struct lustre_msg *msg) |
969 | { | |
970 | switch (msg->lm_magic) { | |
971 | case LUSTRE_MSG_MAGIC_V2: { | |
972 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 973 | |
d7e09d03 PT |
974 | if (!pb) { |
975 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
976 | return 0; | |
977 | } | |
978 | return pb->pb_last_committed; | |
979 | } | |
980 | default: | |
981 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
982 | return 0; | |
983 | } | |
984 | } | |
985 | EXPORT_SYMBOL(lustre_msg_get_last_committed); | |
986 | ||
987 | __u64 *lustre_msg_get_versions(struct lustre_msg *msg) | |
988 | { | |
989 | switch (msg->lm_magic) { | |
d7e09d03 PT |
990 | case LUSTRE_MSG_MAGIC_V2: { |
991 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 992 | |
d7e09d03 PT |
993 | if (!pb) { |
994 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
995 | return NULL; | |
996 | } | |
997 | return pb->pb_pre_versions; | |
998 | } | |
999 | default: | |
1000 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
1001 | return NULL; | |
1002 | } | |
1003 | } | |
1004 | EXPORT_SYMBOL(lustre_msg_get_versions); | |
1005 | ||
1006 | __u64 lustre_msg_get_transno(struct lustre_msg *msg) | |
1007 | { | |
1008 | switch (msg->lm_magic) { | |
1009 | case LUSTRE_MSG_MAGIC_V2: { | |
1010 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1011 | |
d7e09d03 PT |
1012 | if (!pb) { |
1013 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
1014 | return 0; | |
1015 | } | |
1016 | return pb->pb_transno; | |
1017 | } | |
1018 | default: | |
1019 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
1020 | return 0; | |
1021 | } | |
1022 | } | |
1023 | EXPORT_SYMBOL(lustre_msg_get_transno); | |
1024 | ||
1025 | int lustre_msg_get_status(struct lustre_msg *msg) | |
1026 | { | |
1027 | switch (msg->lm_magic) { | |
1028 | case LUSTRE_MSG_MAGIC_V2: { | |
1029 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1030 | |
2e4fe2bd AD |
1031 | if (pb) |
1032 | return pb->pb_status; | |
1033 | ||
1034 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
d7e09d03 | 1035 | } |
2e4fe2bd | 1036 | /* no break */ |
d7e09d03 PT |
1037 | default: |
1038 | /* status might be printed in debug code while message | |
dadfcdab OD |
1039 | * uninitialized |
1040 | */ | |
d7e09d03 PT |
1041 | return -EINVAL; |
1042 | } | |
1043 | } | |
1044 | EXPORT_SYMBOL(lustre_msg_get_status); | |
1045 | ||
1046 | __u64 lustre_msg_get_slv(struct lustre_msg *msg) | |
1047 | { | |
1048 | switch (msg->lm_magic) { | |
1049 | case LUSTRE_MSG_MAGIC_V2: { | |
1050 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1051 | |
d7e09d03 PT |
1052 | if (!pb) { |
1053 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
1054 | return -EINVAL; | |
1055 | } | |
1056 | return pb->pb_slv; | |
1057 | } | |
1058 | default: | |
1059 | CERROR("invalid msg magic %08x\n", msg->lm_magic); | |
1060 | return -EINVAL; | |
1061 | } | |
1062 | } | |
d7e09d03 | 1063 | |
d7e09d03 PT |
1064 | void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv) |
1065 | { | |
1066 | switch (msg->lm_magic) { | |
1067 | case LUSTRE_MSG_MAGIC_V2: { | |
1068 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1069 | |
d7e09d03 PT |
1070 | if (!pb) { |
1071 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
1072 | return; | |
1073 | } | |
1074 | pb->pb_slv = slv; | |
1075 | return; | |
1076 | } | |
1077 | default: | |
1078 | CERROR("invalid msg magic %x\n", msg->lm_magic); | |
1079 | return; | |
1080 | } | |
1081 | } | |
d7e09d03 PT |
1082 | |
1083 | __u32 lustre_msg_get_limit(struct lustre_msg *msg) | |
1084 | { | |
1085 | switch (msg->lm_magic) { | |
1086 | case LUSTRE_MSG_MAGIC_V2: { | |
1087 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1088 | |
d7e09d03 PT |
1089 | if (!pb) { |
1090 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
1091 | return -EINVAL; | |
1092 | } | |
1093 | return pb->pb_limit; | |
1094 | } | |
1095 | default: | |
1096 | CERROR("invalid msg magic %x\n", msg->lm_magic); | |
1097 | return -EINVAL; | |
1098 | } | |
1099 | } | |
d7e09d03 | 1100 | |
d7e09d03 PT |
1101 | void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit) |
1102 | { | |
1103 | switch (msg->lm_magic) { | |
1104 | case LUSTRE_MSG_MAGIC_V2: { | |
1105 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1106 | |
d7e09d03 PT |
1107 | if (!pb) { |
1108 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
1109 | return; | |
1110 | } | |
1111 | pb->pb_limit = limit; | |
1112 | return; | |
1113 | } | |
1114 | default: | |
1115 | CERROR("invalid msg magic %08x\n", msg->lm_magic); | |
1116 | return; | |
1117 | } | |
1118 | } | |
d7e09d03 PT |
1119 | |
1120 | __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg) | |
1121 | { | |
1122 | switch (msg->lm_magic) { | |
1123 | case LUSTRE_MSG_MAGIC_V2: { | |
1124 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1125 | |
d7e09d03 PT |
1126 | if (!pb) { |
1127 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
1128 | return 0; | |
1129 | } | |
1130 | return pb->pb_conn_cnt; | |
1131 | } | |
1132 | default: | |
1133 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
1134 | return 0; | |
1135 | } | |
1136 | } | |
1137 | EXPORT_SYMBOL(lustre_msg_get_conn_cnt); | |
1138 | ||
d7e09d03 PT |
1139 | __u32 lustre_msg_get_magic(struct lustre_msg *msg) |
1140 | { | |
1141 | switch (msg->lm_magic) { | |
1142 | case LUSTRE_MSG_MAGIC_V2: | |
1143 | return msg->lm_magic; | |
1144 | default: | |
1145 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
1146 | return 0; | |
1147 | } | |
1148 | } | |
d7e09d03 PT |
1149 | |
1150 | __u32 lustre_msg_get_timeout(struct lustre_msg *msg) | |
1151 | { | |
1152 | switch (msg->lm_magic) { | |
d7e09d03 PT |
1153 | case LUSTRE_MSG_MAGIC_V2: { |
1154 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1155 | |
d7e09d03 PT |
1156 | if (!pb) { |
1157 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
1158 | return 0; | |
d7e09d03 PT |
1159 | } |
1160 | return pb->pb_timeout; | |
1161 | } | |
1162 | default: | |
1163 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
2e4fe2bd | 1164 | return -EPROTO; |
d7e09d03 PT |
1165 | } |
1166 | } | |
1167 | ||
1168 | __u32 lustre_msg_get_service_time(struct lustre_msg *msg) | |
1169 | { | |
1170 | switch (msg->lm_magic) { | |
d7e09d03 PT |
1171 | case LUSTRE_MSG_MAGIC_V2: { |
1172 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1173 | |
d7e09d03 PT |
1174 | if (!pb) { |
1175 | CERROR("invalid msg %p: no ptlrpc body!\n", msg); | |
1176 | return 0; | |
d7e09d03 PT |
1177 | } |
1178 | return pb->pb_service_time; | |
1179 | } | |
1180 | default: | |
1181 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
1182 | return 0; | |
1183 | } | |
1184 | } | |
1185 | ||
d7e09d03 PT |
1186 | __u32 lustre_msg_get_cksum(struct lustre_msg *msg) |
1187 | { | |
1188 | switch (msg->lm_magic) { | |
1189 | case LUSTRE_MSG_MAGIC_V2: | |
1190 | return msg->lm_cksum; | |
1191 | default: | |
1192 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
1193 | return 0; | |
1194 | } | |
1195 | } | |
1196 | ||
d7e09d03 | 1197 | __u32 lustre_msg_calc_cksum(struct lustre_msg *msg) |
d7e09d03 PT |
1198 | { |
1199 | switch (msg->lm_magic) { | |
1200 | case LUSTRE_MSG_MAGIC_V2: { | |
1201 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
d7e09d03 PT |
1202 | __u32 crc; |
1203 | unsigned int hsize = 4; | |
50ffcb7e | 1204 | |
d7e09d03 | 1205 | cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb, |
24c198e9 OD |
1206 | lustre_msg_buflen(msg, |
1207 | MSG_PTLRPC_BODY_OFF), | |
1208 | NULL, 0, (unsigned char *)&crc, &hsize); | |
d7e09d03 | 1209 | return crc; |
d7e09d03 PT |
1210 | } |
1211 | default: | |
1212 | CERROR("incorrect message magic: %08x\n", msg->lm_magic); | |
1213 | return 0; | |
1214 | } | |
1215 | } | |
1216 | ||
1217 | void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle) | |
1218 | { | |
1219 | switch (msg->lm_magic) { | |
1220 | case LUSTRE_MSG_MAGIC_V2: { | |
1221 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1222 | |
d7e09d03 PT |
1223 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1224 | pb->pb_handle = *handle; | |
1225 | return; | |
1226 | } | |
1227 | default: | |
1228 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1229 | } | |
1230 | } | |
d7e09d03 PT |
1231 | |
1232 | void lustre_msg_set_type(struct lustre_msg *msg, __u32 type) | |
1233 | { | |
1234 | switch (msg->lm_magic) { | |
1235 | case LUSTRE_MSG_MAGIC_V2: { | |
1236 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1237 | |
d7e09d03 PT |
1238 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1239 | pb->pb_type = type; | |
1240 | return; | |
1241 | } | |
1242 | default: | |
1243 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1244 | } | |
1245 | } | |
d7e09d03 PT |
1246 | |
1247 | void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc) | |
1248 | { | |
1249 | switch (msg->lm_magic) { | |
1250 | case LUSTRE_MSG_MAGIC_V2: { | |
1251 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1252 | |
d7e09d03 PT |
1253 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1254 | pb->pb_opc = opc; | |
1255 | return; | |
1256 | } | |
1257 | default: | |
1258 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1259 | } | |
1260 | } | |
d7e09d03 | 1261 | |
96049bd1 GP |
1262 | void lustre_msg_set_last_xid(struct lustre_msg *msg, u64 last_xid) |
1263 | { | |
1264 | switch (msg->lm_magic) { | |
1265 | case LUSTRE_MSG_MAGIC_V2: { | |
1266 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
1267 | ||
1268 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); | |
1269 | pb->pb_last_xid = last_xid; | |
1270 | return; | |
1271 | } | |
1272 | default: | |
1273 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1274 | } | |
1275 | } | |
1276 | ||
e33115e3 GP |
1277 | void lustre_msg_set_tag(struct lustre_msg *msg, __u16 tag) |
1278 | { | |
1279 | switch (msg->lm_magic) { | |
1280 | case LUSTRE_MSG_MAGIC_V2: { | |
1281 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
1282 | ||
1283 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); | |
1284 | pb->pb_tag = tag; | |
1285 | return; | |
1286 | } | |
1287 | default: | |
1288 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1289 | } | |
1290 | } | |
1291 | EXPORT_SYMBOL(lustre_msg_set_tag); | |
1292 | ||
d7e09d03 PT |
1293 | void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions) |
1294 | { | |
1295 | switch (msg->lm_magic) { | |
d7e09d03 PT |
1296 | case LUSTRE_MSG_MAGIC_V2: { |
1297 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1298 | |
d7e09d03 PT |
1299 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1300 | pb->pb_pre_versions[0] = versions[0]; | |
1301 | pb->pb_pre_versions[1] = versions[1]; | |
1302 | pb->pb_pre_versions[2] = versions[2]; | |
1303 | pb->pb_pre_versions[3] = versions[3]; | |
1304 | return; | |
1305 | } | |
1306 | default: | |
1307 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1308 | } | |
1309 | } | |
1310 | EXPORT_SYMBOL(lustre_msg_set_versions); | |
1311 | ||
1312 | void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno) | |
1313 | { | |
1314 | switch (msg->lm_magic) { | |
1315 | case LUSTRE_MSG_MAGIC_V2: { | |
1316 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1317 | |
d7e09d03 PT |
1318 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1319 | pb->pb_transno = transno; | |
1320 | return; | |
1321 | } | |
1322 | default: | |
1323 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1324 | } | |
1325 | } | |
1326 | EXPORT_SYMBOL(lustre_msg_set_transno); | |
1327 | ||
1328 | void lustre_msg_set_status(struct lustre_msg *msg, __u32 status) | |
1329 | { | |
1330 | switch (msg->lm_magic) { | |
1331 | case LUSTRE_MSG_MAGIC_V2: { | |
1332 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1333 | |
d7e09d03 PT |
1334 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1335 | pb->pb_status = status; | |
1336 | return; | |
1337 | } | |
1338 | default: | |
1339 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1340 | } | |
1341 | } | |
1342 | EXPORT_SYMBOL(lustre_msg_set_status); | |
1343 | ||
1344 | void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt) | |
1345 | { | |
1346 | switch (msg->lm_magic) { | |
1347 | case LUSTRE_MSG_MAGIC_V2: { | |
1348 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1349 | |
d7e09d03 PT |
1350 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1351 | pb->pb_conn_cnt = conn_cnt; | |
1352 | return; | |
1353 | } | |
1354 | default: | |
1355 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1356 | } | |
1357 | } | |
d7e09d03 PT |
1358 | |
1359 | void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout) | |
1360 | { | |
1361 | switch (msg->lm_magic) { | |
d7e09d03 PT |
1362 | case LUSTRE_MSG_MAGIC_V2: { |
1363 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1364 | |
d7e09d03 PT |
1365 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1366 | pb->pb_timeout = timeout; | |
1367 | return; | |
1368 | } | |
1369 | default: | |
1370 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1371 | } | |
1372 | } | |
1373 | ||
1374 | void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time) | |
1375 | { | |
1376 | switch (msg->lm_magic) { | |
d7e09d03 PT |
1377 | case LUSTRE_MSG_MAGIC_V2: { |
1378 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
50ffcb7e | 1379 | |
d7e09d03 PT |
1380 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); |
1381 | pb->pb_service_time = service_time; | |
1382 | return; | |
1383 | } | |
1384 | default: | |
1385 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1386 | } | |
1387 | } | |
1388 | ||
1389 | void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid) | |
1390 | { | |
1391 | switch (msg->lm_magic) { | |
d7e09d03 PT |
1392 | case LUSTRE_MSG_MAGIC_V2: { |
1393 | __u32 opc = lustre_msg_get_opc(msg); | |
1394 | struct ptlrpc_body *pb; | |
1395 | ||
b6da17f3 | 1396 | /* Don't set jobid for ldlm ast RPCs, they've been shrunk. |
dadfcdab OD |
1397 | * See the comment in ptlrpc_request_pack(). |
1398 | */ | |
d7e09d03 PT |
1399 | if (!opc || opc == LDLM_BL_CALLBACK || |
1400 | opc == LDLM_CP_CALLBACK || opc == LDLM_GL_CALLBACK) | |
1401 | return; | |
1402 | ||
1403 | pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, | |
1404 | sizeof(struct ptlrpc_body)); | |
1405 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); | |
1406 | ||
8b382089 | 1407 | if (jobid) |
c9fe1f7f | 1408 | memcpy(pb->pb_jobid, jobid, LUSTRE_JOBID_SIZE); |
d7e09d03 PT |
1409 | else if (pb->pb_jobid[0] == '\0') |
1410 | lustre_get_jobid(pb->pb_jobid); | |
1411 | return; | |
1412 | } | |
1413 | default: | |
1414 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1415 | } | |
1416 | } | |
1417 | EXPORT_SYMBOL(lustre_msg_set_jobid); | |
1418 | ||
1419 | void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum) | |
1420 | { | |
1421 | switch (msg->lm_magic) { | |
d7e09d03 PT |
1422 | case LUSTRE_MSG_MAGIC_V2: |
1423 | msg->lm_cksum = cksum; | |
1424 | return; | |
1425 | default: | |
1426 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1427 | } | |
1428 | } | |
1429 | ||
8bcaef92 LZ |
1430 | void lustre_msg_set_mbits(struct lustre_msg *msg, __u64 mbits) |
1431 | { | |
1432 | switch (msg->lm_magic) { | |
1433 | case LUSTRE_MSG_MAGIC_V2: { | |
1434 | struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg); | |
1435 | ||
1436 | LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg); | |
1437 | pb->pb_mbits = mbits; | |
1438 | return; | |
1439 | } | |
1440 | default: | |
1441 | LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic); | |
1442 | } | |
1443 | } | |
1444 | ||
d7e09d03 PT |
1445 | void ptlrpc_request_set_replen(struct ptlrpc_request *req) |
1446 | { | |
1447 | int count = req_capsule_filled_sizes(&req->rq_pill, RCL_SERVER); | |
1448 | ||
1449 | req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count, | |
1450 | req->rq_pill.rc_area[RCL_SERVER]); | |
1451 | if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2) | |
1452 | req->rq_reqmsg->lm_repsize = req->rq_replen; | |
1453 | } | |
1454 | EXPORT_SYMBOL(ptlrpc_request_set_replen); | |
1455 | ||
d7e09d03 PT |
1456 | /** |
1457 | * Send a remote set_info_async. | |
1458 | * | |
1459 | * This may go from client to server or server to client. | |
1460 | */ | |
1461 | int do_set_info_async(struct obd_import *imp, | |
1462 | int opcode, int version, | |
21aef7d9 OD |
1463 | u32 keylen, void *key, |
1464 | u32 vallen, void *val, | |
d7e09d03 PT |
1465 | struct ptlrpc_request_set *set) |
1466 | { | |
1467 | struct ptlrpc_request *req; | |
d0bfef31 CH |
1468 | char *tmp; |
1469 | int rc; | |
d7e09d03 PT |
1470 | |
1471 | req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO); | |
8b382089 | 1472 | if (!req) |
0a3bdb00 | 1473 | return -ENOMEM; |
d7e09d03 PT |
1474 | |
1475 | req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, | |
1476 | RCL_CLIENT, keylen); | |
1477 | req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL, | |
1478 | RCL_CLIENT, vallen); | |
1479 | rc = ptlrpc_request_pack(req, version, opcode); | |
1480 | if (rc) { | |
1481 | ptlrpc_request_free(req); | |
0a3bdb00 | 1482 | return rc; |
d7e09d03 PT |
1483 | } |
1484 | ||
1485 | tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); | |
1486 | memcpy(tmp, key, keylen); | |
1487 | tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL); | |
1488 | memcpy(tmp, val, vallen); | |
1489 | ||
1490 | ptlrpc_request_set_replen(req); | |
1491 | ||
1492 | if (set) { | |
1493 | ptlrpc_set_add_req(set, req); | |
1494 | ptlrpc_check_set(NULL, set); | |
1495 | } else { | |
1496 | rc = ptlrpc_queue_wait(req); | |
1497 | ptlrpc_req_finished(req); | |
1498 | } | |
1499 | ||
0a3bdb00 | 1500 | return rc; |
d7e09d03 PT |
1501 | } |
1502 | EXPORT_SYMBOL(do_set_info_async); | |
1503 | ||
1504 | /* byte flipping routines for all wire types declared in | |
1505 | * lustre_idl.h implemented here. | |
1506 | */ | |
1507 | void lustre_swab_ptlrpc_body(struct ptlrpc_body *b) | |
1508 | { | |
0d100bfc KM |
1509 | __swab32s(&b->pb_type); |
1510 | __swab32s(&b->pb_version); | |
1511 | __swab32s(&b->pb_opc); | |
1512 | __swab32s(&b->pb_status); | |
1513 | __swab64s(&b->pb_last_xid); | |
e33115e3 | 1514 | __swab16s(&b->pb_tag); |
0d100bfc KM |
1515 | __swab64s(&b->pb_last_committed); |
1516 | __swab64s(&b->pb_transno); | |
1517 | __swab32s(&b->pb_flags); | |
1518 | __swab32s(&b->pb_op_flags); | |
1519 | __swab32s(&b->pb_conn_cnt); | |
1520 | __swab32s(&b->pb_timeout); | |
1521 | __swab32s(&b->pb_service_time); | |
1522 | __swab32s(&b->pb_limit); | |
1523 | __swab64s(&b->pb_slv); | |
1524 | __swab64s(&b->pb_pre_versions[0]); | |
1525 | __swab64s(&b->pb_pre_versions[1]); | |
1526 | __swab64s(&b->pb_pre_versions[2]); | |
1527 | __swab64s(&b->pb_pre_versions[3]); | |
8bcaef92 | 1528 | __swab64s(&b->pb_mbits); |
f440d909 AB |
1529 | BUILD_BUG_ON(offsetof(typeof(*b), pb_padding0) == 0); |
1530 | BUILD_BUG_ON(offsetof(typeof(*b), pb_padding1) == 0); | |
1531 | BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_0) == 0); | |
1532 | BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_1) == 0); | |
1533 | BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_2) == 0); | |
d7e09d03 PT |
1534 | /* While we need to maintain compatibility between |
1535 | * clients and servers without ptlrpc_body_v2 (< 2.3) | |
1536 | * do not swab any fields beyond pb_jobid, as we are | |
1537 | * using this swab function for both ptlrpc_body | |
dadfcdab OD |
1538 | * and ptlrpc_body_v2. |
1539 | */ | |
f440d909 | 1540 | BUILD_BUG_ON(offsetof(typeof(*b), pb_jobid) == 0); |
d7e09d03 | 1541 | } |
d7e09d03 PT |
1542 | |
1543 | void lustre_swab_connect(struct obd_connect_data *ocd) | |
1544 | { | |
1545 | __swab64s(&ocd->ocd_connect_flags); | |
1546 | __swab32s(&ocd->ocd_version); | |
1547 | __swab32s(&ocd->ocd_grant); | |
1548 | __swab64s(&ocd->ocd_ibits_known); | |
1549 | __swab32s(&ocd->ocd_index); | |
1550 | __swab32s(&ocd->ocd_brw_size); | |
1551 | /* ocd_blocksize and ocd_inodespace don't need to be swabbed because | |
dadfcdab OD |
1552 | * they are 8-byte values |
1553 | */ | |
d7e09d03 PT |
1554 | __swab16s(&ocd->ocd_grant_extent); |
1555 | __swab32s(&ocd->ocd_unused); | |
1556 | __swab64s(&ocd->ocd_transno); | |
1557 | __swab32s(&ocd->ocd_group); | |
1558 | __swab32s(&ocd->ocd_cksum_types); | |
1559 | __swab32s(&ocd->ocd_instance); | |
1560 | /* Fields after ocd_cksum_types are only accessible by the receiver | |
1561 | * if the corresponding flag in ocd_connect_flags is set. Accessing | |
1562 | * any field after ocd_maxbytes on the receiver without a valid flag | |
dadfcdab OD |
1563 | * may result in out-of-bound memory access and kernel oops. |
1564 | */ | |
d7e09d03 PT |
1565 | if (ocd->ocd_connect_flags & OBD_CONNECT_MAX_EASIZE) |
1566 | __swab32s(&ocd->ocd_max_easize); | |
1567 | if (ocd->ocd_connect_flags & OBD_CONNECT_MAXBYTES) | |
1568 | __swab64s(&ocd->ocd_maxbytes); | |
872cbbdf GP |
1569 | if (ocd->ocd_connect_flags & OBD_CONNECT_MULTIMODRPCS) |
1570 | __swab16s(&ocd->ocd_maxmodrpcs); | |
f440d909 AB |
1571 | BUILD_BUG_ON(!offsetof(typeof(*ocd), padding0)); |
1572 | BUILD_BUG_ON(offsetof(typeof(*ocd), padding1) == 0); | |
3ce173a1 FY |
1573 | if (ocd->ocd_connect_flags & OBD_CONNECT_FLAGS2) |
1574 | __swab64s(&ocd->ocd_connect_flags2); | |
f440d909 AB |
1575 | BUILD_BUG_ON(offsetof(typeof(*ocd), padding3) == 0); |
1576 | BUILD_BUG_ON(offsetof(typeof(*ocd), padding4) == 0); | |
1577 | BUILD_BUG_ON(offsetof(typeof(*ocd), padding5) == 0); | |
1578 | BUILD_BUG_ON(offsetof(typeof(*ocd), padding6) == 0); | |
1579 | BUILD_BUG_ON(offsetof(typeof(*ocd), padding7) == 0); | |
1580 | BUILD_BUG_ON(offsetof(typeof(*ocd), padding8) == 0); | |
1581 | BUILD_BUG_ON(offsetof(typeof(*ocd), padding9) == 0); | |
1582 | BUILD_BUG_ON(offsetof(typeof(*ocd), paddingA) == 0); | |
1583 | BUILD_BUG_ON(offsetof(typeof(*ocd), paddingB) == 0); | |
1584 | BUILD_BUG_ON(offsetof(typeof(*ocd), paddingC) == 0); | |
1585 | BUILD_BUG_ON(offsetof(typeof(*ocd), paddingD) == 0); | |
1586 | BUILD_BUG_ON(offsetof(typeof(*ocd), paddingE) == 0); | |
1587 | BUILD_BUG_ON(offsetof(typeof(*ocd), paddingF) == 0); | |
d7e09d03 PT |
1588 | } |
1589 | ||
fcdf51c1 | 1590 | static void lustre_swab_obdo(struct obdo *o) |
d7e09d03 | 1591 | { |
0d100bfc | 1592 | __swab64s(&o->o_valid); |
d7e09d03 | 1593 | lustre_swab_ost_id(&o->o_oi); |
0d100bfc KM |
1594 | __swab64s(&o->o_parent_seq); |
1595 | __swab64s(&o->o_size); | |
1596 | __swab64s(&o->o_mtime); | |
1597 | __swab64s(&o->o_atime); | |
1598 | __swab64s(&o->o_ctime); | |
1599 | __swab64s(&o->o_blocks); | |
1600 | __swab64s(&o->o_grant); | |
1601 | __swab32s(&o->o_blksize); | |
1602 | __swab32s(&o->o_mode); | |
1603 | __swab32s(&o->o_uid); | |
1604 | __swab32s(&o->o_gid); | |
1605 | __swab32s(&o->o_flags); | |
1606 | __swab32s(&o->o_nlink); | |
1607 | __swab32s(&o->o_parent_oid); | |
1608 | __swab32s(&o->o_misc); | |
1609 | __swab64s(&o->o_ioepoch); | |
1610 | __swab32s(&o->o_stripe_idx); | |
1611 | __swab32s(&o->o_parent_ver); | |
d7e09d03 PT |
1612 | /* o_handle is opaque */ |
1613 | /* o_lcookie is swabbed elsewhere */ | |
0d100bfc KM |
1614 | __swab32s(&o->o_uid_h); |
1615 | __swab32s(&o->o_gid_h); | |
1616 | __swab64s(&o->o_data_version); | |
f440d909 AB |
1617 | BUILD_BUG_ON(offsetof(typeof(*o), o_padding_4) == 0); |
1618 | BUILD_BUG_ON(offsetof(typeof(*o), o_padding_5) == 0); | |
1619 | BUILD_BUG_ON(offsetof(typeof(*o), o_padding_6) == 0); | |
d7e09d03 | 1620 | } |
d7e09d03 | 1621 | |
0d100bfc | 1622 | void lustre_swab_obd_statfs(struct obd_statfs *os) |
d7e09d03 | 1623 | { |
0d100bfc KM |
1624 | __swab64s(&os->os_type); |
1625 | __swab64s(&os->os_blocks); | |
1626 | __swab64s(&os->os_bfree); | |
1627 | __swab64s(&os->os_bavail); | |
1628 | __swab64s(&os->os_files); | |
1629 | __swab64s(&os->os_ffree); | |
d7e09d03 | 1630 | /* no need to swab os_fsid */ |
0d100bfc KM |
1631 | __swab32s(&os->os_bsize); |
1632 | __swab32s(&os->os_namelen); | |
1633 | __swab64s(&os->os_maxbytes); | |
1634 | __swab32s(&os->os_state); | |
f440d909 AB |
1635 | BUILD_BUG_ON(offsetof(typeof(*os), os_fprecreated) == 0); |
1636 | BUILD_BUG_ON(offsetof(typeof(*os), os_spare2) == 0); | |
1637 | BUILD_BUG_ON(offsetof(typeof(*os), os_spare3) == 0); | |
1638 | BUILD_BUG_ON(offsetof(typeof(*os), os_spare4) == 0); | |
1639 | BUILD_BUG_ON(offsetof(typeof(*os), os_spare5) == 0); | |
1640 | BUILD_BUG_ON(offsetof(typeof(*os), os_spare6) == 0); | |
1641 | BUILD_BUG_ON(offsetof(typeof(*os), os_spare7) == 0); | |
1642 | BUILD_BUG_ON(offsetof(typeof(*os), os_spare8) == 0); | |
1643 | BUILD_BUG_ON(offsetof(typeof(*os), os_spare9) == 0); | |
d7e09d03 | 1644 | } |
d7e09d03 PT |
1645 | |
1646 | void lustre_swab_obd_ioobj(struct obd_ioobj *ioo) | |
1647 | { | |
1648 | lustre_swab_ost_id(&ioo->ioo_oid); | |
1649 | __swab32s(&ioo->ioo_max_brw); | |
1650 | __swab32s(&ioo->ioo_bufcnt); | |
1651 | } | |
d7e09d03 | 1652 | |
0d100bfc | 1653 | void lustre_swab_niobuf_remote(struct niobuf_remote *nbr) |
d7e09d03 | 1654 | { |
638814f6 JH |
1655 | __swab64s(&nbr->rnb_offset); |
1656 | __swab32s(&nbr->rnb_len); | |
1657 | __swab32s(&nbr->rnb_flags); | |
d7e09d03 | 1658 | } |
d7e09d03 | 1659 | |
0d100bfc | 1660 | void lustre_swab_ost_body(struct ost_body *b) |
d7e09d03 | 1661 | { |
0d100bfc | 1662 | lustre_swab_obdo(&b->oa); |
d7e09d03 | 1663 | } |
d7e09d03 | 1664 | |
21aef7d9 | 1665 | void lustre_swab_ost_last_id(u64 *id) |
d7e09d03 PT |
1666 | { |
1667 | __swab64s(id); | |
1668 | } | |
d7e09d03 PT |
1669 | |
1670 | void lustre_swab_generic_32s(__u32 *val) | |
1671 | { | |
1672 | __swab32s(val); | |
1673 | } | |
d7e09d03 PT |
1674 | |
1675 | void lustre_swab_gl_desc(union ldlm_gl_desc *desc) | |
1676 | { | |
1677 | lustre_swab_lu_fid(&desc->lquota_desc.gl_id.qid_fid); | |
1678 | __swab64s(&desc->lquota_desc.gl_flags); | |
1679 | __swab64s(&desc->lquota_desc.gl_ver); | |
1680 | __swab64s(&desc->lquota_desc.gl_hardlimit); | |
1681 | __swab64s(&desc->lquota_desc.gl_softlimit); | |
1682 | __swab64s(&desc->lquota_desc.gl_time); | |
f440d909 | 1683 | BUILD_BUG_ON(offsetof(typeof(desc->lquota_desc), gl_pad2) == 0); |
d7e09d03 PT |
1684 | } |
1685 | ||
1686 | void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb) | |
1687 | { | |
1688 | __swab64s(&lvb->lvb_size); | |
1689 | __swab64s(&lvb->lvb_mtime); | |
1690 | __swab64s(&lvb->lvb_atime); | |
1691 | __swab64s(&lvb->lvb_ctime); | |
1692 | __swab64s(&lvb->lvb_blocks); | |
1693 | } | |
1694 | EXPORT_SYMBOL(lustre_swab_ost_lvb_v1); | |
1695 | ||
1696 | void lustre_swab_ost_lvb(struct ost_lvb *lvb) | |
1697 | { | |
1698 | __swab64s(&lvb->lvb_size); | |
1699 | __swab64s(&lvb->lvb_mtime); | |
1700 | __swab64s(&lvb->lvb_atime); | |
1701 | __swab64s(&lvb->lvb_ctime); | |
1702 | __swab64s(&lvb->lvb_blocks); | |
1703 | __swab32s(&lvb->lvb_mtime_ns); | |
1704 | __swab32s(&lvb->lvb_atime_ns); | |
1705 | __swab32s(&lvb->lvb_ctime_ns); | |
1706 | __swab32s(&lvb->lvb_padding); | |
1707 | } | |
1708 | EXPORT_SYMBOL(lustre_swab_ost_lvb); | |
1709 | ||
1710 | void lustre_swab_lquota_lvb(struct lquota_lvb *lvb) | |
1711 | { | |
1712 | __swab64s(&lvb->lvb_flags); | |
1713 | __swab64s(&lvb->lvb_id_may_rel); | |
1714 | __swab64s(&lvb->lvb_id_rel); | |
1715 | __swab64s(&lvb->lvb_id_qunit); | |
1716 | __swab64s(&lvb->lvb_pad1); | |
1717 | } | |
1718 | EXPORT_SYMBOL(lustre_swab_lquota_lvb); | |
1719 | ||
0d100bfc | 1720 | void lustre_swab_mdt_body(struct mdt_body *b) |
d7e09d03 | 1721 | { |
2e1b5b8b JH |
1722 | lustre_swab_lu_fid(&b->mbo_fid1); |
1723 | lustre_swab_lu_fid(&b->mbo_fid2); | |
d7e09d03 | 1724 | /* handle is opaque */ |
2e1b5b8b JH |
1725 | __swab64s(&b->mbo_valid); |
1726 | __swab64s(&b->mbo_size); | |
1727 | __swab64s(&b->mbo_mtime); | |
1728 | __swab64s(&b->mbo_atime); | |
1729 | __swab64s(&b->mbo_ctime); | |
1730 | __swab64s(&b->mbo_blocks); | |
1731 | __swab64s(&b->mbo_ioepoch); | |
1732 | __swab64s(&b->mbo_t_state); | |
1733 | __swab32s(&b->mbo_fsuid); | |
1734 | __swab32s(&b->mbo_fsgid); | |
1735 | __swab32s(&b->mbo_capability); | |
1736 | __swab32s(&b->mbo_mode); | |
1737 | __swab32s(&b->mbo_uid); | |
1738 | __swab32s(&b->mbo_gid); | |
1739 | __swab32s(&b->mbo_flags); | |
1740 | __swab32s(&b->mbo_rdev); | |
1741 | __swab32s(&b->mbo_nlink); | |
f440d909 | 1742 | BUILD_BUG_ON(offsetof(typeof(*b), mbo_unused2) == 0); |
2e1b5b8b JH |
1743 | __swab32s(&b->mbo_suppgid); |
1744 | __swab32s(&b->mbo_eadatasize); | |
1745 | __swab32s(&b->mbo_aclsize); | |
1746 | __swab32s(&b->mbo_max_mdsize); | |
f440d909 | 1747 | BUILD_BUG_ON(!offsetof(typeof(*b), mbo_unused3)); |
2e1b5b8b JH |
1748 | __swab32s(&b->mbo_uid_h); |
1749 | __swab32s(&b->mbo_gid_h); | |
f440d909 | 1750 | BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_5) == 0); |
d7e09d03 | 1751 | } |
d7e09d03 | 1752 | |
0d100bfc | 1753 | void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b) |
d7e09d03 PT |
1754 | { |
1755 | /* handle is opaque */ | |
a823acf5 | 1756 | /* mio_handle is opaque */ |
f440d909 AB |
1757 | BUILD_BUG_ON(!offsetof(typeof(*b), mio_unused1)); |
1758 | BUILD_BUG_ON(!offsetof(typeof(*b), mio_unused2)); | |
1759 | BUILD_BUG_ON(!offsetof(typeof(*b), mio_padding)); | |
d7e09d03 | 1760 | } |
d7e09d03 PT |
1761 | |
1762 | void lustre_swab_mgs_target_info(struct mgs_target_info *mti) | |
1763 | { | |
1764 | int i; | |
50ffcb7e | 1765 | |
d7e09d03 PT |
1766 | __swab32s(&mti->mti_lustre_ver); |
1767 | __swab32s(&mti->mti_stripe_index); | |
1768 | __swab32s(&mti->mti_config_ver); | |
1769 | __swab32s(&mti->mti_flags); | |
1770 | __swab32s(&mti->mti_instance); | |
1771 | __swab32s(&mti->mti_nid_count); | |
f440d909 | 1772 | BUILD_BUG_ON(sizeof(lnet_nid_t) != sizeof(__u64)); |
d7e09d03 PT |
1773 | for (i = 0; i < MTI_NIDS_MAX; i++) |
1774 | __swab64s(&mti->mti_nids[i]); | |
1775 | } | |
d7e09d03 PT |
1776 | |
1777 | void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *entry) | |
1778 | { | |
97cba130 | 1779 | __u8 i; |
d7e09d03 PT |
1780 | |
1781 | __swab64s(&entry->mne_version); | |
1782 | __swab32s(&entry->mne_instance); | |
1783 | __swab32s(&entry->mne_index); | |
1784 | __swab32s(&entry->mne_length); | |
1785 | ||
1786 | /* mne_nid_(count|type) must be one byte size because we're gonna | |
1787 | * access it w/o swapping. */ | |
f440d909 AB |
1788 | BUILD_BUG_ON(sizeof(entry->mne_nid_count) != sizeof(__u8)); |
1789 | BUILD_BUG_ON(sizeof(entry->mne_nid_type) != sizeof(__u8)); | |
d7e09d03 PT |
1790 | |
1791 | /* remove this assertion if ipv6 is supported. */ | |
1792 | LASSERT(entry->mne_nid_type == 0); | |
1793 | for (i = 0; i < entry->mne_nid_count; i++) { | |
f440d909 | 1794 | BUILD_BUG_ON(sizeof(lnet_nid_t) != sizeof(__u64)); |
d7e09d03 PT |
1795 | __swab64s(&entry->u.nids[i]); |
1796 | } | |
1797 | } | |
1798 | EXPORT_SYMBOL(lustre_swab_mgs_nidtbl_entry); | |
1799 | ||
1800 | void lustre_swab_mgs_config_body(struct mgs_config_body *body) | |
1801 | { | |
1802 | __swab64s(&body->mcb_offset); | |
1803 | __swab32s(&body->mcb_units); | |
1804 | __swab16s(&body->mcb_type); | |
1805 | } | |
d7e09d03 PT |
1806 | |
1807 | void lustre_swab_mgs_config_res(struct mgs_config_res *body) | |
1808 | { | |
1809 | __swab64s(&body->mcr_offset); | |
1810 | __swab64s(&body->mcr_size); | |
1811 | } | |
d7e09d03 | 1812 | |
0d100bfc | 1813 | static void lustre_swab_obd_dqinfo(struct obd_dqinfo *i) |
d7e09d03 | 1814 | { |
0d100bfc KM |
1815 | __swab64s(&i->dqi_bgrace); |
1816 | __swab64s(&i->dqi_igrace); | |
1817 | __swab32s(&i->dqi_flags); | |
1818 | __swab32s(&i->dqi_valid); | |
d7e09d03 PT |
1819 | } |
1820 | ||
0d100bfc | 1821 | static void lustre_swab_obd_dqblk(struct obd_dqblk *b) |
d7e09d03 | 1822 | { |
0d100bfc KM |
1823 | __swab64s(&b->dqb_ihardlimit); |
1824 | __swab64s(&b->dqb_isoftlimit); | |
1825 | __swab64s(&b->dqb_curinodes); | |
1826 | __swab64s(&b->dqb_bhardlimit); | |
1827 | __swab64s(&b->dqb_bsoftlimit); | |
1828 | __swab64s(&b->dqb_curspace); | |
1829 | __swab64s(&b->dqb_btime); | |
1830 | __swab64s(&b->dqb_itime); | |
1831 | __swab32s(&b->dqb_valid); | |
f440d909 | 1832 | BUILD_BUG_ON(offsetof(typeof(*b), dqb_padding) == 0); |
d7e09d03 PT |
1833 | } |
1834 | ||
0d100bfc | 1835 | void lustre_swab_obd_quotactl(struct obd_quotactl *q) |
d7e09d03 | 1836 | { |
0d100bfc KM |
1837 | __swab32s(&q->qc_cmd); |
1838 | __swab32s(&q->qc_type); | |
1839 | __swab32s(&q->qc_id); | |
1840 | __swab32s(&q->qc_stat); | |
1841 | lustre_swab_obd_dqinfo(&q->qc_dqinfo); | |
1842 | lustre_swab_obd_dqblk(&q->qc_dqblk); | |
d7e09d03 | 1843 | } |
d7e09d03 | 1844 | |
d7e09d03 PT |
1845 | void lustre_swab_fid2path(struct getinfo_fid2path *gf) |
1846 | { | |
1847 | lustre_swab_lu_fid(&gf->gf_fid); | |
1848 | __swab64s(&gf->gf_recno); | |
1849 | __swab32s(&gf->gf_linkno); | |
1850 | __swab32s(&gf->gf_pathlen); | |
1851 | } | |
1852 | EXPORT_SYMBOL(lustre_swab_fid2path); | |
1853 | ||
cbd4d4a8 | 1854 | static void lustre_swab_fiemap_extent(struct fiemap_extent *fm_extent) |
d7e09d03 PT |
1855 | { |
1856 | __swab64s(&fm_extent->fe_logical); | |
1857 | __swab64s(&fm_extent->fe_physical); | |
1858 | __swab64s(&fm_extent->fe_length); | |
1859 | __swab32s(&fm_extent->fe_flags); | |
1860 | __swab32s(&fm_extent->fe_device); | |
1861 | } | |
1862 | ||
cbd4d4a8 | 1863 | void lustre_swab_fiemap(struct fiemap *fiemap) |
d7e09d03 | 1864 | { |
97cba130 | 1865 | __u32 i; |
d7e09d03 PT |
1866 | |
1867 | __swab64s(&fiemap->fm_start); | |
1868 | __swab64s(&fiemap->fm_length); | |
1869 | __swab32s(&fiemap->fm_flags); | |
1870 | __swab32s(&fiemap->fm_mapped_extents); | |
1871 | __swab32s(&fiemap->fm_extent_count); | |
1872 | __swab32s(&fiemap->fm_reserved); | |
1873 | ||
1874 | for (i = 0; i < fiemap->fm_mapped_extents; i++) | |
1875 | lustre_swab_fiemap_extent(&fiemap->fm_extents[i]); | |
1876 | } | |
d7e09d03 | 1877 | |
d7e09d03 PT |
1878 | void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr) |
1879 | { | |
1880 | __swab32s(&rr->rr_opcode); | |
1881 | __swab32s(&rr->rr_cap); | |
1882 | __swab32s(&rr->rr_fsuid); | |
1883 | /* rr_fsuid_h is unused */ | |
1884 | __swab32s(&rr->rr_fsgid); | |
1885 | /* rr_fsgid_h is unused */ | |
1886 | __swab32s(&rr->rr_suppgid1); | |
1887 | /* rr_suppgid1_h is unused */ | |
1888 | __swab32s(&rr->rr_suppgid2); | |
1889 | /* rr_suppgid2_h is unused */ | |
1890 | lustre_swab_lu_fid(&rr->rr_fid1); | |
1891 | lustre_swab_lu_fid(&rr->rr_fid2); | |
1892 | __swab64s(&rr->rr_mtime); | |
1893 | __swab64s(&rr->rr_atime); | |
1894 | __swab64s(&rr->rr_ctime); | |
1895 | __swab64s(&rr->rr_size); | |
1896 | __swab64s(&rr->rr_blocks); | |
1897 | __swab32s(&rr->rr_bias); | |
1898 | __swab32s(&rr->rr_mode); | |
1899 | __swab32s(&rr->rr_flags); | |
1900 | __swab32s(&rr->rr_flags_h); | |
1901 | __swab32s(&rr->rr_umask); | |
1902 | ||
f440d909 | 1903 | BUILD_BUG_ON(offsetof(typeof(*rr), rr_padding_4) == 0); |
d7e09d03 | 1904 | }; |
d7e09d03 | 1905 | |
0d100bfc | 1906 | void lustre_swab_lov_desc(struct lov_desc *ld) |
d7e09d03 | 1907 | { |
0d100bfc KM |
1908 | __swab32s(&ld->ld_tgt_count); |
1909 | __swab32s(&ld->ld_active_tgt_count); | |
1910 | __swab32s(&ld->ld_default_stripe_count); | |
1911 | __swab32s(&ld->ld_pattern); | |
1912 | __swab64s(&ld->ld_default_stripe_size); | |
1913 | __swab64s(&ld->ld_default_stripe_offset); | |
1914 | __swab32s(&ld->ld_qos_maxage); | |
d7e09d03 PT |
1915 | /* uuid endian insensitive */ |
1916 | } | |
1917 | EXPORT_SYMBOL(lustre_swab_lov_desc); | |
1918 | ||
6e23ea98 | 1919 | /* This structure is always in little-endian */ |
1920 | static void lustre_swab_lmv_mds_md_v1(struct lmv_mds_md_v1 *lmm1) | |
1921 | { | |
1922 | int i; | |
1923 | ||
1924 | __swab32s(&lmm1->lmv_magic); | |
1925 | __swab32s(&lmm1->lmv_stripe_count); | |
1926 | __swab32s(&lmm1->lmv_master_mdt_index); | |
1927 | __swab32s(&lmm1->lmv_hash_type); | |
1928 | __swab32s(&lmm1->lmv_layout_version); | |
1929 | for (i = 0; i < lmm1->lmv_stripe_count; i++) | |
1930 | lustre_swab_lu_fid(&lmm1->lmv_stripe_fids[i]); | |
1931 | } | |
1932 | ||
1933 | void lustre_swab_lmv_mds_md(union lmv_mds_md *lmm) | |
1934 | { | |
1935 | switch (lmm->lmv_magic) { | |
1936 | case LMV_MAGIC_V1: | |
1937 | lustre_swab_lmv_mds_md_v1(&lmm->lmv_md_v1); | |
1938 | break; | |
1939 | default: | |
1940 | break; | |
1941 | } | |
1942 | } | |
4a7beb18 | 1943 | EXPORT_SYMBOL(lustre_swab_lmv_mds_md); |
6e23ea98 | 1944 | |
2de35386 | 1945 | void lustre_swab_lmv_user_md(struct lmv_user_md *lum) |
1946 | { | |
1947 | __swab32s(&lum->lum_magic); | |
1948 | __swab32s(&lum->lum_stripe_count); | |
1949 | __swab32s(&lum->lum_stripe_offset); | |
1950 | __swab32s(&lum->lum_hash_type); | |
1951 | __swab32s(&lum->lum_type); | |
f440d909 | 1952 | BUILD_BUG_ON(!offsetof(typeof(*lum), lum_padding1)); |
2de35386 | 1953 | } |
1954 | EXPORT_SYMBOL(lustre_swab_lmv_user_md); | |
1955 | ||
d7e09d03 PT |
1956 | static void lustre_swab_lmm_oi(struct ost_id *oi) |
1957 | { | |
1958 | __swab64s(&oi->oi.oi_id); | |
1959 | __swab64s(&oi->oi.oi_seq); | |
1960 | } | |
1961 | ||
1962 | static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum) | |
1963 | { | |
d7e09d03 PT |
1964 | __swab32s(&lum->lmm_magic); |
1965 | __swab32s(&lum->lmm_pattern); | |
1966 | lustre_swab_lmm_oi(&lum->lmm_oi); | |
1967 | __swab32s(&lum->lmm_stripe_size); | |
1968 | __swab16s(&lum->lmm_stripe_count); | |
1969 | __swab16s(&lum->lmm_stripe_offset); | |
d7e09d03 PT |
1970 | } |
1971 | ||
1972 | void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum) | |
1973 | { | |
d7e09d03 PT |
1974 | CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n"); |
1975 | lustre_swab_lov_user_md_common(lum); | |
d7e09d03 PT |
1976 | } |
1977 | EXPORT_SYMBOL(lustre_swab_lov_user_md_v1); | |
1978 | ||
1979 | void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum) | |
1980 | { | |
d7e09d03 PT |
1981 | CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n"); |
1982 | lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum); | |
1983 | /* lmm_pool_name nothing to do with char */ | |
d7e09d03 PT |
1984 | } |
1985 | EXPORT_SYMBOL(lustre_swab_lov_user_md_v3); | |
1986 | ||
1987 | void lustre_swab_lov_mds_md(struct lov_mds_md *lmm) | |
1988 | { | |
d7e09d03 PT |
1989 | CDEBUG(D_IOCTL, "swabbing lov_mds_md\n"); |
1990 | __swab32s(&lmm->lmm_magic); | |
1991 | __swab32s(&lmm->lmm_pattern); | |
1992 | lustre_swab_lmm_oi(&lmm->lmm_oi); | |
1993 | __swab32s(&lmm->lmm_stripe_size); | |
1994 | __swab16s(&lmm->lmm_stripe_count); | |
1995 | __swab16s(&lmm->lmm_layout_gen); | |
d7e09d03 | 1996 | } |
1fbf3e5f | 1997 | EXPORT_SYMBOL(lustre_swab_lov_mds_md); |
d7e09d03 PT |
1998 | |
1999 | void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod, | |
2000 | int stripe_count) | |
2001 | { | |
2002 | int i; | |
29aaf496 | 2003 | |
d7e09d03 | 2004 | for (i = 0; i < stripe_count; i++) { |
49880263 EL |
2005 | lustre_swab_ost_id(&lod[i].l_ost_oi); |
2006 | __swab32s(&lod[i].l_ost_gen); | |
2007 | __swab32s(&lod[i].l_ost_idx); | |
d7e09d03 | 2008 | } |
d7e09d03 PT |
2009 | } |
2010 | EXPORT_SYMBOL(lustre_swab_lov_user_md_objects); | |
2011 | ||
fcdf51c1 | 2012 | static void lustre_swab_ldlm_res_id(struct ldlm_res_id *id) |
d7e09d03 | 2013 | { |
d0bfef31 | 2014 | int i; |
d7e09d03 PT |
2015 | |
2016 | for (i = 0; i < RES_NAME_SIZE; i++) | |
0d100bfc | 2017 | __swab64s(&id->name[i]); |
d7e09d03 | 2018 | } |
d7e09d03 | 2019 | |
394a9726 | 2020 | static void lustre_swab_ldlm_policy_data(union ldlm_wire_policy_data *d) |
d7e09d03 PT |
2021 | { |
2022 | /* the lock data is a union and the first two fields are always an | |
2023 | * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock | |
dadfcdab OD |
2024 | * data the same way. |
2025 | */ | |
d7e09d03 PT |
2026 | __swab64s(&d->l_extent.start); |
2027 | __swab64s(&d->l_extent.end); | |
2028 | __swab64s(&d->l_extent.gid); | |
2029 | __swab64s(&d->l_flock.lfw_owner); | |
2030 | __swab32s(&d->l_flock.lfw_pid); | |
2031 | } | |
d7e09d03 | 2032 | |
0d100bfc | 2033 | void lustre_swab_ldlm_intent(struct ldlm_intent *i) |
d7e09d03 | 2034 | { |
0d100bfc | 2035 | __swab64s(&i->opc); |
d7e09d03 | 2036 | } |
d7e09d03 | 2037 | |
fcdf51c1 | 2038 | static void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r) |
d7e09d03 | 2039 | { |
0d100bfc | 2040 | __swab32s(&r->lr_type); |
f440d909 | 2041 | BUILD_BUG_ON(offsetof(typeof(*r), lr_padding) == 0); |
0d100bfc | 2042 | lustre_swab_ldlm_res_id(&r->lr_name); |
d7e09d03 | 2043 | } |
d7e09d03 | 2044 | |
09eb98b3 | 2045 | static void lustre_swab_ldlm_lock_desc(struct ldlm_lock_desc *l) |
d7e09d03 | 2046 | { |
0d100bfc KM |
2047 | lustre_swab_ldlm_resource_desc(&l->l_resource); |
2048 | __swab32s(&l->l_req_mode); | |
2049 | __swab32s(&l->l_granted_mode); | |
2050 | lustre_swab_ldlm_policy_data(&l->l_policy_data); | |
d7e09d03 | 2051 | } |
d7e09d03 | 2052 | |
0d100bfc | 2053 | void lustre_swab_ldlm_request(struct ldlm_request *rq) |
d7e09d03 | 2054 | { |
0d100bfc KM |
2055 | __swab32s(&rq->lock_flags); |
2056 | lustre_swab_ldlm_lock_desc(&rq->lock_desc); | |
2057 | __swab32s(&rq->lock_count); | |
d7e09d03 PT |
2058 | /* lock_handle[] opaque */ |
2059 | } | |
d7e09d03 | 2060 | |
0d100bfc | 2061 | void lustre_swab_ldlm_reply(struct ldlm_reply *r) |
d7e09d03 | 2062 | { |
0d100bfc | 2063 | __swab32s(&r->lock_flags); |
f440d909 | 2064 | BUILD_BUG_ON(offsetof(typeof(*r), lock_padding) == 0); |
0d100bfc | 2065 | lustre_swab_ldlm_lock_desc(&r->lock_desc); |
d7e09d03 | 2066 | /* lock_handle opaque */ |
0d100bfc KM |
2067 | __swab64s(&r->lock_policy_res1); |
2068 | __swab64s(&r->lock_policy_res2); | |
d7e09d03 | 2069 | } |
d7e09d03 | 2070 | |
d7e09d03 PT |
2071 | /* Dump functions */ |
2072 | void dump_ioo(struct obd_ioobj *ioo) | |
2073 | { | |
2074 | CDEBUG(D_RPCTRACE, | |
2d00bd17 JP |
2075 | "obd_ioobj: ioo_oid=" DOSTID ", ioo_max_brw=%#x, ioo_bufct=%d\n", |
2076 | POSTID(&ioo->ioo_oid), ioo->ioo_max_brw, | |
d7e09d03 PT |
2077 | ioo->ioo_bufcnt); |
2078 | } | |
d7e09d03 PT |
2079 | |
2080 | void dump_rniobuf(struct niobuf_remote *nb) | |
2081 | { | |
b0f5aad5 | 2082 | CDEBUG(D_RPCTRACE, "niobuf_remote: offset=%llu, len=%d, flags=%x\n", |
638814f6 | 2083 | nb->rnb_offset, nb->rnb_len, nb->rnb_flags); |
d7e09d03 | 2084 | } |
d7e09d03 | 2085 | |
09eb98b3 | 2086 | static void dump_obdo(struct obdo *oa) |
d7e09d03 PT |
2087 | { |
2088 | __u32 valid = oa->o_valid; | |
2089 | ||
2090 | CDEBUG(D_RPCTRACE, "obdo: o_valid = %08x\n", valid); | |
2091 | if (valid & OBD_MD_FLID) | |
1ada25dc | 2092 | CDEBUG(D_RPCTRACE, "obdo: id = " DOSTID "\n", POSTID(&oa->o_oi)); |
d7e09d03 | 2093 | if (valid & OBD_MD_FLFID) |
55f5a824 | 2094 | CDEBUG(D_RPCTRACE, "obdo: o_parent_seq = %#llx\n", |
d7e09d03 PT |
2095 | oa->o_parent_seq); |
2096 | if (valid & OBD_MD_FLSIZE) | |
f537dd2c | 2097 | CDEBUG(D_RPCTRACE, "obdo: o_size = %lld\n", oa->o_size); |
d7e09d03 | 2098 | if (valid & OBD_MD_FLMTIME) |
f537dd2c | 2099 | CDEBUG(D_RPCTRACE, "obdo: o_mtime = %lld\n", oa->o_mtime); |
d7e09d03 | 2100 | if (valid & OBD_MD_FLATIME) |
f537dd2c | 2101 | CDEBUG(D_RPCTRACE, "obdo: o_atime = %lld\n", oa->o_atime); |
d7e09d03 | 2102 | if (valid & OBD_MD_FLCTIME) |
f537dd2c | 2103 | CDEBUG(D_RPCTRACE, "obdo: o_ctime = %lld\n", oa->o_ctime); |
d7e09d03 | 2104 | if (valid & OBD_MD_FLBLOCKS) /* allocation of space */ |
f537dd2c | 2105 | CDEBUG(D_RPCTRACE, "obdo: o_blocks = %lld\n", oa->o_blocks); |
d7e09d03 | 2106 | if (valid & OBD_MD_FLGRANT) |
f537dd2c | 2107 | CDEBUG(D_RPCTRACE, "obdo: o_grant = %lld\n", oa->o_grant); |
d7e09d03 PT |
2108 | if (valid & OBD_MD_FLBLKSZ) |
2109 | CDEBUG(D_RPCTRACE, "obdo: o_blksize = %d\n", oa->o_blksize); | |
2110 | if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE)) | |
2111 | CDEBUG(D_RPCTRACE, "obdo: o_mode = %o\n", | |
2112 | oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) | | |
2113 | (valid & OBD_MD_FLMODE ? ~S_IFMT : 0))); | |
2114 | if (valid & OBD_MD_FLUID) | |
2115 | CDEBUG(D_RPCTRACE, "obdo: o_uid = %u\n", oa->o_uid); | |
2116 | if (valid & OBD_MD_FLUID) | |
2117 | CDEBUG(D_RPCTRACE, "obdo: o_uid_h = %u\n", oa->o_uid_h); | |
2118 | if (valid & OBD_MD_FLGID) | |
2119 | CDEBUG(D_RPCTRACE, "obdo: o_gid = %u\n", oa->o_gid); | |
2120 | if (valid & OBD_MD_FLGID) | |
2121 | CDEBUG(D_RPCTRACE, "obdo: o_gid_h = %u\n", oa->o_gid_h); | |
2122 | if (valid & OBD_MD_FLFLAGS) | |
2123 | CDEBUG(D_RPCTRACE, "obdo: o_flags = %x\n", oa->o_flags); | |
2124 | if (valid & OBD_MD_FLNLINK) | |
2125 | CDEBUG(D_RPCTRACE, "obdo: o_nlink = %u\n", oa->o_nlink); | |
2126 | else if (valid & OBD_MD_FLCKSUM) | |
2127 | CDEBUG(D_RPCTRACE, "obdo: o_checksum (o_nlink) = %u\n", | |
2128 | oa->o_nlink); | |
2129 | if (valid & OBD_MD_FLGENER) | |
2130 | CDEBUG(D_RPCTRACE, "obdo: o_parent_oid = %x\n", | |
2131 | oa->o_parent_oid); | |
2132 | if (valid & OBD_MD_FLEPOCH) | |
f537dd2c | 2133 | CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = %lld\n", |
d7e09d03 PT |
2134 | oa->o_ioepoch); |
2135 | if (valid & OBD_MD_FLFID) { | |
2136 | CDEBUG(D_RPCTRACE, "obdo: o_stripe_idx = %u\n", | |
2137 | oa->o_stripe_idx); | |
2138 | CDEBUG(D_RPCTRACE, "obdo: o_parent_ver = %x\n", | |
2139 | oa->o_parent_ver); | |
2140 | } | |
2141 | if (valid & OBD_MD_FLHANDLE) | |
f537dd2c | 2142 | CDEBUG(D_RPCTRACE, "obdo: o_handle = %lld\n", |
d7e09d03 | 2143 | oa->o_handle.cookie); |
d7e09d03 | 2144 | } |
d7e09d03 PT |
2145 | |
2146 | void dump_ost_body(struct ost_body *ob) | |
2147 | { | |
2148 | dump_obdo(&ob->oa); | |
2149 | } | |
d7e09d03 PT |
2150 | |
2151 | void dump_rcs(__u32 *rc) | |
2152 | { | |
2153 | CDEBUG(D_RPCTRACE, "rmf_rcs: %d\n", *rc); | |
2154 | } | |
d7e09d03 PT |
2155 | |
2156 | static inline int req_ptlrpc_body_swabbed(struct ptlrpc_request *req) | |
2157 | { | |
2158 | LASSERT(req->rq_reqmsg); | |
2159 | ||
2160 | switch (req->rq_reqmsg->lm_magic) { | |
2161 | case LUSTRE_MSG_MAGIC_V2: | |
2162 | return lustre_req_swabbed(req, MSG_PTLRPC_BODY_OFF); | |
2163 | default: | |
2164 | CERROR("bad lustre msg magic: %#08X\n", | |
2165 | req->rq_reqmsg->lm_magic); | |
2166 | } | |
2167 | return 0; | |
2168 | } | |
2169 | ||
2170 | static inline int rep_ptlrpc_body_swabbed(struct ptlrpc_request *req) | |
2171 | { | |
2172 | LASSERT(req->rq_repmsg); | |
2173 | ||
2174 | switch (req->rq_repmsg->lm_magic) { | |
2175 | case LUSTRE_MSG_MAGIC_V2: | |
2176 | return lustre_rep_swabbed(req, MSG_PTLRPC_BODY_OFF); | |
2177 | default: | |
2178 | /* uninitialized yet */ | |
2179 | return 0; | |
2180 | } | |
2181 | } | |
2182 | ||
2183 | void _debug_req(struct ptlrpc_request *req, | |
2184 | struct libcfs_debug_msg_data *msgdata, | |
0d100bfc | 2185 | const char *fmt, ...) |
d7e09d03 PT |
2186 | { |
2187 | int req_ok = req->rq_reqmsg != NULL; | |
2188 | int rep_ok = req->rq_repmsg != NULL; | |
2189 | lnet_nid_t nid = LNET_NID_ANY; | |
2190 | va_list args; | |
2191 | ||
2192 | if (ptlrpc_req_need_swab(req)) { | |
2193 | req_ok = req_ok && req_ptlrpc_body_swabbed(req); | |
2194 | rep_ok = rep_ok && rep_ptlrpc_body_swabbed(req); | |
2195 | } | |
2196 | ||
2197 | if (req->rq_import && req->rq_import->imp_connection) | |
2198 | nid = req->rq_import->imp_connection->c_peer.nid; | |
2199 | else if (req->rq_export && req->rq_export->exp_connection) | |
2200 | nid = req->rq_export->exp_connection->c_peer.nid; | |
2201 | ||
2202 | va_start(args, fmt); | |
2203 | libcfs_debug_vmsg2(msgdata, fmt, args, | |
219e6de6 | 2204 | " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n", |
d7e09d03 PT |
2205 | req, req->rq_xid, req->rq_transno, |
2206 | req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0, | |
2207 | req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1, | |
2208 | req->rq_import ? | |
2d00bd17 JP |
2209 | req->rq_import->imp_obd->obd_name : |
2210 | req->rq_export ? | |
2211 | req->rq_export->exp_client_uuid.uuid : | |
2212 | "<?>", | |
d7e09d03 PT |
2213 | libcfs_nid2str(nid), |
2214 | req->rq_request_portal, req->rq_reply_portal, | |
2215 | req->rq_reqlen, req->rq_replen, | |
219e6de6 AB |
2216 | req->rq_early_count, (s64)req->rq_timedout, |
2217 | (s64)req->rq_deadline, | |
d7e09d03 PT |
2218 | atomic_read(&req->rq_refcount), |
2219 | DEBUG_REQ_FLAGS(req), | |
2220 | req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1, | |
2221 | rep_ok ? lustre_msg_get_flags(req->rq_repmsg) : -1, | |
2222 | req->rq_status, | |
2223 | rep_ok ? lustre_msg_get_status(req->rq_repmsg) : -1); | |
353471a6 | 2224 | va_end(args); |
d7e09d03 PT |
2225 | } |
2226 | EXPORT_SYMBOL(_debug_req); | |
2227 | ||
2228 | void lustre_swab_lustre_capa(struct lustre_capa *c) | |
2229 | { | |
2230 | lustre_swab_lu_fid(&c->lc_fid); | |
0d100bfc KM |
2231 | __swab64s(&c->lc_opc); |
2232 | __swab64s(&c->lc_uid); | |
2233 | __swab64s(&c->lc_gid); | |
2234 | __swab32s(&c->lc_flags); | |
2235 | __swab32s(&c->lc_keyid); | |
2236 | __swab32s(&c->lc_timeout); | |
2237 | __swab32s(&c->lc_expiry); | |
d7e09d03 | 2238 | } |
d7e09d03 | 2239 | |
d7e09d03 PT |
2240 | void lustre_swab_hsm_user_state(struct hsm_user_state *state) |
2241 | { | |
2242 | __swab32s(&state->hus_states); | |
2243 | __swab32s(&state->hus_archive_id); | |
2244 | } | |
d7e09d03 PT |
2245 | |
2246 | void lustre_swab_hsm_state_set(struct hsm_state_set *hss) | |
2247 | { | |
2248 | __swab32s(&hss->hss_valid); | |
2249 | __swab64s(&hss->hss_setmask); | |
2250 | __swab64s(&hss->hss_clearmask); | |
2251 | __swab32s(&hss->hss_archive_id); | |
2252 | } | |
2253 | EXPORT_SYMBOL(lustre_swab_hsm_state_set); | |
2254 | ||
2adf5e87 | 2255 | static void lustre_swab_hsm_extent(struct hsm_extent *extent) |
d7e09d03 PT |
2256 | { |
2257 | __swab64s(&extent->offset); | |
2258 | __swab64s(&extent->length); | |
2259 | } | |
2260 | ||
2261 | void lustre_swab_hsm_current_action(struct hsm_current_action *action) | |
2262 | { | |
2263 | __swab32s(&action->hca_state); | |
2264 | __swab32s(&action->hca_action); | |
2265 | lustre_swab_hsm_extent(&action->hca_location); | |
2266 | } | |
d7e09d03 PT |
2267 | |
2268 | void lustre_swab_hsm_user_item(struct hsm_user_item *hui) | |
2269 | { | |
2270 | lustre_swab_lu_fid(&hui->hui_fid); | |
2271 | lustre_swab_hsm_extent(&hui->hui_extent); | |
2272 | } | |
d7e09d03 PT |
2273 | |
2274 | void lustre_swab_layout_intent(struct layout_intent *li) | |
2275 | { | |
2276 | __swab32s(&li->li_opc); | |
2277 | __swab32s(&li->li_flags); | |
2278 | __swab64s(&li->li_start); | |
2279 | __swab64s(&li->li_end); | |
2280 | } | |
d7e09d03 PT |
2281 | |
2282 | void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk) | |
2283 | { | |
2284 | lustre_swab_lu_fid(&hpk->hpk_fid); | |
2285 | __swab64s(&hpk->hpk_cookie); | |
2286 | __swab64s(&hpk->hpk_extent.offset); | |
2287 | __swab64s(&hpk->hpk_extent.length); | |
2288 | __swab16s(&hpk->hpk_flags); | |
2289 | __swab16s(&hpk->hpk_errval); | |
2290 | } | |
d7e09d03 PT |
2291 | |
2292 | void lustre_swab_hsm_request(struct hsm_request *hr) | |
2293 | { | |
2294 | __swab32s(&hr->hr_action); | |
2295 | __swab32s(&hr->hr_archive_id); | |
2296 | __swab64s(&hr->hr_flags); | |
2297 | __swab32s(&hr->hr_itemcount); | |
2298 | __swab32s(&hr->hr_data_len); | |
2299 | } | |
d7e09d03 | 2300 | |
d7e09d03 PT |
2301 | void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl) |
2302 | { | |
2303 | __swab64s(&msl->msl_flags); | |
2304 | } | |
2305 | EXPORT_SYMBOL(lustre_swab_swap_layouts); | |
48d23e61 JX |
2306 | |
2307 | void lustre_swab_close_data(struct close_data *cd) | |
2308 | { | |
2309 | lustre_swab_lu_fid(&cd->cd_fid); | |
2310 | __swab64s(&cd->cd_data_version); | |
2311 | } |