From 0b709637f87306ab08b3512f26281ef830682d4b Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Sun, 12 Nov 2023 14:52:28 -0500 Subject: [PATCH] EX-7600 osc: use pages_left in unmerge_chunk Since we have compressed chunks < chunk_size (if they're after EOF), we must use pages_left in unmgerge_chunk or it will go off the end of the page array. This also lets us remove the workaround where unmerge_chunk would skip pages that were not present. unmerge_chunk always works with a known and complete set of pages, so this check is unneeded. We should also check that our count of bytes is correct when we finish. Signed-off-by: Patrick Farrell Change-Id: I88896307990ff839514e54e9a7e18390a457e5d8 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53095 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/obdclass/lustre_compr.c | 3 +-- lustre/osc/osc_compress.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lustre/obdclass/lustre_compr.c b/lustre/obdclass/lustre_compr.c index 05c072c..3156c44 100644 --- a/lustre/obdclass/lustre_compr.c +++ b/lustre/obdclass/lustre_compr.c @@ -298,8 +298,6 @@ void unmerge_chunk(struct brw_page **pga, struct niobuf_local *lnb, int first, for (i = 0; i < count; i++) { if (pga) { brwpg = pga[first + i]; - if (!brwpg) - continue; vmpage = brwpg->pg; pg_len = &brwpg->count; offset = brwpg->off; @@ -327,5 +325,6 @@ void unmerge_chunk(struct brw_page **pga, struct niobuf_local *lnb, int first, CDEBUG(D_SEC, "pg_len: %u, left %u\n", *pg_len, left); } + LASSERT(left == 0); } EXPORT_SYMBOL(unmerge_chunk); diff --git a/lustre/osc/osc_compress.c b/lustre/osc/osc_compress.c index 91b245e..c6853e5 100644 --- a/lustre/osc/osc_compress.c +++ b/lustre/osc/osc_compress.c @@ -308,8 +308,7 @@ int decompress_request(struct osc_brw_async_args *aa, int page_count) if (src == NULL || dst == NULL) GOTO(out, rc = -ENOMEM); } - pages_left = ((page_count - i) > pages_in_chunk) ? - pages_in_chunk : page_count - i; + pages_left = min_t(int, pages_in_chunk, page_count - i); CDEBUG(D_SEC, "Merge chunk [%i, %i], src: %px\n", i, i + pages_left - 1, src); @@ -334,7 +333,7 @@ int decompress_request(struct osc_brw_async_args *aa, int page_count) dst_size, done); LASSERT(dst_size <= chunk_size); - unmerge_chunk(pga, NULL, i, pages_in_chunk, dst, dst_size); + unmerge_chunk(pga, NULL, i, pages_left, dst, dst_size); count++; } -- 1.8.3.1