Whamcloud - gitweb
LU-14291 ptlrpc: format UPDATE messages in server-only code 25/41125/7
authorMr NeilBrown <neilb@suse.de>
Fri, 30 Oct 2020 04:01:00 +0000 (15:01 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 6 Apr 2021 03:02:23 +0000 (03:02 +0000)
There are some ptlrpc messages that are only used for targets to
communicate with each other: Object Updates between Targets (OUT).

These are never needed by the client, so the code for handling them
can be conditionally compiled with HAVE_SERVER_SUPPORT.

The code in layout.c needs struct declaration that are in the file, so
group them at the end of the file and add #ifdef.
The code in pack_generic.c can stand alone, so move it to a new
pack_server.c and compile that only when server code is requested.

For simplicity, also make req_check_sepol() completely server-side
and provide an inline stub for client-only code.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I788352575a2109df389760fff45207ad6de3391b
Reviewed-on: https://review.whamcloud.com/41125
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_req_layout.h
lustre/ptlrpc/Makefile.in
lustre/ptlrpc/layout.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/pack_server.c [new file with mode: 0644]

index 31d9719..a023c6b 100644 (file)
@@ -128,7 +128,14 @@ int req_capsule_server_grow(struct req_capsule *pill,
                            __u32 newlen);
 int  req_layout_init(void);
 void req_layout_fini(void);
                            __u32 newlen);
 int  req_layout_init(void);
 void req_layout_fini(void);
+#ifdef HAVE_SERVER_SUPPORT
 int req_check_sepol(struct req_capsule *pill);
 int req_check_sepol(struct req_capsule *pill);
+#else
+static inline int req_check_sepol(struct req_capsule *pill)
+{
+       return 0;
+}
+#endif
 
 extern struct req_format RQF_OBD_PING;
 extern struct req_format RQF_OBD_SET_INFO;
 
 extern struct req_format RQF_OBD_PING;
 extern struct req_format RQF_OBD_SET_INFO;
index 27cff00..2688d8c 100644 (file)
@@ -30,7 +30,7 @@ nodemap_objs += nodemap_idmap.o nodemap_rbtree.o nodemap_member.o
 nodemap_objs += nodemap_storage.o
 
 ptlrpc-objs := $(ldlm_objs) $(ptlrpc_objs) $(TARGET)barrier.o
 nodemap_objs += nodemap_storage.o
 
 ptlrpc-objs := $(ldlm_objs) $(ptlrpc_objs) $(TARGET)barrier.o
-@SERVER_TRUE@ptlrpc-objs += $(target_objs) $(nodemap_objs) $(nrs_server_objs)
+@SERVER_TRUE@ptlrpc-objs += $(target_objs) $(nodemap_objs) $(nrs_server_objs) pack_server.o
 
 @GSS_TRUE@obj-m += gss/
 
 
 @GSS_TRUE@obj-m += gss/
 
@@ -54,6 +54,7 @@ barrier.c: @LUSTRE@/target/barrier.c
 EXTRA_DIST := $(ptlrpc_objs:.o=.c) ptlrpc_internal.h
 EXTRA_DIST += $(nodemap_objs:.o=.c) nodemap_internal.h heap.h
 EXTRA_DIST += $(nrs_server_objs:.o=.c)
 EXTRA_DIST := $(ptlrpc_objs:.o=.c) ptlrpc_internal.h
 EXTRA_DIST += $(nodemap_objs:.o=.c) nodemap_internal.h heap.h
 EXTRA_DIST += $(nrs_server_objs:.o=.c)
+EXTRA_DIST += pack_server.c
 
 EXTRA_PRE_CFLAGS := -I@LUSTRE@/ldlm -I@LUSTRE@/target
 
 
 EXTRA_PRE_CFLAGS := -I@LUSTRE@/ldlm -I@LUSTRE@/target
 
index a2ac442..d7a9c28 100644 (file)
@@ -583,17 +583,6 @@ static const struct req_msg_field *mds_setattr_server[] = {
         &RMF_CAPA2
 };
 
         &RMF_CAPA2
 };
 
