From ac9d1920bb8378e50b8a5d43ec6ae622f1b38042 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 15 Sep 2023 13:30:04 -0400 Subject: [PATCH] EX-8270 osc: minor compression cleanups This cleans up some style and argument issues I found made the code a little harder to follow. Signed-off-by: Patrick Farrell Change-Id: Ia3492ae79acf6c83d724cc91b0201c7872325853 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52425 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/osc/osc_compress.c | 19 ++++++++++--------- lustre/osc/osc_compress.h | 4 ++-- lustre/osc/osc_request.c | 31 +++++++++++++++++-------------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/lustre/osc/osc_compress.c b/lustre/osc/osc_compress.c index 2e80212..eb9e985 100644 --- a/lustre/osc/osc_compress.c +++ b/lustre/osc/osc_compress.c @@ -315,7 +315,7 @@ int fill_cpga(struct brw_page **cpga, struct brw_page **pga, int compress_request(const char *obd_name, struct obdo *oa, struct brw_page **pga, struct brw_page ***cpga, - u32 page_count, int *pcount) + u32 *page_count) { struct cl_page *clpage; unsigned int applied_type = LL_COMPR_TYPE_UNCHANGED; @@ -349,7 +349,7 @@ int compress_request(const char *obd_name, struct obdo *oa, if (clpage->cp_inode && IS_ENCRYPTED(clpage->cp_inode)) fill_bits |= CPGA_FILL_ENCRYPTED; - OBD_ALLOC(*cpga, page_count * sizeof(**cpga)); + OBD_ALLOC(*cpga, *page_count * sizeof(**cpga)); src_buf_bits = chunk_bits; dest_buf_bits = chunk_bits + 1; sptlrpc_enc_pool_get_buf(&src, src_buf_bits); @@ -358,9 +358,9 @@ int compress_request(const char *obd_name, struct obdo *oa, if (*cpga == NULL || wrkmem == NULL || src == NULL) GOTO(out, rc = -ENOMEM); - for (pga_i = 0; pga_i < page_count; pga_i++) { + for (pga_i = 0; pga_i < *page_count; pga_i++) { if ((pga_i + 1 - chunk_start == pages_in_chunk) || - (pga_i == page_count - 1) || + (pga_i == *page_count - 1) || !can_merge_pages(pga[pga_i], pga[pga_i + 1])) { clpage = oap2cl_page(brw_page2oap(pga[chunk_start])); /* TDB: change chunk size, reallocate src. @@ -385,7 +385,7 @@ int compress_request(const char *obd_name, struct obdo *oa, * preserve the right size of object */ if (clpage->cp_comp_type != LL_COMPR_TYPE_NONE && - applied_type && (pga_i != page_count - 1)) { + applied_type && (pga_i != *page_count - 1)) { done = compress_chunk(obd_name, oa, src, src_size, dst, &dst_size, wrkmem, clpage, @@ -421,7 +421,6 @@ int compress_request(const char *obd_name, struct obdo *oa, CDEBUG(D_SEC, "Compressed content: %i pages (%i chunks)\n", cpga_i, count); - *pcount = cpga_i; out: if (wrkmem != NULL) sptlrpc_enc_pool_put_buf(&wrkmem, dest_buf_bits); @@ -429,9 +428,11 @@ out: if (src != NULL) sptlrpc_enc_pool_put_buf(&src, src_buf_bits); - if (rc != 0 && *cpga != NULL) { - free_cpga(*cpga, page_count); - } + if (rc != 0 && *cpga != NULL) + free_cpga(*cpga, *page_count); + + if (rc == 0) + *page_count = cpga_i; RETURN(rc); } diff --git a/lustre/osc/osc_compress.h b/lustre/osc/osc_compress.h index 80c7010..542f42c 100644 --- a/lustre/osc/osc_compress.h +++ b/lustre/osc/osc_compress.h @@ -28,8 +28,8 @@ #define OSC_COMPRESS_H int compress_request(const char *obd_name, struct obdo *oa, - struct brw_page **pga, struct brw_page ***cpga, - u32 page_count, int *pcount); + struct brw_page **pga, struct brw_page ***cpga, + u32 *page_count); int decompress_request(struct osc_brw_async_args *aa, int page_count); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index b59735c..69c6a00 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1505,31 +1505,35 @@ osc_brw_prep_request(int cmd, struct client_obd *cli, struct obdo *oa, u32 *pcount, struct brw_page ***orig_pga, struct ptlrpc_request **reqp, int resend) { - /* This values will be replaced */ + /* These values will be replaced */ struct brw_page **pga = *orig_pga; u32 page_count = *pcount; - /* Save original to store in the aa */ struct brw_page **ncpga = *orig_pga; u32 ncpcount = *pcount; - struct ptlrpc_request *req; + struct osc_brw_async_args *aa; struct ptlrpc_bulk_desc *desc; - struct ost_body *body; - struct obd_ioobj *ioobj; struct niobuf_remote *niobuf; - int niocount, i, requested_nob, opc, rc, short_io_size = 0; - struct osc_brw_async_args *aa; + struct ptlrpc_request *req; + struct inode *inode = NULL; struct req_capsule *pill; struct brw_page *pg_prev; - void *short_io_buf; - const char *obd_name = cli->cl_import->imp_obd->obd_name; - struct inode *inode = NULL; - bool directio = false; - bool enable_checksum = true; + struct obd_ioobj *ioobj; struct cl_page *clpage; + struct ost_body *body; + const char *obd_name = cli->cl_import->imp_obd->obd_name; bool page_access_allowed = true; + bool enable_checksum = true; bool compressed = false; + bool directio = false; + int short_io_size = 0; + void *short_io_buf; + int requested_nob; + int niocount; + int opc; + int rc; + int i; ENTRY; if (pga[0]->pg) { @@ -1585,8 +1589,7 @@ osc_brw_prep_request(int cmd, struct client_obd *cli, struct obdo *oa, RETURN(-EINVAL); if (opc == OST_WRITE && compressed) { - rc = compress_request(obd_name, oa, pga, &pga, page_count, - &page_count); + rc = compress_request(obd_name, oa, pga, &pga, &page_count); if (rc) { /* * TDB: disable for a file if e.g. 512KB+ of -- 1.8.3.1