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