#!/bin/bash
-# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
-# vim:shiftwidth=4:softtabstop=4:tabstop=4:
#
# Run select tests by setting ONLY, or as arguments to the script.
# Skip specific tests by setting EXCEPT.
#
-# Run test by setting NOSETUP=true when ltest has setup env for us
SRCDIR=$(dirname $0)
export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
TGT_UUID2=$(for i in $TGT_LIST2; do printf "$FSNAME-OST%04x_UUID " $i; done)
create_dir() {
- local dir=$1
- local pool=$2
- local count=${3:-"-1"}
- local idx=$4
+ local dir=$1
+ local pool=$2
+ local count=${3:-"-1"}
+ local idx=$4
- mkdir -p $dir
- if [[ -n $idx ]]; then
- $SETSTRIPE -c $count -p $pool -i $idx $dir
- else
- $SETSTRIPE -c $count -p $pool $dir
- fi
- [[ $? -eq 0 ]] ||
- error "$SETSTRIPE -p $pool $dir failed."
+ mkdir -p $dir
+ if [[ -n $idx ]]; then
+ $LFS setstripe -c $count -p $pool -i $idx $dir
+ else
+ $LFS setstripe -c $count -p $pool $dir
+ fi
+ [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $dir failed"
+ [[ "$($LFS getstripe --pool $dir)" == "$pool" ]] ||
+ error "$dir not created in expected pool '$pool'"
}
create_file() {
- local file=$1
- local pool=$2
- local count=${3:-"-1"}
- local index=${4:-"-1"}
- rm -f $file
- $SETSTRIPE -i $index -c $count -p $pool $file
- [[ $? -eq 0 ]] ||
- error "$SETSTRIPE -p $pool $file failed."
+ local file=$1
+ local pool=$2
+ local count=${3:-"-1"}
+ local index=${4:-"-1"}
+ rm -f $file
+ $LFS setstripe -i $index -c $count -p $pool $file
+ [[ $? -eq 0 ]] || error "$LFS setstripe -p $pool $file failed"
+ [[ "$($LFS getstripe --pool $file)" == "$pool" ]] ||
+ error "$file not created in '$pool'"
}
osts_in_pool() {
}
check_dir_in_pool() {
- local dir=$1
- local pool=$2
- local res=$($GETSTRIPE $dir | grep "^stripe_count:" |
- cut -d ':' -f 5 | tr -d "[:blank:]")
- if [[ "$res" != "$pool" ]]; then
- error found $res instead of $pool
- return 1
- fi
+ local dir=$1
+ local pool=$2
+ local res=$($LFS getstripe --pool $dir)
- return 0
-}
+ [ -n "$res" ] || error "dir '$dir' not in any pool"
-check_file_in_pool() {
- local osts=$(osts_in_pool $2)
- check_file_in_osts $1 "$osts" $3
+ [ "$res" == "$pool" ] ||
+ error "dir '$dir' in pool '$res' instead of '$pool'"
}
-check_file_in_osts() {
- local file=$1
- local pool_list=${2:-$TGT_LIST}
- local count=$3
- local res=$($GETSTRIPE $file | grep 0x | cut -f2)
- local i
- for i in $res; do
- found=$(echo :$pool_list: | tr " " ":" | grep :$i:)
- if [[ "$found" == "" ]]; then
- echo "pool list: $pool_list"
- echo "striping: $res"
- $GETSTRIPE $file
- error "$file not allocated from OSTs $pool_list."
- return 1
- fi
- done
+check_file_in_pool() {
+ local file="$1"
+ local pool=$2
+ local count=$3
+ local osts=$(osts_in_pool $pool)
+ local res=$($LFS getstripe --pool $file)
- local ost_count=$($GETSTRIPE $file | grep 0x | wc -l)
- [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
- { error "Stripe count $count expected; got $ost_count" && return 1;}
+ [ -n "$res" ] || error "file '$file' not in any pool"
+ [ "$res" == "$pool" ] ||
+ error "file '$file' in pool '$res' instead of '$pool'"
+ local osts=$(osts_in_pool $2)
+ check_file_in_osts "$file" "$osts" $count
}
-file_pool() {
- $GETSTRIPE -v $1 | grep "^lmm_pool:" | tr -d "[:blank:]" | cut -f 2 -d ':'
+check_file_in_osts() {
+ local file=$1
+ local ost_list=${2:-$TGT_LIST}
+ local count=$3
+ local res=$($LFS getstripe $file | awk '/0x/ { print $1 }')
+ local i
+
+ for i in $res; do
+ found=$(echo :$ost_list: | tr " " ":" | grep :$i:)
+ if [[ "$found" == "" ]]; then
+ echo "ost list: $ost_list"
+ echo "striping: $res"
+ $LFS getstripe -v $file
+ error "$file not allocated from OSTs $ost_list."
+ fi
+ done
+
+ local ost_count=$($LFS getstripe -c $file)
+ [[ -n "$count" ]] && [[ $ost_count -ne $count ]] &&
+ error "$file stripe count $count expected; got $ost_count" &&
+ return 1
+
}
check_file_not_in_pool() {
- local file=$1
- local pool=$2
- local res=$(file_pool $file)
+ local file=$1
+ local pool=$2
+ local res=$($LFS getstripe --pool $file)
- if [[ "$res" == "$pool" ]]; then
- error "File $file is in pool: $res"
- return 1
- else
- return 0
- fi
+ [ "$res" != "$pool" ] || error "File '$file' is in pool: $res"
}
check_dir_not_in_pool() {
local dir=$1
local pool=$2
- local res=$($GETSTRIPE -v $dir | grep "^stripe_count" | head -n1 |
- cut -f 8 -d ' ')
- if [[ "$res" == "$pool" ]]; then
- error "File $dir is in pool: $res"
- return 1
- fi
- return 0
+ local res=$($LFS getstripe --pool $dir)
+
+ [ "$res" != "$pool" ] || error "Dir '$dir' is in pool: $res"
}
drain_pool() {
create_dir $POOL_ROOT/dir1 $POOL
create_dir $POOL_ROOT/dir2 $POOL2
- check_dir_in_pool $POOL_ROOT/dir1 $POOL
- check_dir_in_pool $POOL_ROOT/dir1 $POOL
local numfiles=100
createmany -o $POOL_ROOT/dir1/$tfile $numfiles ||
create_file $POOL_ROOT/file2 $POOL2
echo Checking the files created
- check_dir_in_pool $POOL_ROOT/dir1 $POOL
- check_dir_in_pool $POOL_ROOT/dir2 $POOL2
check_file_in_pool $POOL_ROOT/file1 $POOL
check_file_in_pool $POOL_ROOT/file2 $POOL2
check_file_in_pool $file $POOL $OSTCOUNT
done
- create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
- create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
- create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
- check_file_in_pool $POOL_ROOT/dir1/file1 $POOL 1
- check_file_in_pool $POOL_ROOT/dir1/file2 $POOL 1
- create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
- check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
- check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
- check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
+ create_file $POOL_ROOT/dir1/file1 $POOL 1 $TGT_FIRST
+ create_file $POOL_ROOT/dir1/file2 $POOL 1 $((TGT_FIRST + 1))
+ create_file $POOL_ROOT/dir1/file3 $POOL 1 $((TGT_FIRST + 2))
+ check_file_in_osts $POOL_ROOT/dir1/file1 $((16#$TGT_FIRST))
+ check_file_in_osts $POOL_ROOT/dir1/file2 "$((TGT_FIRST + 1))"
+ check_file_in_osts $POOL_ROOT/dir1/file3 "$((TGT_FIRST + 2))"
create_dir $POOL_ROOT/dir2 $POOL $count
createmany -o $POOL_ROOT/dir2/$tfile- $numfiles ||
check_file_in_pool $file $POOL 1
done
- create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
- createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
- error "createmany $POOL_ROOT/dir5/$tfile- failed!"
- for file in $POOL_ROOT/dir5/*; do
- check_file_in_pool $file $POOL 1
- check_file_in_osts $file "$((TGT_FIRST + 2))"
- done
+ create_dir $POOL_ROOT/dir5 $POOL 1 $((TGT_FIRST + 2))
+ createmany -o $POOL_ROOT/dir5/$tfile- $numfiles ||
+ error "createmany $POOL_ROOT/dir5/$tfile- failed!"
+ for file in $POOL_ROOT/dir5/*; do
+ check_file_in_pool $file $POOL 1
+ done
- rm -rf $POOL_ROOT/dir[1-5]/
+ rm -rf $POOL_ROOT/dir[1-5]/
- return 0
+ return 0
}
run_test 13 "Striping characteristics in a pool"
add_pool $POOL $TGT_HALF "$TGT_UUID2"
add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
- create_dir $POOL_ROOT/dir1 $POOL 1
- create_file $POOL_ROOT/dir1/file $POOL 1
- local OST=$($GETSTRIPE -i $POOL_ROOT/dir1/file)
- i=0
- while [[ $i -lt $numfiles ]]; do
- OST=$((OST + 2))
- [[ $OST -gt $((16#$TGT_MAX)) ]] && OST=$TGT_FIRST
-
- # echo "Iteration: $i OST: $OST"
- create_file $POOL_ROOT/dir1/file${i} $POOL 1
- check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
- i=$((i + 1))
- done
+ create_dir $POOL_ROOT/dir1 $POOL 1
+ create_file $POOL_ROOT/dir1/file $POOL 1
+ local ost=$($LFS getstripe -i $POOL_ROOT/dir1/file)
+ i=0
+ while [[ $i -lt $numfiles ]]; do
+ ost=$((ost + 2))
+ [[ $ost -gt $((16#$TGT_MAX)) ]] && ost=$TGT_FIRST
+
+ # echo "Iteration: $i OST: $ost"
+ create_file $POOL_ROOT/dir1/file${i} $POOL 1
+ check_file_in_pool $POOL_ROOT/dir1/file${i} $POOL
+ i=$((i + 1))
+ done
# Fill up OST0 until it is nearly full.
# Create 9 files of size OST0_SIZE/10 each.
add_pool $POOL $TGT_HALF "$TGT_UUID2"
- create_dir $dir $POOL $OSTCOUNT
- create_file $dir/file1 $POOL $OSTCOUNT
- $GETSTRIPE -v $dir/file1
- check_file_in_pool $dir/file1 $POOL
+ create_dir $dir $POOL $OSTCOUNT
+ create_file $dir/file1 $POOL $OSTCOUNT
+ $LFS getstripe -v $dir/file1
+ check_file_in_pool $dir/file1 $POOL
- rm -rf $dir
+ rm -rf $dir
- return 0
+ return 0
}
run_test 21 "OST pool with fewer OSTs than stripe count"
mkdir $POOL_ROOT/dir4
- for i in 1 2 3 4; do
- dir=${POOL_ROOT}/dir${i}
- local pool
- local pool1
- local count
- local count1
- local index
- local size
- local size1
-
- createmany -o $dir/${tfile} $numfiles ||
- error "createmany $dir/${tfile} failed!"
- res=$($GETSTRIPE -v $dir | grep "^stripe_count:")
- if [ $? -ne 0 ]; then
- res=$($GETSTRIPE -v $dir | grep "^(Default) ")
- pool=$(cut -f 9 -d ' ' <<< $res)
- index=$(cut -f 7 -d ' ' <<< $res)
- size=$(cut -f 5 -d ' ' <<< $res)
- count=$(cut -f 3 -d ' ' <<< $res)
- else
- pool=$(cut -f 8 -d ' ' <<< $res)
- index=$(cut -f 6 -d ' ' <<< $res)
- size=$(cut -f 4 -d ' ' <<< $res)
- count=$(cut -f 2 -d ' ' <<< $res)
- fi
-
- for file in $dir/*; do
- if [ "$pool" != "" ]; then
- check_file_in_pool $file $pool
- fi
- pool1=$(file_pool $file)
- count1=$($GETSTRIPE -v $file | grep "^lmm_stripe_count:" |
- tr -d '[:blank:]' | cut -f 2 -d ':')
- size1=$($GETSTRIPE -v $file | grep "^lmm_stripe_size:" |
- tr -d '[:blank:]' | cut -f 2 -d ':')
- [[ "$pool" != "$pool1" ]] &&
- error "Pool name ($pool) not inherited in $file($pool1)"
- [[ "$count" != "$count1" ]] &&
- error "Stripe count ($count) not inherited in $file ($count1)"
- [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
- error "Stripe size ($size) not inherited in $file ($size1)"
- done
- done
+ for i in 1 2 3 4; do
+ dir=${POOL_ROOT}/dir${i}
+ local pool
+ local pool1
+ local count
+ local count1
+ local index
+ local size
+ local size1
+
+ createmany -o $dir/${tfile} $numfiles ||
+ error "createmany $dir/${tfile} failed!"
+ pool=$($LFS getstripe --pool $dir)
+ index=$($LFS getstripe -i $dir)
+ size=$($LFS getstripe -S $dir)
+ count=$($LFS getstripe -c $dir)
+
+ for file in $dir/*; do
+ if [ "$pool" != "" ]; then
+ check_file_in_pool $file $pool
+ fi
+ pool1=$($LFS getstripe --pool $file)
+ count1=$($LFS getstripe -c $file)
+ size1=$($LFS getstripe -S $file)
+ [[ "$pool" != "$pool1" ]] &&
+ error "Pool '$pool' not on $file:$pool1"
+ [[ "$count" != "$count1" ]] &&
+ error "Stripe count $count not on $file:$count1"
+ [[ "$size" != "$size1" ]] && [[ "$size" != "0" ]] &&
+ error "Stripe size $size not on $file:$size1"
+ done
+ done
- rm -rf $POOL_ROOT
+ rm -rf $POOL_ROOT
- return 0
+ return 0
}
run_test 24 "Independence of pool from other setstripe parameters"
# Veriy that the pool got created and is usable
df $POOL_ROOT > /dev/null
sleep 5
+
# Make sure OST0 can be striped on
$SETSTRIPE -i 0 -c 1 $POOL_ROOT/$tfile
- STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x |
- cut -f2 | tr -d " ")
+ local STR=$($LFS getstripe -i $POOL_ROOT/$tfile)
rm $POOL_ROOT/$tfile
if [[ "$STR" == "0" ]]; then
echo "Creating a file in pool$i"