1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/ptlrpc/layout.c
5 * Lustre Metadata Target (mdt) request handler
7 * Copyright (c) 2006 Cluster File Systems, Inc.
8 * Author: Nikita Danilov <nikita@clusterfs.com>
10 * This file is part of the Lustre file system, http://www.lustre.org
11 * Lustre is a trademark of Cluster File Systems, Inc.
13 * You may have signed or agreed to another license before downloading
14 * this software. If so, you are bound by the terms and conditions
15 * of that agreement, and the following does not apply to you. See the
16 * LICENSE file included with this distribution for more information.
18 * If you did not agree to a different license, then this copy of Lustre
19 * is open source software; you can redistribute it and/or modify it
20 * under the terms of version 2 of the GNU General Public License as
21 * published by the Free Software Foundation.
23 * In either case, Lustre is distributed in the hope that it will be
24 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * license text for more details.
29 #if !defined(__REQ_LAYOUT_USER__)
32 # define EXPORT_SYMTAB
34 #define DEBUG_SUBSYSTEM S_RPC
37 #include <linux/module.h>
39 # include <liblustre.h>
42 /* LUSTRE_VERSION_CODE */
43 #include <lustre_ver.h>
45 #include <obd_support.h>
46 /* lustre_swab_mdt_body */
47 #include <lustre/lustre_idl.h>
48 /* obd2cli_tgt() (required by DEBUG_REQ()) */
51 /* __REQ_LAYOUT_USER__ */
53 /* struct ptlrpc_request, lustre_msg* */
54 #include <lustre_req_layout.h>
55 #include <linux/lustre_acl.h>
58 * empty set of fields... for suitable definition of emptiness.
60 static const struct req_msg_field *empty[] = {
64 static const struct req_msg_field *mgs_target_info_only[] = {
69 static const struct req_msg_field *mgs_set_info[] = {
74 static const struct req_msg_field *log_cancel_client[] = {
79 static const struct req_msg_field *mdt_body_only[] = {
84 static const struct req_msg_field *mdt_body_capa[] = {
90 static const struct req_msg_field *quotactl_only[] = {
95 static const struct req_msg_field *qunit_data_only[] = {
100 static const struct req_msg_field *mdt_close_client[] = {
107 static const struct req_msg_field *obd_statfs_server[] = {
112 static const struct req_msg_field *seq_query_client[] = {
118 static const struct req_msg_field *seq_query_server[] = {
123 static const struct req_msg_field *fld_query_client[] = {
129 static const struct req_msg_field *fld_query_server[] = {
134 static const struct req_msg_field *mds_getattr_name_client[] = {
141 static const struct req_msg_field *mds_reint_client[] = {
146 static const struct req_msg_field *mds_reint_create_client[] = {
153 static const struct req_msg_field *mds_reint_create_slave_client[] = {
162 static const struct req_msg_field *mds_reint_create_rmt_acl_client[] = {
171 static const struct req_msg_field *mds_reint_create_sym_client[] = {
180 static const struct req_msg_field *mds_reint_open_client[] = {
189 static const struct req_msg_field *mds_reint_open_server[] = {
198 static const struct req_msg_field *mds_reint_unlink_client[] = {
206 static const struct req_msg_field *mds_reint_link_client[] = {
215 static const struct req_msg_field *mds_reint_rename_client[] = {
225 static const struct req_msg_field *mds_last_unlink_server[] = {
232 static const struct req_msg_field *mds_reint_setattr_client[] = {
242 static const struct req_msg_field *mds_reint_setxattr_client[] = {
250 static const struct req_msg_field *obd_connect_client[] = {
258 static const struct req_msg_field *obd_connect_server[] = {
263 static const struct req_msg_field *mds_set_info_client[] = {
269 static const struct req_msg_field *ldlm_enqueue_client[] = {
274 static const struct req_msg_field *ldlm_enqueue_server[] = {
279 static const struct req_msg_field *ldlm_enqueue_lvb_server[] = {
285 static const struct req_msg_field *ldlm_cp_callback_client[] = {
291 static const struct req_msg_field *ldlm_gl_callback_server[] = {
296 static const struct req_msg_field *ldlm_intent_client[] = {
303 static const struct req_msg_field *ldlm_intent_server[] = {
311 static const struct req_msg_field *ldlm_intent_open_server[] = {
321 static const struct req_msg_field *ldlm_intent_getattr_client[] = {
325 &RMF_MDT_BODY, /* coincides with mds_getattr_name_client[] */
330 static const struct req_msg_field *ldlm_intent_getattr_server[] = {
339 static const struct req_msg_field *ldlm_intent_create_client[] = {
343 &RMF_REC_REINT, /* coincides with mds_reint_create_client[] */
349 static const struct req_msg_field *ldlm_intent_open_client[] = {
353 &RMF_REC_REINT, /* coincides with mds_reint_open_client[] */
361 static const struct req_msg_field *ldlm_intent_unlink_client[] = {
365 &RMF_REC_REINT, /* coincides with mds_reint_unlink_client[] */
370 static const struct req_msg_field *mds_getxattr_client[] = {
378 static const struct req_msg_field *mds_getxattr_server[] = {
384 static const struct req_msg_field *mds_getattr_server[] = {
393 static const struct req_msg_field *mds_setattr_server[] = {
402 static const struct req_msg_field *llog_catinfo_client[] = {
408 static const struct req_msg_field *llog_catinfo_server[] = {
413 static const struct req_msg_field *llog_origin_handle_create_client[] = {
419 static const struct req_msg_field *llogd_body_only[] = {
424 static const struct req_msg_field *llog_log_hdr_only[] = {
429 static const struct req_msg_field *llogd_conn_body_only[] = {
434 static const struct req_msg_field *llog_origin_handle_next_block_server[] = {
440 static const struct req_msg_field *ost_body_only[] = {
445 static const struct req_msg_field *ost_body_capa[] = {
451 static const struct req_msg_field *ost_destroy_client[] = {
458 static const struct req_msg_field *ost_brw_client[] = {
466 static const struct req_msg_field *ost_brw_server[] = {
472 static const struct req_msg_field *ost_set_info_client[] = {
478 static const struct req_msg_field *ost_get_info_client[] = {
483 static const struct req_msg_field *ost_get_info_server[] = {
487 static const struct req_format *req_formats[] = {
500 &RQF_MDS_GETATTR_NAME,
509 &RQF_MDS_DONE_WRITING,
511 &RQF_MDS_REINT_CREATE,
512 &RQF_MDS_REINT_CREATE_RMT_ACL,
513 &RQF_MDS_REINT_CREATE_SLAVE,
514 &RQF_MDS_REINT_CREATE_SYM,
516 &RQF_MDS_REINT_UNLINK,
518 &RQF_MDS_REINT_RENAME,
519 &RQF_MDS_REINT_SETATTR,
520 &RQF_MDS_REINT_SETXATTR,
523 &RQF_MDS_QUOTA_DQACQ,
539 &RQF_LDLM_ENQUEUE_LVB,
543 &RQF_LDLM_CP_CALLBACK,
544 &RQF_LDLM_BL_CALLBACK,
545 &RQF_LDLM_GL_CALLBACK,
547 &RQF_LDLM_INTENT_GETATTR,
548 &RQF_LDLM_INTENT_OPEN,
549 &RQF_LDLM_INTENT_CREATE,
550 &RQF_LDLM_INTENT_UNLINK,
553 &RQF_LLOG_ORIGIN_HANDLE_CREATE,
554 &RQF_LLOG_ORIGIN_HANDLE_DESTROY,
555 &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK,
556 &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK,
557 &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER,
558 &RQF_LLOG_ORIGIN_CONNECT
561 struct req_msg_field {
563 const char *rmf_name;
565 * Field length. (-1) means "variable length".
568 void (*rmf_swabber)(void *);
569 int rmf_offset[ARRAY_SIZE(req_formats)][RCL_NR];
573 RMF_F_STRING = 1 << 0
581 #define DEFINE_MSGF(name, flags, size, swabber) { \
582 .rmf_name = (name), \
583 .rmf_flags = (flags), \
584 .rmf_size = (size), \
585 .rmf_swabber = (void (*)(void*))(swabber) \
588 const struct req_msg_field RMF_MGS_TARGET_INFO =
589 DEFINE_MSGF("mgs_target_info", 0,
590 sizeof(struct mgs_target_info),
591 lustre_swab_mgs_target_info);
592 EXPORT_SYMBOL(RMF_MGS_TARGET_INFO);
594 const struct req_msg_field RMF_MGS_SEND_PARAM =
595 DEFINE_MSGF("mgs_send_param", 0,
596 sizeof(struct mgs_send_param),
598 EXPORT_SYMBOL(RMF_MGS_SEND_PARAM);
600 const struct req_msg_field RMF_SETINFO_VAL =
601 DEFINE_MSGF("setinfo_val", 0,
602 sizeof(__u32), lustre_swab_generic_32s);
603 EXPORT_SYMBOL(RMF_SETINFO_VAL);
605 const struct req_msg_field RMF_SEQ_OPC =
606 DEFINE_MSGF("seq_query_opc", 0,
607 sizeof(__u32), lustre_swab_generic_32s);
608 EXPORT_SYMBOL(RMF_SEQ_OPC);
610 const struct req_msg_field RMF_SEQ_RANGE =
611 DEFINE_MSGF("seq_query_range", 0,
612 sizeof(struct lu_range), lustre_swab_lu_range);
613 EXPORT_SYMBOL(RMF_SEQ_RANGE);
615 const struct req_msg_field RMF_FLD_OPC =
616 DEFINE_MSGF("fld_query_opc", 0,
617 sizeof(__u32), lustre_swab_generic_32s);
618 EXPORT_SYMBOL(RMF_FLD_OPC);
620 const struct req_msg_field RMF_FLD_MDFLD =
621 DEFINE_MSGF("fld_query_mdfld", 0,
622 sizeof(struct md_fld), lustre_swab_md_fld);
623 EXPORT_SYMBOL(RMF_FLD_MDFLD);
625 const struct req_msg_field RMF_MDT_BODY =
626 DEFINE_MSGF("mdt_body", 0,
627 sizeof(struct mdt_body), lustre_swab_mdt_body);
628 EXPORT_SYMBOL(RMF_MDT_BODY);
630 const struct req_msg_field RMF_OBD_QUOTACTL =
631 DEFINE_MSGF("obd_quotactl", 0,
632 sizeof(struct obd_quotactl), lustre_swab_obd_quotactl);
633 EXPORT_SYMBOL(RMF_OBD_QUOTACTL);
635 const struct req_msg_field RMF_QUNIT_DATA =
636 DEFINE_MSGF("qunit_data", 0,
637 sizeof(struct qunit_data), NULL);
638 EXPORT_SYMBOL(RMF_QUNIT_DATA);
640 const struct req_msg_field RMF_MDT_EPOCH =
641 DEFINE_MSGF("mdt_epoch", 0,
642 sizeof(struct mdt_epoch), lustre_swab_mdt_epoch);
643 EXPORT_SYMBOL(RMF_MDT_EPOCH);
645 const struct req_msg_field RMF_PTLRPC_BODY =
646 DEFINE_MSGF("ptlrpc_body", 0,
647 sizeof(struct ptlrpc_body), lustre_swab_ptlrpc_body);
648 EXPORT_SYMBOL(RMF_PTLRPC_BODY);
650 const struct req_msg_field RMF_OBD_STATFS =
651 DEFINE_MSGF("obd_statfs", 0,
652 sizeof(struct obd_statfs), lustre_swab_obd_statfs);
653 EXPORT_SYMBOL(RMF_OBD_STATFS);
655 const struct req_msg_field RMF_SETINFO_KEY =
656 DEFINE_MSGF("setinfo_key", 0, -1, NULL);
657 EXPORT_SYMBOL(RMF_SETINFO_KEY);
659 const struct req_msg_field RMF_NAME =
660 DEFINE_MSGF("name", RMF_F_STRING, -1, NULL);
661 EXPORT_SYMBOL(RMF_NAME);
663 const struct req_msg_field RMF_SYMTGT =
664 DEFINE_MSGF("symtgt", RMF_F_STRING, -1, NULL);
665 EXPORT_SYMBOL(RMF_SYMTGT);
667 const struct req_msg_field RMF_TGTUUID =
668 DEFINE_MSGF("tgtuuid", RMF_F_STRING, sizeof(struct obd_uuid) - 1, NULL);
669 EXPORT_SYMBOL(RMF_TGTUUID);
671 const struct req_msg_field RMF_CLUUID =
672 DEFINE_MSGF("cluuid", RMF_F_STRING, sizeof(struct obd_uuid) - 1, NULL);
673 EXPORT_SYMBOL(RMF_CLUUID);
675 const struct req_msg_field RMF_STRING =
676 DEFINE_MSGF("string", RMF_F_STRING, -1, NULL);
677 EXPORT_SYMBOL(RMF_STRING);
679 const struct req_msg_field RMF_LLOGD_BODY =
680 DEFINE_MSGF("llogd_body", 0,
681 sizeof(struct llogd_body), lustre_swab_llogd_body);
682 EXPORT_SYMBOL(RMF_LLOGD_BODY);
684 const struct req_msg_field RMF_LLOG_LOG_HDR =
685 DEFINE_MSGF("llog_log_hdr", 0,
686 sizeof(struct llog_log_hdr), lustre_swab_llog_hdr);
687 EXPORT_SYMBOL(RMF_LLOG_LOG_HDR);
689 const struct req_msg_field RMF_LLOGD_CONN_BODY =
690 DEFINE_MSGF("llogd_conn_body", 0,
691 sizeof(struct llogd_conn_body),
692 lustre_swab_llogd_conn_body);
693 EXPORT_SYMBOL(RMF_LLOGD_CONN_BODY);
696 * connection handle received in MDS_CONNECT request.
700 const struct req_msg_field RMF_CONN =
701 DEFINE_MSGF("conn", 0, sizeof(struct lustre_handle), NULL);
702 EXPORT_SYMBOL(RMF_CONN);
704 const struct req_msg_field RMF_CONNECT_DATA =
705 DEFINE_MSGF("cdata", 0,
706 sizeof(struct obd_connect_data), lustre_swab_connect);
707 EXPORT_SYMBOL(RMF_CONNECT_DATA);
709 const struct req_msg_field RMF_DLM_REQ =
710 DEFINE_MSGF("dlm_req", 0,
711 sizeof(struct ldlm_request), lustre_swab_ldlm_request);
712 EXPORT_SYMBOL(RMF_DLM_REQ);
714 const struct req_msg_field RMF_DLM_REP =
715 DEFINE_MSGF("dlm_rep", 0,
716 sizeof(struct ldlm_reply), lustre_swab_ldlm_reply);
717 EXPORT_SYMBOL(RMF_DLM_REP);
719 const struct req_msg_field RMF_LDLM_INTENT =
720 DEFINE_MSGF("ldlm_intent", 0,
721 sizeof(struct ldlm_intent), lustre_swab_ldlm_intent);
722 EXPORT_SYMBOL(RMF_LDLM_INTENT);
724 const struct req_msg_field RMF_DLM_LVB =
725 DEFINE_MSGF("dlm_lvb", 0, sizeof(struct ost_lvb), NULL);
726 EXPORT_SYMBOL(RMF_DLM_LVB);
728 const struct req_msg_field RMF_MDT_MD =
729 DEFINE_MSGF("mdt_md", 0, MIN_MD_SIZE, NULL);
730 EXPORT_SYMBOL(RMF_MDT_MD);
732 const struct req_msg_field RMF_REC_REINT =
733 DEFINE_MSGF("rec_reint", 0, sizeof(struct mdt_rec_reint),
734 lustre_swab_mdt_rec_reint);
735 EXPORT_SYMBOL(RMF_REC_REINT);
737 const struct req_msg_field RMF_REC_JOINFILE =
738 DEFINE_MSGF("rec_joinfile", 0, sizeof(struct mdt_rec_join),
739 lustre_swab_mdt_rec_join);
740 EXPORT_SYMBOL(RMF_REC_JOINFILE);
742 /* FIXME: this length should be defined as a macro */
743 const struct req_msg_field RMF_EADATA = DEFINE_MSGF("eadata", 0, -1, NULL);
744 EXPORT_SYMBOL(RMF_EADATA);
746 const struct req_msg_field RMF_ACL =
747 DEFINE_MSGF("acl", 0, LUSTRE_POSIX_ACL_MAX_SIZE, NULL);
748 EXPORT_SYMBOL(RMF_ACL);
750 const struct req_msg_field RMF_LOGCOOKIES =
751 DEFINE_MSGF("logcookies", 0, sizeof(struct llog_cookie), NULL);
752 EXPORT_SYMBOL(RMF_LOGCOOKIES);
754 const struct req_msg_field RMF_CAPA1 =
755 DEFINE_MSGF("capa", 0, sizeof(struct lustre_capa),
756 lustre_swab_lustre_capa);
757 EXPORT_SYMBOL(RMF_CAPA1);
759 const struct req_msg_field RMF_CAPA2 =
760 DEFINE_MSGF("capa", 0, sizeof(struct lustre_capa),
761 lustre_swab_lustre_capa);
762 EXPORT_SYMBOL(RMF_CAPA2);
767 const struct req_msg_field RMF_OST_BODY =
768 DEFINE_MSGF("ost_body", 0,
769 sizeof(struct ost_body), lustre_swab_ost_body);
770 EXPORT_SYMBOL(RMF_OST_BODY);
772 const struct req_msg_field RMF_OBD_IOOBJ =
773 DEFINE_MSGF("obd_ioobj", 0,
774 sizeof(struct obd_ioobj), lustre_swab_obd_ioobj);
775 EXPORT_SYMBOL(RMF_OBD_IOOBJ);
777 const struct req_msg_field RMF_NIOBUF_REMOTE =
778 DEFINE_MSGF("niobuf_remote", 0, -1, lustre_swab_niobuf_remote);
779 EXPORT_SYMBOL(RMF_NIOBUF_REMOTE);
781 const struct req_msg_field RMF_OBD_ID =
782 DEFINE_MSGF("obd_id", 0,
783 sizeof(obd_id), lustre_swab_ost_last_id);
784 EXPORT_SYMBOL(RMF_OBD_ID);
796 const struct req_msg_field **d;
800 #define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) { \
814 #define DEFINE_REQ_FMT0(name, client, server) \
815 DEFINE_REQ_FMT(name, client, ARRAY_SIZE(client), server, ARRAY_SIZE(server))
817 const struct req_format RQF_OBD_PING =
818 DEFINE_REQ_FMT0("OBD_PING", empty, empty);
819 EXPORT_SYMBOL(RQF_OBD_PING);
821 const struct req_format RQF_SEC_CTX =
822 DEFINE_REQ_FMT0("SEC_CTX", empty, empty);
823 EXPORT_SYMBOL(RQF_SEC_CTX);
825 const struct req_format RQF_MGS_TARGET_REG =
826 DEFINE_REQ_FMT0("MGS_TARGET_REG", mgs_target_info_only,
827 mgs_target_info_only);
828 EXPORT_SYMBOL(RQF_MGS_TARGET_REG);
830 const struct req_format RQF_MGS_SET_INFO =
831 DEFINE_REQ_FMT0("MGS_SET_INTO", mgs_set_info,
833 EXPORT_SYMBOL(RQF_MGS_SET_INFO);
835 const struct req_format RQF_LOG_CANCEL =
836 DEFINE_REQ_FMT0("OBD_LOG_CANCEL", log_cancel_client, empty);
837 EXPORT_SYMBOL(RQF_LOG_CANCEL);
839 const struct req_format RQF_MDS_QUOTACHECK =
840 DEFINE_REQ_FMT0("MDS_QUOTACHECK", quotactl_only, empty);
841 EXPORT_SYMBOL(RQF_MDS_QUOTACHECK);
843 const struct req_format RQF_OST_QUOTACHECK =
844 DEFINE_REQ_FMT0("OST_QUOTACHECK", quotactl_only, empty);
845 EXPORT_SYMBOL(RQF_OST_QUOTACHECK);
847 const struct req_format RQF_MDS_QUOTACTL =
848 DEFINE_REQ_FMT0("MDS_QUOTACTL", quotactl_only, quotactl_only);
849 EXPORT_SYMBOL(RQF_MDS_QUOTACTL);
851 const struct req_format RQF_OST_QUOTACTL =
852 DEFINE_REQ_FMT0("OST_QUOTACTL", quotactl_only, quotactl_only);
853 EXPORT_SYMBOL(RQF_OST_QUOTACTL);
855 const struct req_format RQF_QC_CALLBACK =
856 DEFINE_REQ_FMT0("QC_CALLBACK", quotactl_only, empty);
857 EXPORT_SYMBOL(RQF_QC_CALLBACK);
859 const struct req_format RQF_MDS_QUOTA_DQACQ =
860 DEFINE_REQ_FMT0("MDS_QUOTA_DQACQ", qunit_data_only, qunit_data_only);
861 EXPORT_SYMBOL(RQF_MDS_QUOTA_DQACQ);
863 const struct req_format RQF_SEQ_QUERY =
864 DEFINE_REQ_FMT0("SEQ_QUERY", seq_query_client, seq_query_server);
865 EXPORT_SYMBOL(RQF_SEQ_QUERY);
867 const struct req_format RQF_FLD_QUERY =
868 DEFINE_REQ_FMT0("FLD_QUERY", fld_query_client, fld_query_server);
869 EXPORT_SYMBOL(RQF_FLD_QUERY);
871 const struct req_format RQF_MDS_GETSTATUS =
872 DEFINE_REQ_FMT0("MDS_GETSTATUS", mdt_body_only, mdt_body_capa);
873 EXPORT_SYMBOL(RQF_MDS_GETSTATUS);
875 const struct req_format RQF_MDS_STATFS =
876 DEFINE_REQ_FMT0("MDS_STATFS", empty, obd_statfs_server);
877 EXPORT_SYMBOL(RQF_MDS_STATFS);
879 const struct req_format RQF_MDS_SYNC =
880 DEFINE_REQ_FMT0("MDS_SYNC", mdt_body_capa, mdt_body_only);
881 EXPORT_SYMBOL(RQF_MDS_SYNC);
883 const struct req_format RQF_MDS_GETATTR =
884 DEFINE_REQ_FMT0("MDS_GETATTR", mdt_body_capa, mds_getattr_server);
885 EXPORT_SYMBOL(RQF_MDS_GETATTR);
887 const struct req_format RQF_MDS_GETXATTR =
888 DEFINE_REQ_FMT0("MDS_GETXATTR",
889 mds_getxattr_client, mds_getxattr_server);
890 EXPORT_SYMBOL(RQF_MDS_GETXATTR);
892 const struct req_format RQF_MDS_GETATTR_NAME =
893 DEFINE_REQ_FMT0("MDS_GETATTR_NAME",
894 mds_getattr_name_client, mds_getattr_server);
895 EXPORT_SYMBOL(RQF_MDS_GETATTR_NAME);
897 const struct req_format RQF_MDS_REINT =
898 DEFINE_REQ_FMT0("MDS_REINT", mds_reint_client, mdt_body_only);
899 EXPORT_SYMBOL(RQF_MDS_REINT);
901 const struct req_format RQF_MDS_REINT_CREATE =
902 DEFINE_REQ_FMT0("MDS_REINT_CREATE",
903 mds_reint_create_client, mdt_body_capa);
904 EXPORT_SYMBOL(RQF_MDS_REINT_CREATE);
906 const struct req_format RQF_MDS_REINT_CREATE_RMT_ACL =
907 DEFINE_REQ_FMT0("MDS_REINT_CREATE_RMT_ACL",
908 mds_reint_create_rmt_acl_client, mdt_body_capa);
909 EXPORT_SYMBOL(RQF_MDS_REINT_CREATE_RMT_ACL);
911 const struct req_format RQF_MDS_REINT_CREATE_SLAVE =
912 DEFINE_REQ_FMT0("MDS_REINT_CREATE_EA",
913 mds_reint_create_slave_client, mdt_body_capa);
914 EXPORT_SYMBOL(RQF_MDS_REINT_CREATE_SLAVE);
916 const struct req_format RQF_MDS_REINT_CREATE_SYM =
917 DEFINE_REQ_FMT0("MDS_REINT_CREATE_SYM",
918 mds_reint_create_sym_client, mdt_body_capa);
919 EXPORT_SYMBOL(RQF_MDS_REINT_CREATE_SYM);
921 const struct req_format RQF_MDS_REINT_OPEN =
922 DEFINE_REQ_FMT0("MDS_REINT_OPEN",
923 mds_reint_open_client, mds_reint_open_server);
924 EXPORT_SYMBOL(RQF_MDS_REINT_OPEN);
926 const struct req_format RQF_MDS_REINT_UNLINK =
927 DEFINE_REQ_FMT0("MDS_REINT_UNLINK", mds_reint_unlink_client,
928 mds_last_unlink_server);
929 EXPORT_SYMBOL(RQF_MDS_REINT_UNLINK);
931 const struct req_format RQF_MDS_REINT_LINK =
932 DEFINE_REQ_FMT0("MDS_REINT_LINK",
933 mds_reint_link_client, mdt_body_only);
934 EXPORT_SYMBOL(RQF_MDS_REINT_LINK);
936 const struct req_format RQF_MDS_REINT_RENAME =
937 DEFINE_REQ_FMT0("MDS_REINT_RENAME", mds_reint_rename_client,
938 mds_last_unlink_server);
939 EXPORT_SYMBOL(RQF_MDS_REINT_RENAME);
941 const struct req_format RQF_MDS_REINT_SETATTR =
942 DEFINE_REQ_FMT0("MDS_REINT_SETATTR",
943 mds_reint_setattr_client, mds_setattr_server);
944 EXPORT_SYMBOL(RQF_MDS_REINT_SETATTR);
946 const struct req_format RQF_MDS_REINT_SETXATTR =
947 DEFINE_REQ_FMT0("MDS_REINT_SETXATTR",
948 mds_reint_setxattr_client, mdt_body_only);
949 EXPORT_SYMBOL(RQF_MDS_REINT_SETXATTR);
951 const struct req_format RQF_MDS_CONNECT =
952 DEFINE_REQ_FMT0("MDS_CONNECT",
953 obd_connect_client, obd_connect_server);
954 EXPORT_SYMBOL(RQF_MDS_CONNECT);
956 const struct req_format RQF_MDS_DISCONNECT =
957 DEFINE_REQ_FMT0("MDS_DISCONNECT", empty, empty);
958 EXPORT_SYMBOL(RQF_MDS_DISCONNECT);
960 const struct req_format RQF_MDS_SET_INFO =
961 DEFINE_REQ_FMT0("MDS_SET_INFO", mds_set_info_client, empty);
962 EXPORT_SYMBOL(RQF_MDS_SET_INFO);
964 const struct req_format RQF_LDLM_ENQUEUE =
965 DEFINE_REQ_FMT0("LDLM_ENQUEUE",
966 ldlm_enqueue_client, ldlm_enqueue_lvb_server);
967 EXPORT_SYMBOL(RQF_LDLM_ENQUEUE);
969 const struct req_format RQF_LDLM_ENQUEUE_LVB =
970 DEFINE_REQ_FMT0("LDLM_ENQUEUE_LVB",
971 ldlm_enqueue_client, ldlm_enqueue_lvb_server);
972 EXPORT_SYMBOL(RQF_LDLM_ENQUEUE_LVB);
974 const struct req_format RQF_LDLM_CONVERT =
975 DEFINE_REQ_FMT0("LDLM_CONVERT",
976 ldlm_enqueue_client, ldlm_enqueue_server);
977 EXPORT_SYMBOL(RQF_LDLM_CONVERT);
979 const struct req_format RQF_LDLM_CANCEL =
980 DEFINE_REQ_FMT0("LDLM_CANCEL", ldlm_enqueue_client, empty);
981 EXPORT_SYMBOL(RQF_LDLM_CANCEL);
983 const struct req_format RQF_LDLM_CALLBACK =
984 DEFINE_REQ_FMT0("LDLM_CALLBACK", ldlm_enqueue_client, empty);
985 EXPORT_SYMBOL(RQF_LDLM_CALLBACK);
987 const struct req_format RQF_LDLM_CP_CALLBACK =
988 DEFINE_REQ_FMT0("LDLM_CP_CALLBACK", ldlm_cp_callback_client, empty);
989 EXPORT_SYMBOL(RQF_LDLM_CP_CALLBACK);
991 const struct req_format RQF_LDLM_BL_CALLBACK =
992 DEFINE_REQ_FMT0("LDLM_BL_CALLBACK", ldlm_enqueue_client, empty);
993 EXPORT_SYMBOL(RQF_LDLM_BL_CALLBACK);
995 const struct req_format RQF_LDLM_GL_CALLBACK =
996 DEFINE_REQ_FMT0("LDLM_GL_CALLBACK", ldlm_enqueue_client,
997 ldlm_gl_callback_server);
998 EXPORT_SYMBOL(RQF_LDLM_GL_CALLBACK);
1000 const struct req_format RQF_LDLM_INTENT =
1001 DEFINE_REQ_FMT0("LDLM_INTENT",
1002 ldlm_intent_client, ldlm_intent_server);
1003 EXPORT_SYMBOL(RQF_LDLM_INTENT);
1005 const struct req_format RQF_LDLM_INTENT_GETATTR =
1006 DEFINE_REQ_FMT0("LDLM_INTENT_GETATTR",
1007 ldlm_intent_getattr_client, ldlm_intent_getattr_server);
1008 EXPORT_SYMBOL(RQF_LDLM_INTENT_GETATTR);
1010 const struct req_format RQF_LDLM_INTENT_OPEN =
1011 DEFINE_REQ_FMT0("LDLM_INTENT_OPEN",
1012 ldlm_intent_open_client, ldlm_intent_open_server);
1013 EXPORT_SYMBOL(RQF_LDLM_INTENT_OPEN);
1015 const struct req_format RQF_LDLM_INTENT_CREATE =
1016 DEFINE_REQ_FMT0("LDLM_INTENT_CREATE",
1017 ldlm_intent_create_client, ldlm_intent_getattr_server);
1018 EXPORT_SYMBOL(RQF_LDLM_INTENT_CREATE);
1020 const struct req_format RQF_LDLM_INTENT_UNLINK =
1021 DEFINE_REQ_FMT0("LDLM_INTENT_UNLINK",
1022 ldlm_intent_unlink_client, ldlm_intent_server);
1023 EXPORT_SYMBOL(RQF_LDLM_INTENT_UNLINK);
1025 const struct req_format RQF_MDS_CLOSE =
1026 DEFINE_REQ_FMT0("MDS_CLOSE",
1027 mdt_close_client, mds_last_unlink_server);
1028 EXPORT_SYMBOL(RQF_MDS_CLOSE);
1030 const struct req_format RQF_MDS_PIN =
1031 DEFINE_REQ_FMT0("MDS_PIN",
1032 mdt_body_capa, mdt_body_only);
1033 EXPORT_SYMBOL(RQF_MDS_PIN);
1035 const struct req_format RQF_MDS_UNPIN =
1036 DEFINE_REQ_FMT0("MDS_UNPIN", mdt_body_only, empty);
1037 EXPORT_SYMBOL(RQF_MDS_UNPIN);
1039 const struct req_format RQF_MDS_DONE_WRITING =
1040 DEFINE_REQ_FMT0("MDS_DONE_WRITING",
1041 mdt_close_client, mdt_body_only);
1042 EXPORT_SYMBOL(RQF_MDS_DONE_WRITING);
1044 const struct req_format RQF_MDS_READPAGE =
1045 DEFINE_REQ_FMT0("MDS_READPAGE",
1046 mdt_body_capa, mdt_body_only);
1047 EXPORT_SYMBOL(RQF_MDS_READPAGE);
1049 /* This is for split */
1050 const struct req_format RQF_MDS_WRITEPAGE =
1051 DEFINE_REQ_FMT0("MDS_WRITEPAGE",
1052 mdt_body_capa, mdt_body_only);
1053 EXPORT_SYMBOL(RQF_MDS_WRITEPAGE);
1055 const struct req_format RQF_MDS_IS_SUBDIR =
1056 DEFINE_REQ_FMT0("MDS_IS_SUBDIR",
1057 mdt_body_only, mdt_body_only);
1058 EXPORT_SYMBOL(RQF_MDS_IS_SUBDIR);
1060 const struct req_format RQF_LLOG_CATINFO =
1061 DEFINE_REQ_FMT0("LLOG_CATINFO",
1062 llog_catinfo_client, llog_catinfo_server);
1063 EXPORT_SYMBOL(RQF_LLOG_CATINFO);
1065 const struct req_format RQF_LLOG_ORIGIN_HANDLE_CREATE =
1066 DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_CREATE",
1067 llog_origin_handle_create_client, llogd_body_only);
1068 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_CREATE);
1070 const struct req_format RQF_LLOG_ORIGIN_HANDLE_DESTROY =
1071 DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_DESTROY",
1072 llogd_body_only, llogd_body_only);
1073 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_DESTROY);
1075 const struct req_format RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK =
1076 DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_NEXT_BLOCK",
1077 llogd_body_only, llog_origin_handle_next_block_server);
1078 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK);
1080 const struct req_format RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK =
1081 DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_PREV_BLOCK",
1082 llogd_body_only, llog_origin_handle_next_block_server);
1083 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK);
1085 const struct req_format RQF_LLOG_ORIGIN_HANDLE_READ_HEADER =
1086 DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_READ_HEADER",
1087 llogd_body_only, llog_log_hdr_only);
1088 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_HANDLE_READ_HEADER);
1090 const struct req_format RQF_LLOG_ORIGIN_CONNECT =
1091 DEFINE_REQ_FMT0("LLOG_ORIGIN_CONNECT", llogd_conn_body_only, empty);
1092 EXPORT_SYMBOL(RQF_LLOG_ORIGIN_CONNECT);
1094 const struct req_format RQF_OST_CONNECT =
1095 DEFINE_REQ_FMT0("OST_CONNECT",
1096 obd_connect_client, obd_connect_server);
1097 EXPORT_SYMBOL(RQF_OST_CONNECT);
1099 const struct req_format RQF_OST_DISCONNECT =
1100 DEFINE_REQ_FMT0("OST_DISCONNECT", empty, empty);
1101 EXPORT_SYMBOL(RQF_OST_DISCONNECT);
1103 const struct req_format RQF_OST_GETATTR =
1104 DEFINE_REQ_FMT0("OST_GETATTR", ost_body_capa, ost_body_only);
1105 EXPORT_SYMBOL(RQF_OST_GETATTR);
1107 const struct req_format RQF_OST_SETATTR =
1108 DEFINE_REQ_FMT0("OST_SETATTR", ost_body_capa, ost_body_only);
1109 EXPORT_SYMBOL(RQF_OST_SETATTR);
1111 const struct req_format RQF_OST_CREATE =
1112 DEFINE_REQ_FMT0("OST_CREATE", ost_body_only, ost_body_only);
1113 EXPORT_SYMBOL(RQF_OST_CREATE);
1115 const struct req_format RQF_OST_PUNCH =
1116 DEFINE_REQ_FMT0("OST_PUNCH", ost_body_capa, ost_body_only);
1117 EXPORT_SYMBOL(RQF_OST_PUNCH);
1119 const struct req_format RQF_OST_SYNC =
1120 DEFINE_REQ_FMT0("OST_SYNC", ost_body_capa, ost_body_only);
1121 EXPORT_SYMBOL(RQF_OST_SYNC);
1123 const struct req_format RQF_OST_DESTROY =
1124 DEFINE_REQ_FMT0("OST_DESTROY", ost_destroy_client, ost_body_only);
1125 EXPORT_SYMBOL(RQF_OST_DESTROY);
1127 const struct req_format RQF_OST_BRW =
1128 DEFINE_REQ_FMT0("OST_BRW", ost_brw_client, ost_brw_server);
1129 EXPORT_SYMBOL(RQF_OST_BRW);
1131 const struct req_format RQF_OST_STATFS =
1132 DEFINE_REQ_FMT0("OST_STATFS", empty, obd_statfs_server);
1133 EXPORT_SYMBOL(RQF_OST_STATFS);
1135 const struct req_format RQF_OST_SET_INFO =
1136 DEFINE_REQ_FMT0("OST_SET_INFO", ost_set_info_client, empty);
1137 EXPORT_SYMBOL(RQF_OST_SET_INFO);
1139 const struct req_format RQF_OST_GET_INFO =
1140 DEFINE_REQ_FMT0("OST_GET_INFO", ost_get_info_client,
1141 ost_get_info_server);
1142 EXPORT_SYMBOL(RQF_OST_GET_INFO);
1145 #if !defined(__REQ_LAYOUT_USER__)
1147 int req_layout_init(void)
1153 for (i = 0; i < ARRAY_SIZE(req_formats); ++i) {
1154 struct req_format *rf;
1156 rf = (struct req_format *)req_formats[i];
1158 for (j = 0; j < RCL_NR; ++j) {
1159 LASSERT(rf->rf_fields[j].nr <= REQ_MAX_FIELD_NR);
1160 for (k = 0; k < rf->rf_fields[j].nr; ++k) {
1161 struct req_msg_field *field;
1163 field = (typeof(field))rf->rf_fields[j].d[k];
1164 LASSERT(field->rmf_offset[i][j] == 0);
1166 * k + 1 to detect unused format/field
1169 field->rmf_offset[i][j] = k + 1;
1175 EXPORT_SYMBOL(req_layout_init);
1177 void req_layout_fini(void)
1180 EXPORT_SYMBOL(req_layout_fini);
1182 void req_capsule_init_area(struct req_capsule *pill)
1186 for (i = 0; i < ARRAY_SIZE(pill->rc_area[RCL_CLIENT]); i++) {
1187 pill->rc_area[RCL_CLIENT][i] = -1;
1188 pill->rc_area[RCL_SERVER][i] = -1;
1191 EXPORT_SYMBOL(req_capsule_init_area);
1194 * Initialize capsule.
1196 * @area is an array of REQ_MAX_FIELD_NR elements, used to store sizes of
1197 * variable-sized fields.
1199 void req_capsule_init(struct req_capsule *pill,
1200 struct ptlrpc_request *req,
1201 enum req_location location)
1203 LASSERT(location == RCL_SERVER || location == RCL_CLIENT);
1205 memset(pill, 0, sizeof *pill);
1207 pill->rc_loc = location;
1208 req_capsule_init_area(pill);
1210 EXPORT_SYMBOL(req_capsule_init);
1212 void req_capsule_fini(struct req_capsule *pill)
1215 EXPORT_SYMBOL(req_capsule_fini);
1217 static int __req_format_is_sane(const struct req_format *fmt)
1220 0 <= fmt->rf_idx && fmt->rf_idx < ARRAY_SIZE(req_formats) &&
1221 req_formats[fmt->rf_idx] == fmt;
1224 static struct lustre_msg *__req_msg(const struct req_capsule *pill,
1225 enum req_location loc)
1227 struct ptlrpc_request *req;
1230 return loc == RCL_CLIENT ? req->rq_reqmsg : req->rq_repmsg;
1233 void req_capsule_set(struct req_capsule *pill, const struct req_format *fmt)
1235 LASSERT(pill->rc_fmt == NULL);
1236 LASSERT(__req_format_is_sane(fmt));
1240 EXPORT_SYMBOL(req_capsule_set);
1242 int req_capsule_filled_sizes(struct req_capsule *pill,
1243 enum req_location loc)
1245 const struct req_format *fmt = pill->rc_fmt;
1248 LASSERT(fmt != NULL);
1250 for (i = 0; i < fmt->rf_fields[loc].nr; ++i) {
1251 if (pill->rc_area[loc][i] == -1) {
1252 pill->rc_area[loc][i] =
1253 fmt->rf_fields[loc].d[i]->rmf_size;
1254 if (pill->rc_area[loc][i] == -1) {
1255 /* skip the following fields */
1256 LASSERT(loc != RCL_SERVER);
1263 EXPORT_SYMBOL(req_capsule_filled_sizes);
1265 int req_capsule_server_pack(struct req_capsule *pill)
1267 const struct req_format *fmt;
1271 LASSERT(pill->rc_loc == RCL_SERVER);
1273 LASSERT(fmt != NULL);
1275 count = req_capsule_filled_sizes(pill, RCL_SERVER);
1276 rc = lustre_pack_reply(pill->rc_req, count,
1277 pill->rc_area[RCL_SERVER], NULL);
1279 DEBUG_REQ(D_ERROR, pill->rc_req,
1280 "Cannot pack %d fields in format `%s': ",
1281 count, fmt->rf_name);
1285 EXPORT_SYMBOL(req_capsule_server_pack);
1287 static int __req_capsule_offset(const struct req_capsule *pill,
1288 const struct req_msg_field *field,
1289 enum req_location loc)
1293 offset = field->rmf_offset[pill->rc_fmt->rf_idx][loc];
1294 LASSERTF(offset > 0, "%s:%s, off=%d, loc=%d\n",
1295 pill->rc_fmt->rf_name,
1296 field->rmf_name, offset, loc);
1298 LASSERT(0 <= offset && offset < (sizeof(pill->rc_swabbed) << 3));
1302 static void *__req_capsule_get(struct req_capsule *pill,
1303 const struct req_msg_field *field,
1304 enum req_location loc,
1305 void (*swabber)( void *))
1307 const struct req_format *fmt;
1308 struct lustre_msg *msg;
1313 void *(*getter)(struct lustre_msg *m, int n, int minlen);
1315 static const char *rcl_names[RCL_NR] = {
1316 [RCL_CLIENT] = "client",
1317 [RCL_SERVER] = "server"
1321 LASSERT(fmt != NULL);
1322 LASSERT(__req_format_is_sane(fmt));
1324 offset = __req_capsule_offset(pill, field, loc);
1326 msg = __req_msg(pill, loc);
1327 LASSERT(msg != NULL);
1329 getter = (field->rmf_flags & RMF_F_STRING) ?
1330 (typeof(getter))lustre_msg_string : lustre_msg_buf;
1332 if (pill->rc_area[loc][offset] != -1)
1333 len = pill->rc_area[loc][offset];
1335 len = max(field->rmf_size, 0);
1336 value = getter(msg, offset, len);
1338 swabber = swabber ?: field->rmf_swabber;
1339 if (!(pill->rc_swabbed & (1 << offset)) && loc != pill->rc_loc &&
1340 swabber != NULL && value != NULL &&
1341 lustre_msg_swabbed(msg)) {
1343 pill->rc_swabbed |= (1 << offset);
1345 if (value == NULL) {
1346 DEBUG_REQ(D_ERROR, pill->rc_req,
1347 "Wrong buffer for field `%s' (%d of %d) "
1348 "in format `%s': %d vs. %d (%s)\n",
1349 field->rmf_name, offset, lustre_msg_bufcount(msg), fmt->rf_name,
1350 lustre_msg_buflen(msg, offset), len,
1357 void *req_capsule_client_get(struct req_capsule *pill,
1358 const struct req_msg_field *field)
1360 return __req_capsule_get(pill, field, RCL_CLIENT, NULL);
1362 EXPORT_SYMBOL(req_capsule_client_get);
1364 void *req_capsule_client_swab_get(struct req_capsule *pill,
1365 const struct req_msg_field *field,
1366 void (*swabber)(void* ))
1368 return __req_capsule_get(pill, field, RCL_CLIENT, swabber);
1370 EXPORT_SYMBOL(req_capsule_client_swab_get);
1372 void *req_capsule_client_sized_get(struct req_capsule *pill,
1373 const struct req_msg_field *field,
1376 req_capsule_set_size(pill, field, RCL_CLIENT, len);
1377 return __req_capsule_get(pill, field, RCL_CLIENT, NULL);
1379 EXPORT_SYMBOL(req_capsule_client_sized_get);
1381 void *req_capsule_server_get(struct req_capsule *pill,
1382 const struct req_msg_field *field)
1384 return __req_capsule_get(pill, field, RCL_SERVER, NULL);
1386 EXPORT_SYMBOL(req_capsule_server_get);
1388 void *req_capsule_server_swab_get(struct req_capsule *pill,
1389 const struct req_msg_field *field,
1392 return __req_capsule_get(pill, field, RCL_SERVER, swabber);
1394 EXPORT_SYMBOL(req_capsule_server_swab_get);
1397 void *req_capsule_server_sized_get(struct req_capsule *pill,
1398 const struct req_msg_field *field,
1401 req_capsule_set_size(pill, field, RCL_SERVER, len);
1402 return __req_capsule_get(pill, field, RCL_SERVER, NULL);
1404 EXPORT_SYMBOL(req_capsule_server_sized_get);
1406 const void *req_capsule_other_get(struct req_capsule *pill,
1407 const struct req_msg_field *field)
1409 return __req_capsule_get(pill, field, pill->rc_loc ^ 1, NULL);
1411 EXPORT_SYMBOL(req_capsule_other_get);
1413 void req_capsule_set_size(struct req_capsule *pill,
1414 const struct req_msg_field *field,
1415 enum req_location loc, int size)
1417 LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
1419 pill->rc_area[loc][__req_capsule_offset(pill, field, loc)] = size;
1421 EXPORT_SYMBOL(req_capsule_set_size);
1423 /* NB: this function doesn't correspond with req_capsule_set_size(), which
1424 * actually sets the size in pill.rc_area[loc][offset], but this function
1425 * returns the message buflen[offset], maybe we should use another name.
1427 int req_capsule_get_size(const struct req_capsule *pill,
1428 const struct req_msg_field *field,
1429 enum req_location loc)
1431 LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
1433 return lustre_msg_buflen(__req_msg(pill, loc),
1434 __req_capsule_offset(pill, field, loc));
1436 EXPORT_SYMBOL(req_capsule_get_size);
1438 int req_capsule_msg_size(const struct req_capsule *pill, enum req_location loc)
1440 return lustre_msg_size(pill->rc_req->rq_import->imp_msg_magic,
1441 pill->rc_fmt->rf_fields[loc].nr,
1442 (int *)pill->rc_area[loc]);
1445 int req_capsule_fmt_size(__u32 magic, const struct req_format *fmt,
1446 enum req_location loc)
1450 size = lustre_msg_hdr_size(magic, fmt->rf_fields[loc].nr);
1454 if (magic == LUSTRE_MSG_MAGIC_V1)
1457 for (; i < fmt->rf_fields[loc].nr; ++i)
1458 if (fmt->rf_fields[loc].d[i]->rmf_size != -1)
1459 size += size_round(fmt->rf_fields[loc].d[i]->rmf_size);
1463 #define FMT_FIELD(fmt, i, j) (fmt)->rf_fields[(i)].d[(j)]
1465 void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt)
1470 const struct req_format *old;
1472 LASSERT(pill->rc_fmt != NULL);
1473 LASSERT(__req_format_is_sane(fmt));
1477 * Sanity checking...
1479 for (i = 0; i < RCL_NR; ++i) {
1480 LASSERT(fmt->rf_fields[i].nr >= old->rf_fields[i].nr);
1481 for (j = 0; j < old->rf_fields[i].nr - 1; ++j) {
1482 LASSERT(FMT_FIELD(fmt, i, j) == FMT_FIELD(old, i, j));
1485 * Last field in old format can be shorter than in new.
1487 LASSERT(FMT_FIELD(fmt, i, j)->rmf_size >=
1488 FMT_FIELD(old, i, j)->rmf_size);
1490 /* last field should be returned to the unswabbed state */
1491 pill->rc_swabbed &= ~(__u32)(1 << j);
1494 EXPORT_SYMBOL(req_capsule_extend);
1496 int req_capsule_has_field(const struct req_capsule *pill,
1497 const struct req_msg_field *field,
1498 enum req_location loc)
1500 LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
1502 return field->rmf_offset[pill->rc_fmt->rf_idx][loc];
1504 EXPORT_SYMBOL(req_capsule_has_field);
1506 int req_capsule_field_present(const struct req_capsule *pill,
1507 const struct req_msg_field *field,
1508 enum req_location loc)
1512 LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
1513 LASSERT(req_capsule_has_field(pill, field, loc));
1515 offset = __req_capsule_offset(pill, field, loc);
1516 return lustre_msg_bufcount(__req_msg(pill, loc)) > offset;
1518 EXPORT_SYMBOL(req_capsule_field_present);
1520 void req_capsule_shrink(struct req_capsule *pill,
1521 const struct req_msg_field *field,
1522 unsigned int newlen,
1523 enum req_location loc)
1525 const struct req_format *fmt;
1526 struct lustre_msg *msg;
1531 LASSERT(fmt != NULL);
1532 LASSERT(__req_format_is_sane(fmt));
1533 LASSERT(req_capsule_has_field(pill, field, loc));
1534 LASSERT(req_capsule_field_present(pill, field, loc));
1536 offset = __req_capsule_offset(pill, field, loc);
1538 msg = __req_msg(pill, loc);
1539 len = lustre_msg_buflen(msg, offset);
1540 LASSERTF(newlen <= len, "%s:%s, oldlen=%d, newlen=%d\n",
1541 fmt->rf_name, field->rmf_name, len, newlen);
1543 if (loc == RCL_CLIENT)
1544 pill->rc_req->rq_reqlen = lustre_shrink_msg(msg, offset, newlen,
1547 pill->rc_req->rq_replen = lustre_shrink_msg(msg, offset, newlen,
1550 EXPORT_SYMBOL(req_capsule_shrink);
1552 /* __REQ_LAYOUT_USER__ */