Whamcloud - gitweb
LU-15279 ptlrpc: use a cached value 61/45661/5
authorAlexey Lyashkov <alexey.lyashkov@hpe.com>
Thu, 25 Nov 2021 18:12:21 +0000 (21:12 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 23 Dec 2021 07:19:45 +0000 (07:19 +0000)
Don't calculate a early reply size - use a cached,
as it don't changed after start

Signed-off-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Change-Id: I3a6bd5013d0646b6165db52d6a7fb38b263756e6
Reviewed-on: https://review.whamcloud.com/45661
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_net.h
lustre/mdc/mdc_locks.c
lustre/ptlrpc/gss/sec_gss.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/ptlrpc_internal.h
lustre/ptlrpc/ptlrpc_module.c
lustre/ptlrpc/sec_null.c
lustre/ptlrpc/sec_plain.c

index 6ad7e06..1b6d96b 100644 (file)
@@ -2273,7 +2273,7 @@ __u32 lustre_msg_hdr_size(__u32 magic, __u32 count);
 __u32 lustre_msg_size(__u32 magic, int count, __u32 *lengths);
 __u32 lustre_msg_size_v2(int count, __u32 *lengths);
 __u32 lustre_packed_msg_size(struct lustre_msg *msg);
-__u32 lustre_msg_early_size(void);
+extern __u32 lustre_msg_early_size;
 void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, __u32 n, __u32 min_size);
 void *lustre_msg_buf(struct lustre_msg *m, __u32 n, __u32 minlen);
 __u32 lustre_msg_buflen(struct lustre_msg *m, __u32 n);
index 8f9a1fb..cb098e6 100644 (file)
@@ -400,7 +400,7 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it,
 
        /* Get real repbuf allocated size as rounded up power of 2 */
        repsize = size_roundup_power2(req->rq_replen +
-                                     lustre_msg_early_size());
+                                     lustre_msg_early_size);
        /* Estimate free space for DoM files in repbuf */
        repsize_estimate = repsize - (req->rq_replen -
                           mdt_md_capsule_size +
@@ -418,7 +418,7 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it,
                CDEBUG(D_INFO, "Increase repbuf by %d bytes, total: %d\n",
                       repsize, req->rq_replen);
                repsize = size_roundup_power2(req->rq_replen +
-                                             lustre_msg_early_size());
+                                             lustre_msg_early_size);
        }
        /* The only way to report real allocated repbuf size to the server
         * is the lm_repsize but it must be set prior buffer allocation itself
index 6f6a978..86e13e6 100644 (file)
@@ -2838,11 +2838,11 @@ static void gss_init_at_reply_offset(void)
         int clearsize;
 
         buflens[0] = PTLRPC_GSS_HEADER_SIZE;
-        buflens[1] = lustre_msg_early_size();
+        buflens[1] = lustre_msg_early_size;
         buflens[2] = gss_cli_payload(NULL, buflens[1], 0);
         gss_at_reply_off_integ = lustre_msg_size_v2(3, buflens);
 
-        buflens[0] = lustre_msg_early_size();
+        buflens[0] = lustre_msg_early_size;
         clearsize = lustre_msg_size_v2(1, buflens);
         buflens[0] = PTLRPC_GSS_HEADER_SIZE;
         buflens[1] = gss_cli_payload(NULL, clearsize, 0);
index 7a6f112..88831c7 100644 (file)
@@ -95,14 +95,16 @@ int lustre_msg_check_version(struct lustre_msg *msg,
 #undef LUSTRE_MSG_MAGIC_V1
 }
 
+__u32 lustre_msg_early_size;
+EXPORT_SYMBOL(lustre_msg_early_size);
+
 /* early reply size */
-__u32 lustre_msg_early_size()
+void lustre_msg_early_size_init(void)
 {
        __u32 pblen = sizeof(struct ptlrpc_body);
 
-       return lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, &pblen);
+       lustre_msg_early_size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, &pblen);
 }
-EXPORT_SYMBOL(lustre_msg_early_size);
 
 __u32 lustre_msg_size_v2(int count, __u32 *lengths)
 {
index b120031..c699c28 100644 (file)
@@ -271,6 +271,7 @@ void ptlrpc_fill_bulk_md(struct lnet_md *md, struct ptlrpc_bulk_desc *desc,
 struct ptlrpc_reply_state *
 lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt);
 void lustre_put_emerg_rs(struct ptlrpc_reply_state *rs);
+void lustre_msg_early_size_init(void); /* just for init */
 
 /* pinger.c */
 int ptlrpc_start_pinger(void);
index f7630ef..abde1f2 100644 (file)
@@ -53,6 +53,7 @@ static __init int ptlrpc_init(void)
        mutex_init(&pinger_mutex);
        mutex_init(&ptlrpcd_mutex);
        ptlrpc_init_xid();
+       lustre_msg_early_size_init();
 
        rc = req_layout_init();
        if (rc)
index cc44c8d..4fb3a09 100644 (file)
@@ -191,7 +191,7 @@ int null_alloc_repbuf(struct ptlrpc_sec *sec,
                      int msgsize)
 {
        /* add space for early replied */
-       msgsize += lustre_msg_early_size();
+       msgsize += lustre_msg_early_size;
 
        msgsize = size_roundup_power2(msgsize);
 
@@ -352,7 +352,7 @@ int null_authorize(struct ptlrpc_request *req)
 
        if (likely(req->rq_packed_final)) {
                if (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)
-                       req->rq_reply_off = lustre_msg_early_size();
+                       req->rq_reply_off = lustre_msg_early_size;
        } else {
                __u32 cksum;
 
index f1141a0..7cf3a2c 100644 (file)
@@ -1012,7 +1012,7 @@ int sptlrpc_plain_init(void)
        __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, };
        int rc;
 
-       buflens[PLAIN_PACK_MSG_OFF] = lustre_msg_early_size();
+       buflens[PLAIN_PACK_MSG_OFF] = lustre_msg_early_size;
        plain_at_offset = lustre_msg_size_v2(PLAIN_PACK_SEGMENTS, buflens);
 
        rc = sptlrpc_register_policy(&plain_policy);