+test_27I() {
+ [ $PARALLEL == "yes" ] && skip "skip parallel run"
+ [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+ local pool=$TESTNAME
+ local ostrange="1 1 1"
+
+ save_layout_restore_at_exit $MOUNT
+ $LFS setstripe -c 2 -i 0 $MOUNT
+ pool_add $pool || error "pool_add failed"
+ pool_add_targets $pool $ostrange || "pool_add_targets failed"
+ test_mkdir $DIR/$tdir
+ $LFS setstripe -p $pool $DIR/$tdir
+ $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
+ $LFS getstripe $DIR/$tdir/$tfile
+}
+run_test 27I "check that root dir striping does not break parent dir one"
+
+test_27J() {
+ [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.51) ]] &&
+ skip "Need MDS version newer than 2.12.51"
+
+ test_mkdir $DIR/$tdir
+ local uuid1=$(cat /proc/sys/kernel/random/uuid)
+ local uuid2=$(cat /proc/sys/kernel/random/uuid)
+
+ # create foreign file (raw way)
+ create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
+ -t 1 -F 0xda08 || error "create_foreign_file failed"
+
+ # verify foreign file (raw way)
+ parse_foreign_file -f $DIR/$tdir/$tfile |
+ grep "lov_foreign_magic: 0x0BD70BD0" ||
+ error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
+ parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
+ error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
+ parse_foreign_file -f $DIR/$tdir/$tfile |
+ grep "lov_foreign_size: 73" ||
+ error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
+ parse_foreign_file -f $DIR/$tdir/$tfile |
+ grep "lov_foreign_type: 1" ||
+ error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
+ parse_foreign_file -f $DIR/$tdir/$tfile |
+ grep "lov_foreign_flags: 0x0000DA08" ||
+ error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
+ local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
+ grep "lov_foreign_value: 0x" |
+ sed -e 's/lov_foreign_value: 0x//')
+ local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
+ [[ $lov = ${lov2// /} ]] ||
+ error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
+
+ # create foreign file (lfs + API)
+ $LFS setstripe --foreign=daos --flags 0xda08 \
+ -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
+ error "$DIR/$tdir/${tfile}2: create failed"
+
+ $LFS getstripe -v $DIR/$tdir/${tfile}2 |
+ grep "lfm_magic:.*0x0BD70BD0" ||
+ error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
+ # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
+ $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
+ error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
+ $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
+ error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
+ $LFS getstripe -v $DIR/$tdir/${tfile}2 |
+ grep "lfm_flags:.*0x0000DA08" ||
+ error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
+ $LFS getstripe $DIR/$tdir/${tfile}2 |
+ grep "lfm_value:.*${uuid1}@${uuid2}" ||
+ error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
+
+ # modify striping should fail
+ $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
+ error "$DIR/$tdir/$tfile: setstripe should fail"
+ $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
+ error "$DIR/$tdir/${tfile}2: setstripe should fail"
+
+ # R/W should fail
+ cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
+ cat $DIR/$tdir/${tfile}2 &&
+ error "$DIR/$tdir/${tfile}2: read should fail"
+ cat /etc/passwd > $DIR/$tdir/$tfile &&
+ error "$DIR/$tdir/$tfile: write should fail"
+ cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
+ error "$DIR/$tdir/${tfile}2: write should fail"
+
+ # chmod should work
+ chmod 222 $DIR/$tdir/$tfile ||
+ error "$DIR/$tdir/$tfile: chmod failed"
+ chmod 222 $DIR/$tdir/${tfile}2 ||
+ error "$DIR/$tdir/${tfile}2: chmod failed"
+
+ # chown should work
+ chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
+ error "$DIR/$tdir/$tfile: chown failed"
+ chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
+ error "$DIR/$tdir/${tfile}2: chown failed"
+
+ # rename should work
+ mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
+ error "$DIR/$tdir/$tfile: rename of foreign file has failed"
+ mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
+ error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
+
+ #remove foreign file
+ rm $DIR/$tdir/${tfile}.new ||
+ error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
+ rm $DIR/$tdir/${tfile}2.new ||
+ error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
+}
+run_test 27J "basic ops on file with foreign LOV"
+
+test_27K() {
+ [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.12.49) ]] &&
+ skip "Need MDS version newer than 2.12.49"
+
+ test_mkdir $DIR/$tdir
+ local uuid1=$(cat /proc/sys/kernel/random/uuid)
+ local uuid2=$(cat /proc/sys/kernel/random/uuid)
+
+ # create foreign dir (raw way)
+ create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
+ error "create_foreign_dir FAILED"
+
+ # verify foreign dir (raw way)
+ parse_foreign_dir -d $DIR/$tdir/$tdir |
+ grep "lmv_foreign_magic:.*0xcd50cd0" ||
+ error "$DIR/$tdir/$tfile: invalid LMV EA magic"
+ parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
+ error "$DIR/$tdir/$tdir: invalid LMV EA size"
+ parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
+ error "$DIR/$tdir/$tdir: invalid LMV EA type"
+ parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
+ error "$DIR/$tdir/$tdir: invalid LMV EA flags"
+ local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
+ grep "lmv_foreign_value: 0x" |
+ sed 's/lmv_foreign_value: 0x//')
+ local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
+ sed 's/ //g')
+ [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
+
+ # create foreign dir (lfs + API)
+ $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
+ $DIR/$tdir/${tdir}2 ||
+ error "$DIR/$tdir/${tdir}2: create failed"
+
+ $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
+ grep "lfm_magic:.*0x0CD50CD0" ||
+ error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
+ # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
+ # - sizeof(lfm_type) - sizeof(lfm_flags)
+ $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
+ error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
+ $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
+ error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
+ $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
+ grep "lfm_flags:.*0x0000DA05" ||
+ error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
+ $LFS getdirstripe $DIR/$tdir/${tdir}2 |
+ grep "lfm_value.*${uuid1}@${uuid2}" ||
+ error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
+
+ # file create in dir should fail
+ touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
+ touch $DIR/$tdir/${tdir}2/$tfile &&
+ "$DIR/${tdir}2: file create should fail"
+
+ # chmod should work
+ chmod 777 $DIR/$tdir/$tdir ||
+ error "$DIR/$tdir: chmod failed"
+ chmod 777 $DIR/$tdir/${tdir}2 ||
+ error "$DIR/${tdir}2: chmod failed"
+
+ # chown should work
+ chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
+ error "$DIR/$tdir: chown failed"
+ chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
+ error "$DIR/${tdir}2: chown failed"
+
+ # rename should work
+ mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
+ error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
+ mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
+ error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
+
+ #remove foreign dir
+ rmdir $DIR/$tdir/${tdir}.new ||
+ error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
+ rmdir $DIR/$tdir/${tdir}2.new ||
+ error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
+}
+run_test 27K "basic ops on dir with foreign LMV"
+
+test_27L() {
+ remote_mds_nodsh && skip "remote MDS with nodsh"
+
+ local POOL=${POOL:-$TESTNAME}
+
+ if ! combined_mgs_mds ; then
+ mount_mgs_client
+ trap umount_mgs_client EXIT
+ fi
+
+ pool_add $POOL || error "pool_add failed"
+
+ lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
+ error "pool_list does not contain ${FSNAME}.${POOL}:" \
+ "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
+}
+run_test 27L "lfs pool_list gives correct pool name"
+