echo "File system has 4 OSTs with ~660 MiB of space each"
echo ""
lfs df
echo ""
echo "filling OSTs to ~50%"
lfs setstripe -c 4 fill_osts
dd if=/dev/zero bs=1M count=1320 of=./fill_osts

sleep 5

lfs df

echo ""
echo "creating pools"
lctl pool_new lustre.pool1
lctl pool_new lustre.pool2
lctl pool_add lustre.pool1 lustre-OST0000
lctl pool_add lustre.pool1 lustre-OST0001
lctl pool_add lustre.pool2 lustre-OST0002
lctl pool_add lustre.pool2 lustre-OST0003

sleep 10

echo ""
echo "Create PFL file, 0-400M 1 stripe in pool1, 400M-EOF 2 stripes pool2"
echo "lfs setstripe -E 400M -c 1 -p pool1 -E -1 -p pool2 -c 2 pfl_file"
lfs setstripe -E 400M -c 1 -p "pool1" -E -1 -p "pool2" -c 2 pfl_file
echo "press enter to continue"
read junk

echo ""
echo "Getstripe:"
lfs getstripe pfl_file
echo "press enter to continue"
read junk

echo ""
echo "Write 400M to to this file - Get ENOSPC"
dd if=/dev/zero bs=1M count=400 of=./pfl_file
echo ""
echo "File size:"
ls -la pfl_file
echo "press enter to continue"
read junk

echo ""
echo "Getstripe again.  No change:"
lfs getstripe pfl_file

echo "press enter to continue"
read junk

echo ""
echo "Create SEL file, 0-400M 1 stripe in pool1, 400M-EOF 2 stripes pool2"
echo "64 MiB extension size on pool1"
echo "lfs setstripe -E 400M -c 1 -x 64M -p pool1 -E -1 -p pool2 -c 2 sel_file"
lfs setstripe -E 400M -c 1 -x 64M -p "pool1" -E -1 -p "pool2" -c 2 sel_file
echo "press enter to continue"
read junk

echo ""
echo "Getstripe:"
lfs getstripe sel_file
echo "press enter to continue"
read junk

echo ""
echo "Write 400M to to this file - No ENOSPC"
dd if=/dev/zero bs=1M count=400 of=./sel_file
echo ""
echo "File size:"
ls -la sel_file
echo "press enter to continue"
read junk

echo ""
echo "Getstripe again - First component stops at 256 MiB"
lfs getstripe sel_file
echo "press enter to continue"
read junk

echo "Cleaning files..."
rm -f fill_osts pfl_file sel_file

echo "Removing pools"
lctl pool_remove lustre.pool1 lustre-OST0000
lctl pool_remove lustre.pool1 lustre-OST0001
lctl pool_remove lustre.pool2 lustre-OST0002
lctl pool_remove lustre.pool2 lustre-OST0003
lctl pool_destroy lustre.pool1
lctl pool_destroy lustre.pool2

sleep 10

echo "Done"
