Whamcloud - gitweb
EX-6269 csdc: tune allowed compression type on server
authorBobi Jam <bobijam@whamcloud.com>
Thu, 7 Sep 2023 09:29:42 +0000 (17:29 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 13 Jan 2024 02:44:51 +0000 (02:44 +0000)
Use lctl get_param {mdt|obdfiler}.*.compress_types to list supported
compression types on server.

Use lctl set_param {mdt|obdfilter}.*.compress_types="+gzip-lzo" to
add gzip to and delete lzo from existing compression types on server.

Server will negotiate supported compression types with client in
ocd_compress_types and client import stats could show the negotiated
supported compression types in "lctl get_param {mdc|odc}.*.import"
connect_data section:

import:
  ....
  connect_data:
     ....
     compress_types: [ fast,best,gzip,lz4fast,lz4hc,lzo ]

The OST support for the connect flags is enabled in this patch, but
MDT enabling is pending unaligned compression support for DoM files.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I18943352e25ed9d5fe82442df9f00a7ef388f242
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52307
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
18 files changed:
libcfs/include/libcfs/libcfs_string.h
libcfs/libcfs/libcfs_string.c
lustre/include/lu_target.h
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/llite/llite_lib.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_lproc.c
lustre/obdclass/lprocfs_status.c
lustre/ofd/lproc_ofd.c
lustre/ofd/ofd_obd.c
lustre/osc/osc_request.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/wiretest.c
lustre/target/tgt_main.c
lustre/tests/sanity-compr.sh
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index c99ccef..3d946d0 100644 (file)
@@ -44,6 +44,8 @@ char *cfs_strrstr(const char *haystack, const char *needle);
 /* Convert a text string to a bitmask */
 int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
                 int *oldmask, int minmask, int allmask, int defmask);
+int cfs_str2mask64(const char *str, const char *(*bit2str)(int bit),
+                  __u64 *oldmask, __u64 minmask, __u64 allmask, __u64 defmask);
 /* trim leading and trailing space characters */
 char *cfs_firststr(char *str, size_t size);
 
index 0e80698..7963181 100644 (file)
@@ -67,13 +67,14 @@ char *cfs_strrstr(const char *haystack, const char *needle)
 }
 EXPORT_SYMBOL(cfs_strrstr);
 
