Whamcloud - gitweb
EX-7775 utils: fix cp_comp_type size
authorSebastien Buisson <sbuisson@ddn.com>
Wed, 28 Jun 2023 09:34:22 +0000 (09:34 +0000)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 1 Jul 2023 10:01:55 +0000 (10:01 +0000)
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 <sbuisson@ddn.com>
Change-Id: Ia15868ac0ac003b62942540a57f782226ae8c141
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51481
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/cl_object.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/lov/lov_ea.c
lustre/lov/lov_io.c
lustre/lov/lov_object.c
lustre/osc/osc_compress.c
lustre/osc/osc_request.c
lustre/utils/liblustreapi_layout.c

index abd261b..250fa6c 100644 (file)
@@ -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.
index d630e80..f966540 100644 (file)
@@ -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
index f5f1225..29777ee 100644 (file)
@@ -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,
index 81ae127..4091687 100644 (file)
@@ -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;
index 459cd10..d316c5c 100644 (file)
@@ -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)) {
index 804ac0d..61dbad9 100644 (file)
@@ -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;
index cc4e75d..36eb46b 100644 (file)
@@ -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;
                }
index a5eeb0b..bceb431 100644 (file)
@@ -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;