From a7bd8d0948701229fcdf8ecca757e33aa8268fd0 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Tue, 21 Nov 2023 12:32:20 -0500 Subject: [PATCH] EX-7601 osc: rearrange compress_request A trivial rearrangement of compress_request to make it more readable before redoing the core logic. Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: I1d34cd2a2a6d84bc30cc7dae8eb07586c4837f7d Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53110 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/osc/osc_compress.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lustre/osc/osc_compress.c b/lustre/osc/osc_compress.c index 3465546..1de528e 100644 --- a/lustre/osc/osc_compress.c +++ b/lustre/osc/osc_compress.c @@ -123,6 +123,7 @@ int compress_request(const char *obd_name, struct obdo *oa, unsigned int src_size; unsigned int dst_size; int chunk_start = 0; + int chunk_count = 0; int pages_per_chunk; int dest_buf_bits; int src_buf_bits; @@ -131,7 +132,6 @@ int compress_request(const char *obd_name, struct obdo *oa, int chunk_size; int chunk_bits; int cpga_i = 0; - int count = 0; int rc = 0; int pga_i; int lvl; @@ -162,13 +162,14 @@ int compress_request(const char *obd_name, struct obdo *oa, !can_merge_pages(pga[pga_i], pga[pga_i + 1])) { CDEBUG(D_SEC, "Chunk [%i,%i]\n", chunk_start, pga_i); - merge_chunk(pga, NULL, chunk_start, - pga_i + 1 - chunk_start, src, &src_size); dst_size = 2 * chunk_size; sptlrpc_pool_get_pages(&dst, dest_buf_bits); if (dst == NULL) GOTO(out, rc = -ENOMEM); + merge_chunk(pga, NULL, chunk_start, + pga_i + 1 - chunk_start, src, &src_size); + /* * - applied_type == 0 if no supported algorithms * found during the previous compress_chunk call @@ -182,10 +183,6 @@ int compress_request(const char *obd_name, struct obdo *oa, "%s: rc %d: inode "DFID"\n", obd_name, rc, oa->o_parent_seq, oa->o_parent_oid, oa->o_parent_ver); - - CDEBUG(D_SEC, - "Compressed %u, plain %u\n", - dst_size, src_size); } else { compressed = false; dst_size = src_size; @@ -194,25 +191,29 @@ int compress_request(const char *obd_name, struct obdo *oa, rc = fill_cpga(*cpga, pga, compressed ? dst : NULL, chunk_start, cpga_i, dst_size); - if (!compressed) { - sptlrpc_pool_put_pages(&dst, dest_buf_bits); - } else { + if (compressed) { + CDEBUG(D_SEC, + "Compressed %u, plain %u\n", + dst_size, src_size); + (*cpga)[cpga_i]->bp_cmp_chunk = dst; (*cpga)[cpga_i]->bp_cmp_chunk_size = dest_buf_bits; + } else { + sptlrpc_pool_put_pages(&dst, dest_buf_bits); } if (rc) GOTO(out, rc); cpga_i += ((dst_size - 1) >> PAGE_SHIFT) + 1; - count++; + chunk_count++; chunk_start = pga_i + 1; } } CDEBUG(D_SEC, "Compressed content: %i pages (%i chunks)\n", cpga_i, - count); + chunk_count); out: if (src != NULL) sptlrpc_pool_put_pages(&src, src_buf_bits); -- 1.8.3.1