-static const struct req_msg_field *mds_update_client[] = {
-       &RMF_PTLRPC_BODY,
-       &RMF_OUT_UPDATE_HEADER,
-       &RMF_OUT_UPDATE_BUF,
-};
-
-static const struct req_msg_field *mds_update_server[] = {
-       &RMF_PTLRPC_BODY,
-       &RMF_OUT_UPDATE_REPLY,
-};
-
 static const struct req_msg_field *llog_origin_handle_create_client[] = {
        &RMF_PTLRPC_BODY,
        &RMF_LLOGD_BODY,
 static const struct req_msg_field *llog_origin_handle_create_client[] = {
        &RMF_PTLRPC_BODY,
        &RMF_LLOGD_BODY,
@@ -815,7 +804,9 @@ static struct req_format *req_formats[] = {
        &RQF_MDS_HSM_REQUEST,
        &RQF_MDS_SWAP_LAYOUTS,
        &RQF_MDS_RMFID,
        &RQF_MDS_HSM_REQUEST,
        &RQF_MDS_SWAP_LAYOUTS,
        &RQF_MDS_RMFID,
+#ifdef HAVE_SERVER_SUPPORT
        &RQF_OUT_UPDATE,
        &RQF_OUT_UPDATE,
+#endif
        &RQF_OST_CONNECT,
        &RQF_OST_DISCONNECT,
        &RQF_OST_QUOTACTL,
        &RQF_OST_CONNECT,
        &RQF_OST_DISCONNECT,
        &RQF_OST_QUOTACTL,
@@ -1285,15 +1276,6 @@ struct req_msg_field RMF_MDS_HSM_REQUEST =
                    lustre_swab_hsm_request, NULL);
 EXPORT_SYMBOL(RMF_MDS_HSM_REQUEST);
 
                    lustre_swab_hsm_request, NULL);
 EXPORT_SYMBOL(RMF_MDS_HSM_REQUEST);
 
-struct req_msg_field RMF_OUT_UPDATE = DEFINE_MSGFL("object_update", 0, -1,
-                               lustre_swab_object_update_request, NULL);
-EXPORT_SYMBOL(RMF_OUT_UPDATE);
-
-struct req_msg_field RMF_OUT_UPDATE_REPLY =
-                       DEFINE_MSGFL("object_update_reply", 0, -1,
-                                   lustre_swab_object_update_reply, NULL);
-EXPORT_SYMBOL(RMF_OUT_UPDATE_REPLY);
-
 struct req_msg_field RMF_SWAP_LAYOUTS =
        DEFINE_MSGF("swap_layouts", 0, sizeof(struct  mdc_swap_layouts),
                    lustre_swab_swap_layouts, NULL);
 struct req_msg_field RMF_SWAP_LAYOUTS =
        DEFINE_MSGF("swap_layouts", 0, sizeof(struct  mdc_swap_layouts),
                    lustre_swab_swap_layouts, NULL);
@@ -1321,15 +1303,6 @@ struct req_msg_field RMF_OST_LADVISE =
                    lustre_swab_ladvise, NULL);
 EXPORT_SYMBOL(RMF_OST_LADVISE);
 
                    lustre_swab_ladvise, NULL);
 EXPORT_SYMBOL(RMF_OST_LADVISE);
 
-struct req_msg_field RMF_OUT_UPDATE_HEADER = DEFINE_MSGF("out_update_header", 0,
-                               -1, lustre_swab_out_update_header, NULL);
-EXPORT_SYMBOL(RMF_OUT_UPDATE_HEADER);
-
-struct req_msg_field RMF_OUT_UPDATE_BUF = DEFINE_MSGF("update_buf",
-                       RMF_F_STRUCT_ARRAY, sizeof(struct out_update_buffer),
-                       lustre_swab_out_update_buffer, NULL);
-EXPORT_SYMBOL(RMF_OUT_UPDATE_BUF);
-
 /*
  * Request formats.
  */
 /*
  * Request formats.
  */
@@ -1551,11 +1524,6 @@ struct req_format RQF_MDS_GET_INFO =
                         mds_getinfo_server);
 EXPORT_SYMBOL(RQF_MDS_GET_INFO);
 
                         mds_getinfo_server);
 EXPORT_SYMBOL(RQF_MDS_GET_INFO);
 
