test out attr2 with different number of extents and number

of EAs - with both sizes shrinking and enlarging and changing
formats. Need to fix up the output before setting live.
Merge of master-melb:xfs-cmds:27208a by kenmcd.

  test out attr2 with different number of extents and number
  of EAs - with both sizes shrinking and enlarging and changing
  formats. Need to fix up the output before setting live.
This commit is contained in:
Tim Shimmin
2006-10-17 06:10:19 +00:00
parent b60faa180d
commit 7dcf3ce6f9
4 changed files with 2113 additions and 4 deletions
Executable
+174
View File
@@ -0,0 +1,174 @@
#! /bin/sh
# FS QA Test No. 135
#
# Test the attr2 code
# Let's look, xfs_db, at the inode and its literal area for the
# extents and the attributes
#
#-----------------------------------------------------------------------
# Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
#-----------------------------------------------------------------------
#
# creator
owner=tes@puffy.melbourne.sgi.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
# real QA test starts here
_notrun "Need to fix up filtering before checkin"
# Modify as appropriate.
_supported_fs xfs
_supported_os IRIX Linux
_require_scratch
export MKFS_OPTIONS="-i size=512,attr=2"
_scratch_mkfs_xfs
_scratch_mount
file=$SCRATCH_MNT/file
touch $file
inum=`ls -i $file | awk '{print $1}'`
echo "inum=$inum"
add_eas()
{
start=$1
end=$2
echo ""; echo "** add $start..$end EAs **"
i=$start
while [ $i -le $end ]; do
attr -s name.$i -V value $file >/dev/null
i=`expr $i + 1`
done
}
rm_eas()
{
start=$1
end=$2
echo ""; echo "** rm $start..$end EAs **"
i=$start
while [ $i -le $end ]; do
attr -r name.$i $file >/dev/null
i=`expr $i + 1`
done
}
do_extents()
{
num=$1
echo ""; echo "** $num extents **"
src/makeextents -v -p -w -n $num $file
}
_print_inode()
{
#sync
#sleep 2
umount $SCRATCH_MNT
xfs_db -r -c "inode $inum" -c "print" $SCRATCH_DEV |\
awk '
/nextents/ { print; next }
/naextents/ { print; next }
/u\./ { print; next }
/a\./ { print; next }
/forkoff/ { printf("core.forkoff = %d (%d bytes)\n", $3, $3*8); next }
/format/ { print; next }
/size/ { print; next }
'
_scratch_mount
}
# main
_print_inode
add_eas 1 1
_print_inode
add_eas 2 2
_print_inode
add_eas 3 4
_print_inode
add_eas 5 8
_print_inode
add_eas 9 16
_print_inode
add_eas 17 20
_print_inode
add_eas 21 21
_print_inode
add_eas 22 22
_print_inode
add_eas 23 23
_print_inode
add_eas 24 24
_print_inode
add_eas 25 25
_print_inode
add_eas 26 30
_print_inode
add_eas 31 35
_print_inode
rm_eas 1 34
_print_inode
# now do the extents
#build up
j=1
while [ $j -le 30 ]; do
do_extents $j
_print_inode
j=`expr $j + 2`
done
#scale down
j=30
while [ $j -ge 1 ]; do
do_extents $j
_print_inode
j=`expr $j - 2`
done
#build up
j=1
while [ $j -le 30 ]; do
do_extents $j
_print_inode
j=`expr $j + 2`
done
# success, all done
status=0
exit
+1903
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -215,3 +215,4 @@ pattern ajones@sgi.com
133 rw 133 rw
134 quota auto 134 quota auto
135 metadata auto 135 metadata auto
136 attr2
+35 -4
View File
@@ -24,6 +24,7 @@
char *progname; char *progname;
__uint64_t num_holes = 1000; __uint64_t num_holes = 1000;
__uint64_t curr_holes;
int verbose_opt = 0; int verbose_opt = 0;
char *filename; char *filename;
int status_num = 100; int status_num = 100;
@@ -32,6 +33,10 @@ int preserve;
unsigned int blocksize; unsigned int blocksize;
__uint64_t fileoffset; __uint64_t fileoffset;
#define JUMP_SIZE (128 * 1024)
#define NUMHOLES_TO_SIZE(i) (i * JUMP_SIZE)
#define SIZE_TO_NUMHOLES(s) (s / JUMP_SIZE)
void void
usage(void) usage(void)
{ {
@@ -50,7 +55,7 @@ main(int argc, char *argv[])
__uint64_t offset; __uint64_t offset;
int blocksize = 512; int blocksize = 512;
unsigned char *buffer = NULL; unsigned char *buffer = NULL;
struct stat stat;
progname = argv[0]; progname = argv[0];
@@ -101,9 +106,35 @@ main(int argc, char *argv[])
return 1; return 1;
} }
for (i = 0; i < num_holes; i++) { if (fstat(fd, &stat) < 0) {
perror("stat");
return 1;
}
if (preserve) {
curr_holes = SIZE_TO_NUMHOLES(stat.st_size);
if (num_holes < curr_holes) {
/* we need to truncate back */
if (ftruncate(fd, NUMHOLES_TO_SIZE(num_holes)) < 0) {
perror("ftruncate");
return 1;
}
if (verbose_opt) {
printf("truncating back to %lu\n", NUMHOLES_TO_SIZE(num_holes));
}
return 0;
}
}
else {
curr_holes = 0;
}
if (curr_holes != 0 && verbose_opt) {
printf("creating %lu more holes\n", num_holes - curr_holes);
}
/* create holes by seeking and writing */
for (i = curr_holes; i < num_holes; i++) {
offset = i * 128 * 1024 + fileoffset; offset = NUMHOLES_TO_SIZE(i) + fileoffset;
if (lseek64(fd, offset, SEEK_SET) < 0) { if (lseek64(fd, offset, SEEK_SET) < 0) {
perror("lseek"); perror("lseek");
@@ -116,7 +147,7 @@ main(int argc, char *argv[])
} }
if (verbose_opt && ((i+1) % status_num == 0)) { if (verbose_opt && ((i+1) % status_num == 0)) {
printf("seeked and wrote %llu times\n", i+1); printf("seeked and wrote %lu times\n", i+1);
} }
} }