From db58f65cb900705a4d4f88172c00bbf1f65d9574 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 28 Jun 2023 09:34:22 +0000 Subject: [PATCH] EX-7775 utils: fix cp_comp_type size cp_comp_type should be 8 bits, as llch_compr_type and all associated variables are declared as u8. So remove useless cp_comp_enabled and fix code to test for compressed component with cp_comp_type against LL_COMPR_TYPE_NONE. And update LL_COMPR_TYPE_MAX value to 255 to avoid conflicts with future compression types. Fixes: f43b9ce9af ("EX-6127 osc: osc brw request compression") Test-Parameters: trivial Signed-off-by: Sebastien Buisson Change-Id: Ia15868ac0ac003b62942540a57f782226ae8c141 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51481 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/include/cl_object.h | 6 ++---- lustre/include/uapi/linux/lustre/lustre_user.h | 2 +- lustre/lov/lov_ea.c | 2 +- lustre/lov/lov_io.c | 4 ++-- lustre/lov/lov_object.c | 2 +- lustre/osc/osc_compress.c | 7 ++++--- lustre/osc/osc_request.c | 4 ++-- lustre/utils/liblustreapi_layout.c | 2 +- 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index abd261b..250fa6c 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -772,13 +772,11 @@ struct cl_page { /* which slab kmem index this memory allocated from */ short int cp_kmem_index; /* 48 bits */ /** Compression type **/ - enum ll_compr_type cp_comp_type:4; + enum ll_compr_type cp_comp_type:8; /** Compression level **/ u8 cp_comp_level:4; - /** Compression enabled **/ - u8 cp_comp_enabled:1; /** Chunk Size **/ - u8 cp_chunk_log_bits:7; /* 64 bits */ + u8 cp_chunk_log_bits:4; /* 64 bits */ /** * Owning IO in cl_page_state::CPS_OWNED state. Sub-page can be owned * by sub-io. Protected by a VM lock. diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index d630e80..f966540 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -2931,7 +2931,7 @@ enum ll_compr_type { LL_COMPR_TYPE_LZ4HC = 5, LL_COMPR_TYPE_LZO = 6, LL_COMPR_TYPE_MAX, - LL_COMPR_TYPE_UNCHANGED = 15 + LL_COMPR_TYPE_UNCHANGED = 255 }; #define COMPR_CHUNK_MIN_BITS 16 diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index f5f1225..29777ee 100644 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -703,7 +703,7 @@ void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm) lse->lsme_pattern, lse->lsme_layout_gen, lse->lsme_stripe_count, lse->lsme_stripe_size, lse->lsme_pool_name); - if (lse->lsme_compr_type > 0) { + if (lse->lsme_compr_type != LL_COMPR_TYPE_NONE) { CDEBUG(level, " compr_type %u, compr_lvl %u, " "compr_chunk_log_bits %u\n", lse->lsme_compr_type, diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 81ae127..4091687 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -848,7 +848,8 @@ static int lov_io_iter_init(const struct lu_env *env, lsme = lsm->lsm_entries[0]; /* No support for compressed yet. */ - if (cl_io_is_fallocate(parent) && lsme->lsme_compr_type) { + if (cl_io_is_fallocate(parent) && + lsme->lsme_compr_type != LL_COMPR_TYPE_NONE) { struct lov_io *lio = cl2lov_io(env, ios); struct lov_object *loo = lio->lis_object; @@ -1405,7 +1406,6 @@ static void __set_page_compression(struct cl_page *page, struct lov_stripe_md_entry *lsme) { if (lsme->lsme_pattern & LOV_PATTERN_COMPRESS) { - page->cp_comp_enabled = true; page->cp_comp_type = lsme->lsme_compr_type; page->cp_comp_level = lsme->lsme_compr_lvl; page->cp_chunk_log_bits = lsme->lsme_compr_chunk_log_bits; diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index 459cd10..d316c5c 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -1981,7 +1981,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj, lsme = lsm->lsm_entries[0]; /* No support for compressed yet. */ - if (lsme->lsme_compr_type) + if (lsme->lsme_compr_type != LL_COMPR_TYPE_NONE) GOTO(out_lsm, rc = -EOPNOTSUPP); if (!(fiemap->fm_flags & FIEMAP_FLAG_DEVICE_ORDER)) { diff --git a/lustre/osc/osc_compress.c b/lustre/osc/osc_compress.c index 804ac0d..61dbad9 100644 --- a/lustre/osc/osc_compress.c +++ b/lustre/osc/osc_compress.c @@ -336,13 +336,14 @@ int compress_request(const char *obd_name, struct obdo *oa, * - last chunk in the request is not compressed to * preserve the right size of object */ - if (clpage->cp_comp_type && applied_type && - (pga_i != page_count - 1)) { + if (clpage->cp_comp_type != LL_COMPR_TYPE_NONE && + applied_type && (pga_i != page_count - 1)) { done = compress_chunk(obd_name, oa, src, src_size, dst, &dst_size, wrkmem, clpage, &applied_type); - CDEBUG(D_SEC, "Compressed %u, plain %u, rc %i\n", + CDEBUG(D_SEC, + "Compressed %u, plain %u, rc %i\n", dst_size, src_size, done); } else { done = 0; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index cc4e75d..36eb46b 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1565,8 +1565,8 @@ osc_brw_prep_request(int cmd, struct client_obd *cli, struct obdo *oa, * If compression disabled for the file -1 is set to * all pages, so it is enough to check only one * */ - if ((oap2cl_page(brw_page2oap(pga[0])))->cp_comp_enabled - == false) { + if ((oap2cl_page(brw_page2oap(pga[0])))->cp_comp_type + == LL_COMPR_TYPE_NONE) { compressed = 0; goto skip_compression; } diff --git a/lustre/utils/liblustreapi_layout.c b/lustre/utils/liblustreapi_layout.c index a5eeb0b..bceb431 100644 --- a/lustre/utils/liblustreapi_layout.c +++ b/lustre/utils/liblustreapi_layout.c @@ -1555,7 +1555,7 @@ int llapi_layout_compress_set(struct llapi_layout *layout, if (comp == NULL) goto fail; - /* type 0 means this is not a compress component */ + /* type LL_COMPR_TYPE_NONE means this is not a compress component */ comp->llc_compr_type = type; if (type == LL_COMPR_TYPE_NONE) return 0; -- 1.8.3.1