void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum);
void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum);
void lustre_swab_lov_comp_md_v1(struct lov_comp_md_v1 *lum);
+int lustre_check_lov_comp_md_v1(struct lov_comp_md_v1 *lum);
void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
int stripe_count);
void lustre_swab_lov_user_md(struct lov_user_md *lum, size_t size);
+int lustre_check_lov_user_md(struct lov_user_md *lum);
void lustre_swab_lov_mds_md(struct lov_mds_md *lmm);
void lustre_swab_idx_info(struct idx_info *ii);
void lustre_swab_lip_header(struct lu_idxpage *lip);
lustre_swab_lov_user_md(lum, 0);
}
+ rc = lustre_check_lov_user_md(lum);
+ if (rc < 0)
+ RETURN(rc);
+
ll_inode_size_lock(inode);
rc = ll_intent_file_open(dentry, lum, lum_size, &oit);
if (rc < 0)
ktime_t kstart = ktime_get();
int op_type = flags == XATTR_REPLACE ? LPROC_LL_REMOVEXATTR :
LPROC_LL_SETXATTR;
+ struct lov_user_md *lum = (struct lov_user_md *)value;
int rc;
LASSERT(inode);
/* lustre/trusted.lov.xxx would be passed through xattr API */
if (!strcmp(name, "lov")) {
- rc = ll_setstripe_ea(dentry, (struct lov_user_md *)value,
- size);
+ rc = ll_setstripe_ea(dentry, lum, size);
ll_stats_ops_tally(ll_i2sbi(inode), op_type,
ktime_us_delta(ktime_get(), kstart));
return rc;
return 0;
}
- if (strncmp(name, "lov.", 4) == 0 &&
- (__swab32(((struct lov_user_md *)value)->lmm_magic) &
- le32_to_cpu(LOV_MAGIC_MASK)) == le32_to_cpu(LOV_MAGIC_MAGIC))
- lustre_swab_lov_user_md((struct lov_user_md *)value, 0);
+ if (strncmp(name, "lov.", 4) == 0) {
+ if ((__swab32(lum->lmm_magic) & le32_to_cpu(LOV_MAGIC_MASK)) ==
+ le32_to_cpu(LOV_MAGIC_MAGIC))
+ lustre_swab_lov_user_md(lum, 0);
+
+ rc = lustre_check_lov_user_md(lum);
+ if (rc < 0)
+ return rc;
+ }
return ll_xattr_set_common(handler, mnt_userns, dentry, inode, name,
value, size, flags);
#include <lustre_lib.h>
#include "lov_internal.h"
-int llite_enable_compression;
-EXPORT_SYMBOL(llite_enable_compression);
-
static inline void
lu_extent_le_to_cpu(struct lu_extent *dst, const struct lu_extent *src)
{
#include "ptlrpc_internal.h"
+int llite_enable_compression;
+EXPORT_SYMBOL(llite_enable_compression);
+
static inline __u32 lustre_msg_hdr_size_v2(__u32 count)
{
return cfs_size_round(offsetof(struct lustre_msg_v2,
}
EXPORT_SYMBOL(lustre_swab_lov_comp_md_v1);
+int lustre_check_lov_comp_md_v1(struct lov_comp_md_v1 *lum)
+{
+ struct lov_comp_md_entry_v1 *ent;
+ int i;
+ int rc = 0;
+
+ for (i = 0; i < lum->lcm_entry_count; i++) {
+ ent = &lum->lcm_entries[i];
+ if (!llite_enable_compression &&
+ ent->lcme_compr_type != LL_COMPR_TYPE_NONE) {
+ return -ENOTSUPP;
+ }
+ }
+ return rc;
+}
+EXPORT_SYMBOL(lustre_check_lov_comp_md_v1);
+
+
void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
int stripe_count)
{
}
EXPORT_SYMBOL(lustre_swab_lov_user_md);
+int lustre_check_lov_user_md(struct lov_user_md *lum)
+{
+ int rc = 0;
+ switch (lum->lmm_magic) {
+ case LOV_USER_MAGIC_V1:
+ case LOV_USER_MAGIC_V3:
+ case LOV_USER_MAGIC_SPECIFIC:
+ case LOV_USER_MAGIC_FOREIGN:
+ break;
+ case LOV_USER_MAGIC_COMP_V1:
+ rc = lustre_check_lov_comp_md_v1((struct lov_comp_md_v1 *)lum);
+ break;
+ default:
+ CDEBUG(D_IOCTL, "Invalid LOV magic %08x\n", lum->lmm_magic);
+ }
+
+ return rc;
+}
+EXPORT_SYMBOL(lustre_check_lov_user_md);
+
void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
{
ENTRY;
}
}
run_test 100c "create compress file with improper compress arguments"
-export LFS_SETSTRIPE_COMPR_OK=""
test_100d() {
(( $MDS1_VERSION >= $(version_code 2.14.0.88) )) ||
}
run_test 100d "lfs find compress component"
+test_100e() {
+ (( $MDS1_VERSION >= $(version_code 2.14.0.88) )) ||
+ skip "Need MDS >= 2.14.0.88 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=0
+
+ test_mkdir $DIR/$tdir
+ $LFS setstripe -E1024 -Eeof -Z lz4:5 --compress-chunk=64 $tf &&
+ error "should not set compress file $tf"
+ local stripe_info=$($LFS getstripe $tf)
+ if ! grep -q "has no stripe info" <<< "$stripe_info" ; then
+ echo $stripe_info
+ error "$tf should has no stripe info"
+ fi
+ rm -f $tf || error "delete $tf failed"
+}
+run_test 100e "don't set compress file with llite.*.enable_compression=0"
+
+export LFS_SETSTRIPE_COMPR_OK=""
+
complete_test $SECONDS
check_and_cleanup_lustre
exit_status