From: Bobi Jam Date: Tue, 28 May 2013 03:29:46 +0000 (+0800) Subject: LU-3401 tests: make sanity test_27z robust and verbose X-Git-Tag: 2.1.6~4 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F68%2F6468%2F5;p=fs%2Flustre-release.git LU-3401 tests: make sanity test_27z robust and verbose * do not depend on positional parameters for most output * use "lfs getstripe [-c|-i|-s]" options to get specific values * parse OST index/objid/seq on a line-by-line basis * dispaly more infomation in error messages Test-Parameters: envdefinitions=SLOW=yes,ENABLE_QUOTA=yes clientdistro=el6 serverdistro=el6 clientarch=x86_64 serverarch=x86_64 serverjobs=lustre-master serverbuildno=1508 testlist=sanity Signed-off-by: Bobi Jam Change-Id: Iaf4bbd30a1f9c3bf47d634ddc5e122de60a25776 Reviewed-on: http://review.whamcloud.com/6468 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 291f1488..c5e583d 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -1392,68 +1392,99 @@ run_test 27y "create files while OST0 is degraded and the rest inactive" check_seq_oid() { - echo check file $1 - local old_ifs="$IFS" - IFS=$'\t\n :' - lmm=($($GETSTRIPE -v $1)) + log "check file $1" + + lmm_count=$($GETSTRIPE -c $1) + lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }') + lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }') + local old_ifs="$IFS" IFS=$'[:]' fid=($($LFS path2fid $1)) IFS="$old_ifs" + log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}" + log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count" + # compare lmm_seq and lu_fid->f_seq - [ ${lmm[4]} = ${fid[1]} ] || { error "SEQ mismatch"; return 1; } + [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; } # compare lmm_object_id and lu_fid->oid - [ ${lmm[6]} = ${fid[2]} ] || { error "OID mismatch"; return 2; } - - echo -e "\tseq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}\n\tstripe count: ${lmm[8]}" - - [ "$FSTYPE" != "ldiskfs" ] && skip "can not check trusted.fid FSTYPE=$FSTYPE" && return 0 - - # check the trusted.fid attribute of the OST objects of the file - for (( i=0, j=19; i < ${lmm[8]}; i++, j+=4 )); do - local obdidx=${lmm[$j]} - local devnum=$((obdidx + 1)) - local objid=${lmm[$((j+1))]} - local group=${lmm[$((j+3))]} - local dev=$(ostdevname $devnum) - local dir=${MOUNT%/*}/ost$devnum - local mntpt=$(facet_mntpt ost$devnum) - - stop ost$devnum - do_facet ost$devnum mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS || - { error "mounting $dev as $FSTYPE failed"; return 3; } - - obj_filename=$(do_facet ost$devnum find $dir/O/$group -name $objid) - local ff=$(do_facet ost$devnum $LL_DECODE_FILTER_FID $obj_filename) - IFS=$'/= [:]' - ff=($(echo $ff)) - IFS="$old_ifs" - - # compare lmm_seq and filter_fid->ff_parent.f_seq - [ ${ff[11]} = ${lmm[4]} ] || { error "parent SEQ mismatch"; return 4; } - # compare lmm_object_id and filter_fid->ff_parent.f_oid - [ ${ff[12]} = ${lmm[6]} ] || { error "parent OID mismatch"; return 5; } - let stripe=${ff[13]} - [ $stripe -eq $i ] || { error "stripe mismatch"; return 6; } - - echo -e "\t\tost $obdidx, objid $objid, group $group" - do_facet ost$devnum umount -d $mntpt - start ost$devnum $dev $OST_MOUNT_OPTS - done + [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; } + + [ "$FSTYPE" != "ldiskfs" ] && + skip "cannot check filter fid FSTYPE=$FSTYPE" && return 0 + + # check the trusted.fid attribute of the OST objects of the file + local have_obdidx=false + local stripe_nr=0 + $GETSTRIPE $1 | while read obdidx oid hex seq; do + # skip lines up to and including "obdidx" + [ -z "$obdidx" ] && break + [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue + $have_obdidx || continue + + local ost=$((obdidx + 1)) + local dev=$(ostdevname $ost) + local dir=$(facet_mntpt ost$ost) + local oid_hex + + log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq" + + stop ost$ost + do_facet ost$ost mount -t $FSTYPE $opts $dev $dir $OST_MOUNT_OPTS || + { error "mounting $dev as $FSTYPE failed"; return 3; } + + seq=$(echo $seq | sed -e "s/^0x//g") + if [ $seq == 0 ]; then + oid_hex=$(echo $oid) + else + oid_hex=$(echo $hex | sed -e "s/^0x//g") + fi + local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid_hex) + local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file) + do_facet ost$ost umount -d $dir + start ost$ost $dev $OST_MOUNT_OPTS + + [ -z "$ff" ] && error "$obj_file: no filter_fid info" + + echo "$ff" | sed -e 's#.*objid=#got: objid=#' + + # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1] + # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1 + local ff_parent=$(echo $ff|sed -e 's/.*parent=.//') + local ff_pseq=$(echo $ff_parent | cut -d: -f1) + local ff_poid=$(echo $ff_parent | cut -d: -f2) + local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//') + + # compare lmm_seq and filter_fid->ff_parent.f_seq + [ $ff_pseq = $lmm_seq ] || + error "FF parent SEQ $ff_pseq != $lmm_seq" + # compare lmm_object_id and filter_fid->ff_parent.f_oid + [ $ff_poid = $lmm_oid ] || + error "FF parent OID $ff_poid != $lmm_oid" + [ $ff_pstripe = $stripe_nr ] || + error "FF stripe $ff_pstripe != $stripe_nr" + + stripe_nr=$((stripe_nr + 1)) + done } test_27z() { + remote_ost_nodsh && skip "remote OST with nodsh" && return mkdir -p $DIR/$tdir - $SETSTRIPE $DIR/$tdir/$tfile-1 -c 1 -o 0 -s 1m || + $SETSTRIPE -c 1 -i 0 -s 64k $DIR/$tdir/$tfile-1 || { error "setstripe -c -1 failed"; return 1; } + # We need to send a write to every object to get parent FID info set. + # This _should_ also work for setattr, but does not currently. dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 || - { error "dd 1 mb failed"; return 2; } - $SETSTRIPE $DIR/$tdir/$tfile-2 -c -1 -o $(($OSTCOUNT - 1)) -s 1m || + { error "dd $tfile-1 failed"; return 2; } + $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -s 1M $DIR/$tdir/$tfile-2 || { error "setstripe -c 1 failed"; return 3; } dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT || - { error "dd $OSTCOUNT mb failed"; return 4; } - sync + { error "dd $tfile-2 failed"; return 4; } + + # make sure write RPCs have been sent to OSTs + sync; sleep 5; sync check_seq_oid $DIR/$tdir/$tfile-1 || return 5 check_seq_oid $DIR/$tdir/$tfile-2 || return 6 diff --git a/lustre/utils/ll_decode_filter_fid.c b/lustre/utils/ll_decode_filter_fid.c index ac14f25..0f3d483 100644 --- a/lustre/utils/ll_decode_filter_fid.c +++ b/lustre/utils/ll_decode_filter_fid.c @@ -74,11 +74,13 @@ int main(int argc, char *argv[]) fprintf(stderr, "%s: warning: fid larger than expected " "(%d bytes), recompile?\n", argv[i], size); - printf("%s: objid="LPU64" seq="LPU64" parent="DFID"\n", - argv[i], le64_to_cpu(ff->ff_objid), + printf("%s: objid="LPU64" seq="LPU64" parent="DFID + " stripe=%u\n", argv[i], + le64_to_cpu(ff->ff_objid), le64_to_cpu(ff->ff_seq), le64_to_cpu(ff->ff_parent.f_seq), - le32_to_cpu(ff->ff_parent.f_oid), + le32_to_cpu(ff->ff_parent.f_oid), 0 /* ver */, + /* this is stripe_nr actually */ le32_to_cpu(ff->ff_parent.f_ver)); }