export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
ONLY=${ONLY:-"$*"}
-# Bug number for skipped test:
+# Bug number for skipped test: LU-11381
ALWAYS_EXCEPT="$SANITY_FLR_EXCEPT 201"
# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
. $LUSTRE/tests/test-framework.sh
init_test_env $@
. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+get_lustre_env
init_logging
[[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
build_test_filter
+assert_DIR
+rm -rf $DIR/[Rdfs][0-9]*
+
# global array to store mirror IDs
declare -a mirror_array
get_mirror_ids() {
done
for idx in "$@"; do
- wait_osc_import_state client ost$idx DISCONN
+ wait_osc_import_state client ost$idx "\(DISCONN\|IDLE\)"
done
}
done
for idx in "$@"; do
- wait_osc_import_state client ost$idx FULL
+ wait_recovery_complete ost$idx
done
}
verify_mirror_count() {
local tf=$1
local expected=$2
- local mirror_count=$(get_mirror_ids $tf)
+ local mirror_count=$($LFS getstripe -N $tf)
[[ $mirror_count = $expected ]] || {
$LFS getstripe -v $tf
local fl
local expected_list=$(comma_list $expected)
for fl in ${expected_list//,/ }; do
- echo $value | grep -q $fl || {
+ local neg=0
+
+ [[ ${fl:0:1} = "^" ]] && neg=1
+ [[ $neg = 1 ]] && fl=${fl:1}
+
+ $(echo $value | grep -q $fl)
+ local match=$?
+ # 0: matched; 1: not matched
+
+ if [[ $neg = 0 && $match != 0 ||
+ $neg = 1 && $match = 0 ]]; then
$getstripe_cmd $tf
- error "expected flag $fl existing on $comp_id"
- }
+ [[ $neg = 0 ]] && # expect the flag
+ error "expected flag '$fl' not in $comp_id"
+ [[ $neg = 1 ]] && # not expect the flag
+ error "not expected flag '$fl' in $comp_id"
+ fi
done
return
}
test_0g() {
local tf=$DIR/$tfile
- $LFS mirror create -N -E 1M -o0 --flags=prefer -E eof -o1 -N -o1 $tf ||
- error "create mirrored file $tf failed"
+ $LFS mirror create -N -E 1M -S 1M -o0 --flags=prefer -E eof -o1 \
+ -N -o1 $tf || error "create mirrored file $tf failed"
verify_comp_attr lcme_flags $tf 0x10001 prefer
verify_comp_attr lcme_flags $tf 0x10002 prefer
cat $tf &> /dev/null || error "error reading file '$tf'"
# verify that the data was provided by OST1 where mirror 1 resides
- local nr_read=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-ffff*.stats |
+ local nr_read=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[-0-9a-f]*.stats |
awk '/ost_read/{print $2}')
[ -n "$nr_read" ] || error "read was not provided by OST1"
}
run_test 0g "lfs mirror create flags support"
test_0h() {
- local tf=$DIR/$tfile
+ [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
+ skip "Need MDS version at least 2.11.57"
- $LFS mirror create -N -E 1M --flags=prefer -E eof -N2 $tf ||
- error "create mirrored file $tf failed"
+ local td=$DIR/$tdir
+ local tf=$td/$tfile
+ local ids
+ local i
+
+ # create parent directory
+ test_mkdir $td || error "mkdir $td failed"
+
+ $LFS setstripe -N -E 1M -S 1M --flags=prefer -E eof -N2 $td ||
+ error "set default mirrored layout on directory $td failed"
+
+ # verify flags are inherited from the directory
+ touch $tf
verify_comp_attr lcme_flags $tf 0x10001 prefer
verify_comp_attr lcme_flags $tf 0x10002 prefer
local tf=$DIR/$tfile
local tf2=$DIR/$tfile-2
- $LFS setstripe -E 1M -E EOF -c 1 $tf
- $LFS setstripe -E 2M -E EOF -c -1 $tf2
-
- local layout=$($LFS getstripe $tf2 | grep -A 4 lmm_objects)
+ $LFS setstripe -E 1M -S 1M -E EOF -c 1 $tf
+ $LFS setstripe -E 2M -S 1M -E EOF -c -1 $tf2
$LFS mirror extend -N -f $tf2 $tf ||
error "merging $tf2 into $tf failed"
test_mkdir $DIR/$tdir
# set mirror with setstripe options to directory
- $LFS mirror create -N2 -E 1M -E eof $DIR/$tdir ||
+ $LFS mirror create -N2 -E 1M -S 1M -E eof $DIR/$tdir ||
error "set mirror to directory error"
[ x$($LFS getstripe -v $DIR/$tdir | awk '/lcm_flags/{print $2}') = \
test_6() {
local tf=$DIR/$tfile
- $LFS mirror create -N -E 1M -L mdt -E eof -N -E eof $tf &&
+ $LFS mirror create -N -E 1M -S 1M -L mdt -E eof -N -E eof $tf &&
error "expect failure to create mirrored file with DoM"
- $LFS mirror create -N -E 1M -E eof -N -E 1M -L mdt -E eof $tf &&
+ $LFS mirror create -N -E 1M -S 1M -E eof -N -E 1M -L mdt -E eof $tf &&
error "expect failure to create mirrored file with DoM"
- $LFS setstripe -E 1M -L mdt -E eof $tf
+ $LFS setstripe -E 1M -S 1M -L mdt -E eof $tf
$LFS mirror extend -N2 $tf &&
error "expect failure to extend mirror with DoM"
- $LFS mirror create -N2 -E 1M -E eof $tf-2
+ $LFS mirror create -N2 -E 1M -S 1M -E eof $tf-2
$LFS mirror extend -N -f $tf $tf-2 &&
error "expect failure to extend mirrored file with DoM extent"
local osc_name
local count
- osc_name=${FSNAME}-OST$(printf "%04x" $((idx-1)))-osc-'ffff*'
+ osc_name=${FSNAME}-OST$(printf "%04x" $((idx-1)))-osc-'[-0-9a-f]*'
count=$($LCTL get_param -n ldlm.namespaces.$osc_name.lock_count)
lock_count=$((lock_count + count))
done
error "extending mirrored file $DIR/$tfile failed"
# make sure the mirrored file was created successfully
- [ $(get_mirror_ids $DIR/$tfile) -eq 2 ] ||
+ [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
{ $LFS getstripe $DIR/$tfile; error "expected 2 mirrors"; }
drop_client_cache
"without verification failed"
# make sure that $tfile has two mirrors and $tfile-2 does not exist
- [ $(get_mirror_ids $DIR/$tfile) -eq 2 ] ||
+ [ $($LFS getstripe -N $DIR/$tfile) -eq 2 ] ||
{ $LFS getstripe $DIR/$tfile; error "expected count 2"; }
[[ ! -e $DIR/$tfile-2 ]] || error "$DIR/$tfile-2 was not unlinked"
start_osts 1
# read file again with ost2 failed
- $LCTL set_param ldlm.namespaces.lustre-*-osc-ffff*.lru_size=clear
+ $LCTL set_param ldlm.namespaces.lustre-*-osc-[-0-9a-f]*.lru_size=clear
fail ost2 &
sleep 1
[[ "$rs" == "ost1" ]] ||
error "file content error: expected: \"ost1\", actual: \"$rs\""
- wait_osc_import_state client ost2 FULL
+ wait_osc_import_ready client ost2
}
run_test 33 "read can choose available mirror to read"
local tf
for tf in "$@"; do
- $LFS setstripe -E 1M -E 2M -E 4M -E eof -c -1 $tf
- $LFS setstripe -E 3M -E 6M -E eof -c -1 $tf-tmp
+ $LFS setstripe -E 1M -S 1M -E 2M -E 4M -E eof -c -1 $tf
+ $LFS setstripe -E 3M -S 1M -E 6M -E eof -c -1 $tf-tmp
$LFS mirror extend -N -f $tf-tmp $tf ||
error "merging $tf-tmp into $tf failed"
create_file_36 $tf $tf-2 $tf-3
- [ $(get_mirror_ids $tf) -gt 1 ] || error "wrong mirror count"
+ [ $($LFS getstripe -N $tf) -gt 1 ] || error "wrong mirror count"
# test case 1 - check file write and verify layout version
$MULTIOP $tf oO_WRONLY:c ||
verify_ost_layout_version $tf
# test case 2
- local mds_idx=mds$(($($LFS getstripe -M $tf-2) + 1))
+ local mds_facet=mds$(($($LFS getstripe -m $tf-2) + 1))
local delay_sec=10
- do_facet $mds_idx $LCTL set_param fail_val=$delay_sec
+ do_facet $mds_facet $LCTL set_param fail_val=$delay_sec
#define OBD_FAIL_FLR_LV_DELAY 0x1A01
- do_facet $mds_idx $LCTL set_param fail_loc=0x1A01
+ do_facet $mds_facet $LCTL set_param fail_loc=0x1A01
# write should take at least $fail_loc seconds and succeed
local st=$(date +%s)
# verify OST layout version
verify_ost_layout_version $tf
- do_facet $mds_idx $LCTL set_param fail_loc=0
+ do_facet $mds_facet $LCTL set_param fail_loc=0
# test case 3
- mds_idx=mds$(($($LFS getstripe -M $tf-3) + 1))
+ mds_idx=mds$(($($LFS getstripe -m $tf-3) + 1))
#define OBD_FAIL_FLR_LV_INC 0x1A02
- do_facet $mds_idx $LCTL set_param fail_loc=0x1A02
+ do_facet $mds_facet $LCTL set_param fail_loc=0x1A02
# write open file should return error
$MULTIOP $tf-3 oO_WRONLY:O_SYNC:w1024c &&
error "write a mirrored file succeeded" || true
- do_facet $mds_idx $LCTL set_param fail_loc=0
+ do_facet $mds_facet $LCTL set_param fail_loc=0
}
run_test 36 "write to mirrored files"
shift
for tf in "$@"; do
- $LFS setstripe -E 1M -c 1 -E eof -c -1 $tf
+ $LFS setstripe -E 1M -S 1M -c 1 -E eof -c -1 $tf
dd if=/dev/urandom of=$tf bs=1M count=16 &> /dev/null
$TRUNCATE $tf $fsize
test_37()
{
+ [ $MDS1_VERSION -lt $(version_code 2.11.57) ] &&
+ skip "Need MDS version at least 2.11.57"
+
local tf=$DIR/$tfile
local tf2=$DIR/$tfile-2
local tf3=$DIR/$tfile-3
+ local tf4=$DIR/$tfile-4
create_files_37 $((RANDOM + 15 * 1048576)) $tf $tf2 $tf3
+ rm -f $tf4
+ cp $tf $tf4
# assume the mirror id will be 1, 2, and 3
declare -A checksums
- checksums[1]=$(md5sum $tf | cut -f 1 -d' ')
- checksums[2]=$(md5sum $tf2 | cut -f 1 -d' ')
- checksums[3]=$(md5sum $tf3 | cut -f 1 -d' ')
+ checksums[1]=$(cat $tf | md5sum)
+ checksums[2]=$(cat $tf2 | md5sum)
+ checksums[3]=$(cat $tf3 | md5sum)
printf '%s\n' "${checksums[@]}"
local sum
for i in ${mirror_array[@]}; do
- sum=$(mirror_io dump -i $i $tf | md5sum | cut -f 1 -d' ')
+ $LCTL set_param ldlm.namespaces.*.lru_size=clear > /dev/null
+ sum=$($LFS mirror read -N $i $tf | md5sum)
[ "$sum" = "${checksums[$i]}" ] ||
error "$i: mismatch: \'${checksums[$i]}\' vs. \'$sum\'"
done
+ # verify mirror write
+ echo "Verifying mirror write .."
+ $LFS mirror write -N2 $tf < $tf4
+
+ sum=$($LFS mirror read -N2 $tf | md5sum)
+ [[ "$sum" = "${checksums[1]}" ]] ||
+ error "2: mismatch \'${checksums[1]}\' vs. \'$sum\'"
+
# verify mirror copy, write to this mirrored file will invalidate
# the other two mirrors
echo "Verifying mirror copy .."
local osts=$(comma_list $(osts_nodes))
- # define OBD_FAIL_OST_SKIP_LV_CHECK 0x241
- do_nodes $osts lctl set_param fail_loc=0x241
-
- mirror_io copy -i ${mirror_array[0]} \
- -t $(echo ${mirror_array[@]:1} | tr ' ' ',') $tf ||
- error "mirror copy error"
-
- do_nodes $osts lctl set_param fail_loc=0
+ $LFS mirror copy -i ${mirror_array[0]} -o-1 $tf ||
+ error "mirror copy error"
# verify copying is successful by checking checksums
remount_client $MOUNT
for i in ${mirror_array[@]}; do
- sum=$(mirror_io dump -i $i $tf | md5sum | cut -f 1 -d' ')
+ sum=$($LFS mirror read -N $i $tf | md5sum)
[ "$sum" = "${checksums[1]}" ] ||
- error "$i: mismatch checksum after copy"
+ error "$i: mismatch checksum after copy \'$sum\'"
done
rm -f $tf
local tf=$DIR/$tfile
local ref=$DIR/${tfile}-ref
- $LFS setstripe -E 1M -c 1 -E 4M -c 2 -E eof -c -1 $tf
- $LFS setstripe -E 2M -c 1 -E 6M -c 2 -E 8M -c -1 -E eof -c -1 $tf-2
- $LFS setstripe -E 4M -c 1 -E 8M -c 2 -E eof -c -1 $tf-3
+ $LFS setstripe -E 1M -S 1M -c 1 -E 4M -c 2 -E eof -c -1 $tf ||
+ error "creating $tf failed"
+ $LFS setstripe -E 2M -S 1M -c 1 -E 6M -c 2 -E 8M -c -1 -E eof -c -1 \
+ $tf-2 || error "creating $tf-2 failed"
+ $LFS setstripe -E 4M -c 1 -E 8M -c 2 -E eof -c -1 $tf-3 ||
+ error "creating $tf-3 failed"
# instantiate all components
$LFS mirror extend -N -f $tf-2 $tf ||
local fsize=$((RANDOM << 8 + 1048576))
$TRUNCATE $ref $fsize
- local ref_cksum=$(md5sum $ref | cut -f 1 -d' ')
+ local ref_cksum=$(cat $ref | md5sum)
# case 1: verify write to mirrored file & resync work
cp $ref $tf || error "copy from $ref to $f error"
verify_flr_state $tf "wp"
- local file_cksum=$(md5sum $tf | cut -f 1 -d' ')
+ local file_cksum=$(cat $tf | md5sum)
[ "$file_cksum" = "$ref_cksum" ] || error "write failed, cksum mismatch"
get_mirror_ids $tf
local valid_mirror stale_mirror id mirror_cksum
for id in "${mirror_array[@]}"; do
- mirror_cksum=$(mirror_io dump -i $id $tf |
- md5sum | cut -f 1 -d' ')
+ mirror_cksum=$($LFS mirror read -N $id $tf | md5sum)
[ "$ref_cksum" == "$mirror_cksum" ] &&
{ valid_mirror=$id; continue; }
mirror_io resync $tf || error "resync failed"
verify_flr_state $tf "ro"
- mirror_cksum=$(mirror_io dump -i $stale_mirror $tf |
- md5sum | cut -f 1 -d' ')
+ mirror_cksum=$($LFS mirror read -N $stale_mirror $tf | md5sum)
[ "$file_cksum" = "$ref_cksum" ] || error "resync failed"
# case 2: inject an error to make mirror_io exit after changing
for ops in "conv=notrunc" ""; do
rm -f $tf
- $LFS mirror create -N -E2m -E4m -E-1 --flags=prefer \
- -N -E1m -E2m -E4m -E-1 $tf ||
+ $LFS mirror create -N -E 2M -S 1M -E 4M -E -1 --flags=prefer \
+ -N -E 1M -E 2M -E 4M -E -1 $tf ||
error "create PFLR file $tf failed"
dd if=/dev/zero of=$tf $ops bs=1M seek=2 count=1 ||
error "write PFLR file $tf failed"
rm -f $tf $tf-1
echo " **create two FLR files $tf $tf-1"
- $LFS mirror create -N -E2m -E4m -E-1 -N -E1m -E2m -E3m -E-1 $tf ||
+ $LFS mirror create -N -E 2M -S 1M -E 4M -E -1 \
+ -N -E 1M -E 2M -E 3M -E -1 $tf ||
error "create PFLR file $tf failed"
- $LFS mirror create -N -E2m -Eeof -N -E1m -Eeof --flags prefer \
- -N -E4m -Eeof $tf-1 || error "create PFLR file $tf-1 failed"
+ $LFS mirror create -N -E 2M -S 1M -E eof \
+ -N -E 1M -E eof --flags prefer \
+ -N -E 4m -E eof $tf-1 ||
+ error "create PFLR file $tf-1 failed"
# file should be in ro status
echo " **verify files be RDONLY"
# write data in [0, 2M)
dd if=/dev/zero of=$tf bs=1M count=2 conv=notrunc ||
error "writing $tf failed"
- dd if=/dev/zero of=$tf-1 bs=1M count=4 conv=notrunc ||
+ dd if=/dev/urandom of=$tf-1 bs=1M count=4 conv=notrunc ||
error "writing $tf-1 failed"
+ local sum0=$(cat $tf-1 | md5sum)
+
echo " **verify files be WRITE_PENDING"
verify_flr_state $tf "wp"
verify_flr_state $tf-1 "wp"
echo " **full resync"
$LFS mirror resync $tf $tf-1 || error "mirror resync $tf $tf-1 failed"
+ echo " **verify $tf-1 data consistency in all mirrors"
+ for i in 1 2 3; do
+ local sum=$($LFS mirror read -N$i $tf-1 | md5sum)
+ [[ "$sum" = "$sum0" ]] ||
+ error "$tf-1.$i: checksum mismatch: $sum != $sum0"
+ done
+
echo " **verify files be RDONLY"
verify_flr_state $tf "ro"
verify_flr_state $tf-1 "ro"
$mirror_cmd $td &> /dev/null && error "$td is not a regular file"
# create mirrored files
- $LFS mirror create -N -E 4M -E 10M -E EOF $tf ||
+ $LFS mirror create -N -E 4M -S 1M -E 10M -E EOF $tf ||
error "create mirrored file $tf failed"
- $LFS mirror create -N -E 2M -E EOF \
+ $LFS mirror create -N -E 2M -S 1M -E EOF \
-N -E 6M -E 8M -E EOF \
-N -E 16M -E EOF $tf-1 ||
error "create mirrored file $tf-1 failed"
- $LFS mirror create -N -c 2 -o 1,3 -N -S 4M -c -1 $tf-2 ||
+ $LFS mirror create -N -c 2 -o 1,3 -N -S 2M -c -1 $tf-2 ||
error "create mirrored file $tf-2 failed"
# write data in [0, 10M)
error "create remote directory failed"
rm -f $tf $tf1 $tf.mirror~2
# create file with 4 mirrors
- $LFS mirror create -N -E2m -E4m -E-1 -N -E1m -E2m -E3m -E-1 -N2 $tf ||
+ $LFS mirror create -N -E 2M -S 1M -E 4M -E -1 \
+ -N -E 1M -E 2M -E 3M -E -1 -N2 $tf ||
error "create PFLR file $tf failed"
# file should be in ro status
}
run_test 44 "lfs mirror split check"
+test_45() {
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+
+ local file=$DIR/$tdir/$tfile
+ local dir=$DIR/$tdir/$dir
+ local temp=$DIR/$tdir/template
+ rm -rf $DIR/$tdir
+ test_mkdir $DIR/$tdir
+
+ $LFS setstripe -N -E1m -S1m -c2 -o0,1 -E2m -Eeof -N -E4m -Eeof \
+ -N -E3m -S1m -Eeof -N -E8m -Eeof $file ||
+ error "Create $file failed"
+
+ verify_yaml_layout $file $file.copy $temp "1. FLR file"
+ rm -f $file $file.copy
+
+ $LFS setstripe -N -E1m -S1m -c2 -o0,1 -E2m -Eeof -N -E4m -Eeof \
+ -N -E3m -S1m -Eeof -N -E8m --flags=prefer -Eeof $file ||
+ error "Create $file failed"
+
+ verify_yaml_layout $file $file.copy $temp "2. FLR file with flags"
+}
+run_test 45 "Verify setstripe/getstripe with YAML with FLR file"
+
+verify_46() {
+ local src=$1
+ local dst=$2
+ local msg_prefix=$3
+
+ $LFS setstripe --copy=$src $dst || error "setstripe $dst failed"
+
+ local layout1=$(get_layout_param $src)
+ local layout2=$(get_layout_param $dst)
+ # compare their layout info
+ [ "$layout1" == "$layout2" ] ||
+ error "$msg_prefix $src <=> $dst layouts are not equal"
+}
+
+test_46() {
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+
+ local file=$DIR/$tdir/$tfile
+ test_mkdir $DIR/$tdir
+
+ ########################### 1. PFL file #############################
+ echo " ** 1. PFL file"
+ rm -f $file
+ $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \
+ $file || error "1. Create PFL $file failed"
+
+ rm -f $file.copy
+ verify_46 $file $file.copy "1. PFL file"
+
+ ########################### 2. plain file ###########################
+ echo " ** 2. plain file"
+ rm -f $file
+ $LFS setstripe -c2 -o0,1 -i1 $file ||
+ error "2. Create plain $file failed"
+
+ rm -f $file.copy
+ verify_46 $file $file.copy "2. plain file"
+
+ ########################### 3. FLR file #############################
+ echo " ** 3. FLR file"
+ $LFS setstripe -N -E1m -S 1M -c2 -o0,1 -E4m -c1 -Eeof -N -E16m -Eeof \
+ $file || error "3. Create FLR $file failed"
+
+ rm -f $file.copy
+ verify_46 $file $file.copy "3. FLR file"
+
+ local dir=$DIR/$tdir/dir
+ ########################### 4. PFL dir ##############################
+ echo " ** 4. PFL dir"
+ test_mkdir $dir
+ $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir ||
+ error "4. setstripe PFL $dir failed"
+
+ test_mkdir $dir.copy
+ verify_46 $dir $dir.copy "4. PFL dir"
+
+ ########################### 5. plain dir ############################
+ echo " ** 5. plain dir"
+ $LFS setstripe -c2 -i-1 $dir || error "5. setstripe plain $dir failed"
+
+ verify_46 $dir $dir.copy "5. plain dir"
+
+ ########################### 6. FLR dir ##############################
+ echo " ** 6. FLR dir"
+ $LFS setstripe -N -E1m -S 1M -c2 -E2m -c1 -Eeof -N -E4m -Eeof $dir ||
+ error "6. setstripe FLR $dir failed"
+
+ verify_46 $dir $dir.copy "6. FLR dir"
+}
+run_test 46 "Verify setstripe --copy option"
+
+test_47() {
+ [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return
+
+ local file=$DIR/$tdir/$tfile
+ local ids
+ local ost
+ local osts
+
+ test_mkdir $DIR/$tdir
+
+ # test case 1:
+ rm -f $file
+ # mirror1: [comp0]ost0, [comp1]ost1 and ost2
+ # mirror2: [comp2] , [comp3] should not use ost1 or ost2
+ $LFS mirror create -N -E2m -c1 -o0 --flags=prefer -Eeof -c2 -o1,2 \
+ -N -E2m -c1 -Eeof -c1 $file || error "create FLR $file failed"
+ ids=($($LFS getstripe $file | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+
+ dd if=/dev/zero of=$file bs=1M count=3 || error "dd $file failed"
+ $LFS mirror resync $file || error "resync $file failed"
+
+ ost=$($LFS getstripe -I${ids[2]} $file | awk '/l_ost_idx/{print $5}')
+ if [[ x$ost == "x0," ]]; then
+ $LFS getstripe $file
+ error "component ${ids[2]} objects allocated on $ost " \
+ "shouldn't on OST0"
+ fi
+
+ ost=$($LFS getstripe -I${ids[3]} $file | awk '/l_ost_idx/{print $5}')
+ if [[ x$ost == "x1," || x$ost == "x2," ]]; then
+ $LFS getstripe $file
+ error "component ${ids[3]} objects allocated on $ost " \
+ "shouldn't on OST1 or on OST2"
+ fi
+
+ ## test case 2:
+ rm -f $file
+ # mirror1: [comp0] [comp1]
+ # mirror2: [comp2] [comp3]
+ # mirror3: [comp4] [comp5]
+ # mirror4: [comp6] [comp7]
+ $LFS mirror create -N4 -E1m -c1 -Eeof -c1 $file ||
+ error "create FLR $file failed"
+ ids=($($LFS getstripe $file | awk '/lcme_id/{print $2}' | tr '\n' ' '))
+
+ dd if=/dev/zero of=$file bs=1M count=3 || error "dd $file failed"
+ $LFS mirror resync $file || error "resync $file failed"
+
+ for ((i = 0; i < 6; i++)); do
+ osts[$i]=$($LFS getstripe -I${ids[$i]} $file |
+ awk '/l_ost_idx/{print $5}')
+ done
+ # comp[0],comp[2],comp[4] should use different osts
+ if [[ ${osts[0]} == ${osts[2]} || ${osts[0]} == ${osts[4]} ||
+ ${osts[2]} == ${osts[4]} ]]; then
+ $LFS getstripe $file
+ error "component ${ids[0]}, ${ids[2]}, ${ids[4]} have objects "\
+ "allocated on duplicated OSTs"
+ fi
+ # comp[1],comp[3],comp[5] should use different osts
+ if [[ ${osts[1]} == ${osts[3]} || ${osts[1]} == ${osts[5]} ||
+ ${osts[3]} == ${osts[5]} ]]; then
+ $LFS getstripe $file
+ error "component ${ids[1]}, ${ids[3]}, ${ids[5]} have objects "\
+ "allocated on duplicated OSTs"
+ fi
+
+ return 0
+}
+run_test 47 "Verify mirror obj alloc"
+
+test_48() {
+ [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
+ skip "Need MDS version at least 2.11.55"
+
+ local tf=$DIR/$tfile
+
+ rm -f $tf
+ echo " ** create 2 mirrors FLR file $tf"
+ $LFS mirror create -N -E2M -Eeof --flags prefer \
+ -N -E1M -Eeof $tf ||
+ error "create FLR file $tf failed"
+
+ echo " ** write it"
+ dd if=/dev/urandom of=$tf bs=1M count=3 || error "write $tf failed"
+ verify_flr_state $tf "wp"
+
+ local sum0=$(md5sum < $tf)
+
+ echo " ** resync the file"
+ $LFS mirror resync $tf
+
+ echo " ** snapshot mirror 2"
+ $LFS setstripe --comp-set -I 0x20003 --comp-flags=nosync $tf
+
+ echo " ** write it again"
+ dd if=/dev/urandom of=$tf bs=1M count=3 || error "write $tf failed"
+ echo " ** resync it again"
+ $LFS mirror resync $tf
+
+ verify_flr_state $tf "wp"
+ verify_comp_attr lcme_flags $tf 0x20003 nosync,stale
+
+ local sum1=$($LFS mirror read -N1 $tf | md5sum)
+ local sum2=$($LFS mirror read -N2 $tf | md5sum)
+
+ echo " ** verify mirror 2 doesn't change"
+ echo "original checksum: $sum0"
+ echo "mirror 1 checksum: $sum1"
+ echo "mirror 2 checksum: $sum2"
+ [[ $sum0 = $sum2 ]] ||
+ error "original checksum: $sum0, mirror 2 checksum: $sum2"
+ echo " ** mirror 2 stripe info"
+ $LFS getstripe -v --mirror-index=2 $tf
+
+ echo " ** resync mirror 2"
+ $LFS mirror resync --only 2 $tf
+
+ verify_flr_state $tf "ro"
+ verify_comp_attr lcme_flags $tf 0x20003 nosync,^stale
+
+ sum1=$($LFS mirror read -N1 $tf | md5sum)
+ sum2=$($LFS mirror read -N2 $tf | md5sum)
+
+ echo " ** verify mirror 2 resync-ed"
+ echo "original checksum: $sum0"
+ echo "mirror 1 checksum: $sum1"
+ echo "mirror 2 checksum: $sum2"
+ [[ $sum1 = $sum2 ]] ||
+ error "mirror 1 checksum: $sum1, mirror 2 checksum: $sum2"
+ echo " ** mirror 2 stripe info"
+ $LFS getstripe -v --mirror-index=2 $tf
+}
+run_test 48 "Verify snapshot mirror"
+
ctrl_file=$(mktemp /tmp/CTRL.XXXXXX)
lock_file=$(mktemp /var/lock/FLR.XXXXXX)
echo -n "resync file $tf with '$cmd' .."
- $lock_taken && flock -x 200
- $cmd $tf &> /dev/null && echo "done" || echo "failed"
- $lock_taken && flock -u 200
+ if [[ $lock_taken = "true" ]]; then
+ flock -x 200 -c "$cmd $tf &> /dev/null" &&
+ echo "done" || echo "failed"
+ flock -u 200
+ else
+ $cmd $tf &> /dev/null && echo "done" || echo "failed"
+ fi
sleep 0.$((RANDOM % 8 + 1))
done
local tf2=$DIR2/$tfile
local tf3=$DIR3/$tfile
- $LFS setstripe -E 1M -E 2M -c 2 -E 4M -E 16M -E eof $tf
- $LFS setstripe -E 2M -E 6M -c 2 -E 8M -E 32M -E eof $tf-2
+ $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E 4M -E 16M -E eof $tf
+ $LFS setstripe -E 2M -S 1M -E 6M -c 2 -E 8M -E 32M -E eof $tf-2
$LFS setstripe -E 4M -c 2 -E 8M -E 64M -E eof $tf-3
$LFS mirror extend -N -f $tf-2 $tf ||
#define OBD_FAIL_FLR_RANDOM_PICK_MIRROR 0x1A03
$LCTL set_param fail_loc=0x1A03
- local mds_idx=mds$(($($LFS getstripe -M $tf) + 1))
+ local mds_idx=mds$(($($LFS getstripe -m $tf) + 1))
do_facet $mds_idx $LCTL set_param fail_loc=0x1A03
declare -a pids
mirror_io resync $tf
get_mirror_ids $tf
- local csum=$(mirror_io dump -i ${mirror_array[0]} $tf | md5sum)
+ local csum=$($LFS mirror read -N ${mirror_array[0]} $tf | md5sum)
for id in ${mirror_array[@]:1}; do
- [ "$(mirror_io dump -i $id $tf | md5sum)" = "$csum" ] ||
+ [ "$($LFS mirror read -N $id $tf | md5sum)" = "$csum" ] ||
error "checksum error for mirror $id"
done
local tf=$DIR/$tfile
local ids
- $LFS setstripe -E 1M -c 1 $tf
+ $LFS setstripe -E 1M -S 1M -c 1 $tf
ids=($($LFS getstripe $tf | awk '/lcme_id/{print $2}' | tr '\n' ' '))
verify_comp_attr stripe-count $tf ${ids[0]} 1
}
run_test 202 "lfs setstripe --add-component wide striping"
+test_203() {
+ [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
+ skip "Need MDS version at least 2.11.55"
+ [[ $OSTCOUNT -lt 2 ]] && skip "need >= 2 OSTs"
+
+ local tf=$DIR/$tfile
+
+ #create 2 mirrors
+ $LFS mirror create -N2 -c1 $tf || error "create FLR file $tf"
+ #delete first mirror
+ $LFS mirror split --mirror-id=1 -d $tf || error "delete first mirror"
+
+ $LFS getstripe $tf
+ local old_id=$($LFS getstripe --mirror-id=2 -I $tf)
+ local count=$($LFS getstripe --mirror-id=2 -c $tf) ||
+ error "getstripe count of mirror 2"
+ [[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1"
+
+ #extend a mirror with 2 OSTs
+ $LFS mirror extend -N -c2 $tf || error "extend mirror"
+ $LFS getstripe $tf
+
+ local new_id=$($LFS getstripe --mirror-id=2 -I $tf)
+ count=$($LFS getstripe --mirror-id=2 -c $tf) ||
+ error "getstripe count of mirror 2"
+ [[ x$oldid = x$newid ]] ||
+ error "mirror 2 changed ID from $old_id to $new_id"
+ [[ x$count = x1 ]] || error "mirror 2 stripe count $count is not 1"
+
+ count=$($LFS getstripe --mirror-id=3 -c $tf) ||
+ error "getstripe count of mirror 3"
+ [[ x$count = x2 ]] || error "mirror 3 stripe count $count is not 2"
+}
+run_test 203 "mirror file preserve mirror ID"
complete $SECONDS
check_and_cleanup_lustre