On Wed, Jul 23, 2014 at 12:37:34AM +0400, Dmitry Monakhov wrote: > > Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx> Needs a proper commit message. Also, what makes this ext4 specific? Why can't it run on any filesystem with a defrag operation? > +_need_to_be_root > +_require_scratch > +_require_defrag > + > +rm -f $seqres.full > + > +_workout() > +{ > + nr=$1 > + echo "Defragment file with $nr * 2 fragments" > + # Create sparse file > + for ((i=0;i<nr;i++)) > + do > + fallocate -l 4k -o $((409600*i)) $SCRATCH_MNT/test.$nr > + done please use $XFS_IO_PROG -c "falloc" ... for these operations to minimise the number of external dependencies... > + # Fill holes for half of range , as result file will contain nr*1.5 fragments > + fallocate -l $((204800*nr)) $SCRATCH_MNT/test.$nr > + # Data wrilte will convert extetns to inialized ones > + for ((i=0;i<nr;i++)) whitespace > + do > + dd if=/dev/urandom bs=1234 seek=$((100*i)) of=$SCRATCH_MNT/test.$nr \ > + conv=notrunc count=3 >> $seqres.full 2>&1 > + done again, $XFS_IO_PROG -c "pwrite .." rather than dd. And use a fixed pattern, so that the hash of the file is predictable. > + filefrag -v $SCRATCH_MNT/test.$nr >> $seqres.full $XFS_IO_PROG -c "fiemap" .... > + sha1sum $SCRATCH_MNT/test.$nr > $SCRATCH_MNT/test.$nr.sha1sum md5sum is sufficient and faster for this sort of testing, and used everywhere else in xfstests for this purpose. And with predictable file contents, the output can be dumped into the output file like: md5sum $SCRATCH_MNT/test.$nr | _filter_scratch And so we get file contents integrity checking from both the initial write and the defrag command... > + $DEFRAG_PROG $SCRATCH_MNT $SCRATCH_DEV >> $seqres.full 2>&1 > + filefrag -v $SCRATCH_MNT/test.$nr >> $seqres.full > + run_check sha1sum -c $SCRATCH_MNT/test.$nr.sha1sum And this run_check can go away - just dump the md5sum again. -Dave. -- Dave Chinner david@xxxxxxxxxxxxx -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html