From d6a3b0529d7da440a391db4cf6ea6a1516ebe3ac Mon Sep 17 00:00:00 2001 From: Alexey Lyashkov Date: Thu, 25 Nov 2021 21:12:21 +0300 Subject: [PATCH] LU-15279 ptlrpc: use a cached value Don't calculate a early reply size - use a cached, as it don't changed after start Signed-off-by: Alexey Lyashkov Change-Id: I3a6bd5013d0646b6165db52d6a7fb38b263756e6 Reviewed-on: https://review.whamcloud.com/45661 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Andrew Perepechko Reviewed-by: Oleg Drokin --- lustre/include/lustre_net.h | 2 +- lustre/mdc/mdc_locks.c | 4 ++-- lustre/ptlrpc/gss/sec_gss.c | 4 ++-- lustre/ptlrpc/pack_generic.c | 8 +++++--- lustre/ptlrpc/ptlrpc_internal.h | 1 + lustre/ptlrpc/ptlrpc_module.c | 1 + lustre/ptlrpc/sec_null.c | 4 ++-- lustre/ptlrpc/sec_plain.c | 2 +- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 6ad7e06..1b6d96b 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -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); diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index 8f9a1fb..cb098e6 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -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 diff --git a/lustre/ptlrpc/gss/sec_gss.c b/lustre/ptlrpc/gss/sec_gss.c index 6f6a978..86e13e6 100644 --- a/lustre/ptlrpc/gss/sec_gss.c +++ b/lustre/ptlrpc/gss/sec_gss.c @@ -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); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 7a6f112..88831c7 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -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) { diff --git a/lustre/ptlrpc/ptlrpc_internal.h b/lustre/ptlrpc/ptlrpc_internal.h index b120031..c699c28 100644 --- a/lustre/ptlrpc/ptlrpc_internal.h +++ b/lustre/ptlrpc/ptlrpc_internal.h @@ -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); diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c index f7630ef..abde1f2 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -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) diff --git a/lustre/ptlrpc/sec_null.c b/lustre/ptlrpc/sec_null.c index cc44c8d..4fb3a09 100644 --- a/lustre/ptlrpc/sec_null.c +++ b/lustre/ptlrpc/sec_null.c @@ -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; diff --git a/lustre/ptlrpc/sec_plain.c b/lustre/ptlrpc/sec_plain.c index f1141a0..7cf3a2c 100644 --- a/lustre/ptlrpc/sec_plain.c +++ b/lustre/ptlrpc/sec_plain.c @@ -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); -- 1.8.3.1