-struct req_format RQF_OUT_UPDATE =
-       DEFINE_REQ_FMT0("OUT_UPDATE", mds_update_client,
-                       mds_update_server);
-EXPORT_SYMBOL(RQF_OUT_UPDATE);
-
 struct req_format RQF_LDLM_ENQUEUE =
         DEFINE_REQ_FMT0("LDLM_ENQUEUE",
                         ldlm_enqueue_client, ldlm_enqueue_lvb_server);
 struct req_format RQF_LDLM_ENQUEUE =
         DEFINE_REQ_FMT0("LDLM_ENQUEUE",
                         ldlm_enqueue_client, ldlm_enqueue_lvb_server);
@@ -2656,10 +2624,44 @@ int req_capsule_server_grow(struct req_capsule *pill,
 }
 EXPORT_SYMBOL(req_capsule_server_grow);
 
 }
 EXPORT_SYMBOL(req_capsule_server_grow);
 
+#ifdef HAVE_SERVER_SUPPORT
+static const struct req_msg_field *mds_update_client[] = {
+       &RMF_PTLRPC_BODY,
+       &RMF_OUT_UPDATE_HEADER,
+       &RMF_OUT_UPDATE_BUF,
+};
+
+static const struct req_msg_field *mds_update_server[] = {
+       &RMF_PTLRPC_BODY,
+       &RMF_OUT_UPDATE_REPLY,
+};
+
+struct req_msg_field RMF_OUT_UPDATE = DEFINE_MSGFL("object_update", 0, -1,
+                               lustre_swab_object_update_request, NULL);
+EXPORT_SYMBOL(RMF_OUT_UPDATE);
+
+struct req_msg_field RMF_OUT_UPDATE_REPLY =
+                       DEFINE_MSGFL("object_update_reply", 0, -1,
+                                   lustre_swab_object_update_reply, NULL);
+EXPORT_SYMBOL(RMF_OUT_UPDATE_REPLY);
+
+struct req_msg_field RMF_OUT_UPDATE_HEADER = DEFINE_MSGF("out_update_header", 0,
+                               -1, lustre_swab_out_update_header, NULL);
+EXPORT_SYMBOL(RMF_OUT_UPDATE_HEADER);
+
+struct req_msg_field RMF_OUT_UPDATE_BUF = DEFINE_MSGF("update_buf",
+                       RMF_F_STRUCT_ARRAY, sizeof(struct out_update_buffer),
+                       lustre_swab_out_update_buffer, NULL);
+EXPORT_SYMBOL(RMF_OUT_UPDATE_BUF);
+
+struct req_format RQF_OUT_UPDATE =
+       DEFINE_REQ_FMT0("OUT_UPDATE", mds_update_client,
+                       mds_update_server);
+EXPORT_SYMBOL(RQF_OUT_UPDATE);
+
 int req_check_sepol(struct req_capsule *pill)
 {
        int rc = 0;
 int req_check_sepol(struct req_capsule *pill)
 {
        int rc = 0;
-#ifdef HAVE_SERVER_SUPPORT
        struct obd_export *export;
        struct lu_nodemap *nm = NULL;
        const char *sepol = NULL;
        struct obd_export *export;
        struct lu_nodemap *nm = NULL;
        const char *sepol = NULL;
@@ -2693,8 +2695,8 @@ nm:
 
        if (!IS_ERR_OR_NULL(nm))
                nodemap_putref(nm);
 
        if (!IS_ERR_OR_NULL(nm))
                nodemap_putref(nm);
-#endif
 
        return rc;
 }
 EXPORT_SYMBOL(req_check_sepol);
 
        return rc;
 }
 EXPORT_SYMBOL(req_check_sepol);
+#endif
index f7c524b..e4bacc2 100644 (file)
@@ -50,8 +50,6 @@
 #include <obd_cksum.h>
 #include <obd_class.h>
 #include <obd_support.h>
 #include <obd_cksum.h>
 #include <obd_class.h>
 #include <obd_support.h>
