All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <Anand.Jain@oracle.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
	xfs@oss.sgi.com, Chris Mason <chris.mason@oracle.com>
Subject: [PATCH 1/3] 263: Functional test case for the btrfs snapshot
Date: Tue, 11 Oct 2011 19:26:57 +0800	[thread overview]
Message-ID: <4E942801.2030902@oracle.com> (raw)
In-Reply-To: <20111010112151.GA28627@infradead.org>

Create snapshots in various ways, modify the data around the block and
file boundaries and verify the data integrity.

Signed-off-by: Anand Jain <Anand.Jain@oracle.com>
---
  263           |  192 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  263.out       |    2 +
  README        |    7 ++-
  common.config |   14 ++++
  common.rc     |  122 ++++++++++++++++++++++++++++++++++++
  group         |    1 +
  6 files changed, 337 insertions(+), 1 deletions(-)
  create mode 100755 263
  create mode 100644 263.out

diff --git a/263 b/263
new file mode 100755
index 0000000..f26a677
--- /dev/null
+++ b/263
@@ -0,0 +1,192 @@
+#!/bin/bash
+# FS QA Test No. 263
+#
+# Extented btrfs snapshot test cases
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2011 Oracle  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+#-----------------------------------------------------------------------
+#
+# creator
+owner=anand.jain@oracle.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+    rm -f $tmp.*
+}
+
+trap "_cleanup ; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_need_to_be_root
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+
+_scratch_mkfs $SCRATCH_DEV_POOL > /dev/null 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+# Create and save sha256sum
+# arg1 FS to generate sha256
+# arg2 File name to save the sha256 output
+_save_checksum()
+{
+	local i=0
+	>$2
+	cd $1
+	for i in `find . -type f`; do sha256sum $i >> $2; done
+	cd $OLDPWD
+}
+
+# Verify the sha256sum for a FS
+# arg1 FS to be tested
+# arg2 sha256 file
+_verify_checksum()
+{
+	cd $1
+	[ -f $2 ] || _fail "checksum file $2 not found"
+	sha256sum -c $2 | grep "FAILED"
+	cd $OLDPWD
+}
+
+# Create a snapshot
+# arg1 dest dir
+# Return snapshot name in the SNAPNAME
+_create_snap()
+{
+	local x
+	[ -d $1 ] || _fail "Destination dir $1 not present"
+	SNAPNAME=`mktemp -u $SCRATCH_MNT/snap.XXXXXX`
+	btrfs subvolume snapshot $1 $SNAPNAME > /dev/null || _fail "snapshot 
create failed"
+}
+
+# Reads and writes new data but does not allocate new blocks
+# arg1 FS to be modified
+_read_modify_write()
+{
+	local i
+	local FSIZE
+	for i in `find $1 -type f`
+	do
+		FSIZE=`stat -t $i | cut -d" " -f2`
+		dd if=$i of=/dev/null obs=$FSIZE count=1 status=noxfer 2>/dev/null &
+		dd if=/dev/urandom of=$i obs=$FSIZE count=1 status=noxfer 2>/dev/null &
+	done
+	wait $!
+}
+
+# Fills the allocated blocks
+# arg1 FS in question
+_fill_blk()
+{
+	local FSIZE
+	local BLKS
+	local NBLK
+	local FALLOC
+	local WS
+
+	for i in `find /$1 -type f`
+	do
+		FSIZE=`stat -t $i | cut -d" " -f2`
+		BLKS=`stat -c "%B" $i`
+		NBLK=`stat -c "%b" $i`
+		FALLOC=$(($BLKS * $NBLK))
+		WS=$(($FALLOC - $FSIZE))
+		dd if=/dev/urandom of=$i oseek=$FSIZE obs=$WS count=1 status=noxfer 
2>/dev/null &
+	done
+	wait $!
+}
+
+
+# Append a random size to the files
+# arg1 : FS in question
+_append_file()
+{
+	local FSIZE
+	local X
+	local N
+	local i
+	N=0
+	for i in `find $1 -type f`
+	do
+		if [ $N == 0 ]; then
+			X=$i
+			FSIZE=`stat -t $X | cut -d" " -f2`
+			dd if=$X of=$X seek=1 bs=$FSIZE obs=$FSIZE count=1 status=noxfer 
2>/dev/null &
+			N=$(($N+1))
+			continue
+		fi
+		FSIZE=`stat -t $i | cut -d" " -f2`
+		dd if=$X of=$i seek=1 bs=$FSIZE obs=$FSIZE count=1 status=noxfer 
2>/dev/null &
+		X=$i
+	done
+	wait $!
+}
+
+##################### real QA test starts 
here###################################
+# sv1 - is just a name nothing spl
+firstvol="$SCRATCH_MNT/sv1"
+btrfs subvolume create $firstvol > /dev/null || _fail "btrfs subvolume 
create $firstvol failed"
+_fillfs 1 10 100 4096 8192 $firstvol
+SNAPNAME=0
+_create_snap $firstvol
+_save_checksum $firstvol $tmp.sv1.sum
+_verify_checksum $SNAPNAME $tmp.sv1.sum
+
+#Append1 the files
+_fill_blk $SNAPNAME
+_verify_checksum $firstvol $tmp.sv1.sum
+
+#Append2 the files
+_append_file $SNAPNAME
+_verify_checksum $firstvol $tmp.sv1.sum
+
+#read modify write
+_read_modify_write $SNAPNAME
+_verify_checksum $firstvol $tmp.sv1.sum
+
+#nested snapshot test
+src_vol=$firstvol
+for i in `seq 1 7`; do
+	SNAPNAME=0
+	_create_snap $src_vol
+	_verify_checksum $SNAPNAME $tmp.sv1.sum
+	src_vol=$SNAPNAME
+done
+
+# file delete test
+SNAPNAME=0
+_create_snap $firstvol
+tname=`echo $SNAPNAME | rev | cut -d"/" -f1 | rev`
+_save_checksum $SNAPNAME $tmp.$tname.sum
+\rm -rf $firstvol/*
+_verify_checksum $SNAPNAME $tmp.$tname.sum
+
+umount $SCRATCH_DEV || _fail "unmount failed"
+
+echo "Silence is golden"
+status=0; exit
diff --git a/263.out b/263.out
new file mode 100644
index 0000000..7a26e35
--- /dev/null
+++ b/263.out
@@ -0,0 +1,2 @@
+QA output created by 263
+Silence is golden
diff --git a/README b/README
index 5367be6..7c135c7 100644
--- a/README
+++ b/README
@@ -36,12 +36,17 @@ Preparing system for tests (IRIX and Linux):
                not be run.

          (these must be two DIFFERENT partitions)
+
+    - for btrfs only: some tests would need 3 or more independent 
SCRATCH disks,
+      which should be setenv SCRATCH_DEV_POOL instead of SCRATCH_DEV
+

      - setup your environment
          - setenv TEST_DEV "device containing TEST PARTITION"
          - setenv TEST_DIR "mount point of TEST PARTITION"
         	- optionally:
               - setenv SCRATCH_DEV "device containing SCRATCH PARTITION"
+             - setenv SCRATCH_DEV_POOL "pool of SCRATCH disks for 
testing btrfs"
               - setenv SCRATCH_MNT "mount point for SCRATCH PARTITION"
               - setenv TAPE_DEV "tape device for testing xfsdump"
               - setenv RMT_TAPE_DEV "remote tape device for testing 
xfsdump"
@@ -63,7 +68,7 @@ Preparing system for tests (IRIX and Linux):
        tape which can be overwritten.

      - make sure $TEST_DEV is a mounted XFS partition
-    - make sure that $SCRATCH_DEV contains nothing useful
+    - make sure that $SCRATCH_DEV or $SCRATCH_DEV_POOL contains nothing 
useful

  Running tests:

diff --git a/common.config b/common.config
index e94624e..4212fc8 100644
--- a/common.config
+++ b/common.config
@@ -229,6 +229,20 @@ if [ ! -d "$TEST_DIR" ]; then
      exit 1
  fi

+# a btrfs tester will set only SCRATCH_DEV_POOL, we will put first of 
its dev
+# to SCRATCH_DEV and rest to SCRATCH_DEV_POOL to maintain the backward 
compatibility
+if [ "$HOSTOS" == "Linux" ]; then
+    FSTYP_tmp=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
+else
+    FSTYP_tmp=xfs
+fi
+if [ "$FSTYP_tmp" == "btrfs" ]; then
+    if [ ! -z "$SCRATCH_DEV_POOL" ]; then
+	SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | cut -d" " -f 1`
+	SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | cut -d" " -f 2-`
+    fi
+fi
+	
  echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
  if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]; then
      echo "common.config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a 
block device or a NFS filesystem"
diff --git a/common.rc b/common.rc
index e948169..861f1f8 100644
--- a/common.rc
+++ b/common.rc
@@ -1591,6 +1591,128 @@ _test_inode_extsz()
      echo $blocks
  }

+# scratch_dev_pool should contain the disks pool for the btrfs raid
+_require_scratch_dev_pool()
+{
+	local i
+	case "$FSTYP" in
+	btrfs)
+		if [ -z "$SCRATCH_DEV_POOL" ]
+		then
+			_notrun "this test requires a valid \$SCRATCH_DEV_POOL"
+		fi
+		if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt 2 ]
+		then
+			_notrun "this test needs 2 or more disks in SCRATCH_DEV_POOL"
+		fi
+
+		for i in $SCRATCH_DEV_POOL
+		do
+			if [ "`_is_block_dev $i`" = "" ]
+			then
+				_notrun "this test requires valid block disk $i"
+			fi
+			if [ "`_is_block_dev $i`" = "`_is_block_dev $TEST_DEV`" ]
+			then
+				_notrun "$i is part of TEST_DEV, this test requires unique disks"
+			fi
+			if [ "`_is_block_dev $i`" = "`_is_block_dev $SCRATCH_DEV`" ]
+			then
+				_notrun "$i is part of SCRATCH_DEV, this test requires unique disks"
+			fi
+			if _mount | grep -q $i
+			then
+				if ! $UMOUNT_PROG $i
+			        then
+			            echo "failed to unmount $i - aborting"
+			            exit 1
+			        fi
+			fi
+			dd if=/dev/zero of=$i bs=4096 count=100 > /dev/null 2>&1
+		done
+	;;
+	esac
+}
+
+# We will check if the device is virtual (eg: loop device) since it 
does not
+# have the delete entry-point. Otherwise SCSI and USB devices are fine.
+_require_deletable_scratch_dev_pool()
+{
+	local i
+	local x
+	for i in $SCRATCH_DEV_POOL; do
+		x=`echo $i | cut -d"/" -f 3`
+		ls -l /sys/class/block/${x} | grep -q "virtual"
+		if [ $? == "0" ]; then
+			_notrun "$i is a virtual device which is not deletable"
+		fi
+	done
+}
+
+# Generate Random number in a range
+# arg1 min, arg2 max
+_rand_range()
+{
+	local X
+	local Y
+	if [ $2 == 0 ]; then echo 0; return; fi
+	RANDOM=1
+	Y=$RANDOM
+	((X = $2 - $1 + 1))
+	((X = $Y % $X))
+	((X = $X + $1))
+	echo $X
+}
+
+# Create Dir tree and files in it.
+# arg1 basedir
+# arg2 dir depth
+# arg3 nfile_min
+# arg4 nfile_max
+# arg5 fsize_min
+# arg6 fsize_max
+_fillfs()
+{
+	umask 000
+	local j
+	local i
+	local DIRP
+	local FCNT
+	local FILEP
+	local SCNT
+	local BCNT
+	DIRP=$6
+	for ((j=0; j<$1; j++)); do
+		DIRP=`mktemp -dq $DIRP/dir.XXXXXX`
+		FCNT=$(_rand_range $2 $3)
+		for ((i=0; i<$FCNT; i++)); do
+			FILEP=`mktemp -q $DIRP/file.XXXXXX`
+			SCNT=$(_rand_range $4 $5)
+			dd if=/dev/urandom of=$FILEP bs=$SCNT count=1 status=noxfer 
2>/dev/null &
+		done
+	done
+	wait $!
+}
+
+# arg 1 is dev to remove and is output of the below eg.
+# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
+_devmgt_remove()
+{
+	echo 1 > /sys/class/scsi_device/${1}/device/delete || _fail "Remove 
disk failed"
+}
+
+# arg 1 is dev to add and is output of the below eg.
+# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
+_devmgt_add()
+{
+	local h
+	local tdl
+	# arg 1 will be in h:t:d:l format now in the h and "t d l" format
+	h=`echo ${1} | cut -d":" -f 1`
+	tdl=`echo ${1} | cut -d":" -f 2-|sed 's/:/ /g'`
+
+	echo ${tdl} >  /sys/class/scsi_host/host${h}/scan || _fail "Add disk 
failed"
+}

 
################################################################################

diff --git a/group b/group
index 17466a1..d86624f 100644
--- a/group
+++ b/group
@@ -376,3 +376,4 @@ deprecated
  260 auto quick trim
  261 auto quick quota
  262 auto quick quota
+263 auto quick
-- 
1.7.1



WARNING: multiple messages have this Message-ID (diff)
From: Anand Jain <Anand.Jain@oracle.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-fsdevel@vger.kernel.org,
	Chris Mason <chris.mason@oracle.com>,
	linux-btrfs@vger.kernel.org, xfs@oss.sgi.com
Subject: [PATCH 1/3] 263: Functional test case for the btrfs snapshot
Date: Tue, 11 Oct 2011 19:26:57 +0800	[thread overview]
Message-ID: <4E942801.2030902@oracle.com> (raw)
In-Reply-To: <20111010112151.GA28627@infradead.org>

Create snapshots in various ways, modify the data around the block and
file boundaries and verify the data integrity.

Signed-off-by: Anand Jain <Anand.Jain@oracle.com>
---
  263           |  192 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  263.out       |    2 +
  README        |    7 ++-
  common.config |   14 ++++
  common.rc     |  122 ++++++++++++++++++++++++++++++++++++
  group         |    1 +
  6 files changed, 337 insertions(+), 1 deletions(-)
  create mode 100755 263
  create mode 100644 263.out

diff --git a/263 b/263
new file mode 100755
index 0000000..f26a677
--- /dev/null
+++ b/263
@@ -0,0 +1,192 @@
+#!/bin/bash
+# FS QA Test No. 263
+#
+# Extented btrfs snapshot test cases
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2011 Oracle  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+#-----------------------------------------------------------------------
+#
+# creator
+owner=anand.jain@oracle.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+    rm -f $tmp.*
+}
+
+trap "_cleanup ; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_need_to_be_root
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+
+_scratch_mkfs $SCRATCH_DEV_POOL > /dev/null 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+# Create and save sha256sum
+# arg1 FS to generate sha256
+# arg2 File name to save the sha256 output
+_save_checksum()
+{
+	local i=0
+	>$2
+	cd $1
+	for i in `find . -type f`; do sha256sum $i >> $2; done
+	cd $OLDPWD
+}
+
+# Verify the sha256sum for a FS
+# arg1 FS to be tested
+# arg2 sha256 file
+_verify_checksum()
+{
+	cd $1
+	[ -f $2 ] || _fail "checksum file $2 not found"
+	sha256sum -c $2 | grep "FAILED"
+	cd $OLDPWD
+}
+
+# Create a snapshot
+# arg1 dest dir
+# Return snapshot name in the SNAPNAME
+_create_snap()
+{
+	local x
+	[ -d $1 ] || _fail "Destination dir $1 not present"
+	SNAPNAME=`mktemp -u $SCRATCH_MNT/snap.XXXXXX`
+	btrfs subvolume snapshot $1 $SNAPNAME > /dev/null || _fail "snapshot 
create failed"
+}
+
+# Reads and writes new data but does not allocate new blocks
+# arg1 FS to be modified
+_read_modify_write()
+{
+	local i
+	local FSIZE
+	for i in `find $1 -type f`
+	do
+		FSIZE=`stat -t $i | cut -d" " -f2`
+		dd if=$i of=/dev/null obs=$FSIZE count=1 status=noxfer 2>/dev/null &
+		dd if=/dev/urandom of=$i obs=$FSIZE count=1 status=noxfer 2>/dev/null &
+	done
+	wait $!
+}
+
+# Fills the allocated blocks
+# arg1 FS in question
+_fill_blk()
+{
+	local FSIZE
+	local BLKS
+	local NBLK
+	local FALLOC
+	local WS
+
+	for i in `find /$1 -type f`
+	do
+		FSIZE=`stat -t $i | cut -d" " -f2`
+		BLKS=`stat -c "%B" $i`
+		NBLK=`stat -c "%b" $i`
+		FALLOC=$(($BLKS * $NBLK))
+		WS=$(($FALLOC - $FSIZE))
+		dd if=/dev/urandom of=$i oseek=$FSIZE obs=$WS count=1 status=noxfer 
2>/dev/null &
+	done
+	wait $!
+}
+
+
+# Append a random size to the files
+# arg1 : FS in question
+_append_file()
+{
+	local FSIZE
+	local X
+	local N
+	local i
+	N=0
+	for i in `find $1 -type f`
+	do
+		if [ $N == 0 ]; then
+			X=$i
+			FSIZE=`stat -t $X | cut -d" " -f2`
+			dd if=$X of=$X seek=1 bs=$FSIZE obs=$FSIZE count=1 status=noxfer 
2>/dev/null &
+			N=$(($N+1))
+			continue
+		fi
+		FSIZE=`stat -t $i | cut -d" " -f2`
+		dd if=$X of=$i seek=1 bs=$FSIZE obs=$FSIZE count=1 status=noxfer 
2>/dev/null &
+		X=$i
+	done
+	wait $!
+}
+
+##################### real QA test starts 
here###################################
+# sv1 - is just a name nothing spl
+firstvol="$SCRATCH_MNT/sv1"
+btrfs subvolume create $firstvol > /dev/null || _fail "btrfs subvolume 
create $firstvol failed"
+_fillfs 1 10 100 4096 8192 $firstvol
+SNAPNAME=0
+_create_snap $firstvol
+_save_checksum $firstvol $tmp.sv1.sum
+_verify_checksum $SNAPNAME $tmp.sv1.sum
+
+#Append1 the files
+_fill_blk $SNAPNAME
+_verify_checksum $firstvol $tmp.sv1.sum
+
+#Append2 the files
+_append_file $SNAPNAME
+_verify_checksum $firstvol $tmp.sv1.sum
+
+#read modify write
+_read_modify_write $SNAPNAME
+_verify_checksum $firstvol $tmp.sv1.sum
+
+#nested snapshot test
+src_vol=$firstvol
+for i in `seq 1 7`; do
+	SNAPNAME=0
+	_create_snap $src_vol
+	_verify_checksum $SNAPNAME $tmp.sv1.sum
+	src_vol=$SNAPNAME
+done
+
+# file delete test
+SNAPNAME=0
+_create_snap $firstvol
+tname=`echo $SNAPNAME | rev | cut -d"/" -f1 | rev`
+_save_checksum $SNAPNAME $tmp.$tname.sum
+\rm -rf $firstvol/*
+_verify_checksum $SNAPNAME $tmp.$tname.sum
+
+umount $SCRATCH_DEV || _fail "unmount failed"
+
+echo "Silence is golden"
+status=0; exit
diff --git a/263.out b/263.out
new file mode 100644
index 0000000..7a26e35
--- /dev/null
+++ b/263.out
@@ -0,0 +1,2 @@
+QA output created by 263
+Silence is golden
diff --git a/README b/README
index 5367be6..7c135c7 100644
--- a/README
+++ b/README
@@ -36,12 +36,17 @@ Preparing system for tests (IRIX and Linux):
                not be run.

          (these must be two DIFFERENT partitions)
+
+    - for btrfs only: some tests would need 3 or more independent 
SCRATCH disks,
+      which should be setenv SCRATCH_DEV_POOL instead of SCRATCH_DEV
+

      - setup your environment
          - setenv TEST_DEV "device containing TEST PARTITION"
          - setenv TEST_DIR "mount point of TEST PARTITION"
         	- optionally:
               - setenv SCRATCH_DEV "device containing SCRATCH PARTITION"
+             - setenv SCRATCH_DEV_POOL "pool of SCRATCH disks for 
testing btrfs"
               - setenv SCRATCH_MNT "mount point for SCRATCH PARTITION"
               - setenv TAPE_DEV "tape device for testing xfsdump"
               - setenv RMT_TAPE_DEV "remote tape device for testing 
xfsdump"
@@ -63,7 +68,7 @@ Preparing system for tests (IRIX and Linux):
        tape which can be overwritten.

      - make sure $TEST_DEV is a mounted XFS partition
-    - make sure that $SCRATCH_DEV contains nothing useful
+    - make sure that $SCRATCH_DEV or $SCRATCH_DEV_POOL contains nothing 
useful

  Running tests:

diff --git a/common.config b/common.config
index e94624e..4212fc8 100644
--- a/common.config
+++ b/common.config
@@ -229,6 +229,20 @@ if [ ! -d "$TEST_DIR" ]; then
      exit 1
  fi

+# a btrfs tester will set only SCRATCH_DEV_POOL, we will put first of 
its dev
+# to SCRATCH_DEV and rest to SCRATCH_DEV_POOL to maintain the backward 
compatibility
+if [ "$HOSTOS" == "Linux" ]; then
+    FSTYP_tmp=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
+else
+    FSTYP_tmp=xfs
+fi
+if [ "$FSTYP_tmp" == "btrfs" ]; then
+    if [ ! -z "$SCRATCH_DEV_POOL" ]; then
+	SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | cut -d" " -f 1`
+	SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | cut -d" " -f 2-`
+    fi
+fi
+	
  echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
  if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]; then
      echo "common.config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a 
block device or a NFS filesystem"
diff --git a/common.rc b/common.rc
index e948169..861f1f8 100644
--- a/common.rc
+++ b/common.rc
@@ -1591,6 +1591,128 @@ _test_inode_extsz()
      echo $blocks
  }

+# scratch_dev_pool should contain the disks pool for the btrfs raid
+_require_scratch_dev_pool()
+{
+	local i
+	case "$FSTYP" in
+	btrfs)
+		if [ -z "$SCRATCH_DEV_POOL" ]
+		then
+			_notrun "this test requires a valid \$SCRATCH_DEV_POOL"
+		fi
+		if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt 2 ]
+		then
+			_notrun "this test needs 2 or more disks in SCRATCH_DEV_POOL"
+		fi
+
+		for i in $SCRATCH_DEV_POOL
+		do
+			if [ "`_is_block_dev $i`" = "" ]
+			then
+				_notrun "this test requires valid block disk $i"
+			fi
+			if [ "`_is_block_dev $i`" = "`_is_block_dev $TEST_DEV`" ]
+			then
+				_notrun "$i is part of TEST_DEV, this test requires unique disks"
+			fi
+			if [ "`_is_block_dev $i`" = "`_is_block_dev $SCRATCH_DEV`" ]
+			then
+				_notrun "$i is part of SCRATCH_DEV, this test requires unique disks"
+			fi
+			if _mount | grep -q $i
+			then
+				if ! $UMOUNT_PROG $i
+			        then
+			            echo "failed to unmount $i - aborting"
+			            exit 1
+			        fi
+			fi
+			dd if=/dev/zero of=$i bs=4096 count=100 > /dev/null 2>&1
+		done
+	;;
+	esac
+}
+
+# We will check if the device is virtual (eg: loop device) since it 
does not
+# have the delete entry-point. Otherwise SCSI and USB devices are fine.
+_require_deletable_scratch_dev_pool()
+{
+	local i
+	local x
+	for i in $SCRATCH_DEV_POOL; do
+		x=`echo $i | cut -d"/" -f 3`
+		ls -l /sys/class/block/${x} | grep -q "virtual"
+		if [ $? == "0" ]; then
+			_notrun "$i is a virtual device which is not deletable"
+		fi
+	done
+}
+
+# Generate Random number in a range
+# arg1 min, arg2 max
+_rand_range()
+{
+	local X
+	local Y
+	if [ $2 == 0 ]; then echo 0; return; fi
+	RANDOM=1
+	Y=$RANDOM
+	((X = $2 - $1 + 1))
+	((X = $Y % $X))
+	((X = $X + $1))
+	echo $X
+}
+
+# Create Dir tree and files in it.
+# arg1 basedir
+# arg2 dir depth
+# arg3 nfile_min
+# arg4 nfile_max
+# arg5 fsize_min
+# arg6 fsize_max
+_fillfs()
+{
+	umask 000
+	local j
+	local i
+	local DIRP
+	local FCNT
+	local FILEP
+	local SCNT
+	local BCNT
+	DIRP=$6
+	for ((j=0; j<$1; j++)); do
+		DIRP=`mktemp -dq $DIRP/dir.XXXXXX`
+		FCNT=$(_rand_range $2 $3)
+		for ((i=0; i<$FCNT; i++)); do
+			FILEP=`mktemp -q $DIRP/file.XXXXXX`
+			SCNT=$(_rand_range $4 $5)
+			dd if=/dev/urandom of=$FILEP bs=$SCNT count=1 status=noxfer 
2>/dev/null &
+		done
+	done
+	wait $!
+}
+
+# arg 1 is dev to remove and is output of the below eg.
+# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
+_devmgt_remove()
+{
+	echo 1 > /sys/class/scsi_device/${1}/device/delete || _fail "Remove 
disk failed"
+}
+
+# arg 1 is dev to add and is output of the below eg.
+# ls -l /sys/class/block/sdd | rev | cut -d "/" -f 3 | rev
+_devmgt_add()
+{
+	local h
+	local tdl
+	# arg 1 will be in h:t:d:l format now in the h and "t d l" format
+	h=`echo ${1} | cut -d":" -f 1`
+	tdl=`echo ${1} | cut -d":" -f 2-|sed 's/:/ /g'`
+
+	echo ${tdl} >  /sys/class/scsi_host/host${h}/scan || _fail "Add disk 
failed"
+}

 
################################################################################

diff --git a/group b/group
index 17466a1..d86624f 100644
--- a/group
+++ b/group
@@ -376,3 +376,4 @@ deprecated
  260 auto quick trim
  261 auto quick quota
  262 auto quick quota
+263 auto quick
-- 
1.7.1


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2011-10-11 11:26 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-05  7:59 [PATCH] snapshot, defragment and raid test cases for btrfs Anand Jain
2011-08-05  7:59 ` Anand Jain
2011-08-05 13:53 ` Amir Goldstein
2011-08-05 13:53   ` Amir Goldstein
2011-08-05 13:53   ` Amir Goldstein
2011-08-05 15:40   ` Greg Freemyer
2011-08-05 15:40     ` Greg Freemyer
2011-08-05 15:40     ` Greg Freemyer
2011-08-05 21:42     ` Greg Freemyer
2011-08-05 21:42       ` Greg Freemyer
2011-08-05 21:42       ` Greg Freemyer
2011-08-06 14:06 ` Dave Chinner
2011-08-06 14:06   ` Dave Chinner
2011-08-11 19:52   ` Anand Jain
2011-08-11 19:52     ` Anand Jain
2011-08-11 20:01 ` [PATCH 1/3] Added test case 257 for btrfs extended snapshot tests Anand Jain
2011-08-11 20:01   ` Anand Jain
2011-08-15  7:52   ` [PATCH v2 " Anand Jain
2011-08-15  7:52     ` Anand Jain
2011-09-02  8:45   ` [PATCH " Christoph Hellwig
2011-09-02  8:45     ` Christoph Hellwig
2011-08-11 20:01 ` [PATCH 2/3] Added test case 258 for btrfs defragmentation Anand Jain
2011-08-11 20:01   ` Anand Jain
2011-08-11 20:01 ` [PATCH 3/3] Added test case 259 for the btrfs raid features Anand Jain
2011-08-11 20:01   ` Anand Jain
2011-09-02  8:49   ` Christoph Hellwig
2011-09-02  8:49     ` Christoph Hellwig
2011-10-03 11:25     ` Anand Jain
2011-10-03 11:25       ` Anand Jain
2011-10-10  9:58     ` [PATCH] Changes to received review comments Anand Jain
2011-10-10  9:58       ` Anand Jain
2011-10-10 11:21       ` Christoph Hellwig
2011-10-10 11:21         ` Christoph Hellwig
2011-10-11 11:25         ` Anand Jain
2011-10-11 11:25           ` Anand Jain
2011-10-11 11:26         ` Anand Jain [this message]
2011-10-11 11:26           ` [PATCH 1/3] 263: Functional test case for the btrfs snapshot Anand Jain
2011-10-11 11:38           ` David Sterba
2011-10-11 11:38             ` David Sterba
2011-10-11 11:42             ` Christoph Hellwig
2011-10-11 11:42               ` Christoph Hellwig
2011-10-11 11:47               ` David Sterba
2011-10-11 11:47                 ` David Sterba
2011-10-11 11:27         ` [PATCH 2/3] 264: Functional test case for the btrfs de-fragmentation Anand Jain
2011-10-11 11:27           ` Anand Jain
2011-10-11 11:28         ` [PATCH 3/3] 265: Functional test case for the btrfs raid operations Anand Jain
2011-10-11 11:28           ` Anand Jain
2011-10-12  4:52 ` [PATCH 0/3] xfstest patch Anand Jain
2011-10-12  4:52   ` Anand Jain
2011-10-12  4:52   ` [PATCH 1/3] 263: Functional test case for the btrfs snapshot Anand Jain
2011-10-12  4:52     ` Anand Jain
2011-10-13  0:56     ` Dave Chinner
2011-10-13  0:56       ` Dave Chinner
2011-10-18  6:28       ` [PATCH 0/3] xfstests patches Anand Jain
2011-10-18  6:28         ` Anand Jain
2011-10-18  6:28         ` [PATCH 1/3] 264: Functional test case for the btrfs snapshot Anand Jain
2011-10-18  6:28           ` Anand Jain
2011-10-19  9:42           ` Christoph Hellwig
2011-10-19  9:42             ` Christoph Hellwig
2011-10-20 15:31             ` Anand Jain
2011-10-20 15:31               ` Anand Jain
2011-10-18  6:28         ` [PATCH 2/3] 265: Functional test case for the btrfs de-fragmentation Anand Jain
2011-10-18  6:28           ` Anand Jain
2011-10-19  9:43           ` Christoph Hellwig
2011-10-19  9:43             ` Christoph Hellwig
2011-10-20 15:32             ` Anand Jain
2011-10-20 15:32               ` Anand Jain
2011-10-18  6:28         ` [PATCH 3/3] 266: Functional test case for the btrfs raid operations Anand Jain
2011-10-18  6:28           ` Anand Jain
2011-10-19  9:45           ` Christoph Hellwig
2011-10-19  9:45             ` Christoph Hellwig
2011-10-20 15:32             ` Anand Jain
2011-10-20 15:32               ` Anand Jain
2011-10-20 15:41         ` [PATCH 0/5] xfstests enhancement and bug fix Anand Jain
2011-10-20 15:41           ` Anand Jain
2011-10-20 15:41           ` [PATCH 1/5] fill files with random data Anand Jain
2011-10-20 15:41             ` Anand Jain
2011-10-25 11:35             ` Christoph Hellwig
2011-10-25 11:35               ` Christoph Hellwig
2011-10-20 15:41           ` [PATCH 2/5] Added SCRATCH_DEV_POOL to specify multiple disks for the btrfs RAID Anand Jain
2011-10-20 15:41             ` Anand Jain
2011-10-25 11:36             ` Christoph Hellwig
2011-10-25 11:36               ` Christoph Hellwig
2011-10-20 15:41           ` [PATCH 3/5] 264: Functional test case for the btrfs snapshot Anand Jain
2011-10-20 15:41             ` Anand Jain
2011-10-25 11:36             ` Christoph Hellwig
2011-10-25 11:36               ` Christoph Hellwig
2011-10-20 15:41           ` [PATCH 4/5] 265: Functional test case for the btrfs raid operations Anand Jain
2011-10-20 15:41             ` Anand Jain
2011-10-25 11:37             ` Christoph Hellwig
2011-10-25 11:37               ` Christoph Hellwig
2011-10-20 15:41           ` [PATCH 5/5] _populate_fs should use OPTIND when getopts is used Anand Jain
2011-10-20 15:41             ` Anand Jain
2011-10-25 11:37             ` Christoph Hellwig
2011-10-25 11:37               ` Christoph Hellwig
2011-10-12  4:52   ` [PATCH 2/3] 264: Functional test case for the btrfs de-fragmentation Anand Jain
2011-10-12  4:52     ` Anand Jain
2011-10-12  4:52   ` [PATCH 3/3] 265: Functional test case for the btrfs raid operations Anand Jain
2011-10-12  4:52     ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E942801.2030902@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=chris.mason@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.