-/* Convert a text string to a bitmask */
-int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
-                int *oldmask, int minmask, int allmask, int defmask)
+/* Convert a text string to a 64bit-mask */
+int cfs_str2mask64(const char *str, const char *(*bit2str)(int bit),
+                __u64 *oldmask, __u64 minmask, __u64 allmask, __u64 defmask)
 {
        const char *debugstr;
        char op = 0;
-       int newmask = minmask, i, len, found = 0;
+       __u64 newmask = minmask;
+       int i, len, found = 0;
 
        ENTRY;
        /* <str> must be a list of tokens separated by whitespace or comma,
@@ -105,7 +106,7 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
 
                /* match token */
                found = 0;
-               for (i = 0; i < 32; i++) {
+               for (i = 0; i < 64; i++) {
                        debugstr = bit2str(i);
                        if (debugstr != NULL &&
                            strlen(debugstr) == len &&
@@ -146,6 +147,24 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
        *oldmask = newmask;
        return 0;
 }
+EXPORT_SYMBOL(cfs_str2mask64);
+
+/* Convert a text string to a bitmask */
+int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
+                int *oldmask, int minmask, int allmask, int defmask)
+{
+       __u64 old = *oldmask;
+       __u64 min = minmask;
+       __u64 all = allmask;
+       __u64 def = defmask;
+       int rc;
+
+       rc = cfs_str2mask64(str, bit2str, &old, min, all, def);
+       if (rc == 0)
+               *oldmask = (int)old;
+
+       return rc;
+}
 EXPORT_SYMBOL(cfs_str2mask);
 
 /* get the first string out of @str */
index 104ce1c..24d31ea 100644 (file)
@@ -178,6 +178,8 @@ struct lu_target {
                                 lut_no_create:1;
        /* checksum types supported on this node */
        enum cksum_types         lut_cksum_types_supported;
+       /* compression types supported on this node */
+       __u64                    lut_compress_types_supported;
        /** last_rcvd file */
        struct dt_object        *lut_last_rcvd;
        /* transaction callbacks */
index 3cef00e..f840eef 100644 (file)
@@ -961,7 +961,8 @@ struct ptlrpc_body_v2 {
 
 #define OST_CONNECT_SUPPORTED2 (OBD_CONNECT2_LOCKAHEAD | OBD_CONNECT2_INC_XID |\
                                OBD_CONNECT2_ENCRYPT | OBD_CONNECT2_LSEEK | \
-                               OBD_CONNECT2_REPLAY_CREATE)
+                               OBD_CONNECT2_REPLAY_CREATE | \
+                               OBD_CONNECT2_COMPRESS)
 
 #define ECHO_CONNECT_SUPPORTED (OBD_CONNECT_FID)
 #define ECHO_CONNECT_SUPPORTED2 0
@@ -1007,7 +1008,7 @@ struct obd_connect_data {
        __u16 padding0;          /* READ BELOW! also fix lustre_swab_connect */
        __u32 padding1;          /* READ BELOW! also fix lustre_swab_connect */
        __u64 ocd_connect_flags2;/* OBD_CONNECT2_* per above */
-       __u64 ocd_compr_type;    /* bitmask of supported compression types */
+       __u64 ocd_compress_types;/* bitmask of supported compression types */
        __u64 padding4;          /* READ BELOW! also fix lustre_swab_connect */
        __u64 padding5;          /* READ BELOW! also fix lustre_swab_connect */
        __u64 padding6;          /* READ BELOW! also fix lustre_swab_connect */
@@ -1066,6 +1067,39 @@ enum cksum_types {
 #define OBD_CKSUM_T10_TOP OBD_CKSUM_ADLER
 
 /*
+ * Supported compression algorithms. Up to 64 compression types are supported.
+ */
+#define COMPRESS_TYPE_TO_BIT(ll_compr_type)                            \
+               ((ll_compr_type == LL_COMPR_TYPE_NONE) ? 0 :            \
+                (1U << ((ll_compr_type) - 1)))
+#define COMPRESS_TYPE_MAX_BIT  (LL_COMPR_TYPE_MAX - 1)
+
+enum obd_compress_types {
+       OBD_COMPR_NONE          = 0,
+       OBD_COMPR_FAST          = COMPRESS_TYPE_TO_BIT(LL_COMPR_TYPE_FAST),
+       OBD_COMPR_BEST          = COMPRESS_TYPE_TO_BIT(LL_COMPR_TYPE_BEST),
+       OBD_COMPR_GZIP          = COMPRESS_TYPE_TO_BIT(LL_COMPR_TYPE_GZIP),
+       OBD_COMPR_LZ4FAST       = COMPRESS_TYPE_TO_BIT(LL_COMPR_TYPE_LZ4FAST),
+       OBD_COMPR_LZ4HC         = COMPRESS_TYPE_TO_BIT(LL_COMPR_TYPE_LZ4HC),
+       OBD_COMPR_LZO           = COMPRESS_TYPE_TO_BIT(LL_COMPR_TYPE_LZO),
+       OBD_COMPR_ALL           = OBD_COMPR_FAST | OBD_COMPR_BEST |
+                                 OBD_COMPR_GZIP | OBD_COMPR_LZ4FAST |
+                                 OBD_COMPR_LZ4HC | OBD_COMPR_LZO
+};
+
+#define COMPRESS_NAMES { "fast", "best", "gzip", "lz4fast", "lz4hc", "lzo" }
+
+static inline const char *compress_type2str(int type_bit)
+{
+       static const char *const compress_name[] = COMPRESS_NAMES;
+
+       if (type_bit >= COMPRESS_TYPE_MAX_BIT)
+               return NULL;
+
+       return compress_name[type_bit];
+}
+
+/*
  *   OST requests: OBDO & OBD request records
  */
 
index be5c9da..4e4badc 100644 (file)
@@ -2959,7 +2959,8 @@ struct fid_array {
 #define OBD_MAX_FIDS_IN_ARRAY  4096
 
 /**
- * component compress algorithm type
+ * component compress algorithm type, remember to update obd_compress_types
+ * and COMPRESS_NAMES accordingly
  */
 enum ll_compr_type {
        LL_COMPR_TYPE_NONE      = 0,
index f2cef2b..2d8a988 100644 (file)
@@ -528,7 +528,8 @@ retry_connect:
                                  OBD_CONNECT_BULK_MBITS | OBD_CONNECT_SHORTIO |
                                  OBD_CONNECT_FLAGS2 | OBD_CONNECT_GRANT_SHRINK;
        data->ocd_connect_flags2 = OBD_CONNECT2_LOCKAHEAD |
-                                  OBD_CONNECT2_INC_XID | OBD_CONNECT2_LSEEK;
+                                  OBD_CONNECT2_INC_XID | OBD_CONNECT2_LSEEK |
+                                  OBD_CONNECT2_COMPRESS;
 
        if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_GRANT_PARAM))
                data->ocd_connect_flags |= OBD_CONNECT_GRANT_PARAM;
@@ -544,6 +545,7 @@ retry_connect:
                data->ocd_cksum_types = OBD_CKSUM_ADLER;
        else
                data->ocd_cksum_types = obd_cksum_types_supported_client();
+       data->ocd_compress_types = OBD_COMPR_ALL;
 
 #ifdef HAVE_LRU_RESIZE_SUPPORT
        data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
index afc256f..c5439c2 100644 (file)
@@ -6721,6 +6721,10 @@ static int mdt_connect_internal(const struct lu_env *env,
                       exp->exp_obd->obd_name, obd_export_nid2str(exp));
        }
 
+       if (OCD_HAS_FLAG2(data, COMPRESS))
+               data->ocd_compress_types &=
+                               mdt->mdt_lut.lut_compress_types_supported;
+
        if ((data->ocd_connect_flags & OBD_CONNECT_MDS_MDS) &&
            !(data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT)) {
                atomic_inc(&mdt->mdt_mds_mds_conns);
index 5ee90b1..982038b 100644 (file)
@@ -1302,6 +1302,62 @@ ssize_t job_xattr_store(struct kobject *kobj, struct attribute *attr,
 
 LPROC_SEQ_FOPS_RO(mdt_checksum_type);
 
+/*
+ * mdt_compress_types(server) proc handling
+ */
+static int mdt_compress_types_seq_show(struct seq_file *m, void *data)
+{
+       struct obd_device *obd = m->private;
+       struct lu_target *lut;
+       bool first = true;
+       int i;
+
+       if (!obd)
+               return 0;
+
+       lut = obd->u.obt.obt_lut;
+
+       for (i = 0; i < COMPRESS_TYPE_MAX_BIT; i++) {
+               if ((BIT(i) & lut->lut_compress_types_supported) == 0)
+                       continue;
+
+               seq_printf(m, "%s%s", first ? "" : ",", compress_type2str(i));
+               first = false;
+       }
+       seq_puts(m, "\n");
+
+       return 0;
+}
+
+static ssize_t mdt_compress_types_seq_write(struct file *file,
+                                           const char __user *buffer,
+                                           size_t count, loff_t *off)
+{
+       struct seq_file *seq = file->private_data;
+       struct obd_device *obd = seq->private;
+       struct lu_target *lut;
+       char *kbuf;
+       int rc = 0;
+
+       lut = obd->u.obt.obt_lut;
+
+       OBD_ALLOC(kbuf, count + 1);
+       if (kbuf == NULL)
+               return -ENOMEM;
+
+       if (copy_from_user(kbuf, buffer, count))
+               GOTO(out, rc = -EFAULT);
+       kbuf[count] = 0;
+
+       rc = cfs_str2mask64(kbuf, compress_type2str,
+                           &lut->lut_compress_types_supported, 0, ~0, ~0);
+
+out:
+       OBD_FREE(kbuf, count + 1);
+       return rc < 0 ? rc : count;
+}
+LPROC_SEQ_FOPS(mdt_compress_types);
+
 LPROC_SEQ_FOPS_RO_TYPE(mdt, hash);
 LPROC_SEQ_FOPS_WR_ONLY(mdt, mds_evict_client);
 LPROC_SEQ_FOPS_RW_TYPE(mdt, checksum_dump);
@@ -1394,6 +1450,8 @@ static struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
          .fops =       &mdt_nosquash_nids_fops                 },
        { .name =       "checksum_type",
          .fops =       &mdt_checksum_type_fops                 },
+       { .name =       "compress_types",
+         .fops =       &mdt_compress_types_fops                },
        { NULL }
 };
 
index 4df7d85..9a15590 100644 (file)
@@ -558,6 +558,20 @@ static void obd_import_flags2str(struct obd_import *imp, struct seq_file *m)
        flag2str(imp, connect_tried);
 }
 
+static void obd_compress_type2str(struct seq_file *m, __u64 compress_types)
+{
+       bool first = true;
+       int i;
+
+       for (i = 0; i < COMPRESS_TYPE_MAX_BIT; i++) {
+               if ((BIT(i) & compress_types)) {
+                       seq_printf(m, "%s%s",
+                                  first ? "" : ",", compress_type2str(i));
+                       first = false;
+               }
+       }
+}
+
 static const char *const obd_connect_names[] = {
        "read_only",                    /* 0x01 */
        "lov_index",                    /* 0x02 */
@@ -740,9 +754,11 @@ void
 obd_connect_data_seqprint(struct seq_file *m, struct obd_connect_data *ocd)
 {
        __u64 flags;
+       __u64 flags2;
 
        LASSERT(ocd != NULL);
        flags = ocd->ocd_connect_flags;
+       flags2 = ocd->ocd_connect_flags2;
 
        seq_printf(m, "    connect_data:\n"
                   "       flags: %#llx\n"
@@ -781,6 +797,11 @@ obd_connect_data_seqprint(struct seq_file *m, struct obd_connect_data *ocd)
        if (flags & OBD_CONNECT_CKSUM)
                seq_printf(m, "       cksum_types: %#x\n",
                           ocd->ocd_cksum_types);
+       if (flags2 & OBD_CONNECT2_COMPRESS) {
+               seq_printf(m, "       compress_types: [ ");
+               obd_compress_type2str(m, ocd->ocd_compress_types);
+               seq_printf(m, " ]\n");
+       }
        if (flags & OBD_CONNECT_MAX_EASIZE)
                seq_printf(m, "       max_easize: %d\n", ocd->ocd_max_easize);
        if (flags & OBD_CONNECT_MAXBYTES)
index 0940c1c..f9fafc0 100644 (file)
@@ -517,6 +517,60 @@ static int ofd_checksum_type_seq_show(struct seq_file *m, void *data)
 
 LPROC_SEQ_FOPS_RO(ofd_checksum_type);
 
+/*
+ * ofd_compress_types(server) proc handling
+ */
+static int ofd_compress_types_seq_show(struct seq_file *m, void *data)
+{
+       struct obd_device *obd = m->private;
+       struct lu_target *lut;
+       bool first = true;
+       int i;
+
+       if (!obd)
+               return 0;
+
+       lut = obd->u.obt.obt_lut;
+
+       for (i = 0; i < COMPRESS_TYPE_MAX_BIT; i++) {
+               if ((BIT(i) & lut->lut_compress_types_supported) == 0)
+                       continue;
+
+               seq_printf(m, "%s%s", first ? "" : ",", compress_type2str(i));
+               first = false;
+       }
+       seq_puts(m, "\n");
+
+       return 0;
+}
+
+static ssize_t ofd_compress_types_seq_write(struct file *file,
+                                           const char __user *buffer,
+                                           size_t count, loff_t *off)
+{
+       struct seq_file *seq = file->private_data;
+       struct obd_device *obd = seq->private;
+       struct lu_target *lut;
+       char *kbuf;
+       int rc = 0;
+
+       lut = obd->u.obt.obt_lut;
+
+       OBD_ALLOC(kbuf, count + 1);
+       if (kbuf == NULL)
+               return -ENOMEM;
+
+       if (copy_from_user(kbuf, buffer, count))
+               GOTO(out, rc = -EFAULT);
+       kbuf[count] = 0;
+
+       rc = cfs_str2mask64(kbuf, compress_type2str,
+                           &lut->lut_compress_types_supported, 0, ~0, ~0);
+out:
+       OBD_FREE(kbuf, count + 1);
+       return rc < 0 ? rc : count;
+}
+LPROC_SEQ_FOPS(ofd_compress_types);
 
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
 static ssize_t sync_on_lock_cancel_show(struct kobject *kobj,
@@ -1053,6 +1107,8 @@ struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
          .fops =       &ofd_site_stats_fops            },
        { .name =       "checksum_type",
          .fops =       &ofd_checksum_type_fops         },
+       { .name =       "compress_types",
+         .fops =       &ofd_compress_types_fops        },
        { NULL }
 };
 
index 16acfa7..e2dffb0 100644 (file)
@@ -258,6 +258,10 @@ static int ofd_parse_connect_data(const struct lu_env *env,
                       exp->exp_obd->obd_name, obd_export_nid2str(exp));
        }
 
+       if (OCD_HAS_FLAG2(data, COMPRESS))
+               data->ocd_compress_types &=
+                               ofd->ofd_lut.lut_compress_types_supported;
+
        if (data->ocd_connect_flags & OBD_CONNECT_MAXBYTES)
                data->ocd_maxbytes = ofd->ofd_lut.lut_dt_conf.ddp_maxbytes;
 
index 624aa90..11a8ad9 100644 (file)
@@ -1520,7 +1520,7 @@ osc_brw_prep_request(int cmd, struct client_obd *cli, struct obdo *oa,
        struct req_capsule *pill;
        struct brw_page *pg_prev;
        struct obd_ioobj *ioobj;
-       struct cl_page *clpage;
+       struct cl_page *clpage = NULL;
        struct ost_body *body;
        const char *obd_name = cli->cl_import->imp_obd->obd_name;
        bool page_access_allowed = true;
@@ -1608,11 +1608,26 @@ osc_brw_prep_request(int cmd, struct client_obd *cli, struct obdo *oa,
                RETURN(-EINVAL);
 
        if (opc == OST_WRITE && compressed) {
+               struct obd_connect_data *ocd =
+                       &cli->cl_import->imp_connect_data;
                struct brw_page **cpga = NULL;
                __u64 kms = -1;
 
                clpage = oap2cl_page(oap);
 
+               /**
+                * if server now does not support certain compression algorithm
+                * which is supposed to be used in this file chunk, try
+                * FAST compression type.
+                */
+               if ((COMPRESS_TYPE_TO_BIT(clpage->cp_comp_type) &
+                    ocd->ocd_compress_types) == 0) {
+                       for (i = 0; i < page_count; i++) {
+                               clpage = oap2cl_page(brw_page2oap(pga[i]));
+                               clpage->cp_comp_type = LL_COMPR_TYPE_FAST;
+                       }
+               }
+
                /* if a write is beyond the current known minimum size, we
                 * know there is no data in the chunk, so no possibility of
                 * read-modify write.  this means we can compress that chunk
index 6c76d37..178a3c8 100644 (file)
@@ -1784,7 +1784,7 @@ void lustre_swab_connect(struct obd_connect_data *ocd)
        if (ocd->ocd_connect_flags & OBD_CONNECT_FLAGS2) {
                __swab64s(&ocd->ocd_connect_flags2);
                if (ocd->ocd_connect_flags2 & OBD_CONNECT2_COMPRESS)
-                       __swab64s(&ocd->ocd_compr_type);
+                       __swab64s(&ocd->ocd_compress_types);
        }
        BUILD_BUG_ON(offsetof(typeof(*ocd), padding4) == 0);
        BUILD_BUG_ON(offsetof(typeof(*ocd), padding5) == 0);
index 3fac4c1..c04cc26 100644 (file)
@@ -1229,10 +1229,10 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obd_connect_data, ocd_connect_flags2));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_connect_flags2) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_connect_flags2));
-       LASSERTF((int)offsetof(struct obd_connect_data, ocd_compr_type) == 88, "found %lld\n",
-                (long long)(int)offsetof(struct obd_connect_data, ocd_compr_type));
-       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_compr_type) == 8, "found %lld\n",
-                (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_compr_type));
+       LASSERTF((int)offsetof(struct obd_connect_data, ocd_compress_types) == 88, "found %lld\n",
+                (long long)(int)offsetof(struct obd_connect_data, ocd_compress_types));
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_compress_types) == 8, "found %lld\n",
+                (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_compress_types));
        LASSERTF((int)offsetof(struct obd_connect_data, padding4) == 96, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding4));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding4) == 8, "found %lld\n",
index 7009020..b6ee1d6 100644 (file)
@@ -509,6 +509,7 @@ int tgt_init(const struct lu_env *env, struct lu_target *lut,
        lut->lut_cksum_t10pi_enforce = 0;
        lut->lut_cksum_types_supported =
                obd_cksum_types_supported_server(obd->obd_name);
+       lut->lut_compress_types_supported = OBD_COMPR_ALL;
 
        spin_lock_init(&lut->lut_slc_locks_guard);
        INIT_LIST_HEAD(&lut->lut_slc_locks);
index 6112f57..2e9ae08 100644 (file)
@@ -35,6 +35,91 @@ save_layout_restore_at_exit $MOUNT
 # Set file system with different layout
 COMPR_EXTRA_LAYOUT=${COMPR_EXTRA_LAYOUT:-"-E EOF -c 1"}
 $LFS setstripe $COMPR_EXTRA_LAYOUT $MOUNT
+ALWAYS_EXCEPT_SAVE=$ALWAYS_EXCEPT
+
+test_0a() {
+       local types_save=($(do_facet ost1 \
+                           $LCTL get_param -n obdfilter.*.compress_types))
+
+       [[ -n "$types_save" ]] || skip "no OST support for compress_types"
+       stack_trap "do_facet ost1 \
+                   $LCTL set_param obdfilter.*.compress_types='$types_save'"
+
+       echo " ** add gzip, delete lzo compression type on OST"
+       do_facet ost1 $LCTL set_param obdfilter.*.compress_types=+gzip-lzo
+
+       # remount client to get new compression types from OSS
+       umount_client $MOUNT
+       mount_client $MOUNT
+
+       local types=$($LCTL get_param -n osc.*.import | grep compress_types)
+       [[ -n "$types" ]] || {
+               do_facet ost1 $LCTL get_param obdfilter.*.compress_types
+               echo $types
+               error "cannot find any compress support on client"
+       }
+
+       [[ "$types" =~ "gzip" ]] || {
+               do_facet ost1 $LCTL get_param obdfilter.*.compress_types
+               echo $types
+               error "cannot find gzip compress support on client"
+       }
+
+       [[ "$types" =~ "lzo" ]] && {
+               do_facet ost1 $LCTL get_param obdfilter.*.compress_types
+               echo $types
+               error "should not have lzo compress support on client"
+       }
+
+       do_facet ost1 $LCTL set_param obdfilter.*.compress_types='$types_save'
+       # need to remount to allow client to use all compression types
+       umount_client $MOUNT
+       mount_client $MOUNT
+}
+run_test 0a "compression types negotiation between client and OST"
+
+test_0b() {
+       local types_save=($(do_facet mds1 \
+                           $LCTL get_param -n mdt.*.compress_types))
+
+       skip "MDT support for compression connect flags is disabled for now"
+
+       [[ -n "$types_save" ]] || skip "no MDT support for compress_types"
+       stack_trap "do_facet mds1 \
+                   $LCTL set_param mdt.*.compress_types='$types_save'"
+
+       echo " ** add gzip, delete lzo compression type on MDT"
+       do_facet mds1 $LCTL set_param mdt.*.compress_types=+gzip-lzo
+
+       # remount client to get new compression types from MDS
+       umount_client $MOUNT
+       mount_client $MOUNT
+
+       local types=$($LCTL get_param -n mdc.*.import | grep compress_types)
+       [[ -n "$types" ]] || {
+               do_facet mds1 $LCTL get_param obdfilter.*.compress_types
+               echo $types
+               error "cannot find any compress support on client"
+       }
+
+       [[ "$types" =~ "gzip" ]] || {
+               do_facet mds1 $LCTL get_param obdfilter.*.compress_types
+               echo $types
+               error "cannot find gzip compress support on client"
+       }
+
+       [[ "$types" =~ "lzo" ]] && {
+               do_facet mds1 $LCTL get_param obdfilter.*.compress_types
+               echo $types
+               error "should not have lzo compress support on client"
+       }
+
+       do_facet mds1 $LCTL set_param mdt.*.compress_types='$types_save'
+       # need to remount to allow client to use all compression types
+       umount_client $MOUNT
+       mount_client $MOUNT
+}
+run_test 0b "compression types negotiation between client and MDT"
 
 test_sanity()
 {
index f7cc11b..56c6295 100644 (file)
@@ -579,7 +579,7 @@ check_obd_connect_data(void)
        CHECK_MEMBER(obd_connect_data, padding0);
        CHECK_MEMBER(obd_connect_data, padding1);
        CHECK_MEMBER(obd_connect_data, ocd_connect_flags2);
-       CHECK_MEMBER(obd_connect_data, ocd_compr_type);
+       CHECK_MEMBER(obd_connect_data, ocd_compress_types);
        CHECK_MEMBER(obd_connect_data, padding4);
        CHECK_MEMBER(obd_connect_data, padding5);
        CHECK_MEMBER(obd_connect_data, padding6);
index ea9505c..f387f3b 100644 (file)
@@ -1265,10 +1265,10 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct obd_connect_data, ocd_connect_flags2));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_connect_flags2) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_connect_flags2));
-       LASSERTF((int)offsetof(struct obd_connect_data, ocd_compr_type) == 88, "found %lld\n",
-                (long long)(int)offsetof(struct obd_connect_data, ocd_compr_type));
-       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_compr_type) == 8, "found %lld\n",
-                (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_compr_type));
+       LASSERTF((int)offsetof(struct obd_connect_data, ocd_compress_types) == 88, "found %lld\n",
+                (long long)(int)offsetof(struct obd_connect_data, ocd_compress_types));
+       LASSERTF((int)sizeof(((struct obd_connect_data *)0)->ocd_compress_types) == 8, "found %lld\n",
+                (long long)(int)sizeof(((struct obd_connect_data *)0)->ocd_compress_types));
        LASSERTF((int)offsetof(struct obd_connect_data, padding4) == 96, "found %lld\n",
                 (long long)(int)offsetof(struct obd_connect_data, padding4));
        LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding4) == 8, "found %lld\n",