-#include <obj_update.h>
-
 #include "ptlrpc_internal.h"
 
 static inline __u32 lustre_msg_hdr_size_v2(__u32 count)
 #include "ptlrpc_internal.h"
 
 static inline __u32 lustre_msg_hdr_size_v2(__u32 count)
@@ -2894,110 +2892,6 @@ void lustre_swab_hsm_request(struct hsm_request *hr)
        __swab32s(&hr->hr_data_len);
 }
 
        __swab32s(&hr->hr_data_len);
 }
 
-void lustre_swab_object_update(struct object_update *ou)
-{
-       struct object_update_param *param;
-       size_t  i;
-
-       __swab16s(&ou->ou_type);
-       __swab16s(&ou->ou_params_count);
-       __swab32s(&ou->ou_result_size);
-       __swab32s(&ou->ou_flags);
-       __swab32s(&ou->ou_padding1);
-       __swab64s(&ou->ou_batchid);
-       lustre_swab_lu_fid(&ou->ou_fid);
-       param = &ou->ou_params[0];
-       for (i = 0; i < ou->ou_params_count; i++) {
-               __swab16s(&param->oup_len);
-               __swab16s(&param->oup_padding);
-               __swab32s(&param->oup_padding2);
-               param = (struct object_update_param *)((char *)param +
-                        object_update_param_size(param));
-       }
-}
-
-int lustre_swab_object_update_request(struct object_update_request *our,
-                                     __u32 len)
-{
-       __u32 i, size = 0;
-       struct object_update *ou;
-
-       __swab32s(&our->ourq_magic);
-       __swab16s(&our->ourq_count);
-       __swab16s(&our->ourq_padding);
-
-       /* Don't need to calculate request size if len is 0. */
-       if (len > 0) {
-               size = sizeof(struct object_update_request);
-               for (i = 0; i < our->ourq_count; i++) {
-                       ou = object_update_request_get(our, i, NULL);
-                       if (ou == NULL)
-                               return -EPROTO;
-                       size += sizeof(struct object_update) +
-                               ou->ou_params_count *
-                               sizeof(struct object_update_param);
-               }
-               if (unlikely(size > len))
-                       return -EOVERFLOW;
-       }
-
-       for (i = 0; i < our->ourq_count; i++) {
-               ou = object_update_request_get(our, i, NULL);
-               lustre_swab_object_update(ou);
-       }
-
-       return size;
-}
-
-void lustre_swab_object_update_result(struct object_update_result *our)
-{
-       __swab32s(&our->our_rc);
-       __swab16s(&our->our_datalen);
-       __swab16s(&our->our_padding);
-}
-
-int lustre_swab_object_update_reply(struct object_update_reply *our, __u32 len)
-{
-       __u32 i, size;
-
-       __swab32s(&our->ourp_magic);
-       __swab16s(&our->ourp_count);
-       __swab16s(&our->ourp_padding);
-
-       size = sizeof(struct object_update_reply) + our->ourp_count *
-              (sizeof(__u16) + sizeof(struct object_update_result));
-       if (unlikely(size > len))
-               return -EOVERFLOW;
-
-       for (i = 0; i < our->ourp_count; i++) {
-               struct object_update_result *ourp;
-
-               __swab16s(&our->ourp_lens[i]);
-               ourp = object_update_result_get(our, i, NULL);
-               if (ourp == NULL)
-                       return -EPROTO;
-               lustre_swab_object_update_result(ourp);
-       }
-
-       return size;
-}
-
-void lustre_swab_out_update_header(struct out_update_header *ouh)
-{
-       __swab32s(&ouh->ouh_magic);
-       __swab32s(&ouh->ouh_count);
-       __swab32s(&ouh->ouh_inline_length);
-       __swab32s(&ouh->ouh_reply_size);
-}
-EXPORT_SYMBOL(lustre_swab_out_update_header);
-
-void lustre_swab_out_update_buffer(struct out_update_buffer *oub)
-{
-       __swab32s(&oub->oub_size);
-       __swab32s(&oub->oub_padding);
-}
-EXPORT_SYMBOL(lustre_swab_out_update_buffer);
-
 void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl)
 {
        __swab64s(&msl->msl_flags);
 void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl)
 {
        __swab64s(&msl->msl_flags);
diff --git a/lustre/ptlrpc/pack_server.c b/lustre/ptlrpc/pack_server.c
new file mode 100644 (file)
index 0000000..ec1c20d
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2011, 2017, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ *
+ * lustre/ptlrpc/pack_server.c
+ *
+ * (Un)packing of OST requests
+ *
+ */
+
+#define DEBUG_SUBSYSTEM S_RPC
+
+#include <llog_swab.h>
+#include <obd_class.h>
+
+void lustre_swab_object_update(struct object_update *ou)
+{
+       struct object_update_param *param;
+       size_t  i;
+
+       __swab16s(&ou->ou_type);
+       __swab16s(&ou->ou_params_count);
+       __swab32s(&ou->ou_result_size);
+       __swab32s(&ou->ou_flags);
+       __swab32s(&ou->ou_padding1);
+       __swab64s(&ou->ou_batchid);
+       lustre_swab_lu_fid(&ou->ou_fid);
+       param = &ou->ou_params[0];
+       for (i = 0; i < ou->ou_params_count; i++) {
+               __swab16s(&param->oup_len);
+               __swab16s(&param->oup_padding);
+               __swab32s(&param->oup_padding2);
+               param = (struct object_update_param *)((char *)param +
+                        object_update_param_size(param));
+       }
+}
+
+int lustre_swab_object_update_request(struct object_update_request *our,
+                                     __u32 len)
+{
+       __u32 i, size = 0;
+       struct object_update *ou;
+
+       __swab32s(&our->ourq_magic);
+       __swab16s(&our->ourq_count);
+       __swab16s(&our->ourq_padding);
+
+       /* Don't need to calculate request size if len is 0. */
+       if (len > 0) {
+               size = sizeof(struct object_update_request);
+               for (i = 0; i < our->ourq_count; i++) {
+                       ou = object_update_request_get(our, i, NULL);
+                       if (ou == NULL)
+                               return -EPROTO;
+                       size += sizeof(struct object_update) +
+                               ou->ou_params_count *
+                               sizeof(struct object_update_param);
+               }
+               if (unlikely(size > len))
+                       return -EOVERFLOW;
+       }
+
+       for (i = 0; i < our->ourq_count; i++) {
+               ou = object_update_request_get(our, i, NULL);
+               lustre_swab_object_update(ou);
+       }
+
+       return size;
+}
+
+void lustre_swab_object_update_result(struct object_update_result *our)
+{
+       __swab32s(&our->our_rc);
+       __swab16s(&our->our_datalen);
+       __swab16s(&our->our_padding);
+}
+
+int lustre_swab_object_update_reply(struct object_update_reply *our, __u32 len)
+{
+       __u32 i, size;
+
+       __swab32s(&our->ourp_magic);
+       __swab16s(&our->ourp_count);
+       __swab16s(&our->ourp_padding);
+
+       size = sizeof(struct object_update_reply) + our->ourp_count *
+              (sizeof(__u16) + sizeof(struct object_update_result));
+       if (unlikely(size > len))
+               return -EOVERFLOW;
+
+       for (i = 0; i < our->ourp_count; i++) {
+               struct object_update_result *ourp;
+
+               __swab16s(&our->ourp_lens[i]);
+               ourp = object_update_result_get(our, i, NULL);
+               if (ourp == NULL)
+                       return -EPROTO;
+               lustre_swab_object_update_result(ourp);
+       }
+
+       return size;
+}
+
+void lustre_swab_out_update_header(struct out_update_header *ouh)
+{
+       __swab32s(&ouh->ouh_magic);
+       __swab32s(&ouh->ouh_count);
+       __swab32s(&ouh->ouh_inline_length);
+       __swab32s(&ouh->ouh_reply_size);
+}
+EXPORT_SYMBOL(lustre_swab_out_update_header);
+
+void lustre_swab_out_update_buffer(struct out_update_buffer *oub)
+{
+       __swab32s(&oub->oub_size);
+       __swab32s(&oub->oub_padding);
+}
+EXPORT_SYMBOL(lustre_swab_out_update_buffer);