Whamcloud - gitweb
b=18525
[fs/lustre-release.git] / lustre / ptlrpc / layout.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/ptlrpc/layout.c
37  *
38  * Lustre Metadata Target (mdt) request handler
39  *
40  * Author: Nikita Danilov <nikita@clusterfs.com>
41  */
42
43 #if !defined(__REQ_LAYOUT_USER__)
44
45 #ifndef EXPORT_SYMTAB
46 # define EXPORT_SYMTAB
47 #endif
48 #define DEBUG_SUBSYSTEM S_RPC
49
50 #ifdef __KERNEL__
51 #include <linux/module.h>
52 #else
53 # include <liblustre.h>
54 #endif
55
56 /* LUSTRE_VERSION_CODE */
57 #include <lustre_ver.h>
58
59 #include <obd_support.h>
60 /* lustre_swab_mdt_body */
61 #include <lustre/lustre_idl.h>
62 /* obd2cli_tgt() (required by DEBUG_REQ()) */
63 #include <obd.h>
64
65 /* __REQ_LAYOUT_USER__ */
66 #endif
67 /* struct ptlrpc_request, lustre_msg* */
68 #include <lustre_req_layout.h>
69 #include <lustre_acl.h>
70
71 /*
72  * empty set of fields... for suitable definition of emptiness.
73  */
74 static const struct req_msg_field *empty[] = {
75         &RMF_PTLRPC_BODY
76 };
77
78 static const struct req_msg_field *mgs_target_info_only[] = {
79         &RMF_PTLRPC_BODY,
80         &RMF_MGS_TARGET_INFO
81 };
82
83 static const struct req_msg_field *mgs_set_info[] = {
84         &RMF_PTLRPC_BODY,
85         &RMF_MGS_SEND_PARAM
86 };
87
88 static const struct req_msg_field *log_cancel_client[] = {
89         &RMF_PTLRPC_BODY,
90         &RMF_LOGCOOKIES
91 };
92
93 static const struct req_msg_field *mdt_body_only[] = {
94         &RMF_PTLRPC_BODY,
95         &RMF_MDT_BODY
96 };
97
98 static const struct req_msg_field *mdt_body_capa[] = {
99         &RMF_PTLRPC_BODY,
100         &RMF_MDT_BODY,
101         &RMF_CAPA1
102 };
103
104 static const struct req_msg_field *quotactl_only[] = {
105         &RMF_PTLRPC_BODY,
106         &RMF_OBD_QUOTACTL
107 };
108 static const struct req_msg_field *quota_adjust_qunit_only[] = {
109         &RMF_PTLRPC_BODY,
110         &RMF_QUOTA_ADJUST_QUNIT
111 };
112
113 static const struct req_msg_field *qunit_data_only[] = {
114         &RMF_PTLRPC_BODY,
115         &RMF_QUNIT_DATA
116 };
117
118 static const struct req_msg_field *mdt_close_client[] = {
119         &RMF_PTLRPC_BODY,
120         &RMF_MDT_EPOCH,
121         &RMF_REC_REINT,
122         &RMF_CAPA1
123 };
124
125 static const struct req_msg_field *obd_statfs_server[] = {
126         &RMF_PTLRPC_BODY,
127         &RMF_OBD_STATFS
128 };
129
130 static const struct req_msg_field *seq_query_client[] = {
131         &RMF_PTLRPC_BODY,
132         &RMF_SEQ_OPC,
133         &RMF_SEQ_RANGE
134 };
135
136 static const struct req_msg_field *seq_query_server[] = {
137         &RMF_PTLRPC_BODY,
138         &RMF_SEQ_RANGE
139 };
140
141 static const struct req_msg_field *fld_query_client[] = {
142         &RMF_PTLRPC_BODY,
143         &RMF_FLD_OPC,
144         &RMF_FLD_MDFLD
145 };
146
147 static const struct req_msg_field *fld_query_server[] = {
148         &RMF_PTLRPC_BODY,
149         &RMF_FLD_MDFLD
150 };
151
152 static const struct req_msg_field *mds_getattr_name_client[] = {
153         &RMF_PTLRPC_BODY,
154         &RMF_MDT_BODY,
155         &RMF_CAPA1,
156         &RMF_NAME
157 };
158
159 static const struct req_msg_field *mds_reint_client[] = {
160         &RMF_PTLRPC_BODY,
161         &RMF_REC_REINT
162 };
163
164 static const struct req_msg_field *mds_reint_create_client[] = {
165         &RMF_PTLRPC_BODY,
166         &RMF_REC_REINT,
167         &RMF_CAPA1,
168         &RMF_NAME
169 };
170
171 static const struct req_msg_field *mds_reint_create_slave_client[] = {
172         &RMF_PTLRPC_BODY,
173         &RMF_REC_REINT,
174         &RMF_CAPA1,
175         &RMF_NAME,
176         &RMF_EADATA,
177         &RMF_DLM_REQ
178 };
179
180 static const struct req_msg_field *mds_reint_create_rmt_acl_client[] = {
181         &RMF_PTLRPC_BODY,
182         &RMF_REC_REINT,
183         &RMF_CAPA1,
184         &RMF_NAME,
185         &RMF_EADATA,
186         &RMF_DLM_REQ
187 };
188
189 static const struct req_msg_field *mds_reint_create_sym_client[] = {
190         &RMF_PTLRPC_BODY,
191         &RMF_REC_REINT,
192         &RMF_CAPA1,
193         &RMF_NAME,
194         &RMF_SYMTGT,
195         &RMF_DLM_REQ
196 };
197
198 static const struct req_msg_field *mds_reint_open_client[] = {
199         &RMF_PTLRPC_BODY,
200         &RMF_REC_REINT,
201         &RMF_CAPA1,
202         &RMF_CAPA2,
203         &RMF_NAME,
204         &RMF_EADATA
205 };
206
207 static const struct req_msg_field *mds_reint_open_server[] = {
208         &RMF_PTLRPC_BODY,
209         &RMF_MDT_BODY,
210         &RMF_MDT_MD,
211         &RMF_ACL,
212         &RMF_CAPA1,
213         &RMF_CAPA2
214 };
215
216 static const struct req_msg_field *mds_reint_unlink_client[] = {
217         &RMF_PTLRPC_BODY,
218         &RMF_REC_REINT,
219         &RMF_CAPA1,
220         &RMF_NAME,
221         &RMF_DLM_REQ
222 };
223
224 static const struct req_msg_field *mds_reint_link_client[] = {
225         &RMF_PTLRPC_BODY,
226         &RMF_REC_REINT,
227         &RMF_CAPA1,
228         &RMF_CAPA2,
229         &RMF_NAME,
230         &RMF_DLM_REQ
231 };
232
233 static const struct req_msg_field *mds_reint_rename_client[] = {
234         &RMF_PTLRPC_BODY,
235         &RMF_REC_REINT,
236         &RMF_CAPA1,
237         &RMF_CAPA2,
238         &RMF_NAME,
239         &RMF_SYMTGT,
240         &RMF_DLM_REQ
241 };
242
243 static const struct req_msg_field *mds_last_unlink_server[] = {
244         &RMF_PTLRPC_BODY,
245         &RMF_MDT_BODY,
246         &RMF_MDT_MD,
247         &RMF_LOGCOOKIES,
248         &RMF_CAPA1,
249         &RMF_CAPA2
250 };
251
252 static const struct req_msg_field *mds_reint_setattr_client[] = {
253         &RMF_PTLRPC_BODY,
254         &RMF_REC_REINT,
255         &RMF_CAPA1,
256         &RMF_MDT_EPOCH,
257         &RMF_EADATA,
258         &RMF_LOGCOOKIES,
259         &RMF_DLM_REQ
260 };
261
262 static const struct req_msg_field *mds_reint_setxattr_client[] = {
263         &RMF_PTLRPC_BODY,
264         &RMF_REC_REINT,
265         &RMF_CAPA1,
266         &RMF_NAME,
267         &RMF_EADATA
268 };
269
270 static const struct req_msg_field *obd_connect_client[] = {
271         &RMF_PTLRPC_BODY,
272         &RMF_TGTUUID,
273         &RMF_CLUUID,
274         &RMF_CONN,
275         &RMF_CONNECT_DATA
276 };
277
278 static const struct req_msg_field *obd_connect_server[] = {
279         &RMF_PTLRPC_BODY,
280         &RMF_CONNECT_DATA
281 };
282
283 static const struct req_msg_field *mds_set_info_client[] = {
284         &RMF_PTLRPC_BODY,
285         &RMF_SETINFO_KEY,
286         &RMF_SETINFO_VAL
287 };
288
289 static const struct req_msg_field *mds_getinfo_client[] = {
290         &RMF_PTLRPC_BODY,
291         &RMF_GETINFO_KEY,
292         &RMF_GETINFO_VALLEN
293 };
294
295 static const struct req_msg_field *mds_getinfo_server[] = {
296         &RMF_PTLRPC_BODY,
297         &RMF_GETINFO_VAL,
298 };
299
300 static const struct req_msg_field *ldlm_enqueue_client[] = {
301         &RMF_PTLRPC_BODY,
302         &RMF_DLM_REQ
303 };
304
305 static const struct req_msg_field *ldlm_enqueue_server[] = {
306         &RMF_PTLRPC_BODY,
307         &RMF_DLM_REP
308 };
309
310 static const struct req_msg_field *ldlm_enqueue_lvb_server[] = {
311         &RMF_PTLRPC_BODY,
312         &RMF_DLM_REP,
313         &RMF_DLM_LVB
314 };
315
316 static const struct req_msg_field *ldlm_cp_callback_client[] = {
317         &RMF_PTLRPC_BODY,
318         &RMF_DLM_REQ,
319         &RMF_DLM_LVB
320 };
321
322 static const struct req_msg_field *ldlm_gl_callback_server[] = {
323         &RMF_PTLRPC_BODY,
324         &RMF_DLM_LVB
325 };
326
327 static const struct req_msg_field *ldlm_intent_client[] = {
328         &RMF_PTLRPC_BODY,
329         &RMF_DLM_REQ,
330         &RMF_LDLM_INTENT,
331         &RMF_REC_REINT
332 };
333
334 static const struct req_msg_field *ldlm_intent_server[] = {
335         &RMF_PTLRPC_BODY,
336         &RMF_DLM_REP,
337         &RMF_MDT_BODY,
338         &RMF_MDT_MD,
339         &RMF_ACL
340 };
341
342 static const struct req_msg_field *ldlm_intent_open_server[] = {
343         &RMF_PTLRPC_BODY,
344         &RMF_DLM_REP,
345         &RMF_MDT_BODY,
346         &RMF_MDT_MD,
347         &RMF_ACL,
348         &RMF_CAPA1,
349         &RMF_CAPA2
350 };
351
352 static const struct req_msg_field *ldlm_intent_getattr_client[] = {
353         &RMF_PTLRPC_BODY,
354         &RMF_DLM_REQ,
355         &RMF_LDLM_INTENT,
356         &RMF_MDT_BODY,     /* coincides with mds_getattr_name_client[] */
357         &RMF_CAPA1,
358         &RMF_NAME
359 };
360
361 static const struct req_msg_field *ldlm_intent_getattr_server[] = {
362         &RMF_PTLRPC_BODY,
363         &RMF_DLM_REP,
364         &RMF_MDT_BODY,
365         &RMF_MDT_MD,
366         &RMF_ACL,
367         &RMF_CAPA1
368 };
369
370 static const struct req_msg_field *ldlm_intent_create_client[] = {
371         &RMF_PTLRPC_BODY,
372         &RMF_DLM_REQ,
373         &RMF_LDLM_INTENT,
374         &RMF_REC_REINT,    /* coincides with mds_reint_create_client[] */
375         &RMF_CAPA1,
376         &RMF_NAME,
377         &RMF_EADATA
378 };
379
380 static const struct req_msg_field *ldlm_intent_open_client[] = {
381         &RMF_PTLRPC_BODY,
382         &RMF_DLM_REQ,
383         &RMF_LDLM_INTENT,
384         &RMF_REC_REINT,    /* coincides with mds_reint_open_client[] */
385         &RMF_CAPA1,
386         &RMF_CAPA2,
387         &RMF_NAME,
388         &RMF_EADATA,
389         &RMF_REC_JOINFILE
390 };
391
392 static const struct req_msg_field *ldlm_intent_unlink_client[] = {
393         &RMF_PTLRPC_BODY,
394         &RMF_DLM_REQ,
395         &RMF_LDLM_INTENT,
396         &RMF_REC_REINT,    /* coincides with mds_reint_unlink_client[] */
397         &RMF_CAPA1,
398         &RMF_NAME
399 };
400
401 static const struct req_msg_field *mds_getxattr_client[] = {
402         &RMF_PTLRPC_BODY,
403         &RMF_MDT_BODY,
404         &RMF_CAPA1,
405         &RMF_NAME,
406         &RMF_EADATA
407 };
408
409 static const struct req_msg_field *mds_getxattr_server[] = {
410         &RMF_PTLRPC_BODY,
411         &RMF_MDT_BODY,
412         &RMF_EADATA
413 };
414
415 static const struct req_msg_field *mds_getattr_server[] = {
416         &RMF_PTLRPC_BODY,
417         &RMF_MDT_BODY,
418         &RMF_MDT_MD,
419         &RMF_ACL,
420         &RMF_CAPA1,
421         &RMF_CAPA2
422 };
423
424 static const struct req_msg_field *mds_setattr_server[] = {
425         &RMF_PTLRPC_BODY,
426         &RMF_MDT_BODY,
427         &RMF_MDT_MD,
428         &RMF_ACL,
429         &RMF_CAPA1,
430         &RMF_CAPA2
431 };
432
433 static const struct req_msg_field *llog_catinfo_client[] = {
434         &RMF_PTLRPC_BODY,
435         &RMF_NAME,
436         &RMF_STRING
437 };
438
439 static const struct req_msg_field *llog_catinfo_server[] = {
440         &RMF_PTLRPC_BODY,
441         &RMF_STRING
442 };
443
444 static const struct req_msg_field *llog_origin_handle_create_client[] = {
445         &RMF_PTLRPC_BODY,
446         &RMF_LLOGD_BODY,
447         &RMF_NAME
448 };
449
450 static const struct req_msg_field *llogd_body_only[] = {
451         &RMF_PTLRPC_BODY,
452         &RMF_LLOGD_BODY
453 };
454
455 static const struct req_msg_field *llog_log_hdr_only[] = {
456         &RMF_PTLRPC_BODY,
457         &RMF_LLOG_LOG_HDR
458 };
459
460 static const struct req_msg_field *llogd_conn_body_only[] = {
461         &RMF_PTLRPC_BODY,
462         &RMF_LLOGD_CONN_BODY
463 };
464
465 static const struct req_msg_field *llog_origin_handle_next_block_server[] = {
466         &RMF_PTLRPC_BODY,
467         &RMF_LLOGD_BODY,
468         &RMF_EADATA
469 };
470
471 static const struct req_msg_field *ost_body_only[] = {
472         &RMF_PTLRPC_BODY,
473         &RMF_OST_BODY
474 };
475
476 static const struct req_msg_field *ost_body_capa[] = {
477         &RMF_PTLRPC_BODY,
478         &RMF_OST_BODY,
479         &RMF_CAPA1
480 };
481
482 static const struct req_msg_field *ost_destroy_client[] = {
483         &RMF_PTLRPC_BODY,
484         &RMF_OST_BODY,
485         &RMF_DLM_REQ,
486         &RMF_CAPA1
487 };
488
489
490 static const struct req_msg_field *ost_brw_client[] = {
491         &RMF_PTLRPC_BODY,
492         &RMF_OST_BODY,
493         &RMF_OBD_IOOBJ,
494         &RMF_NIOBUF_REMOTE,
495         &RMF_CAPA1
496 };
497
498 static const struct req_msg_field *ost_brw_server[] = {
499         &RMF_PTLRPC_BODY,
500         &RMF_OST_BODY,
501         &RMF_NIOBUF_REMOTE
502 };
503
504 static const struct req_msg_field *ost_set_info_client[] = {
505         &RMF_PTLRPC_BODY,
506         &RMF_SETINFO_KEY,
507         &RMF_SETINFO_VAL
508 };
509
510 static const struct req_msg_field *ost_get_info_generic_server[] = {
511         &RMF_PTLRPC_BODY,
512         &RMF_GENERIC_DATA,
513 };
514
515 static const struct req_msg_field *ost_get_info_generic_client[] = {
516         &RMF_PTLRPC_BODY,
517         &RMF_SETINFO_KEY
518 };
519
520 static const struct req_msg_field *ost_get_last_id_server[] = {
521         &RMF_PTLRPC_BODY,
522         &RMF_OBD_ID
523 };
524
525 static const struct req_msg_field *ost_get_fiemap_client[] = {
526         &RMF_PTLRPC_BODY,
527         &RMF_FIEMAP_KEY,
528         &RMF_FIEMAP_VAL
529 };
530
531 static const struct req_msg_field *ost_get_fiemap_server[] = {
532         &RMF_PTLRPC_BODY,
533         &RMF_FIEMAP_VAL
534 };
535
536 static const struct req_format *req_formats[] = {
537         &RQF_OBD_PING,
538         &RQF_SEC_CTX,
539         &RQF_MGS_TARGET_REG,
540         &RQF_MGS_SET_INFO,
541         &RQF_SEQ_QUERY,
542         &RQF_FLD_QUERY,
543         &RQF_MDS_CONNECT,
544         &RQF_MDS_DISCONNECT,
545         &RQF_MDS_SET_INFO,
546         &RQF_MDS_GET_INFO,
547         &RQF_MDS_GETSTATUS,
548         &RQF_MDS_STATFS,
549         &RQF_MDS_GETATTR,
550         &RQF_MDS_GETATTR_NAME,
551         &RQF_MDS_GETXATTR,
552         &RQF_MDS_SYNC,
553         &RQF_MDS_CLOSE,
554         &RQF_MDS_PIN,
555         &RQF_MDS_UNPIN,
556         &RQF_MDS_READPAGE,
557         &RQF_MDS_WRITEPAGE,
558         &RQF_MDS_IS_SUBDIR,
559         &RQF_MDS_DONE_WRITING,
560         &RQF_MDS_REINT,
561         &RQF_MDS_REINT_CREATE,
562         &RQF_MDS_REINT_CREATE_RMT_ACL,
563         &RQF_MDS_REINT_CREATE_SLAVE,
564         &RQF_MDS_REINT_CREATE_SYM,
565         &RQF_MDS_REINT_OPEN,
566         &RQF_MDS_REINT_UNLINK,
567         &RQF_MDS_REINT_LINK,
568         &RQF_MDS_REINT_RENAME,
569         &RQF_MDS_REINT_SETATTR,
570         &RQF_MDS_REINT_SETXATTR,
571         &RQF_MDS_QUOTACHECK,
572         &RQF_MDS_QUOTACTL,
573         &RQF_MDS_QUOTA_DQACQ,
574         &RQF_QC_CALLBACK,
575         &RQF_OST_CONNECT,
576         &RQF_OST_DISCONNECT,
577         &RQF_OST_QUOTACHECK,
578         &RQF_OST_QUOTACTL,
579         &RQF_OST_QUOTA_ADJUST_QUNIT,
580         &RQF_OST_GETATTR,
581         &RQF_OST_SETATTR,
582         &RQF_OST_CREATE,
583         &RQF_OST_PUNCH,
584         &RQF_OST_SYNC,
585         &RQF_OST_DESTROY,
586         &RQF_OST_BRW,
587         &RQF_OST_STATFS,
588         &RQF_OST_SET_INFO,
589         &RQF_OST_SET_GRANT_INFO,
590         &RQF_OST_GET_INFO_GENERIC,
591         &RQF_OST_GET_INFO_LAST_ID,
592         &RQF_OST_GET_INFO_FIEMAP,
593         &RQF_LDLM_ENQUEUE,
594         &RQF_LDLM_ENQUEUE_LVB,
595         &RQF_LDLM_CONVERT,
596         &RQF_LDLM_CANCEL,
597         &RQF_LDLM_CALLBACK,
598         &RQF_LDLM_CP_CALLBACK,
599         &RQF_LDLM_BL_CALLBACK,
600         &RQF_LDLM_GL_CALLBACK,
601         &RQF_LDLM_INTENT,
602         &RQF_LDLM_INTENT_GETATTR,
603         &RQF_LDLM_INTENT_OPEN,
604         &RQF_LDLM_INTENT_CREATE,
605         &RQF_LDLM_INTENT_UNLINK,
606         &RQF_LOG_CANCEL,
607         &RQF_LLOG_CATINFO,
608         &RQF_LLOG_ORIGIN_HANDLE_CREATE,
609         &RQF_LLOG_ORIGIN_HANDLE_DESTROY,
610         &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK,
611         &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK,
612         &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER,
613         &RQF_LLOG_ORIGIN_CONNECT
614 };
615
616 struct req_msg_field {
617         __u32       rmf_flags;
618         const char *rmf_name;
619         /**
620          * Field length. (-1) means "variable length".
621          */
622         int         rmf_size;
623         void      (*rmf_swabber)(void *);
624         int         rmf_offset[ARRAY_SIZE(req_formats)][RCL_NR];
625 };
626
627 enum rmf_flags {
628         RMF_F_STRING = 1 << 0,
629         RMF_F_NO_SIZE_CHECK = 1 << 1
630 };
631
632 struct req_capsule;
633
634 /*
635  * Request fields.
636  */
637 #define DEFINE_MSGF(name, flags, size, swabber) {       \
638         .rmf_name    = (name),                          \
639         .rmf_flags   = (flags),                         \
640         .rmf_size    = (size),                          \
641         .rmf_swabber = (void (*)(void*))(swabber)       \
642 }
643
644 const struct req_msg_field RMF_GENERIC_DATA =
645         DEFINE_MSGF("generic_data", 0,
646                     -1, NULL);
647 EXPORT_SYMBOL(RMF_GENERIC_DATA);
648
649 const struct req_msg_field RMF_MGS_TARGET_INFO =
650         DEFINE_MSGF("mgs_target_info", 0,
651                     sizeof(struct mgs_target_info),
652                     lustre_swab_mgs_target_info);
653 EXPORT_SYMBOL(RMF_MGS_TARGET_INFO);
654
655 const struct req_msg_field RMF_MGS_SEND_PARAM =
656         DEFINE_MSGF("mgs_send_param", 0,
657                     sizeof(struct mgs_send_param),
658                     NULL);
659 EXPORT_SYMBOL(RMF_MGS_SEND_PARAM);
660
661 const struct req_msg_field RMF_SETINFO_VAL =
662         DEFINE_MSGF("setinfo_val", 0, -1, NULL);
663 EXPORT_SYMBOL(RMF_SETINFO_VAL);
664
665 const struct req_msg_field RMF_GETINFO_KEY =
666         DEFINE_MSGF("getinfo_key", 0, -1, NULL);
667 EXPORT_SYMBOL(RMF_GETINFO_KEY);
668
669 const struct req_msg_field RMF_GETINFO_VALLEN =
670         DEFINE_MSGF("getinfo_vallen", 0,
671                     sizeof(__u32), lustre_swab_generic_32s);
672 EXPORT_SYMBOL(RMF_GETINFO_VALLEN);
673
674 const struct req_msg_field RMF_GETINFO_VAL =
675         DEFINE_MSGF("getinfo_val", 0, -1, NULL);
676 EXPORT_SYMBOL(RMF_GETINFO_VAL);
677
678 const struct req_msg_field RMF_SEQ_OPC =
679         DEFINE_MSGF("seq_query_opc", 0,
680                     sizeof(__u32), lustre_swab_generic_32s);
681 EXPORT_SYMBOL(RMF_SEQ_OPC);
682
683 const struct req_msg_field RMF_SEQ_RANGE =
684         DEFINE_MSGF("seq_query_range", 0,
685                     sizeof(struct lu_seq_range), lustre_swab_lu_seq_range);
686 EXPORT_SYMBOL(RMF_SEQ_RANGE);
687
688 const struct req_msg_field RMF_FLD_OPC =
689         DEFINE_MSGF("fld_query_opc", 0,
690                     sizeof(__u32), lustre_swab_generic_32s);
691 EXPORT_SYMBOL(RMF_FLD_OPC);
692
693 const struct req_msg_field RMF_FLD_MDFLD =
694         DEFINE_MSGF("fld_query_mdfld", 0,
695                     sizeof(struct lu_seq_range), lustre_swab_lu_seq_range);
696 EXPORT_SYMBOL(RMF_FLD_MDFLD);
697
698 const struct req_msg_field RMF_MDT_BODY =
699         DEFINE_MSGF("mdt_body", 0,
700                     sizeof(struct mdt_body), lustre_swab_mdt_body);
701 EXPORT_SYMBOL(RMF_MDT_BODY);
702
703 const struct req_msg_field RMF_OBD_QUOTACTL =
704         DEFINE_MSGF("obd_quotactl", 0,
705                     sizeof(struct obd_quotactl), lustre_swab_obd_quotactl);
706 EXPORT_SYMBOL(RMF_OBD_QUOTACTL);
707
708 const struct req_msg_field RMF_QUOTA_ADJUST_QUNIT =
709         DEFINE_MSGF("quota_adjust_qunit", 0,
710                     sizeof(struct quota_adjust_qunit),
711                     lustre_swab_quota_adjust_qunit);
712 EXPORT_SYMBOL(RMF_QUOTA_ADJUST_QUNIT);
713
714 const struct req_msg_field RMF_QUNIT_DATA =
715         DEFINE_MSGF("qunit_data", 0,
716                     sizeof(struct qunit_data), NULL);
717 EXPORT_SYMBOL(RMF_QUNIT_DATA);
718
719 const struct req_msg_field RMF_MDT_EPOCH =
720         DEFINE_MSGF("mdt_epoch", 0,
721                     sizeof(struct mdt_epoch), lustre_swab_mdt_epoch);
722 EXPORT_SYMBOL(RMF_MDT_EPOCH);
723
724 const struct req_msg_field RMF_PTLRPC_BODY =
725         DEFINE_MSGF("ptlrpc_body", 0,
726                     sizeof(struct ptlrpc_body), lustre_swab_ptlrpc_body);
727 EXPORT_SYMBOL(RMF_PTLRPC_BODY);
728
729 const struct req_msg_field RMF_OBD_STATFS =
730         DEFINE_MSGF("obd_statfs", 0,
731                     sizeof(struct obd_statfs), lustre_swab_obd_statfs);
732 EXPORT_SYMBOL(RMF_OBD_STATFS);
733
734 const struct req_msg_field RMF_SETINFO_KEY =
735         DEFINE_MSGF("setinfo_key", 0, -1, NULL);
736 EXPORT_SYMBOL(RMF_SETINFO_KEY);
737
738 const struct req_msg_field RMF_NAME =
739         DEFINE_MSGF("name", RMF_F_STRING, -1, NULL);
740 EXPORT_SYMBOL(RMF_NAME);
741
742 const struct req_msg_field RMF_SYMTGT =
743         DEFINE_MSGF("symtgt", RMF_F_STRING, -1, NULL);
744 EXPORT_SYMBOL(RMF_SYMTGT);
745
746 const struct req_msg_field RMF_TGTUUID =
747         DEFINE_MSGF("tgtuuid", RMF_F_STRING, sizeof(struct obd_uuid) - 1, NULL);
748 EXPORT_SYMBOL(RMF_TGTUUID);
749
750 const struct req_msg_field RMF_CLUUID =
751         DEFINE_MSGF("cluuid", RMF_F_STRING, sizeof(struct obd_uuid) - 1, NULL);
752 EXPORT_SYMBOL(RMF_CLUUID);
753
754 const struct req_msg_field RMF_STRING =
755         DEFINE_MSGF("string", RMF_F_STRING, -1, NULL);
756 EXPORT_SYMBOL(RMF_STRING);
757
758 const struct req_msg_field RMF_LLOGD_BODY =
759         DEFINE_MSGF("llogd_body", 0,
760                     sizeof(struct llogd_body), lustre_swab_llogd_body);
761 EXPORT_SYMBOL(RMF_LLOGD_BODY);
762
763 const struct req_msg_field RMF_LLOG_LOG_HDR =
764         DEFINE_MSGF("llog_log_hdr", 0,
765                     sizeof(struct llog_log_hdr), lustre_swab_llog_hdr);
766 EXPORT_SYMBOL(RMF_LLOG_LOG_HDR);
767
768 const struct req_msg_field RMF_LLOGD_CONN_BODY =
769         DEFINE_MSGF("llogd_conn_body", 0,
770                     sizeof(struct llogd_conn_body),
771                     lustre_swab_llogd_conn_body);
772 EXPORT_SYMBOL(RMF_LLOGD_CONN_BODY);
773
774 /*
775  * connection handle received in MDS_CONNECT request.
776  *
777  * XXX no swabbing?
778  */
779 const struct req_msg_field RMF_CONN =
780         DEFINE_MSGF("conn", 0, sizeof(struct lustre_handle), NULL);
781 EXPORT_SYMBOL(RMF_CONN);
782
783 const struct req_msg_field RMF_CONNECT_DATA =
784         DEFINE_MSGF("cdata",
785                     RMF_F_NO_SIZE_CHECK /* we allow extra space for interop */,
786                     sizeof(struct obd_connect_data), lustre_swab_connect);
787 EXPORT_SYMBOL(RMF_CONNECT_DATA);
788
789 const struct req_msg_field RMF_DLM_REQ =
790         DEFINE_MSGF("dlm_req", RMF_F_NO_SIZE_CHECK /* ldlm_request_bufsize */,
791                     sizeof(struct ldlm_request), lustre_swab_ldlm_request);
792 EXPORT_SYMBOL(RMF_DLM_REQ);
793
794 const struct req_msg_field RMF_DLM_REP =
795         DEFINE_MSGF("dlm_rep", 0,
796                     sizeof(struct ldlm_reply), lustre_swab_ldlm_reply);
797 EXPORT_SYMBOL(RMF_DLM_REP);
798
799 const struct req_msg_field RMF_LDLM_INTENT =
800         DEFINE_MSGF("ldlm_intent", 0,
801                     sizeof(struct ldlm_intent), lustre_swab_ldlm_intent);
802 EXPORT_SYMBOL(RMF_LDLM_INTENT);
803
804 const struct req_msg_field RMF_DLM_LVB =
805         DEFINE_MSGF("dlm_lvb", 0, sizeof(struct ost_lvb), NULL);
806 EXPORT_SYMBOL(RMF_DLM_LVB);
807
808 const struct req_msg_field RMF_MDT_MD =
809         DEFINE_MSGF("mdt_md", RMF_F_NO_SIZE_CHECK, MIN_MD_SIZE, NULL);
810 EXPORT_SYMBOL(RMF_MDT_MD);
811
812 const struct req_msg_field RMF_REC_REINT =
813         DEFINE_MSGF("rec_reint", 0, sizeof(struct mdt_rec_reint),
814                     lustre_swab_mdt_rec_reint);
815 EXPORT_SYMBOL(RMF_REC_REINT);
816
817 const struct req_msg_field RMF_REC_JOINFILE =
818         DEFINE_MSGF("rec_joinfile", 0, sizeof(struct mdt_rec_join),
819                     lustre_swab_mdt_rec_join);
820 EXPORT_SYMBOL(RMF_REC_JOINFILE);
821
822 /* FIXME: this length should be defined as a macro */
823 const struct req_msg_field RMF_EADATA = DEFINE_MSGF("eadata", 0, -1, NULL);
824 EXPORT_SYMBOL(RMF_EADATA);
825
826 const struct req_msg_field RMF_ACL =
827         DEFINE_MSGF("acl", RMF_F_NO_SIZE_CHECK,
828                     LUSTRE_POSIX_ACL_MAX_SIZE, NULL);
829 EXPORT_SYMBOL(RMF_ACL);
830
831 const struct req_msg_field RMF_LOGCOOKIES =
832         DEFINE_MSGF("logcookies", RMF_F_NO_SIZE_CHECK /* multiple cookies */,
833                     sizeof(struct llog_cookie), NULL);
834 EXPORT_SYMBOL(RMF_LOGCOOKIES);
835
836 const struct req_msg_field RMF_CAPA1 =
837         DEFINE_MSGF("capa", 0, sizeof(struct lustre_capa),
838                     lustre_swab_lustre_capa);
839 EXPORT_SYMBOL(RMF_CAPA1);
840
841 const struct req_msg_field RMF_CAPA2 =
842         DEFINE_MSGF("capa", 0, sizeof(struct lustre_capa),
843                     lustre_swab_lustre_capa);
844 EXPORT_SYMBOL(RMF_CAPA2);
845
846 /*
847  * OST request field.
848  */
849 const struct req_msg_field RMF_OST_BODY =
850         DEFINE_MSGF("ost_body", 0,
851                     sizeof(struct ost_body), lustre_swab_ost_body);
852 EXPORT_SYMBOL(RMF_OST_BODY);
853
854 const struct req_msg_field RMF_OBD_IOOBJ =
855         DEFINE_MSGF("obd_ioobj", 0,
856                     sizeof(struct obd_ioobj), lustre_swab_obd_ioobj);
857 EXPORT_SYMBOL(RMF_OBD_IOOBJ);
858
859 const struct req_msg_field RMF_NIOBUF_REMOTE =
860         DEFINE_MSGF("niobuf_remote", 0, -1, lustre_swab_niobuf_remote);
861 EXPORT_SYMBOL(RMF_NIOBUF_REMOTE);
862
863 const struct req_msg_field RMF_OBD_ID =
864         DEFINE_MSGF("obd_id", 0,
865                     sizeof(obd_id), lustre_swab_ost_last_id);
866 EXPORT_SYMBOL(RMF_OBD_ID);
867
868 const struct req_msg_field RMF_FIEMAP_KEY =
869         DEFINE_MSGF("fiemap", 0, sizeof(struct ll_fiemap_info_key),
870                     lustre_swab_fiemap);
871 EXPORT_SYMBOL(RMF_FIEMAP_KEY);
872
873 const struct req_msg_field RMF_FIEMAP_VAL =
874         DEFINE_MSGF("fiemap", 0, -1, lustre_swab_fiemap);
875 EXPORT_SYMBOL(RMF_FIEMAP_VAL);
876
877 /*
878  * Request formats.
879  */
880
881 struct req_format {
882         const char *rf_name;
883         int         rf_idx;
884         struct {
885                 int                          nr;
886                 const struct req_msg_field **d;
887         } rf_fields[RCL_NR];
888 };
889
890 #define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) {    \
891         .rf_name   = name,                                              \
892         .rf_fields = {                                                  \
893                 [RCL_CLIENT] = {                                        \
894                         .nr = client_nr,                                \
895                         .d  = client                                    \
896                 },                                                      \
897                 [RCL_SERVER] = {                                        \
898                         .nr = server_nr,                                \
899                         .d  = server                                    \
900                 }                                                       \
901         }                                                               \
902 }
903
904 #define DEFINE_REQ_FMT0(name, client, server)                                  \
905 DEFINE_REQ_FMT(name, client, ARRAY_SIZE(client), server, ARRAY_SIZE(server))
906
907 const struct req_format RQF_OBD_PING =
908         DEFINE_REQ_FMT0("OBD_PING", empty, empty);
909 EXPORT_SYMBOL(RQF_OBD_PING);
910
911 const struct req_format RQF_SEC_CTX =
912         DEFINE_REQ_FMT0("SEC_CTX", empty, empty);
913 EXPORT_SYMBOL(RQF_SEC_CTX);
914
915 const struct req_format RQF_MGS_TARGET_REG =
916         DEFINE_REQ_FMT0("MGS_TARGET_REG", mgs_target_info_only,
917                          mgs_target_info_only);
918 EXPORT_SYMBOL(RQF_MGS_TARGET_REG);
919
920 const struct req_format RQF_MGS_SET_INFO =
921         DEFINE_REQ_FMT0("MGS_SET_INFO", mgs_set_info,
922                          mgs_set_info);
923 EXPORT_SYMBOL(RQF_MGS_SET_INFO);
924
925 const struct req_format RQF_SEQ_QUERY =
926         DEFINE_REQ_FMT0("SEQ_QUERY", seq_query_client, seq_query_server);
927 EXPORT_SYMBOL(RQF_SEQ_QUERY);
928
929 const struct req_format RQF_FLD_QUERY =
930         DEFINE_REQ_FMT0("FLD_QUERY", fld_query_client, fld_query_server);
931 EXPORT_SYMBOL(RQF_FLD_QUERY);
932
933 const struct req_format RQF_LOG_CANCEL =
934         DEFINE_REQ_FMT0("OBD_LOG_CANCEL", log_cancel_client, empty);
935 EXPORT_SYMBOL(RQF_LOG_CANCEL);
936
937 const struct req_format RQF_MDS_QUOTACHECK =
938         DEFINE_REQ_FMT0("MDS_QUOTACHECK", quotactl_only, empty);
939 EXPORT_SYMBOL(RQF_MDS_QUOTACHECK);
940
941 const struct req_format RQF_OST_QUOTACHECK =
942         DEFINE_REQ_FMT0("OST_QUOTACHECK", quotactl_only, empty);
943 EXPORT_SYMBOL(RQF_OST_QUOTACHECK);
944
945 const struct req_format RQF_MDS_QUOTACTL =
946         DEFINE_REQ_FMT0("MDS_QUOTACTL", quotactl_only, quotactl_only);
947 EXPORT_SYMBOL(RQF_MDS_QUOTACTL);
948
949 const struct req_format RQF_OST_QUOTACTL =
950         DEFINE_REQ_FMT0("OST_QUOTACTL", quotactl_only, quotactl_only);
951 EXPORT_SYMBOL(RQF_OST_QUOTACTL);
952
953 const struct req_format RQF_OST_QUOTA_ADJUST_QUNIT =
954         DEFINE_REQ_FMT0("OST_QUOTA_ADJUST_QUNIT", quota_adjust_qunit_only,
955                         quota_adjust_qunit_only);
956 EXPORT_SYMBOL(RQF_OST_QUOTA_ADJUST_QUNIT);
957
958 const struct req_format RQF_QC_CALLBACK =
959         DEFINE_REQ_FMT0("QC_CALLBACK", quotactl_only, empty);
960 EXPORT_SYMBOL(RQF_QC_CALLBACK);
961
962 const struct req_format RQF_MDS_QUOTA_DQACQ =
963         DEFINE_REQ_FMT0("MDS_QUOTA_DQACQ", qunit_data_only, qunit_data_only);
964 EXPORT_SYMBOL(RQF_MDS_QUOTA_DQACQ);
965
966 const struct req_format RQF_MDS_GETSTATUS =
967         DEFINE_REQ_FMT0("MDS_GETSTATUS", mdt_body_only, mdt_body_capa);
968 EXPORT_SYMBOL(RQF_MDS_GETSTATUS);
969
970 const struct req_format RQF_MDS_STATFS =
971         DEFINE_REQ_FMT0("MDS_STATFS", empty, obd_statfs_server);
972 EXPORT_SYMBOL(RQF_MDS_STATFS);
973
974 const struct req_format RQF_MDS_SYNC =
975         DEFINE_REQ_FMT0("MDS_SYNC", mdt_body_capa, mdt_body_only);
976 EXPORT_SYMBOL(RQF_MDS_SYNC);
977
978 const struct req_format RQF_MDS_GETATTR =
979         DEFINE_REQ_FMT0("MDS_GETATTR", mdt_body_capa, mds_getattr_server);
980 EXPORT_SYMBOL(RQF_MDS_GETATTR);
981
982 const struct req_format RQF_MDS_GETXATTR =
983         DEFINE_REQ_FMT0("MDS_GETXATTR",
984                         mds_getxattr_client, mds_getxattr_server);
985 EXPORT_SYMBOL(RQF_MDS_GETXATTR);
986
987 const struct req_format RQF_MDS_GETATTR_NAME =
988         DEFINE_REQ_FMT0("MDS_GETATTR_NAME",
989                         mds_getattr_name_client, mds_getattr_server);
990 EXPORT_SYMBOL(RQF_MDS_GETATTR_NAME);
991
992 const struct req_format RQF_MDS_REINT =
993         DEFINE_REQ_FMT0("MDS_REINT", mds_reint_client, mdt_body_only);
994 EXPORT_SYMBOL(RQF_MDS_REINT);
995
996 const struct req_format RQF_MDS_REINT_CREATE =
997         DEFINE_REQ_FMT0("MDS_REINT_CREATE",
998                         mds_reint_create_client, mdt_body_capa);
999 EXPORT_SYMBOL(RQF_MDS_REINT_CREATE);
1000
1001 const struct req_format RQF_MDS_REINT_CREATE_RMT_ACL =
1002         DEFINE_REQ_FMT0("MDS_REINT_CREATE_RMT_ACL",
1003                         mds_reint_create_rmt_acl_client, mdt_body_capa);
1004 EXPORT_SYMBOL(RQF_MDS_REINT_CREATE_RMT_ACL);
1005
1006 const struct req_format RQF_MDS_REINT_CREATE_SLAVE =
1007         DEFINE_REQ_FMT0("MDS_REINT_CREATE_EA",
1008                         mds_reint_create_slave_client, mdt_body_capa);
1009 EXPORT_SYMBOL(RQF_MDS_REINT_CREATE_SLAVE);
1010
1011 const struct req_format RQF_MDS_REINT_CREATE_SYM =
1012         DEFINE_REQ_FMT0("MDS_REINT_CREATE_SYM",
1013                         mds_reint_create_sym_client, mdt_body_capa);
1014 EXPORT_SYMBOL(RQF_MDS_REINT_CREATE_SYM);
1015
1016 const struct req_format RQF_MDS_REINT_OPEN =
1017         DEFINE_REQ_FMT0("MDS_REINT_OPEN",
1018                         mds_reint_open_client, mds_reint_open_server);
1019 EXPORT_SYMBOL(RQF_MDS_REINT_OPEN);
1020
1021 const struct req_format RQF_MDS_REINT_UNLINK =
1022         DEFINE_REQ_FMT0("MDS_REINT_UNLINK", mds_reint_unlink_client,
1023                         mds_last_unlink_server);
1024 EXPORT_SYMBOL(RQF_MDS_REINT_UNLINK);
1025
1026 const struct req_format RQF_MDS_REINT_LINK =
1027         DEFINE_REQ_FMT0("MDS_REINT_LINK",
1028                         mds_reint_link_client, mdt_body_only);
1029 EXPORT_SYMBOL(RQF_MDS_REINT_LINK);
1030
1031 const struct req_format RQF_MDS_REINT_RENAME =
1032         DEFINE_REQ_FMT0("MDS_REINT_RENAME", mds_reint_rename_client,
1033                         mds_last_unlink_server);
1034 EXPORT_SYMBOL(RQF_MDS_REINT_RENAME);
1035
1036 const struct req_format RQF_MDS_REINT_SETATTR =
1037         DEFINE_REQ_FMT0("MDS_REINT_SETATTR",
1038                         mds_reint_setattr_client, mds_setattr_server);
1039 EXPORT_SYMBOL(RQF_MDS_REINT_SETATTR);
1040
1041 const struct req_format RQF_MDS_REINT_SETXATTR =
1042         DEFINE_REQ_FMT0("MDS_REINT_SETXATTR",
1043                         mds_reint_setxattr_client, mdt_body_only);
1044 EXPORT_SYMBOL(RQF_MDS_REINT_SETXATTR);
1045
1046 const struct req_format RQF_MDS_CONNECT =
1047         DEFINE_REQ_FMT0("MDS_CONNECT",
1048                         obd_connect_client, obd_connect_server);
1049 EXPORT_SYMBOL(RQF_MDS_CONNECT);
1050
1051 const struct req_format RQF_MDS_DISCONNECT =
1052         DEFINE_REQ_FMT0("MDS_DISCONNECT", empty, empty);
1053 EXPORT_SYMBOL(RQF_MDS_DISCONNECT);
1054
1055 const struct req_format RQF_MDS_SET_INFO =
1056         DEFINE_REQ_FMT0("MDS_SET_INFO", mds_set_info_client, empty);
1057 EXPORT_SYMBOL(RQF_MDS_SET_INFO);
1058
1059 const struct req_format RQF_MDS_GET_INFO =
1060         DEFINE_REQ_FMT0("MDS_GET_INFO", mds_getinfo_client,
1061                         mds_getinfo_server);
1062 EXPORT_SYMBOL(RQF_MDS_GET_INFO);
1063
1064 const struct req_format RQF_LDLM_ENQUEUE =
1065         DEFINE_REQ_FMT0("LDLM_ENQUEUE",
1066                         ldlm_enqueue_client, ldlm_enqueue_lvb_server);
1067 EXPORT_SYMBOL(RQF_LDLM_ENQUEUE);
1068
1069 const struct req_format RQF_LDLM_ENQUEUE_LVB =
1070         DEFINE_REQ_FMT0("LDLM_ENQUEUE_LVB",
1071                         ldlm_enqueue_client, ldlm_enqueue_lvb_server);
1072 EXPORT_SYMBOL(RQF_LDLM_ENQUEUE_LVB);
1073
1074 const struct req_format RQF_LDLM_CONVERT =
1075         DEFINE_REQ_FMT0("LDLM_CONVERT",
1076                         ldlm_enqueue_client, ldlm_enqueue_server);
1077 EXPORT_SYMBOL(RQF_LDLM_CONVERT);
1078
1079 const struct req_format RQF_LDLM_CANCEL =
1080         DEFINE_REQ_FMT0("LDLM_CANCEL", ldlm_enqueue_client, empty);
1081 EXPORT_SYMBOL(RQF_LDLM_CANCEL);
1082
1083 const struct req_format RQF_LDLM_CALLBACK =
1084         DEFINE_REQ_FMT0("LDLM_CALLBACK", ldlm_enqueue_client, empty);
1085 EXPORT_SYMBOL(RQF_LDLM_CALLBACK);
1086
1087 const struct req_format RQF_LDLM_CP_CALLBACK =
1088         DEFINE_REQ_FMT0("LDLM_CP_CALLBACK", ldlm_cp_callback_client, empty);
1089 EXPORT_SYMBOL(RQF_LDLM_CP_CALLBACK);
1090
1091 const struct req_format RQF_LDLM_BL_CALLBACK =
1092         DEFINE_REQ_FMT0("LDLM_BL_CALLBACK", ldlm_enqueue_client, empty);
1093 EXPORT_SYMBOL(RQF_LDLM_BL_CALLBACK);
1094
1095 const struct req_format RQF_LDLM_GL_CALLBACK =
1096         DEFINE_REQ_FMT0("LDLM_GL_CALLBACK", ldlm_enqueue_client,
1097                         ldlm_gl_callback_server);
1098 EXPORT_SYMBOL(RQF_LDLM_GL_CALLBACK);
1099
1100 const struct req_format RQF_LDLM_INTENT =
1101         DEFINE_REQ_FMT0("LDLM_INTENT",
1102                         ldlm_intent_client, ldlm_intent_server);
1103 EXPORT_SYMBOL(RQF_LDLM_INTENT);
1104
1105 const struct req_format RQF_LDLM_INTENT_GETATTR =
1106         DEFINE_REQ_FMT0("LDLM_INTENT_GETATTR",
1107                         ldlm_intent_getattr_client, ldlm_intent_getattr_server);
1108 EXPORT_SYMBOL(RQF_LDLM_INTENT_GETATTR);
1109
1110 const struct req_format RQF_LDLM_INTENT_OPEN =
1111         DEFINE_REQ_FMT0("LDLM_INTENT_OPEN",
1112                         ldlm_intent_open_client, ldlm_intent_open_server);
1113 EXPORT_SYMBOL(RQF_LDLM_INTENT_OPEN);
1114
1115 const struct req_format RQF_LDLM_INTENT_CREATE =
1116         DEFINE_REQ_FMT0("LDLM_INTENT_CREATE",
1117                         ldlm_intent_create_client, ldlm_intent_getattr_server);
1118 EXPORT_SYMBOL(RQF_LDLM_INTENT_CREATE);
1119
1120 const struct req_format RQF_LDLM_INTENT_UNLINK =
1121         DEFINE_REQ_FMT0("LDLM_INTENT_UNLINK",
1122                         ldlm_intent_unlink_client, ldlm_intent_server);
1123 EXPORT_SYMBOL(RQF_LDLM_INTENT_UNLINK);
1124
1125 const struct req_format RQF_MDS_CLOSE =
1126         DEFINE_REQ_FMT0("MDS_CLOSE",
1127                         mdt_close_client, mds_last_unlink_server);
1128 EXPORT_SYMBOL(RQF_MDS_CLOSE);
1129
1130 const struct req_format RQF_MDS_PIN =
1131         DEFINE_REQ_FMT0("MDS_PIN",
1132                         mdt_body_capa, mdt_body_only);
1133 EXPORT_SYMBOL(RQF_MDS_PIN);
1134
1135 const struct req_format RQF_MDS_UNPIN =
1136         DEFINE_REQ_FMT0("MDS_UNPIN", mdt_body_only, empty);
1137 EXPORT_SYMBOL(RQF_MDS_UNPIN);
1138
1139 const struct req_format RQF_MDS_DONE_WRITING =
1140         DEFINE_REQ_FMT0("MDS_DONE_WRITING",
1141                         mdt_close_client, mdt_body_only);
1142 EXPORT_SYMBOL(RQF_MDS_DONE_WRITING);
1143
1144 const struct req_format RQF_MDS_READPAGE =
1145         DEFINE_REQ_FMT0("MDS_READPAGE",
1146                         mdt_body_capa, mdt_body_only);
1147 EXPORT_SYMBOL(RQF_MDS_READPAGE);
1148
1149 /* This is for split */
1150 const struct req_format RQF_MDS_WRITEPAGE =
1151         DEFINE_REQ_FMT0("MDS_WRITEPAGE",
1152                         mdt_body_capa, mdt_body_only);
1153 EXPORT_SYMBOL(RQF_MDS_WRITEPAGE);
1154
1155 const struct req_format RQF_MDS_IS_SUBDIR =
1156         DEFINE_REQ_FMT0("MDS_IS_SUBDIR",
1157                         mdt_body_only, mdt_body_only);
1158 EXPORT_SYMBOL(RQF_MDS_IS_SUBDIR);
1159
1160 const struct req_format RQF_LLOG_CATINFO =
1161         DEFINE_REQ_FMT0("LLOG_CATINFO",
1162                         llog_catinfo_client, llog_catinfo_server);
1163 EXPORT_SYMBOL(RQF_LLOG_CATINFO);
1164
1165 const struct req_format RQF_LLOG_ORIGIN_HANDLE_CREATE =
1166         DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_CREATE",
1167                         llog_origin_handle_create_client, llogd_body_only);
1168 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_CREATE);
1169
1170 const struct req_format RQF_LLOG_ORIGIN_HANDLE_DESTROY =
1171         DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_DESTROY",
1172                         llogd_body_only, llogd_body_only);
1173 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_DESTROY);
1174
1175 const struct req_format RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK =
1176         DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_NEXT_BLOCK",
1177                         llogd_body_only, llog_origin_handle_next_block_server);
1178 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK);
1179
1180 const struct req_format RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK =
1181         DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_PREV_BLOCK",
1182                         llogd_body_only, llog_origin_handle_next_block_server);
1183 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK);
1184
1185 const struct req_format RQF_LLOG_ORIGIN_HANDLE_READ_HEADER =
1186         DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_READ_HEADER",
1187                         llogd_body_only, llog_log_hdr_only);
1188 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_READ_HEADER);
1189
1190 const struct req_format RQF_LLOG_ORIGIN_CONNECT =
1191         DEFINE_REQ_FMT0("LLOG_ORIGIN_CONNECT", llogd_conn_body_only, empty);
1192 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_CONNECT);
1193
1194 const struct req_format RQF_OST_CONNECT =
1195         DEFINE_REQ_FMT0("OST_CONNECT",
1196                         obd_connect_client, obd_connect_server);
1197 EXPORT_SYMBOL(RQF_OST_CONNECT);
1198
1199 const struct req_format RQF_OST_DISCONNECT =
1200         DEFINE_REQ_FMT0("OST_DISCONNECT", empty, empty);
1201 EXPORT_SYMBOL(RQF_OST_DISCONNECT);
1202
1203 const struct req_format RQF_OST_GETATTR =
1204         DEFINE_REQ_FMT0("OST_GETATTR", ost_body_capa, ost_body_only);
1205 EXPORT_SYMBOL(RQF_OST_GETATTR);
1206
1207 const struct req_format RQF_OST_SETATTR =
1208         DEFINE_REQ_FMT0("OST_SETATTR", ost_body_capa, ost_body_only);
1209 EXPORT_SYMBOL(RQF_OST_SETATTR);
1210
1211 const struct req_format RQF_OST_CREATE =
1212         DEFINE_REQ_FMT0("OST_CREATE", ost_body_only, ost_body_only);
1213 EXPORT_SYMBOL(RQF_OST_CREATE);
1214
1215 const struct req_format RQF_OST_PUNCH =
1216         DEFINE_REQ_FMT0("OST_PUNCH", ost_body_capa, ost_body_only);
1217 EXPORT_SYMBOL(RQF_OST_PUNCH);
1218
1219 const struct req_format RQF_OST_SYNC =
1220         DEFINE_REQ_FMT0("OST_SYNC", ost_body_capa, ost_body_only);
1221 EXPORT_SYMBOL(RQF_OST_SYNC);
1222
1223 const struct req_format RQF_OST_DESTROY =
1224         DEFINE_REQ_FMT0("OST_DESTROY", ost_destroy_client, ost_body_only);
1225 EXPORT_SYMBOL(RQF_OST_DESTROY);
1226
1227 const struct req_format RQF_OST_BRW =
1228         DEFINE_REQ_FMT0("OST_BRW", ost_brw_client, ost_brw_server);
1229 EXPORT_SYMBOL(RQF_OST_BRW);
1230
1231 const struct req_format RQF_OST_STATFS =
1232         DEFINE_REQ_FMT0("OST_STATFS", empty, obd_statfs_server);
1233 EXPORT_SYMBOL(RQF_OST_STATFS);
1234
1235 const struct req_format RQF_OST_SET_INFO =
1236         DEFINE_REQ_FMT0("OST_SET_INFO", ost_set_info_client, empty);
1237 EXPORT_SYMBOL(RQF_OST_SET_INFO);
1238
1239 const struct req_format RQF_OST_SET_GRANT_INFO =
1240         DEFINE_REQ_FMT0("OST_SET_GRANT_INFO", ost_set_info_client,
1241                          ost_body_only);
1242 EXPORT_SYMBOL(RQF_OST_SET_GRANT_INFO);
1243
1244 const struct req_format RQF_OST_GET_INFO_GENERIC =
1245         DEFINE_REQ_FMT0("OST_GET_INFO", ost_get_info_generic_client,
1246                                         ost_get_info_generic_server);
1247 EXPORT_SYMBOL(RQF_OST_GET_INFO_GENERIC);
1248
1249 const struct req_format RQF_OST_GET_INFO_LAST_ID =
1250         DEFINE_REQ_FMT0("OST_GET_INFO_LAST_ID", ost_get_info_generic_client,
1251                                                 ost_get_last_id_server);
1252 EXPORT_SYMBOL(RQF_OST_GET_INFO_LAST_ID);
1253
1254 const struct req_format RQF_OST_GET_INFO_FIEMAP =
1255         DEFINE_REQ_FMT0("OST_GET_INFO_FIEMAP", ost_get_fiemap_client,
1256                                                ost_get_fiemap_server);
1257 EXPORT_SYMBOL(RQF_OST_GET_INFO_FIEMAP);
1258
1259
1260 #if !defined(__REQ_LAYOUT_USER__)
1261
1262 int req_layout_init(void)
1263 {
1264         int i;
1265         int j;
1266         int k;
1267
1268         for (i = 0; i < ARRAY_SIZE(req_formats); ++i) {
1269                 struct req_format *rf;
1270
1271                 rf = (struct req_format *)req_formats[i];
1272                 rf->rf_idx = i;
1273                 for (j = 0; j < RCL_NR; ++j) {
1274                         LASSERT(rf->rf_fields[j].nr <= REQ_MAX_FIELD_NR);
1275                         for (k = 0; k < rf->rf_fields[j].nr; ++k) {
1276                                 struct req_msg_field *field;
1277
1278                                 field = (typeof(field))rf->rf_fields[j].d[k];
1279                                 LASSERT(field->rmf_offset[i][j] == 0);
1280                                 /*
1281                                  * k + 1 to detect unused format/field
1282                                  * combinations.
1283                                  */
1284                                 field->rmf_offset[i][j] = k + 1;
1285                         }
1286                 }
1287         }
1288         return 0;
1289 }
1290 EXPORT_SYMBOL(req_layout_init);
1291
1292 void req_layout_fini(void)
1293 {
1294 }
1295 EXPORT_SYMBOL(req_layout_fini);
1296
1297 void req_capsule_init_area(struct req_capsule *pill)
1298 {
1299         int i;
1300
1301         for (i = 0; i < ARRAY_SIZE(pill->rc_area[RCL_CLIENT]); i++) {
1302                 pill->rc_area[RCL_CLIENT][i] = -1;
1303                 pill->rc_area[RCL_SERVER][i] = -1;
1304         }
1305 }
1306 EXPORT_SYMBOL(req_capsule_init_area);
1307
1308 /*
1309  * Initialize capsule.
1310  *
1311  * @area is an array of REQ_MAX_FIELD_NR elements, used to store sizes of
1312  * variable-sized fields.
1313  */
1314 void req_capsule_init(struct req_capsule *pill,
1315                       struct ptlrpc_request *req,
1316                       enum req_location location)
1317 {
1318         LASSERT(location == RCL_SERVER || location == RCL_CLIENT);
1319
1320         memset(pill, 0, sizeof *pill);
1321         pill->rc_req = req;
1322         pill->rc_loc = location;
1323         req_capsule_init_area(pill);
1324 }
1325 EXPORT_SYMBOL(req_capsule_init);
1326
1327 void req_capsule_fini(struct req_capsule *pill)
1328 {
1329 }
1330 EXPORT_SYMBOL(req_capsule_fini);
1331
1332 static int __req_format_is_sane(const struct req_format *fmt)
1333 {
1334         return
1335                 0 <= fmt->rf_idx && fmt->rf_idx < ARRAY_SIZE(req_formats) &&
1336                 req_formats[fmt->rf_idx] == fmt;
1337 }
1338
1339 static struct lustre_msg *__req_msg(const struct req_capsule *pill,
1340                                     enum req_location loc)
1341 {
1342         struct ptlrpc_request *req;
1343
1344         req = pill->rc_req;
1345         return loc == RCL_CLIENT ? req->rq_reqmsg : req->rq_repmsg;
1346 }
1347
1348 void req_capsule_set(struct req_capsule *pill, const struct req_format *fmt)
1349 {
1350         LASSERT(pill->rc_fmt == NULL);
1351         LASSERT(__req_format_is_sane(fmt));
1352
1353         pill->rc_fmt = fmt;
1354 }
1355 EXPORT_SYMBOL(req_capsule_set);
1356
1357 int req_capsule_filled_sizes(struct req_capsule *pill,
1358                            enum req_location loc)
1359 {
1360         const struct req_format *fmt = pill->rc_fmt;
1361         int                      i;
1362
1363         LASSERT(fmt != NULL);
1364
1365         for (i = 0; i < fmt->rf_fields[loc].nr; ++i) {
1366                 if (pill->rc_area[loc][i] == -1) {
1367                         pill->rc_area[loc][i] =
1368                                             fmt->rf_fields[loc].d[i]->rmf_size;
1369                         if (pill->rc_area[loc][i] == -1) {
1370                                 /* skip the following fields */
1371                                 LASSERT(loc != RCL_SERVER);
1372                                 break;
1373                         }
1374                 }
1375         }
1376         return i;
1377 }
1378 EXPORT_SYMBOL(req_capsule_filled_sizes);
1379
1380 int req_capsule_server_pack(struct req_capsule *pill)
1381 {
1382         const struct req_format *fmt;
1383         int                      count;
1384         int                      rc;
1385
1386         LASSERT(pill->rc_loc == RCL_SERVER);
1387         fmt = pill->rc_fmt;
1388         LASSERT(fmt != NULL);
1389
1390         count = req_capsule_filled_sizes(pill, RCL_SERVER);
1391         rc = lustre_pack_reply(pill->rc_req, count,
1392                                pill->rc_area[RCL_SERVER], NULL);
1393         if (rc != 0) {
1394                 DEBUG_REQ(D_ERROR, pill->rc_req,
1395                           "Cannot pack %d fields in format `%s': ",
1396                           count, fmt->rf_name);
1397         }
1398         return rc;
1399 }
1400 EXPORT_SYMBOL(req_capsule_server_pack);
1401
1402 static int __req_capsule_offset(const struct req_capsule *pill,
1403                                 const struct req_msg_field *field,
1404                                 enum req_location loc)
1405 {
1406         int offset;
1407
1408         offset = field->rmf_offset[pill->rc_fmt->rf_idx][loc];
1409         LASSERTF(offset > 0, "%s:%s, off=%d, loc=%d\n",
1410                             pill->rc_fmt->rf_name,
1411                             field->rmf_name, offset, loc);
1412         offset --;
1413         LASSERT(0 <= offset && offset < (sizeof(pill->rc_swabbed) << 3));
1414         return offset;
1415 }
1416
1417 static void *__req_capsule_get(struct req_capsule *pill,
1418                                const struct req_msg_field *field,
1419                                enum req_location loc,
1420                                void (*swabber)( void *))
1421 {
1422         const struct req_format *fmt;
1423         struct lustre_msg       *msg;
1424         void                    *value;
1425         int                      len;
1426         int                      offset;
1427
1428         void *(*getter)(struct lustre_msg *m, int n, int minlen);
1429
1430         static const char *rcl_names[RCL_NR] = {
1431                 [RCL_CLIENT] = "client",
1432                 [RCL_SERVER] = "server"
1433         };
1434
1435         LASSERT(pill != NULL);
1436         LASSERT(pill != LP_POISON);
1437         fmt = pill->rc_fmt;
1438         LASSERT(fmt != NULL);
1439         LASSERT(fmt != LP_POISON);
1440         LASSERT(__req_format_is_sane(fmt));
1441
1442         offset = __req_capsule_offset(pill, field, loc);
1443
1444         msg = __req_msg(pill, loc);
1445         LASSERT(msg != NULL);
1446
1447         getter = (field->rmf_flags & RMF_F_STRING) ?
1448                 (typeof(getter))lustre_msg_string : lustre_msg_buf;
1449
1450         if (pill->rc_area[loc][offset] != -1)
1451                 len = pill->rc_area[loc][offset];
1452         else
1453                 len = max(field->rmf_size, 0);
1454         value = getter(msg, offset, len);
1455
1456         swabber = swabber ?: field->rmf_swabber;
1457         if (!(pill->rc_swabbed & (1 << offset)) && loc != pill->rc_loc &&
1458             swabber != NULL && value != NULL &&
1459             lustre_msg_swabbed(msg)) {
1460                 swabber(value);
1461                 pill->rc_swabbed |= (1 << offset);
1462         }
1463         if (value == NULL) {
1464                 DEBUG_REQ(D_ERROR, pill->rc_req,
1465                           "Wrong buffer for field `%s' (%d of %d) "
1466                           "in format `%s': %d vs. %d (%s)\n",
1467                           field->rmf_name, offset, lustre_msg_bufcount(msg), fmt->rf_name,
1468                           lustre_msg_buflen(msg, offset), len,
1469                           rcl_names[loc]);
1470         }
1471
1472         return value;
1473 }
1474
1475 void *req_capsule_client_get(struct req_capsule *pill,
1476                              const struct req_msg_field *field)
1477 {
1478         return __req_capsule_get(pill, field, RCL_CLIENT, NULL);
1479 }
1480 EXPORT_SYMBOL(req_capsule_client_get);
1481
1482 void *req_capsule_client_swab_get(struct req_capsule *pill,
1483                                   const struct req_msg_field *field,
1484                                   void (*swabber)(void* ))
1485 {
1486         return __req_capsule_get(pill, field, RCL_CLIENT, swabber);
1487 }
1488 EXPORT_SYMBOL(req_capsule_client_swab_get);
1489
1490 void *req_capsule_client_sized_get(struct req_capsule *pill,
1491                                    const struct req_msg_field *field,
1492                                    int len)
1493 {
1494         req_capsule_set_size(pill, field, RCL_CLIENT, len);
1495         return __req_capsule_get(pill, field, RCL_CLIENT, NULL);
1496 }
1497 EXPORT_SYMBOL(req_capsule_client_sized_get);
1498
1499 void *req_capsule_server_get(struct req_capsule *pill,
1500                              const struct req_msg_field *field)
1501 {
1502         return __req_capsule_get(pill, field, RCL_SERVER, NULL);
1503 }
1504 EXPORT_SYMBOL(req_capsule_server_get);
1505
1506 void *req_capsule_server_swab_get(struct req_capsule *pill,
1507                                   const struct req_msg_field *field,
1508                                   void *swabber)
1509 {
1510         return __req_capsule_get(pill, field, RCL_SERVER, swabber);
1511 }
1512 EXPORT_SYMBOL(req_capsule_server_swab_get);
1513
1514
1515 void *req_capsule_server_sized_get(struct req_capsule *pill,
1516                                    const struct req_msg_field *field,
1517                                    int len)
1518 {
1519         req_capsule_set_size(pill, field, RCL_SERVER, len);
1520         return __req_capsule_get(pill, field, RCL_SERVER, NULL);
1521 }
1522 EXPORT_SYMBOL(req_capsule_server_sized_get);
1523
1524 const void *req_capsule_other_get(struct req_capsule *pill,
1525                                   const struct req_msg_field *field)
1526 {
1527         return __req_capsule_get(pill, field, pill->rc_loc ^ 1, NULL);
1528 }
1529 EXPORT_SYMBOL(req_capsule_other_get);
1530
1531 void req_capsule_set_size(struct req_capsule *pill,
1532                           const struct req_msg_field *field,
1533                           enum req_location loc, int size)
1534 {
1535         LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
1536
1537         if ((size != field->rmf_size) &&
1538             (field->rmf_size != -1) &&
1539             !(field->rmf_flags & RMF_F_NO_SIZE_CHECK) &&
1540             (size > 0)) {
1541                 CERROR("%s: field size mismatch %d != %d (%d)\n",
1542                        field->rmf_name, size, field->rmf_size, loc);
1543                 LBUG();
1544         }
1545
1546         pill->rc_area[loc][__req_capsule_offset(pill, field, loc)] = size;
1547 }
1548 EXPORT_SYMBOL(req_capsule_set_size);
1549
1550 /* NB: this function doesn't correspond with req_capsule_set_size(), which
1551  * actually sets the size in pill.rc_area[loc][offset], but this function
1552  * returns the message buflen[offset], maybe we should use another name.
1553  */
1554 int req_capsule_get_size(const struct req_capsule *pill,
1555                          const struct req_msg_field *field,
1556                          enum req_location loc)
1557 {
1558         LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
1559
1560         return lustre_msg_buflen(__req_msg(pill, loc),
1561                                  __req_capsule_offset(pill, field, loc));
1562 }
1563 EXPORT_SYMBOL(req_capsule_get_size);
1564
1565 int req_capsule_msg_size(struct req_capsule *pill, enum req_location loc)
1566 {
1567         return lustre_msg_size(pill->rc_req->rq_import->imp_msg_magic,
1568                                pill->rc_fmt->rf_fields[loc].nr,
1569                                pill->rc_area[loc]);
1570 }
1571
1572 int req_capsule_fmt_size(__u32 magic, const struct req_format *fmt,
1573                          enum req_location loc)
1574 {
1575         int size, i = 0;
1576
1577         size = lustre_msg_hdr_size(magic, fmt->rf_fields[loc].nr);
1578         if (size < 0)
1579                 return size;
1580
1581         for (; i < fmt->rf_fields[loc].nr; ++i)
1582                 if (fmt->rf_fields[loc].d[i]->rmf_size != -1)
1583                         size += size_round(fmt->rf_fields[loc].d[i]->rmf_size);
1584         return size;
1585 }
1586
1587 #define FMT_FIELD(fmt, i, j) (fmt)->rf_fields[(i)].d[(j)]
1588
1589 void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt)
1590 {
1591         int i;
1592         int j;
1593
1594         const struct req_format *old;
1595
1596         LASSERT(pill->rc_fmt != NULL);
1597         LASSERT(__req_format_is_sane(fmt));
1598
1599         old = pill->rc_fmt;
1600         /*
1601          * Sanity checking...
1602          */
1603         for (i = 0; i < RCL_NR; ++i) {
1604                 LASSERT(fmt->rf_fields[i].nr >= old->rf_fields[i].nr);
1605                 for (j = 0; j < old->rf_fields[i].nr - 1; ++j) {
1606                         LASSERT(FMT_FIELD(fmt, i, j) == FMT_FIELD(old, i, j));
1607                 }
1608                 /*
1609                  * Last field in old format can be shorter than in new.
1610                  */
1611                 LASSERT(FMT_FIELD(fmt, i, j)->rmf_size >=
1612                         FMT_FIELD(old, i, j)->rmf_size);
1613         }
1614         /* last field should be returned to the unswabbed state */
1615         pill->rc_swabbed &= ~(__u32)(1 << j);
1616         pill->rc_fmt = fmt;
1617 }
1618 EXPORT_SYMBOL(req_capsule_extend);
1619
1620 int req_capsule_has_field(const struct req_capsule *pill,
1621                           const struct req_msg_field *field,
1622                           enum req_location loc)
1623 {
1624         LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
1625
1626         return field->rmf_offset[pill->rc_fmt->rf_idx][loc];
1627 }
1628 EXPORT_SYMBOL(req_capsule_has_field);
1629
1630 int req_capsule_field_present(const struct req_capsule *pill,
1631                               const struct req_msg_field *field,
1632                               enum req_location loc)
1633 {
1634         int offset;
1635
1636         LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
1637         LASSERT(req_capsule_has_field(pill, field, loc));
1638
1639         offset = __req_capsule_offset(pill, field, loc);
1640         return lustre_msg_bufcount(__req_msg(pill, loc)) > offset;
1641 }
1642 EXPORT_SYMBOL(req_capsule_field_present);
1643
1644 void req_capsule_shrink(struct req_capsule *pill,
1645                         const struct req_msg_field *field,
1646                         unsigned int newlen,
1647                         enum req_location loc)
1648 {
1649         const struct req_format *fmt;
1650         struct lustre_msg       *msg;
1651         int                      len;
1652         int                      offset;
1653
1654         fmt = pill->rc_fmt;
1655         LASSERT(fmt != NULL);
1656         LASSERT(__req_format_is_sane(fmt));
1657         LASSERT(req_capsule_has_field(pill, field, loc));
1658         LASSERT(req_capsule_field_present(pill, field, loc));
1659
1660         offset = __req_capsule_offset(pill, field, loc);
1661
1662         msg = __req_msg(pill, loc);
1663         len = lustre_msg_buflen(msg, offset);
1664         LASSERTF(newlen <= len, "%s:%s, oldlen=%d, newlen=%d\n",
1665                                 fmt->rf_name, field->rmf_name, len, newlen);
1666
1667         if (loc == RCL_CLIENT)
1668                 pill->rc_req->rq_reqlen = lustre_shrink_msg(msg, offset, newlen,
1669                                                             1);
1670         else
1671                 pill->rc_req->rq_replen = lustre_shrink_msg(msg, offset, newlen,
1672                                                             1);
1673 }
1674 EXPORT_SYMBOL(req_capsule_shrink);
1675
1676 /* __REQ_LAYOUT_USER__ */
1677 #endif