Whamcloud - gitweb
EX-8038 csdc: sending compression info to server
authorBobi Jam <bobijam@whamcloud.com>
Thu, 12 Oct 2023 14:44:17 +0000 (22:44 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 14 Oct 2023 10:46:24 +0000 (10:46 +0000)
Client fills in layout compression info into obdo and passes it
to server.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: Ieb5d7b3609da41f35f8622ed6116f19ce7567ddb
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52669
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
12 files changed:
lustre/include/cl_object.h
lustre/include/lustre_fid.h
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/lov/lov_internal.h
lustre/lov/lov_io.c
lustre/lov/lovsub_object.c
lustre/osc/osc_io.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/wiretest.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index 47f2288..7a9182e 100644 (file)
@@ -1884,6 +1884,7 @@ struct cl_io {
                        unsigned int             sa_xvalid; /* OP_XVALID */
                        int                      sa_stripe_index;
                        struct ost_layout        sa_layout;
+                       struct ost_layout_compr  sa_layout_compr;
                        const struct lu_fid     *sa_parent_fid;
                        /* SETATTR interface is used for regular setattr, */
                        /* truncate(2) and fallocate(2) subtypes */
index dd527f0..a983ffa 100644 (file)
@@ -344,6 +344,22 @@ static inline void ost_layout_le_to_cpu(struct ost_layout *dst,
        dst->ol_comp_id = __le32_to_cpu(src->ol_comp_id);
 }
 
+static inline void ost_layout_compr_cpu_to_le(struct ost_layout_compr *dst,
+                               const struct ost_layout_compr *src)
+{
+       dst->ol_compr_type = src->ol_compr_type;
+       dst->ol_compr_lvl = src->ol_compr_lvl;
+       dst->ol_compr_chunk_log_bits = src->ol_compr_chunk_log_bits;
+}
+
+static inline void ost_layout_compr_le_to_cpu(struct ost_layout_compr *dst,
+                               const struct ost_layout_compr *src)
+{
+       dst->ol_compr_type = src->ol_compr_type;
+       dst->ol_compr_lvl = src->ol_compr_lvl;
+       dst->ol_compr_chunk_log_bits = src->ol_compr_chunk_log_bits;
+}
+
 static inline void filter_fid_cpu_to_le(struct filter_fid *dst,
                                        const struct filter_fid *src, int size)
 {
index 93317d4..bd7b191 100644 (file)
@@ -3158,7 +3158,8 @@ struct obdo {
                                                 * brw: grant space consumed on
                                                 * the client for the write */
        __u32                   o_projid;
-       __u32                   o_padding_4;    /* also fix
+       struct ost_layout_compr o_layout_compr;
+       __u16                   o_padding_4;    /* also fix
                                                 * lustre_swab_obdo() */
        __u64                   o_padding_5;
        __u64                   o_padding_6;
index cedc0c9..b8ec843 100644 (file)
@@ -351,6 +351,12 @@ struct ost_layout {
        __u32   ol_comp_id;
 } __attribute__((packed));
 
+struct ost_layout_compr {
+       __u8    ol_compr_type;
+       __u8    ol_compr_lvl:4,
+               ol_compr_chunk_log_bits:4;
+} __attribute__((packed));
+
 /* The filter_fid structure has changed several times over its lifetime.
  * For a long time "trusted.fid" held the MDT inode parent FID/IGIF and
  * stripe_index and the "self FID" (objid/seq) to be able to recover the
@@ -946,8 +952,8 @@ struct lov_comp_md_entry_v1 {
        __u64                   lcme_timestamp; /* snapshot time if applicable*/
        __u16                   lcme_padding_1;
        __u8                    lcme_compr_type;        /* compress type */
-       __u8                    lcme_compr_lvl:4;       /* compress level */
-       __u8                    lcme_compr_chunk_log_bits:4;
+       __u8                    lcme_compr_lvl:4,       /* compress level */
+                               lcme_compr_chunk_log_bits:4;
                                     /* chunk_size = 2^(16+chunk_log_bits)
                                      * i.e. power-of-two multiple of 64KiB */
 } __attribute__((packed));
index 040deea..32d00ae 100644 (file)
@@ -421,9 +421,10 @@ static inline struct obd_device *lov2obd(const struct lov_obd *lov)
        return container_of_safe(lov, struct obd_device, u.lov);
 }
 
-static inline void lov_lsm2layout(struct lov_stripe_md *lsm,
-                                 struct lov_stripe_md_entry *lsme,
-                                 struct ost_layout *ol)
+static inline void lov_lsm2layout2(struct lov_stripe_md *lsm,
+                                  struct lov_stripe_md_entry *lsme,
+                                  struct ost_layout *ol,
+                                  struct ost_layout_compr *olc)
 {
        ol->ol_stripe_size = lsme->lsme_stripe_size;
        ol->ol_stripe_count = lsme->lsme_stripe_count;
@@ -431,13 +432,31 @@ static inline void lov_lsm2layout(struct lov_stripe_md *lsm,
                ol->ol_comp_start = lsme->lsme_extent.e_start;
                ol->ol_comp_end = lsme->lsme_extent.e_end;
                ol->ol_comp_id = lsme->lsme_id;
+               if (olc) {
+                       olc->ol_compr_type = lsme->lsme_compr_type;
+                       olc->ol_compr_lvl = lsme->lsme_compr_lvl;
+                       olc->ol_compr_chunk_log_bits =
+                                               lsme->lsme_compr_chunk_log_bits;
+               }
        } else {
                ol->ol_comp_start = 0;
                ol->ol_comp_end = 0;
                ol->ol_comp_id = 0;
+               if (olc) {
+                       olc->ol_compr_type = LL_COMPR_TYPE_NONE;
+                       olc->ol_compr_lvl = 0;
+                       olc->ol_compr_chunk_log_bits = 0;
+               }
        }
 }
 
+static inline void lov_lsm2layout(struct lov_stripe_md *lsm,
+                                 struct lov_stripe_md_entry *lsme,
+                                 struct ost_layout *ol)
+{
+       lov_lsm2layout2(lsm, lsme, ol, NULL);
+}
+
 struct pool_desc *lov_pool_find(struct obd_device *obd, char *poolname);
 void lov_pool_putref(struct pool_desc *pool);
 #endif
index faf54e0..575f009 100644 (file)
@@ -840,8 +840,9 @@ static void lov_io_sub_inherit(struct lov_io_sub *sub, struct lov_io *lio,
                                                      stripe);
                        io->u.ci_setattr.sa_attr.lvb_size = new_size;
                }
-               lov_lsm2layout(lsm, lsm->lsm_entries[index],
-                              &io->u.ci_setattr.sa_layout);
+               lov_lsm2layout2(lsm, lsm->lsm_entries[index],
+                               &io->u.ci_setattr.sa_layout,
+                               &io->u.ci_setattr.sa_layout_compr);
                break;
        }
        case CIT_DATA_VERSION: {
index 9f200ad..949b1cc 100644 (file)
@@ -146,6 +146,7 @@ static void lovsub_req_attr_set(const struct lu_env *env, struct cl_object *obj,
 {
        struct lovsub_object *subobj = cl2lovsub(obj);
        struct lov_stripe_md *lsm = subobj->lso_super->lo_lsm;
+       int index = subobj->lso_index;
 
        ENTRY;
        cl_req_attr_set(env, &subobj->lso_super->lo_cl, attr);
@@ -154,9 +155,10 @@ static void lovsub_req_attr_set(const struct lu_env *env, struct cl_object *obj,
         * There is no OBD_MD_* flag for obdo::o_stripe_idx, so set it
         * unconditionally. It never changes anyway.
         */
-       attr->cra_oa->o_stripe_idx = lov_comp_stripe(subobj->lso_index);
-       lov_lsm2layout(lsm, lsm->lsm_entries[lov_comp_entry(subobj->lso_index)],
-                      &attr->cra_oa->o_layout);
+       attr->cra_oa->o_stripe_idx = lov_comp_stripe(index);
+       lov_lsm2layout2(lsm, lsm->lsm_entries[lov_comp_entry(index)],
+                       &attr->cra_oa->o_layout,
+                       &attr->cra_oa->o_layout_compr);
        attr->cra_oa->o_valid |= OBD_MD_FLOSTLAYOUT;
        EXIT;
 }
index 1aaf4a1..97fc034 100644 (file)
@@ -620,6 +620,7 @@ static int osc_io_setattr_start(const struct lu_env *env,
                obdo_set_parent_fid(oa, io->u.ci_setattr.sa_parent_fid);
                oa->o_stripe_idx = io->u.ci_setattr.sa_stripe_index;
                oa->o_layout = io->u.ci_setattr.sa_layout;
+               oa->o_layout_compr = io->u.ci_setattr.sa_layout_compr;
                oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP |
                        OBD_MD_FLOSTLAYOUT;
                if (ia_avalid & ATTR_CTIME) {
index 2ffd4df..6c76d37 100644 (file)
@@ -1837,6 +1837,7 @@ void lustre_swab_obdo(struct obdo *o)
        __swab32s(&o->o_gid_h);
        __swab64s(&o->o_data_version);
        __swab32s(&o->o_projid);
+       /* do not need to swab o_layout_compr */
        BUILD_BUG_ON(offsetof(typeof(*o), o_padding_4) == 0);
        BUILD_BUG_ON(offsetof(typeof(*o), o_padding_5) == 0);
        BUILD_BUG_ON(offsetof(typeof(*o), o_padding_6) == 0);
index 7e642bc..afda15a 100644 (file)
@@ -1508,6 +1508,16 @@ void lustre_assert_wire_constants(void)
        LASSERTF((int)sizeof(((struct ost_layout *)0)->ol_comp_id) == 4, "found %lld\n",
                 (long long)(int)sizeof(((struct ost_layout *)0)->ol_comp_id));
 
+       /* Checks for struct ost_layout_compr */
+       LASSERTF((int)sizeof(struct ost_layout_compr) == 2, "found %lld\n",
+                (long long)(int)sizeof(struct ost_layout_compr));
+       LASSERTF((int)offsetof(struct ost_layout_compr, ol_compr_type) == 0, "found %lld\n",
+                (long long)(int)offsetof(struct ost_layout_compr, ol_compr_type));
+       LASSERTF((int)sizeof(((struct ost_layout_compr *)0)->ol_compr_type) == 1, "found %lld\n",
+                (long long)(int)sizeof(((struct ost_layout_compr *)0)->ol_compr_type));
+       /* ost_layout_compr.ol_compr_lvl is a bitfield and cannot be checked */
+       /* ost_layout_compr.ol_compr_chunk_log_bits is a bitfield and cannot be checked */
+
        /* Checks for struct obdo */
        LASSERTF((int)sizeof(struct obdo) == 208, "found %lld\n",
                 (long long)(int)sizeof(struct obdo));
@@ -1619,9 +1629,13 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obdo, o_projid));
        LASSERTF((int)sizeof(((struct obdo *)0)->o_projid) == 4, "found %lld\n",
                 (long long)(int)sizeof(((struct obdo *)0)->o_projid));
-       LASSERTF((int)offsetof(struct obdo, o_padding_4) == 188, "found %lld\n",
+       LASSERTF((int)offsetof(struct obdo, o_layout_compr) == 188, "found %lld\n",
+                (long long)(int)offsetof(struct obdo, o_layout_compr));
+       LASSERTF((int)sizeof(((struct obdo *)0)->o_layout_compr) == 2, "found %lld\n",
+                (long long)(int)sizeof(((struct obdo *)0)->o_layout_compr));
+       LASSERTF((int)offsetof(struct obdo, o_padding_4) == 190, "found %lld\n",
                 (long long)(int)offsetof(struct obdo, o_padding_4));
-       LASSERTF((int)sizeof(((struct obdo *)0)->o_padding_4) == 4, "found %lld\n",
+       LASSERTF((int)sizeof(((struct obdo *)0)->o_padding_4) == 2, "found %lld\n",
                 (long long)(int)sizeof(((struct obdo *)0)->o_padding_4));
        LASSERTF((int)offsetof(struct obdo, o_padding_5) == 192, "found %lld\n",
                 (long long)(int)offsetof(struct obdo, o_padding_5));
index 4f323b6..5b89444 100644 (file)
@@ -254,7 +254,6 @@ check_lustre_ost_attrs(void)
        CHECK_MEMBER(lustre_ost_attrs, loa_comp_end);
 }
 
-
 static void
 check_som_attrs(void)
 {
@@ -719,6 +718,16 @@ check_ost_layout(void)
 }
 
 static void
+check_ost_layout_compr(void)
+{
+       BLANK_LINE();
+       CHECK_STRUCT(ost_layout_compr);
+       CHECK_MEMBER(ost_layout_compr, ol_compr_type);
+       CHECK_BITFIELD(ost_layout_compr, ol_compr_lvl);
+       CHECK_BITFIELD(ost_layout_compr, ol_compr_chunk_log_bits);
+}
+
+static void
 check_obdo(void)
 {
        BLANK_LINE();
@@ -750,6 +759,7 @@ check_obdo(void)
        CHECK_MEMBER(obdo, o_gid_h);
        CHECK_MEMBER(obdo, o_data_version);
        CHECK_MEMBER(obdo, o_projid);
+       CHECK_MEMBER(obdo, o_layout_compr);
        CHECK_MEMBER(obdo, o_padding_4);
        CHECK_MEMBER(obdo, o_padding_5);
        CHECK_MEMBER(obdo, o_padding_6);
@@ -3259,6 +3269,7 @@ main(int argc, char **argv)
        check_ptlrpc_body();
        check_obd_connect_data();
        check_ost_layout();
+       check_ost_layout_compr();
        check_obdo();
        check_lov_ost_data_v1();
        check_lov_mds_md_v1();
index dff601c..834bf30 100644 (file)
@@ -1316,6 +1316,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obd_connect_data, paddingF));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->paddingF) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->paddingF));
+
        LASSERTF(OBD_CONNECT_RDONLY == 0x1ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_RDONLY);
        LASSERTF(OBD_CONNECT_INDEX == 0x2ULL, "found 0x%.16llxULL\n",
@@ -1543,6 +1544,16 @@ void lustre_assert_wire_constants(void)
        LASSERTF((int)sizeof(((struct ost_layout *)0)->ol_comp_id) == 4, "found %lld\n",
                 (long long)(int)sizeof(((struct ost_layout *)0)->ol_comp_id));
 
+       /* Checks for struct ost_layout_compr */
+       LASSERTF((int)sizeof(struct ost_layout_compr) == 2, "found %lld\n",
+                (long long)(int)sizeof(struct ost_layout_compr));
+       LASSERTF((int)offsetof(struct ost_layout_compr, ol_compr_type) == 0, "found %lld\n",
+                (long long)(int)offsetof(struct ost_layout_compr, ol_compr_type));
+       LASSERTF((int)sizeof(((struct ost_layout_compr *)0)->ol_compr_type) == 1, "found %lld\n",
+                (long long)(int)sizeof(((struct ost_layout_compr *)0)->ol_compr_type));
+       /* ost_layout_compr.ol_compr_lvl is a bitfield and cannot be checked */
+       /* ost_layout_compr.ol_compr_chunk_log_bits is a bitfield and cannot be checked */
+
        /* Checks for struct obdo */
        LASSERTF((int)sizeof(struct obdo) == 208, "found %lld\n",
                 (long long)(int)sizeof(struct obdo));
@@ -1654,9 +1665,13 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obdo, o_projid));
        LASSERTF((int)sizeof(((struct obdo *)0)->o_projid) == 4, "found %lld\n",
                 (long long)(int)sizeof(((struct obdo *)0)->o_projid));
-       LASSERTF((int)offsetof(struct obdo, o_padding_4) == 188, "found %lld\n",
+       LASSERTF((int)offsetof(struct obdo, o_layout_compr) == 188, "found %lld\n",
+                (long long)(int)offsetof(struct obdo, o_layout_compr));
+       LASSERTF((int)sizeof(((struct obdo *)0)->o_layout_compr) == 2, "found %lld\n",
+                (long long)(int)sizeof(((struct obdo *)0)->o_layout_compr));
+       LASSERTF((int)offsetof(struct obdo, o_padding_4) == 190, "found %lld\n",
                 (long long)(int)offsetof(struct obdo, o_padding_4));
-       LASSERTF((int)sizeof(((struct obdo *)0)->o_padding_4) == 4, "found %lld\n",
+       LASSERTF((int)sizeof(((struct obdo *)0)->o_padding_4) == 2, "found %lld\n",
                 (long long)(int)sizeof(((struct obdo *)0)->o_padding_4));
        LASSERTF((int)offsetof(struct obdo, o_padding_5) == 192, "found %lld\n",
                 (long long)(int)offsetof(struct obdo, o_padding_5));