1# vim: filetype=sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# $FreeBSD$ 24 25# 26# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)scrub_mirror_common.kshlib 1.5 07/10/09 SMI" 30# 31 32function overwrite_verify_mirror 33{ 34 typeset POOL=$1 35 typeset AFFECTED_DEVICE=$2 36 typeset OVERWRITING_DEVICE=$3 37 38 typeset atfile=0 39 set -A files 40 set -A cksums 41 set -A newcksums 42 43 fill_fs $TESTDIR -1 $FILE_COUNT $BLOCKSZ $WRITE_COUNT 44 while [ "$atfile" -lt "$FILE_COUNT" ]; do 45 if [ -f ${TESTDIR}/0/${TESTFILE}.${atfile} ]; then 46 cksums[$atfile]=$($CKSUM ${TESTDIR}/0/${TESTFILE}.${atfile}) 47 fi 48 (( atfile = $atfile + 1 )) 49 done 50 51 # unmount and export before dd 52 log_must $ZPOOL export $POOL 53 54 # dd the affected side of the mirror 55 log_must $DD if=$OVERWRITING_DEVICE of=$(bsddevmap $AFFECTED_DEVICE) \ 56 seek=8 bs=$BLOCKSZ count=$(( WRITE_COUNT - 8 )) conv=notrunc 57 58 # now remount and scrub 59 log_must $ZPOOL import $POOL 60 log_must $ZPOOL scrub $POOL 61 wait_for 60 1 is_pool_scrubbed $POOL 62 63 atfile=0 64 typeset -i failedcount=0 65 while [ "$atfile" -lt "$FILE_COUNT" ]; do 66 if [ -f ${TESTDIR}/0/${TESTFILE}.${atfile} ]; then 67 newcksum=$($CKSUM $TESTDIR/0/${TESTFILE}.${atfile}) 68 if [[ $newcksum != ${cksums[$atfile]} ]]; then 69 (( failedcount = $failedcount + 1 )) 70 else 71 log_note "${TESTFILE}.${atfile} checksums match:"\ 72 "old ${cksums[$atfile]} new $newcksum" 73 fi 74 $RM -f ${files[$atfile]} 75 fi 76 (( atfile = $atfile + 1 )) 77 done 78 79 if [ "$failedcount" -gt 0 ]; then 80 log_fail "of the $FILE_COUNT files $failedcount did not " \ 81 "have the same checksum before and after." 82 fi 83} 84