.B %LS
File's stripe size. For a composite file, this is the stripe size of the last
instantiated component.
+.TP
+.B %LZ
+File's compression information in "<type>:<level>" format. For a
+composite file, this is the compression information of the last instantiated
+component.
.RE
.TP
.BR --projid
int llapi_layout_compress_set(struct llapi_layout *layout,
enum ll_compr_type type, int level,
__u32 chunk_size, unsigned long long stripe_size);
+int llapi_layout_compress_get(struct llapi_layout *layout,
+ __u8 *type, __u8 *level);
/******************** Extension Size ********************/
$LCTL set_param llite.*.enable_compression=1
test_mkdir $DIR/$tdir
- $LFS setstripe -N -Eeof -Z gzip -N -Eeof $tf ||
+ $LFS setstripe -N -Eeof -Z gzip -N -Eeof -Z none $tf ||
error "setstripe $tf failed"
#define OBD_FAIL_LOV_MIRROR_INIT 0x1425
cat $tf || error "read $tf failed"
local index=$($LCTL get_param fail_val -n)
- ((index == 1)) || error "should read 2nd mirror instead of $((index+1))"
+ ((index == 1)) || {
+ $LFS getstripe $tf
+ error "should read 2nd mirror instead of $((index+1))"
+ }
}
run_test 43c "read prefer uncompressed mirror"
test_mkdir $DIR/$tdir
## mirror 0 compressed
## mirror 1 uncompressed
- $LFS mirror create -N -Eeof -Z gzip -N -Eeof $tf ||
+ $LFS mirror create -N -Eeof -Z gzip -N -Eeof -Z none $tf ||
error "create 2 mirrors file $tf failed"
dd if=/dev/zero of=$tf bs=1M count=1 || error "failed to write $tf"
}
run_test 100e "don't set compress file with llite.*.enable_compression=0"
+test_100f() {
+ (( $MDS1_VERSION >= $(version_code 2.14.0.91) )) ||
+ skip "Need MDS >= 2.14.0.91 for compression support"
+
+ local tf=$DIR/$tdir/$tfile
+ local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+ save_lustre_params client "llite.*.enable_compression" > $p
+ stack_trap "rm -rf $DIR/$tdir; restore_lustre_params < $p" EXIT
+ $LCTL set_param llite.*.enable_compression=1
+
+ test_mkdir $DIR/$tdir
+ $LFS setstripe -E1M -Z gzip:1 -E4M -E6M -Z none -Eeof -Z gzip:4 $tf ||
+ error "setstripe $tf failed"
+
+
+ z1=$($LFS find -printf %LZ $tf)
+ [[ $z1 == "gzip:1" ]] || {
+ $LFS getstripe $tf
+ error "1st component compress info $z1 is not gzip:1"
+ }
+
+ dd if=/dev/zero of=$tf bs=1M count=2 || error "write $tf failed"
+ z2=$($LFS find -printf %LZ $tf)
+ [[ $z2 == "gzip:1" ]] || {
+ $LFS getstripe $tf
+ error "2nd component compress info $z2 is not gzip:1"
+ }
+
+ dd if=/dev/zero of=$tf bs=1M count=1 seek=4 || error "write $tf failed"
+ z3=$($LFS find -printf %LZ $tf)
+ [[ $z3 == "none:0" ]] || {
+ $LFS getstripe $tf
+ error "3rd component compress info $z3 is not none:0"
+ }
+
+ dd if=/dev/zero of=$tf bs=1M count=1 seek=6 || error "write $tf failed"
+ z4=$($LFS find -printf %LZ $tf)
+ [[ $z4 == "gzip:4" ]] || {
+ $LFS getstripe $tf
+ error "3rd component compress info $z4 is not gzip:4"
+ }
+}
+run_test 100f "lfs find -printf %LZ support"
+
export LFS_SETSTRIPE_COMPR_OK=""
complete_test $SECONDS
unsigned long long stripe_size;
long long stripe_count;
char *pool_name = NULL;
+ enum ll_compr_type compr_type;
+ int compr_lvl;
+ __u32 compr_chunk_size;
stripe_size = lsa->lsa_stripe_size;
stripe_count = lsa->lsa_stripe_count;
pool_name = lsa->lsa_pool_name;
+ compr_type = lsa->lsa_compr_type;
+ compr_lvl = lsa->lsa_compr_lvl;
+ compr_chunk_size = lsa->lsa_compr_chunk_size;
setstripe_args_init(lsa);
lsa->lsa_stripe_size = stripe_size;
lsa->lsa_stripe_count = stripe_count;
lsa->lsa_pool_name = pool_name;
+ lsa->lsa_compr_type = compr_type;
+ lsa->lsa_compr_lvl = compr_lvl;
+ lsa->lsa_compr_chunk_size = compr_chunk_size;
}
static inline bool setstripe_args_specified(struct lfs_setstripe_args *lsa)
/* Other formats for files/dirs need to be handled differently */
if (d == -1) { /* file */
- //layout = llapi_layout_get_by_xattr(¶m->fp_lmd->lmd_lmm,
- // param->fp_lum_size, 0);
- layout = llapi_layout_get_by_path(path, 0);
+ layout = llapi_layout_get_by_xattr(¶m->fp_lmd->lmd_lmm,
+ param->fp_lum_size, 0);
+ if (layout == NULL)
+ layout = llapi_layout_get_by_path(path, 0);
if (layout == NULL) {
llapi_error(LLAPI_MSG_ERROR, errno,
"error: cannot get file layout\n");
}
*wrote = snprintf(buffer, size, "%"PRIu64, str_size);
break;
+ case 'Z': { /* compression information */
+ __u8 type;
+ __u8 lvl;
+
+ err = llapi_layout_compress_get(layout, &type, &lvl);
+ if (err) {
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "error: cannot get compression information\n");
+ goto format_done;
+ }
+ *wrote = snprintf(buffer, size, "%s:%d",
+ compress_type_2str(type),
+ mapback_compress_level(type, lvl));
+ break;
+ }
default:
rc = 0;
break;
{
char *valid_fmt_single = "abcGkmnpstUwy%";
char *valid_fmt_double = "ACTW";
- char *valid_fmt_lustre = "cFhioPpS";
+ char *valid_fmt_lustre = "cFhioPpSZ";
char curr = *c, next;
if (curr == '\0') {
comp->llc_flags = ent->lcme_flags;
if (comp->llc_flags & LCME_FL_NOSYNC)
comp->llc_timestamp = ent->lcme_timestamp;
+ if (v1->lmm_pattern & LOV_PATTERN_COMPRESS) {
+ comp->llc_compr_type = ent->lcme_compr_type;
+ comp->llc_compr_lvl = ent->lcme_compr_lvl;
+ comp->llc_compr_chunk_log_bits =
+ ent->lcme_compr_chunk_log_bits;
+ }
} else {
comp->llc_extent.e_start = 0;
comp->llc_extent.e_end = LUSTRE_EOF;
return -1;
}
+int llapi_layout_compress_get(struct llapi_layout *layout,
+ __u8 *type, __u8 *level)
+{
+ struct llapi_layout_comp *comp;
+
+ comp = __llapi_layout_cur_comp(layout);
+ if (comp == NULL)
+ return -1;
+
+ if (type)
+ *type = comp->llc_compr_type;
+ if (level)
+ *level = comp->llc_compr_lvl;
+
+ return 0;
+}
+
/**
* Get the RAID pattern of \a layout.
*