+++ /dev/null
-Index: linux-2.6.18-92.1.10/drivers/md/raid5.c
-===================================================================
---- linux-2.6.18-92.1.10.orig/drivers/md/raid5.c 2008-11-10 11:00:51.000000000 +0900
-+++ linux-2.6.18-92.1.10/drivers/md/raid5.c 2008-11-10 11:02:38.000000000 +0900
-@@ -3251,6 +3251,8 @@
- handle_stripe(sh, conf->spare_page, NULL);
- release_stripe(sh);
-
-+ cond_resched();
-+
- spin_lock_irq(&conf->device_lock);
- }
- PRINTK("%d stripes handled\n", handled);
--- /dev/null
+Index: linux-2.6.16.60-0.33/drivers/md/raid5.c
+===================================================================
+--- linux-2.6.16.60-0.33.orig/drivers/md/raid5.c
++++ linux-2.6.16.60-0.33/drivers/md/raid5.c
+@@ -900,6 +900,8 @@ static int add_stripe_bio(struct stripe_
+ bi->bi_next = *bip;
+ *bip = bi;
+ bi->bi_phys_segments ++;
++ if (bio_sync(bi) && !forwrite)
++ clear_bit(R5_UPTODATE, &sh->dev[dd_idx].flags); /* force to read from disk. */
+ spin_unlock_irq(&conf->device_lock);
+ spin_unlock(&sh->lock);
+
+@@ -1617,6 +1619,8 @@ static int make_request (request_queue_t
+ bi->bi_end_io(bi, bytes, 0);
+ }
+ spin_unlock_irq(&conf->device_lock);
++ if (bio_sync(bi))
++ raid5_unplug_device(q);
+ return 0;
+ }
+
--- /dev/null
+Index: linux-2.6.22.14/drivers/md/raid5.c
+===================================================================
+--- linux-2.6.22.14.orig/drivers/md/raid5.c
++++ linux-2.6.22.14/drivers/md/raid5.c
+@@ -1268,6 +1268,8 @@ static int add_stripe_bio(struct stripe_
+ bi->bi_next = *bip;
+ *bip = bi;
+ bi->bi_phys_segments ++;
++ if (bio_sync(bi) && !forwrite)
++ clear_bit(R5_UPTODATE, &sh->dev[dd_idx].flags); /* force to read from disk. */
+ spin_unlock_irq(&conf->device_lock);
+ spin_unlock(&sh->lock);
+
+@@ -2972,6 +2974,8 @@ static int make_request(request_queue_t
+ test_bit(BIO_UPTODATE, &bi->bi_flags)
+ ? 0 : -EIO);
+ }
++ if (bio_sync(bi))
++ raid5_unplug_device(q);
+ return 0;
+ }
+
+++ /dev/null
-#!/bin/bash
-
-export PATH=`dirname $0`/../utils:$PATH
-
-config=${1:-`basename $0 .sh`.xml}
-
-LMC="${LMC:-lmc} -m $config"
-TMP=${TMP:-/tmp}
-
-HOSTNAME=`hostname`
-
-MDSDEV=${MDSDEV:-$TMP/mds1-`hostname`}
-MDSSIZE=${MDSSIZE:-400000}
-FSTYPE=${FSTYPE:-ext3}
-MOUNT=${MOUNT:-/mnt/lustre}
-MOUNT2=${MOUNT2:-${MOUNT}2}
-NETTYPE=${NETTYPE:-tcp}
-
-OSTDEV=${OSTDEV:-$TMP/ost-`hostname`}
-OSTSIZE=${OSTSIZE:-400000}
-
-# specific journal size for the ost, in MB
-JSIZE=${JSIZE:-0}
-[ "$JSIZE" -gt 0 ] && JARG="--journal_size $JSIZE"
-MDSISIZE=${MDSISIZE:-0}
-[ "$MDSISIZE" -gt 0 ] && IARG="--inode_size $MDSISIZE"
-
-STRIPE_BYTES=${STRIPE_BYTES:-1048576}
-STRIPES_PER_OBJ=0 # 0 means stripe over all OSTs
-
-rm -f $config
-
-# create nodes
-${LMC} --add node --node $HOSTNAME || exit 10
-${LMC} --add net --node $HOSTNAME --nid `hostname` --nettype $NETTYPE || exit 11
-${LMC} --add net --node client --nid '*' --nettype $NETTYPE || exit 12
-
-# configure mds server
-${LMC} --add mds --node $HOSTNAME --mds mds1 --fstype $FSTYPE \
- --dev $MDSDEV --size $MDSSIZE $JARG $IARG $MDSOPT || exit 20
-
-# configure ost
-${LMC} -m $config --add lov --lov lov1 --mds mds1 --stripe_sz $STRIPE_BYTES \
- --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0 $LOVOPT || exit 20
-${LMC} --add ost --ost ost1 --node $HOSTNAME --lov lov1 \
- --fstype $FSTYPE --dev $OSTDEV --size $OSTSIZE $JARG $OSTOPT || exit 30
-${LMC} --add ost --ost ost2 --node $HOSTNAME --lov lov1 \
- --fstype $FSTYPE --dev ${OSTDEV}2 --size $OSTSIZE $JARG $OSTOPT || exit 30
-
-# create client config
-${LMC} --add mtpt --node $HOSTNAME --path $MOUNT --mds mds1 --lov lov1 \
- $CLIENTOPT || exit 40
-${LMC} --add mtpt --node client --path $MOUNT2 --mds mds1 --lov lov1 \
- $CLIENTOPT || exit 41
+++ /dev/null
-#!/bin/sh
-set -e
-
-#
-# Runs create.pl and rename.pl on two mountpoints with increasing load, varying
-# debug levels. Assumes that the node is already setup with llmount2.sh
-#
-
-SRCDIR="`dirname $0`"
-CREATE=$SRCDIR/create.pl
-RENAME=$SRCDIR/rename.pl
-
-TIME=${TIME:-/usr/bin/time}
-
-display_elapsed_time() {
- PREVIOUS_TS=$CURRENT_TS
- CURRENT_TS=`date +%s`
- BLOCK_ELAPSED=`expr $CURRENT_TS - $PREVIOUS_TS`
- TOTAL_ELAPSED=`expr $CURRENT_TS - $START_TS`
-
- echo " "
- echo "Elapsed time (block): ${BLOCK_ELAPSED} seconds"
- echo "Elapsed time (TOTAL): ${TOTAL_ELAPSED} seconds"
- echo " "
-}
-
-debug_client_on()
-{
- lctl set_param -n debug=-1
-}
-
-debug_client_off()
-{
- lctl set_param -n debug=0x3f0400
-}
-
-MNT=${MNT:-/mnt/lustre}
-
-# Get our initial timestamps.
-START_TS=`date +%s`
-CURRENT_TS=$START_TS
-PREVIOUS_TS=$START_TS
-
-debug_client_on
-echo "create.pl, 2 mounts, 1 thread, 10 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=10
-echo "create.pl, 2 mounts, 1 thread, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=100 --silent
-echo "create.pl --use_mcreate=0, 2 mounts, 1 thread, 10 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=10 --use_mcreate=0
-echo "create.pl --use_mcreate=0, 2 mounts, 1 thread, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=100 --use_mcreate=0 --silent
-echo "rename.pl, 2 mounts, 1 thread, 10 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=10
-echo "rename.pl, 2 mounts, 1 thread, 100 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=100 --silent
-
-display_elapsed_time
-
-debug_client_off
-echo "create.pl, 2 mounts, 1 thread, 1000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=1000 --silent
-echo "create.pl --use_mcreate=0, 2 mounts, 1 thread, 1000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=1000 --use_mcreate=0 --silent
-echo "rename.pl, 2 mounts, 1 thread, 1000 ops, debug off"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=1000 --silent
-
-display_elapsed_time
-
-debug_client_on
-echo "create.pl, 2 mounts, 2 threads, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=100 --num_threads=2 --silent
-echo "create.pl --use_mcreate=0, 2 mounts, 2 threads, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=100 --num_threads=2 --use_mcreate=0 --silent
-echo "rename.pl, 2 mounts, 2 thread, 1000 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=1000 --num_threads=2 --silent
-
-display_elapsed_time
-
-debug_client_off
-echo "create.pl, 2 mounts, 2 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=2 --silent
-echo "create.pl --use_mcreate=0, 2 mounts, 2 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=2 --use_mcreate=0 --silent
-echo "rename.pl, 2 mounts, 2 threads, 2000 ops, debug off"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=2 --silent
-
-display_elapsed_time
-
-debug_client_on
-echo "create.pl, 2 mounts, 4 threads, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=100 --num_threads=4 --silent
-echo "create.pl --use_mcreate=0, 2 mounts, 4 threads, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=100 --num_threads=4 --use_mcreate=0 --silent
-echo "rename.pl, 2 mounts, 4 threads, 2000 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=4 --silent
-
-display_elapsed_time
-
-debug_client_off
-echo "create.pl, 2 mounts, 4 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=4 --silent
-echo "create.pl --use_mcreate=0, 2 mounts, 4 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=4 --use_mcreate=0 --silent
-echo "rename.pl, 2 mounts, 4 threads, 2000 ops, debug off"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=4 --silent
-
-display_elapsed_time
-
-debug_client_on
-echo "create.pl, 2 mounts, 8 threads, 500 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=500 --num_threads=8 --silent
-echo "create.pl --use_mcreate=0, 2 mounts, 8 threads, 500 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=500 --num_threads=8 --use_mcreate=0 --silent
-echo "rename.pl, 2 mounts, 8 threads, 2000 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=8 --silent
-
-display_elapsed_time
-
-debug_client_off
-echo "create.pl, 2 mounts, 8 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=8 --silent
-echo "create.pl --use_mcreate=0, 2 mounts, 8 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=8 --use_mcreate=0 --silent
-echo "rename.pl, 2 mounts, 8 threads, 2000 ops, debug off"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=2 --iterations=2000 --num_threads=8 --silent
-
-display_elapsed_time
+++ /dev/null
-#!/bin/sh
-set -e
-
-#########################################################################
-# Runs create.pl on a single mountpoint and directory with increasing
-# load across multiple clients.
-#########################################################################
-
-LUSTRE=${LUSTRE:-`dirname $0`/..}
-LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
-PATH=$LUSTRE/utils:$LUSTRE/tests:$PATH
-
-RLUSTRE=${RLUSTRE:-$LUSTRE}
-RPWD=${RPWD:-$PWD}
-
-. $LUSTRE/tests/test-framework.sh
-
-TIME=${TIME:-/usr/bin/time}
-PDSH=${PDSH:-"pdsh -S -w"}
-MOUNTPT=${MOUNTPT:-"/mnt/lustre"}
-
-CREATE=$LUSTRE/tests/create.pl
-RENAME=$LUSTRE/tests/rename.pl
-
-[ -z "$CLIENTS" ] && exit 1
-#CLIENTS=`comma_list $CLIENTS`
-
-display_elapsed_time() {
- PREVIOUS_TS=$CURRENT_TS
- CURRENT_TS=`date +%s`
- BLOCK_ELAPSED=`expr $CURRENT_TS - $PREVIOUS_TS`
- TOTAL_ELAPSED=`expr $CURRENT_TS - $START_TS`
-
- echo " "
- echo "Elapsed time (block): ${BLOCK_ELAPSED} seconds"
- echo "Elapsed time (TOTAL): ${TOTAL_ELAPSED} seconds"
- echo " "
-}
-
-set_debug_level()
-{
- $PDSH $CLIENTS "echo $1 > /proc/sys/lnet/debug"
-}
-
-debug_client_on()
-{
- set_debug_level -1
-}
-
-debug_client_partial()
-{
- set_debug_level 0x3f0400
-}
-
-debug_client_off()
-{
- set_debug_level 0
-}
-
-# Get our initial timestamps.
-START_TS=`date +%s`
-CURRENT_TS=$START_TS
-PREVIOUS_TS=$START_TS
-
-debug_client_off
-
-echo "create.pl, 1 mount, 1 thread, 1000 ops"
-$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $CREATE --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=1000 --silent"
-#echo "create.pl --mcreate=0, 1 mount, 1 thread, 1000 ops, debug off"
-#$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $CREATE --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=1000 --use_mcreate=0 --silent"
-wait
-#echo "rename.pl, 1 mount, 1 thread, 1000 ops, debug off"
-#$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $RENAME --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=1000 --silent"
-
-display_elapsed_time
-
-echo "create.pl, 1 mount, 2 threads, 2000 ops, debug off"
-$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $CREATE --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=2 --silent"
-#echo "create.pl --mcreate=0, 1 mount, 2 threads, 2000 ops, debug off"
-#$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $CREATE --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=2 --use_mcreate=0 --silent"
-wait
-#echo "rename.pl, 1 mount, 2 threads, 2000 ops, debug off"
-#$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $RENAME --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=2 --silent#
-
-display_elapsed_time
-
-echo "create.pl, 1 mount, 4 threads, 2000 ops, debug off"
-$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $CREATE --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=4 --silent"
-#echo "create.pl --mcreate=0, 1 mount, 4 threads, 2000 ops, debug off"
-#$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $CREATE --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=4 --use_mcreate=0 --silent"
-wait
-#echo "rename.pl, 1 mount, 4 threads, 2000 ops, debug off"
-#$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $RENAME --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=4 --silent"
-
-display_elapsed_time
-
-echo "create.pl, 1 mount, 8 threads, 2000 ops, debug off"
-$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $CREATE --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=8 --silent"
-#echo "create.pl --mcreate=0, 1 mount, 8 threads, 2000 ops, debug off"
-#$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $CREATE --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=8 --use_mcreate=0 --silent"
-wait
-#echo "rename.pl, 1 mount, 8 threads, 2000 ops, debug off"
-#$TIME $PDSH $CLIENTS "umask 0022 && cd $RLUSTRE/tests && perl $RENAME --mountpt=${MOUNTPT} --num_mounts=-1 --iterations=2000 --num_threads=8 --silent"
-
-display_elapsed_time
+++ /dev/null
-#!/bin/sh
-set -e
-
-#
-# Runs create.pl and rename.pl on a single mountpoint with increasing
-# load, varying debug levels
-#
-
-SRCDIR="`dirname $0`"
-CREATE=$SRCDIR/create.pl
-RENAME=$SRCDIR/rename.pl
-
-TIME=${TIME:-/usr/bin/time}
-
-display_elapsed_time() {
- PREVIOUS_TS=$CURRENT_TS
- CURRENT_TS=`date +%s`
- BLOCK_ELAPSED=`expr $CURRENT_TS - $PREVIOUS_TS`
- TOTAL_ELAPSED=`expr $CURRENT_TS - $START_TS`
-
- echo " "
- echo "Elapsed time (block): ${BLOCK_ELAPSED} seconds"
- echo "Elapsed time (TOTAL): ${TOTAL_ELAPSED} seconds"
- echo " "
-}
-
-debug_client_on()
-{
- lctl set_param -n debug=-1
-}
-
-debug_client_off()
-{
- lctl set_param -n debug=0x3f0400
-}
-
-MNT=${MNT:-/mnt/lustre}
-
-# Get our initial timestamps.
-START_TS=`date +%s`
-CURRENT_TS=$START_TS
-PREVIOUS_TS=$START_TS
-
-debug_client_on
-echo "create.pl, 1 mount, 1 thread, 10 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=10
-echo "create.pl, 1 mount, 1 thread, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=100 --silent
-echo "create.pl --mcreate=0, 1 mount, 1 thread, 10 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=10 --use_mcreate=0
-echo "create.pl --mcreate=0, 1 mount, 1 thread, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=100 --use_mcreate=0 --silent
-echo "rename.pl, 1 mount, 1 thread, 10 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=10
-echo "rename.pl, 1 mount, 1 thread, 100 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=100 --silent
-
-display_elapsed_time
-
-debug_client_off
-echo "create.pl, 1 mount, 1 thread, 1000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=1000 --silent
-echo "create.pl --mcreate=0, 1 mount, 1 thread, 1000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=1000 --use_mcreate=0 --silent
-echo "rename.pl, 1 mount, 1 thread, 1000 ops, debug off"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=1000 --silent
-
-display_elapsed_time
-
-debug_client_on
-echo "create.pl, 1 mount, 2 threads, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=100 --num_threads=2 --silent
-echo "create.pl --mcreate=0, 1 mount, 2 threads, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=100 --num_threads=2 --use_mcreate=0 --silent
-echo "rename.pl, 1 mount, 2 thread, 1000 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=1000 --num_threads=2 --silent
-
-display_elapsed_time
-
-debug_client_off
-echo "create.pl, 1 mount, 2 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=2 --silent
-echo "create.pl --mcreate=0, 1 mount, 2 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=2 --use_mcreate=0 --silent
-wait
-echo "rename.pl, 1 mount, 2 threads, 2000 ops, debug off"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=2 --silent
-
-display_elapsed_time
-
-debug_client_on
-echo "create.pl, 1 mount, 4 threads, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=100 --num_threads=4 --silent
-echo "create.pl --mcreate=0, 1 mount, 4 threads, 100 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=100 --num_threads=4 --use_mcreate=0 --silent
-echo "rename.pl, 1 mount, 4 threads, 2000 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=4 --silent
-
-display_elapsed_time
-
-debug_client_off
-echo "create.pl, 1 mount, 4 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=4 --silent
-echo "create.pl --mcreate=0, 1 mount, 4 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=4 --use_mcreate=0 --silent
-echo "rename.pl, 1 mount, 4 threads, 2000 ops, debug off"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=4 --silent
-
-display_elapsed_time
-
-debug_client_on
-echo "create.pl, 1 mount, 8 threads, 500 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=500 --num_threads=8 --silent
-echo "create.pl --mcreate=0, 1 mount, 8 threads, 500 ops, debug on"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=500 --num_threads=8 --use_mcreate=0 --silent
-echo "rename.pl, 1 mount, 8 threads, 2000 ops, debug on"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=8 --silent
-
-display_elapsed_time
-
-debug_client_off
-echo "create.pl, 1 mount, 8 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=8 --silent
-echo "create.pl --mcreate=0, 1 mount, 8 threads, 2000 ops, debug off"
-$TIME perl $CREATE --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=8 --use_mcreate=0 --silent
-echo "rename.pl, 1 mount, 8 threads, 2000 ops, debug off"
-$TIME perl $RENAME --mountpt=${MNT} --num_mounts=-1 --iterations=2000 --num_threads=8 --silent
-
-display_elapsed_time
-
-$TIME sh rundbench 1
-
-display_elapsed_time
-
-$TIME sh rundbench 2
-
-display_elapsed_time
-
-$TIME sh rundbench 4
-
-display_elapsed_time
-
-$TIME sh rundbench 8
-
-display_elapsed_time
-
-$TIME sh rundbench 16
-
-display_elapsed_time
-
-$TIME sh rundbench 32
-
-display_elapsed_time
+++ /dev/null
-#!/bin/bash
-
- mkdir /mnt/lustre/d22
- mkdir /mnt/lustre/d22/etc
- ./mcreate /mnt/lustre/d22/etc/foo
- ls -ld /mnt/lustre/etc
- ls -ld /mnt/lustre/d22/etc
+++ /dev/null
-mds_HOST=${mds_HOST:-adev2}
-mdsfailover_HOST=${mdsfailover_HOST:-adev2}
-ost1_HOST=${ost1_HOST:-adev3}
-ost2_HOST=${ost2_HOST:-adev4}
-EXTRA_OSTS=${EXTRA_OSTS:-adev7}
-client_HOST=client
-LIVE_CLIENT=${LIVE_CLIENT:-adev8}
-# This should always be a list, not a regexp
-#FAIL_CLIENTS=${FAIL_CLIENTS:-mdev7}
-FAIL_CLIENTS=${FAIL_CLIENTS:-"adev9 adev10 adev11 adev12"}
-EXTRA_CLIENTS=${EXTRA_CLIENTS:-"adev[13-15]"}
-
-NETTYPE=${NETTYPE:-tcp}
-
-TIMEOUT=${TIMEOUT:-30}
-PTLDEBUG=${PTLDEBUG:-0}
-SUBSYSTEM=${SUBSYSTEM:-0}
-MOUNT=${MOUNT:-"/mnt/lustre"}
-#UPCALL=${CLIENT_UPCALL:-`pwd`/replay-single-upcall.sh}
-
-MDSDEV=${MDSDEV:-/dev/sdc}
-MDSSIZE=${MDSSIZE:-50000}
-MDSJOURNALSIZE=${MDSJOURNALSIZE:-0}
-
-OSTDEV=${OSTDEV:-$TMP/ost%d-`hostname`}
-OSTSIZE=${OSTSIZE:=50000}
-OSTJOURNALSIZE=${OSTJOURNALSIZE:-0}
-
-FSTYPE=${FSTYPE:-ext3}
-STRIPE_BYTES=${STRIPE_BYTES:-1048576}
-STRIPES_PER_OBJ=${STRIPES_PER_OBJ:-0}
-
-FAILURE_MODE=${FAILURE_MODE:-HARD} # or HARD
-POWER_DOWN=${POWER_DOWN:-"powerman --off"}
-POWER_UP=${POWER_UP:-"powerman --on"}
-
-PDSH="pdsh -S -w "
+++ /dev/null
-mds_HOST=${mds_HOST:-mdev4}
-mdsfailover_HOST=${mdsfailover_HOST:-mdev5}
-ost1_HOST=${ost1_HOST:-mdev2}
-ost2_HOST=${ost2_HOST:-mdev3}
-EXTRA_OSTS=${EXTRA_OSTS:-mdev7}
-client_HOST=client
-LIVE_CLIENT=${LIVE_CLIENT:-mdev6}
-# This should always be a list, not a regexp
-FAIL_CLIENTS=${FAIL_CLIENTS:-mdev8}
-#FAIL_CLIENTS=${FAIL_CLIENTS:-""}
-SINGLEMDS=${SINGLEMDS:-"mds"}
-
-NETTYPE=${NETTYPE:-tcp}
-
-TIMEOUT=${TIMEOUT:-30}
-PTLDEBUG=${PTLDEBUG:-0x3f0400}
-SUBSYSTEM=${SUBSYSTEM:- 0xffb7e3ff}
-MOUNT=${MOUNT:-"/mnt/lustre"}
-#UPCALL=${CLIENT_UPCALL:-`pwd`/replay-single-upcall.sh}
-
-MDSDEV=${MDSDEV:-/dev/sda1}
-MDSSIZE=${MDSSIZE:-50000}
-MDSJOURNALSIZE=${MDSJOURNALSIZE:-0}
-
-OSTDEV=${OSTDEV:-$TMP/ost%d-`hostname`}
-OSTSIZE=${OSTSIZE:=500000}
-OSTJOURNALSIZE=${OSTJOURNALSIZE:-0}
-
-FSTYPE=${FSTYPE:-ext3}
-STRIPE_BYTES=${STRIPE_BYTES:-1048576}
-STRIPES_PER_OBJ=${STRIPES_PER_OBJ:-0}
-
-FAILURE_MODE=${FAILURE_MODE:-HARD} # or HARD
-POWER_DOWN=${POWER_DOWN:-"powerman --off"}
-POWER_UP=${POWER_UP:-"powerman --on"}
-
-PDSH="pdsh -S -w "
+++ /dev/null
-
-mds_HOST=${mds_HOST:-mdev4}
-mdsfailover_HOST=${mdsfailover_HOST:-mdev5}
-ost_HOST=${ost_HOST:-mdev2}
-ost2_HOST=${ost2_HOST:-mdev3}
-client_HOST=${client_HOST:-client}
-NETTYPE=${NETTYPE:-tcp}
-SINGLEMDS=${SINGLEMDS:-"mds"}
-
-MOUNT=${MOUNT:-"/mnt/lustre"}
-MOUNT1=${MOUNT1:-$MOUNT}
-MOUNT2=${MOUNT2:-"/mnt/lustre2"}
-DIR=${DIR:-$MOUNT}
-DIR2=${DIR2:-$MOUNT1}
-PTLDEBUG=${PTLDEBUG:-0x3f0400}
-SUBSYSTEM=${SUBSYSTEM:- 0xffb7e3ff}
-PDSH=${PDSH:-pdsh -S -w}
-
-MDSDEV=${MDSDEV:-/dev/sda1}
-MDSSIZE=${MDSSIZE:-100000}
-OSTDEV=${OSTDEV:-/tmp/ost1-`hostname`}
-OSTSIZE=${OSTSIZE:-200000}
-FSTYPE=${FSTYPE:-ext3}
-TIMEOUT=${TIMEOUT:-10}
-#UPCALL=${UPCALL:-$PWD/replay-single-upcall.sh}
-
-STRIPE_BYTES=${STRIPE_BYTES:-1048576}
-STRIPES_PER_OBJ=${STRIPES_PER_OBJ:-0}
-
-FAILURE_MODE=${FAILURE_MODE:-SOFT} # or HARD
-POWER_DOWN=${POWER_DOWN:-"powerman --off"}
-POWER_UP=${POWER_UP:-"powerman --on"}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/tests/cmknod.c
- *
- * Simple test to check that device nodes are correctly created and visible
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#define TEST_MINOR 120
-#define TEST_MAJOR 25
-
-void usage(char *prog)
-{
- fprintf(stderr, "usage: %s <filename>\n", prog);
- exit(1);
-}
-
-/* UMKA: This stuff inlined here instead of using appropriate header
- to avoid linking to symbols which is not present in newer libc.
-
- Currently this is the case, as UML image contains RedHat 9 and
- developers use something newer (Fedora, etc.). */
-inline unsigned int
-__gnu_dev_major (unsigned long long int __dev)
-{
- return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
-}
-
-inline unsigned int
-__gnu_dev_minor (unsigned long long int __dev)
-{
- return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
-}
-
-inline unsigned long long int
-__gnu_dev_makedev (unsigned int __major, unsigned int __minor)
-{
- return ((__minor & 0xff) | ((__major & 0xfff) << 8)
- | (((unsigned long long int) (__minor & ~0xff)) << 12)
- | (((unsigned long long int) (__major & ~0xfff)) << 32));
-}
-
-#define __minor(dev) __gnu_dev_minor(dev)
-#define __major(dev) __gnu_dev_major(dev)
-#define __makedev(maj, min) __gnu_dev_makedev(maj, min)
-
-int main( int argc, char **argv)
-{
- char *prog = argv[0];
- char *filename = argv[1];
- int rc;
- struct stat st;
- dev_t device = __makedev(TEST_MAJOR, TEST_MINOR);
-
- if (argc != 2)
- usage(prog);
-
- unlink(filename);
-
- /* First try block devices */
- rc = mknod(filename, 0700 | S_IFBLK, device);
- if ( rc < 0 ) {
- fprintf(stderr, "%s: mknod(%s) failed: rc %d: %s\n",
- prog, filename, errno, strerror(errno));
- return 2;
- }
-
- rc = stat(filename, &st);
- if ( rc < 0 ) {
- fprintf(stderr, "%s: stat(%s) failed: rc %d: %s\n",
- prog, filename, errno, strerror(errno));
- return 3;
- }
-
- if ( st.st_rdev != device) {
- fprintf(stderr, "%s: created device other than requested: (%u,%u) instead of (%u,%u)\n",
- prog, __major(st.st_rdev),__minor(st.st_rdev),__major(device),__minor(device));
- return 4;
- }
- if (!S_ISBLK(st.st_mode)) {
- fprintf(stderr, "%s: created device of different type. Requested block device, got mode %o\n", prog, st.st_mode);
- return 5;
- }
-
- rc = unlink(filename);
- if ( rc < 0 ) {
- fprintf(stderr, "%s: Cannot unlink created device %s, rc %d: %s\n",
- prog, filename, errno, strerror(errno));
- return 6;
- }
-
- /* Second try char devices */
- rc = mknod(filename, 0700 | S_IFCHR, device);
- if ( rc < 0 ) {
- fprintf(stderr, "%s: mknod(%s) failed: rc %d: %s\n",
- prog, filename, errno, strerror(errno));
- return 7;
- }
-
- rc = stat(filename, &st);
- if ( rc < 0 ) {
- fprintf(stderr, "%s: stat(%s) failed: rc %d: %s\n",
- prog, filename, errno, strerror(errno));
- return 8;
- }
- if ( st.st_rdev != device) {
- fprintf(stderr, "%s: created device other than requested: (%u,%u) instead of (%u,%u)\n",
- prog, __major(st.st_rdev),__minor(st.st_rdev),__major(device),__minor(device));
- return 9;
- }
- if (!S_ISCHR(st.st_mode)) {
- fprintf(stderr, "%s: created device of different type. Requested char device, got mode %o\n", prog, st.st_mode);
- return 10;
- }
-
- rc = unlink(filename);
- if ( rc < 0 ) {
- fprintf(stderr, "%s: Cannot unlink created device %s, rc %d: %s\n",
- prog, filename, errno, strerror(errno));
- return 11;
- }
-
- printf("%s: device nodes created correctly\n", prog);
-
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-
-
-config=${1:-$(basename $0 .sh)}.xml
-
-LMC=${LMC:-../utils/lmc -m $config}
-TMP=${TMP:-/tmp}
-
-HOSTNAME=`hostname`
-
-MDSDEV=${MDSDEV:-$TMP/mds1-`hostname`}
-MDSSIZE=50000
-FSTYPE=${FSTYPE:-ext3}
-
-OSTDEV=${OSTDEV:-$TMP/ost1-`hostname`}
-OSTSIZE=200000
-
-rm -f $config
-# create nodes
-${LMC} --add node --node $HOSTNAME || exit 10
-${LMC} --add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp || exit 11
-
-# configure mds server
-${LMC} --add mds --node $HOSTNAME --mds mds1 --fstype $FSTYPE --dev $MDSDEV --size $MDSSIZE || exit 20
-
-# configure ost
-${LMC} --add ost --node $HOSTNAME --obd obd1 --fstype $FSTYPE --obdtype obdecho || exit 30
-# configure ost
-${LMC} --add ost --node $HOSTNAME --obd obd2 --fstype $FSTYPE --obdtype obdecho || exit 30
-
-${LMC} --add cobd --node $HOSTNAME --real_obd obd1 --cache_obd obd2
-
-# create client config
-# ${LMC} -m $config --add mtpt --node $HOSTNAME --path /mnt/lustre --mds mds1 --obd obd1 || exit 40
+++ /dev/null
-#!/bin/sh
-TMP=${TMP:-/tmp}
-BASEDIR=${1:-`dirname $0`/..}
-LCMD=$TMP/crash-mod-`hostname`
-echo "Storing crash module info in $LCMD"
-cat /tmp/ogdb-`hostname` | while read JUNK M JUNK; do
- MOD="$BASEDIR/$M"
- MODNAME=`basename $MOD .o`
-
- echo mod -s $MODNAME $MOD | tee -a $LCMD
-done
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <time.h>
-#include <sys/time.h>
-
-int thread;
-
-#define BAD_VERBOSE (-999999999)
-
-#define difftime(a, b) \
- ((double)(a)->tv_sec - (b)->tv_sec + \
- ((double)((a)->tv_usec - (b)->tv_usec) / 1000000))
-
-static char *cmdname(char *func)
-{
- static char buf[512];
-
- if (thread) {
- sprintf(buf, "%s-%d", func, thread);
- return buf;
- }
-
- return func;
-}
-
-static int be_verbose(int verbose, struct timeval *next_time,
- unsigned long num, unsigned long *next_num, int num_total)
-{
- struct timeval now;
-
- if (!verbose)
- return 0;
-
- if (next_time != NULL)
- gettimeofday(&now, NULL);
-
- /* A positive verbosity means to print every X iterations */
- if (verbose > 0 && (num >= *next_num || num >= num_total)) {
- *next_num += verbose;
- if (next_time) {
- next_time->tv_sec = now.tv_sec - verbose;
- next_time->tv_usec = now.tv_usec;
- }
- return 1;
- }
-
- /* A negative verbosity means to print at most each X seconds */
- if (verbose < 0 && next_time != NULL && difftime(&now, next_time) >= 0){
- next_time->tv_sec = now.tv_sec - verbose;
- next_time->tv_usec = now.tv_usec;
- *next_num = num;
- return 1;
- }
-
- return 0;
-}
-
-static int get_verbose(char *func, const char *arg)
-{
- int verbose;
- char *end;
-
- if (!arg || arg[0] == 'v')
- verbose = 1;
- else if (arg[0] == 's' || arg[0] == 'q')
- verbose = 0;
- else {
- verbose = (int)strtoul(arg, &end, 0);
- if (*end) {
- fprintf(stderr, "%s: error: bad verbose option '%s'\n",
- func, arg);
- return BAD_VERBOSE;
- }
- }
-
- if (verbose < 0)
- printf("Print status every %d seconds\n", -verbose);
- else if (verbose == 1)
- printf("Print status every operation\n");
- else if (verbose > 1)
- printf("Print status every %d operations\n", verbose);
-
- return verbose;
-}
-
-int main(int argc, char *argv[])
-{
- char filename[1024];
- int verbose = 0;
- unsigned long count, i;
- int threads = 0;
- char *end;
- int rc = 0;
-
- if (argc < 3 || argc > 5) {
- fprintf(stderr,
- "usage: %s <filename> <count> [verbose [threads]]\n",
- argv[0]);
- exit(1);
- }
-
- count = strtoul(argv[2], &end, 0);
- if (*end) {
- fprintf(stderr, "%s: error: bad iteration count '%s'\n",
- argv[0], argv[1]);
- exit(2);
- }
- if (argc == 4) {
- verbose = get_verbose(argv[0], argv[3]);
- if (verbose == BAD_VERBOSE)
- exit(2);
- }
- if (argc == 5) {
- threads = strtoul(argv[4], &end, 0);
- if (*end) {
- fprintf(stderr, "%s: error: bad thread count '%s'\n",
- argv[0], argv[1]);
- exit(2);
- }
- }
-
- for (i = 1; i <= threads; i++) {
- rc = fork();
- if (rc < 0) {
- fprintf(stderr, "%s: error: #%ld - %s\n",
- cmdname(argv[0]), i, strerror(rc = errno));
- break;
- } else if (rc == 0) {
- thread = i;
- break;
- } else
- printf("%s: thread #%ld (PID %d) started\n",
- cmdname(argv[0]), i, rc);
- rc = 0;
- }
-
- if (threads && thread == 0) { /* parent process */
- int live_threads = threads;
-
- while (live_threads > 0) {
- int status;
- pid_t ret;
-
- ret = waitpid(0, &status, 0);
- if (ret == 0) {
- continue;
- }
-
- if (ret < 0) {
- fprintf(stderr, "%s: error: wait - %s\n",
- argv[0], strerror(errno));
- if (!rc)
- rc = errno;
- } else {
- /*
- * This is a hack. We _should_ be able to use
- * WIFEXITED(status) to see if there was an
- * error, but it appears to be broken and it
- * always returns 1 (OK). See wait(2).
- */
- int err = WEXITSTATUS(status);
- if (err || WIFSIGNALED(status))
- fprintf(stderr,
- "%s: error: PID %d had rc=%d\n",
- argv[0], ret, err);
- if (!rc)
- rc = err;
-
- live_threads--;
- }
- }
- } else {
- struct timeval start, end, next_time;
- unsigned long next_count;
- double diff;
-
- gettimeofday(&start, NULL);
- next_time.tv_sec = start.tv_sec - verbose;
- next_time.tv_usec = start.tv_usec;
-
- for (i = 0, next_count = verbose; i < count; i++) {
- if (threads)
- sprintf(filename, "%s-%d-%ld",
- argv[1], thread, i);
- else
- sprintf(filename, "%s-%ld", argv[1], i);
-
- rc = mknod(filename, S_IFREG, 0);
- if (rc < 0) {
- fprintf(stderr, "%s: error: mknod(%s): %s\n",
- cmdname(argv[0]), filename,
- strerror(errno));
- rc = errno;
- break;
- }
- if (unlink(filename) < 0) {
- fprintf(stderr, "%s: error: unlink(%s): %s\n",
- cmdname(argv[0]), filename,
- strerror(errno));
- rc = errno;
- break;
- }
- if (be_verbose(verbose, &next_time,i,&next_count,count))
- printf("%s: number %ld\n", cmdname(argv[0]), i);
- }
-
- gettimeofday(&end, NULL);
- diff = difftime(&end, &start);
-
- printf("%s: %ldx2 files in %.4gs (%.4g ops/s): rc = %d: %s",
- cmdname(argv[0]), i, diff, (double)i * 2 / diff,
- rc, ctime(&end.tv_sec));
- }
- return rc;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-
-int main(int argc, char **argv)
-{
- int fd;
- int rc;
-
- fd = open(".", O_RDONLY);
- if (fd < 0) {
- perror("opening '.' :");
- exit(2);
- }
-
- rc = chdir("/mnt/lustre/subdir/subdir");
- if (rc) {
- perror("cannot chdir subdir:");
- exit(3);
- }
-
- rc = fchdir(fd);
- if (rc) {
- perror("cannot fchdir back\n");
- exit(4);
- }
-
- rc = close(fd);
- if (rc) {
- perror("cannot close '.'\n");
- exit(5);
- }
-
- return(0);
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/utsname.h>
-#include <string.h>
-
-struct file_addr {
- char path[256];
- char modname[32];
- unsigned long base;
-};
-
-int print_symbol_address(struct file_addr * fa)
-{
- char buffer[4096];
- char cmd[256];
- char func_name[256];
- unsigned long addr;
- char mode[256];
- FILE *file;
-
- sprintf(cmd, "modprobe -l %s", fa->modname);
- file = popen(cmd, "r");
- if (!file) {
- printf("failed to execute %s:%s\n."
- "Have you installed modules?\n",
- cmd, strerror(errno));
- pclose(file);
- return -1;
- }
- if (fgets(buffer, 4095, file) == NULL) {
- printf("failed to get modprobe ouput for %s:%s\n",
- fa->modname, strerror(errno));
- pclose(file);
- return -1;
- }
- pclose(file);
-
- sprintf(cmd, "nm -n %s", buffer);
- file = popen(cmd, "r");
- if (!file) {
- printf("failed to execute %s:%s\n."
- "Have you installed modules?\n",
- cmd, strerror(errno));
- return -1;
- }
-
- while (fgets(buffer, 4095, file)) {
- if (fscanf(file, "%x %s %s\n", &addr, mode, func_name) != 3)
- continue;
-
- /* only list symbol in text section. */
- if (strcasecmp(mode, "t") == 0) {
- /* skip __init functoin. How to filter others? */
- if (strcmp(func_name, "init_module") != 0)
- printf("%x %s %s\n", fa->base + addr,
- mode, func_name);
- }
- }
- pclose(file);
- return 0;
-}
-
-
-int generate_symbol_file()
-{
- static char* cmd = "lctl modules";
- char other[4096];
- FILE *file;
- struct file_addr gfa;
-
- memset(&gfa, 0, sizeof(gfa));
- file = popen(cmd, "r");
- if (!file) {
- printf("failed to execute %s: %s\n", cmd, strerror(errno));
- return -1;
- }
-
- while ( fscanf(file, "%s %s %lx\n", other, gfa.path, &gfa.base) == 3) {
- strncpy(gfa.modname, strrchr(gfa.path, '/') + 1,
- strrchr(gfa.path, '.') - strrchr(gfa.path, '/') - 1);
-
- //fprintf(stderr, "%s %s %#x\n", gfa.path, gfa.modname, gfa.base);
-
- /* continue going without checking result */
- print_symbol_address(&gfa);
- memset(&gfa, 0, sizeof(gfa));
- }
- pclose(file);
- return 0;
-}
-
-
-int main()
-{
- return generate_symbol_file();
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <errno.h>
-
-int main(int argc, char **argv)
-{
- DIR *dir;
- struct dirent64 *entry;
-
- if (argc < 2) {
- fprintf(stderr, "Usage: %s dirname\n", argv[0]);
- return 1;
- }
-
- dir = opendir(argv[1]);
- if (!dir) {
- int rc = errno;
- perror("opendir");
- return rc;
- }
-
- while ((entry = readdir64(dir))) {
- puts(entry->d_name);
- }
-
- closedir(dir);
-
- return 0;
-}
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <ldap.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-
-int main(int argc, char **argv)
-{
- LDAP *ld;
- int err;
-
- ld = ldap_init("localhost", 389);
- if (!ld) {
- fprintf(stderr, "ldap_init: %s\n", strerror(errno));
- exit(1);
- }
-
- err = ldap_bind_s(ld, "cn=Manager,dc=lustre,dc=cfs", "secret",
- LDAP_AUTH_SIMPLE);
- if (err) {
- fprintf(stderr, "ldap_bind: %s\n", ldap_err2string(err));
- exit(1);
- }
-
-
-
-
-}
+++ /dev/null
-#!/bin/bash
-
-# liblustre sanity test. specially written for UML for now
-
-LCONF=${LCONF:-../utils/lconf}
-
-LLIP=127.0.0.1
-
-LTREE_KERNEL=${LTREE_KERNEL:-../../lustre}
-LTREE_USER=${LTREE_USER:-../../lustre-lib}
-HOSTNAME=`hostname`
-
-# checking
-if [ ! -e $LTREE_KERNEL ]; then
- echo "$LTREE_KERNEL dosen't exits"
- exit 1
-fi
-
-if [ ! -e $LTREE_USER ]; then
- echo "$LTREE_USER dosen't exits"
- exit 1
-fi
-
-if [ ! -e $LTREE_USER/liblustre/lltest ]; then
- echo "$LTREE_USER/liblustre/lltest dosen't exits"
- exit 1
-fi
-
-workdir=`pwd`
-
-cleanup()
-{
- curdir=`pwd`
- cd $LTREE_KERNEL/tests
- $LCONF --node $HOSTNAME --cleanup --force $LTREE_USER/tests/$configfile 2>&1 > /dev/null
- cd $curdir
-}
-
-configfile=liblustre_sanity_uml.xml
-
-# generate config file
-rm -f $configfile
-MDSNODE=$HOSTNAME OSTNODES=$HOSTNAME CLIENTS=$LLIP sh uml.sh $configfile
-if [ ! -e $configfile ]; then
- echo "fail to generate config file $configfile"
- exit 1
-fi
-
-# generate dump file
-rm -f /tmp/DUMP_FILE
-$LCONF --lctl_dump /tmp/DUMP_FILE --node $LLIP $configfile
-if [ ! -e /tmp/DUMP_FILE ]; then
- echo "error creating dumpfile"
- exit 1
-fi
-
-#setup lustre server
-cd $LTREE_KERNEL/tests
-$LCONF --node $HOSTNAME --reformat $LTREE_USER/tests/$configfile
-rc=$?
-if [ $rc -ne 0 ]; then
- echo "setup lustre server: error $rc"
- cleanup
- exit 1
-fi
-cd $workdir
-
-#do liblustre testing
-$LTREE_USER/liblustre/lltest
-rc=$?
-if [ $rc -ne 0 ]; then
- echo "liblustre test error $rc"
- cleanup
- exit 1
-fi
-
-echo "===== liblustre sanity test complete sucessfully ====="
-
-echo -n "===== cleanup... "; cleanup; echo "done ====="
-
-cd $workdir
-
-exit 0
+++ /dev/null
-#!/bin/sh
-
-PATH=`dirname $0`/../utils:$PATH
-
-LCONF=${LCONF:-lconf}
-NAME=${NAME:-echo}
-
-config=$NAME.xml
-mkconfig=$NAME.sh
-
-if [ "$LUSTRE" ]; then
- lustre_opt="--lustre=$LUSTRE"
-fi
-
-[ -f $config ] || sh -x $mkconfig $config || exit 1
-
-$LCONF $lustre_opt --reformat $@ $OPTS $config || exit 4
-
-cat <<EOF
-
-run getattr tests as:
-`dirname $0`../utils/lctl --device '\$ECHO_$SERVER' test_getattr 1000000
-EOF
+++ /dev/null
-#!/bin/bash
-
-config=${1:-mcr.xml}
-
-LMC="../utils/lmc -m $config"
-
-# TCP/IP servers
-SERVERS="ba-ost-1 ba-ost-2"
-ROUTER=dev5
-
-# Elan clients
-CLIENT_LO=dev2
-CLIENT_HI=dev25
-
-TCPBUF=1048576
-
-
-h2elan () {
- echo $1 | sed 's/[^0-9]*//g'
-}
-
-h2tcp () {
- echo "${1}"
-}
-
-[ -f $config ] && rm $config
-
-# Client node
-${LMC} --add net --node client --nid '*' --nettype elan || exit 1
-# Router node
-${LMC} --add net --router --node $ROUTER --tcpbuf $TCPBUF --nid `h2tcp $ROUTER` --nettype tcp || exit 1
-${LMC} --add net --node $ROUTER --nid `h2elan $ROUTER` --nettype elan|| exit 1
-${LMC} -m $config --add route --node $ROUTER --nettype elan --gw `h2elan $ROUTER` --lo `h2elan $CLIENT_LO` --hi `h2elan $CLIENT_HI` || exit 2
-
-for s in $SERVERS
- do
- # server node
- ${LMC} --add net --node $s --tcpbuf $TCPBUF --nid $s --nettype tcp || exit 1
- # route to server
- ${LMC} --add route --node $ROUTER --nettype tcp --gw `h2tcp $ROUTER` --lo $s || exit 2
- # the device on the server
- ${LMC} --add ost --node $s --obd obd_$s --obdtype=obdecho || exit 3
- # attach to the device on the client (this would normally be a mount)
- ${LMC} --add oscref --node client --osc OSC_obd_$s || exit 4
-done
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-/* for O_DIRECTORY */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-int main(int argc, char **argv)
-{
- int fd, rc;
-
- if (argc != 2) {
- printf("Usage: %s <filename>\n", argv[0]);
- exit(1);
- }
-
- fd = open(argv[1], O_RDONLY | O_CREAT, 0600);
- if (fd == -1) {
- printf("Error opening %s for create: %s\n", argv[1],
- strerror(errno));
- exit(1);
- }
- rc = close(fd);
- if (rc < 0) {
- printf("Error closing %s: %s\n", argv[1], strerror(errno));
- exit(1);
- }
-
- fd = open(argv[1], O_DIRECTORY);
- if (fd >= 0) {
- printf("opening %s as directory should have returned an "
- "error!\n", argv[1]);
- exit(1);
- }
- if (errno != ENOTDIR) {
- printf("opening %s as directory, expected -ENOTDIR and got "
- "%s\n", argv[1], strerror(errno));
- exit(1);
- }
-
- return 0;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-/* for O_DIRECT */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-
-#include <libcfs/libcfs.h>
-#include <lustre/lustre_user.h>
-#ifndef O_DIRECT
-#define O_DIRECT 0
-#endif
-
-int main(int argc, char *argv[])
-{
- char filename[1024];
- unsigned long count, i;
- int thread = 0;
- int threads = 0;
- int rc = 0;
- int fd, ioctl_flags = 0;
-
- if (argc < 3 || argc > 4) {
- fprintf(stderr, "usage: %s <filename> <iterations> [threads]\n",
- argv[0]);
- exit(1);
- }
-
- count = strtoul(argv[2], NULL, 0);
- if (argc == 4)
- threads = strtoul(argv[3], NULL, 0);
-
- for (i = 1; i <= threads; i++) {
- rc = fork();
- if (rc < 0) {
- fprintf(stderr, "error: %s: #%ld - %s\n", argv[0], i,
- strerror(rc = errno));
- break;
- } else if (rc == 0) {
- thread = i;
- argv[2] = "--device";
- break;
- } else
- printf("%s: thread #%ld (PID %d) started\n",
- argv[0], i, rc);
- rc = 0;
- }
-
- if (threads && thread == 0) { /* parent process */
- int live_threads = threads;
-
- while (live_threads > 0) {
- int status;
- pid_t ret;
-
- ret = waitpid(0, &status, 0);
- if (ret == 0)
- continue;
-
- if (ret < 0) {
- if (!rc)
- rc = errno;
- fprintf(stderr, "error: %s: wait - %s\n",
- argv[0], strerror(rc));
- } else {
- /*
- * This is a hack. We _should_ be able to use
- * WIFEXITED(status) to see if there was an
- * error, but it appears to be broken and it
- * always returns 1 (OK). See wait(2).
- */
- int err = WEXITSTATUS(status);
- if (err || WIFSIGNALED(status))
- fprintf(stderr,
- "%s: PID %d had rc=%d\n",
- argv[0], ret, err);
- if (!rc)
- rc = err;
- }
- live_threads--;
- }
- } else {
- if (threads)
- sprintf(filename, "%s-%d", argv[1], thread);
- else
- strcpy(filename, argv[1]);
-
- fd = open(filename, O_RDWR|O_CREAT, 0644);
- if (fd < 0) {
- rc = errno;
- fprintf(stderr, "open(%s, O_CREAT): %s\n", filename,
- strerror(rc));
- exit(rc);
- }
- if (close(fd) < 0) {
- rc = errno;
- fprintf(stderr, "close(): %s\n", strerror(rc));
- goto unlink;
- }
-
- for (i = 0; i < count; i++) {
- fd = open(filename, O_RDWR|O_LARGEFILE|O_DIRECT);
- if (fd < 0) {
- rc = errno;
- fprintf(stderr, "open(%s, O_RDWR): %s\n",
- filename, strerror(rc));
- break;
- }
- if (ioctl(fd, LL_IOC_SETFLAGS, &ioctl_flags) < 0 &&
- errno != ENOTTY) {
- rc = errno;
- fprintf(stderr, "ioctl(): %s\n", strerror(rc));
- break;
- }
- if (close(fd) < 0) {
- rc = errno;
- fprintf(stderr, "close(): %s\n", strerror(rc));
- break;
- }
- }
- unlink:
- if (unlink(filename) < 0) {
- rc = errno;
- fprintf(stderr, "unlink(%s): %s\n", filename,
- strerror(rc));
- }
- if (threads)
- printf("Thread %d done: rc = %d\n", thread, rc);
- else
- printf("Done: rc = %d\n", rc);
- }
- return rc;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
- int fd;
-
- if (argc != 2) {
- printf("Usage openme <filename>\n");
- exit(1);
- }
-
- fd = open(argv[1], O_RDONLY | O_CREAT, 0600);
- if (fd == -1) {
- printf("Error opening %s\n", argv[1]);
- exit(1);
- }
-
- sleep(10000000);
- return 0;
-}
+++ /dev/null
-#!/bin/bash
-#
-# Run select tests by setting ONLY, or as arguments to the script.
-# Skip specific tests by setting EXCEPT.
-#
-# e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
-set -e
-
-ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 2108
-ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
-# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-#case `uname -r` in
-#2.6.*) ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c 55" # bug 3117
-#esac
-
-[ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
-
-SRCDIR=`dirname $0`
-export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
-export SECURITY=${SECURITY:-"null"}
-
-TMP=${TMP:-/tmp}
-FSTYPE=${FSTYPE:-ldiskfs}
-
-CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
-CREATETEST=${CREATETEST:-createtest}
-LFS=${LFS:-lfs}
-LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
-LFIND=${LFIND:-"$LFS find"}
-LVERIFY=${LVERIFY:-ll_dirstripe_verify}
-LCTL=${LCTL:-lctl}
-MCREATE=${MCREATE:-mcreate}
-OPENFILE=${OPENFILE:-openfile}
-OPENUNLINK=${OPENUNLINK:-openunlink}
-TOEXCL=${TOEXCL:-toexcl}
-TRUNCATE=${TRUNCATE:-truncate}
-MUNLINK=${MUNLINK:-munlink}
-SOCKETSERVER=${SOCKETSERVER:-socketserver}
-SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
-IOPENTEST1=${IOPENTEST1:-iopentest1}
-IOPENTEST2=${IOPENTEST2:-iopentest2}
-PTLDEBUG=${PTLDEBUG:-0}
-
-export NAME=${NAME:-lmv}
-
-SAVE_PWD=$PWD
-
-LUSTRE=${LUSTRE:-`dirname $0`/..}
-. $LUSTRE/tests/test-framework.sh
-init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/lmv.sh}
-
-cleanup() {
- echo -n "cln.."
- cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
-}
-CLEANUP=${CLEANUP:-:}
-
-setup() {
- echo -n "mnt.."
- load_modules
- setupall || exit 10
- echo "done"
-}
-
-SETUP=${SETUP:-:}
-
-log() {
- echo "$*"
- $LCTL mark "$*" 2> /dev/null || true
-}
-
-trace() {
- log "STARTING: $*"
- strace -o $TMP/$1.strace -ttt $*
- RC=$?
- log "FINISHED: $*: rc $RC"
- return 1
-}
-TRACE=${TRACE:-""}
-
-check_kernel_version() {
- VERSION_FILE=version
- WANT_VER=$1
- [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
- GOT_VER=$(lctl get_param $VERSION_FILE | awk '/kernel:/ {print $2}')
- [ $GOT_VER -ge $WANT_VER ] && return 0
- log "test needs at least kernel version $WANT_VER, running $GOT_VER"
- return 1
-}
-
-_basetest() {
- echo $*
-}
-
-basetest() {
- IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
-}
-
-run_one() {
- if ! grep -q $DIR /proc/mounts; then
- $SETUP
- fi
- testnum=$1
- message=$2
- BEFORE=`date +%s`
- log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
- export TESTNAME=test_$testnum
- export tfile=f${testnum}
- export tdir=d${base}
- test_${testnum} || error "exit with rc=$?"
- unset TESTNAME
- pass "($((`date +%s` - $BEFORE))s)"
- cd $SAVE_PWD
- $CLEANUP
-}
-
-build_test_filter() {
- [ "$ALWAYS_EXCEPT$EXCEPT$SANITY_EXCEPT" ] && \
- echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITY_EXCEPT`"
-
- for O in $ONLY; do
- eval ONLY_${O}=true
- done
- for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
- eval EXCEPT_${E}=true
- done
-}
-
-_basetest() {
- echo $*
-}
-
-basetest() {
- IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
-}
-
-run_test() {
- export base=`basetest $1`
- if [ "$ONLY" ]; then
- testname=ONLY_$1
- if [ ${!testname}x != x ]; then
- run_one $1 "$2"
- return $?
- fi
- testname=ONLY_$base
- if [ ${!testname}x != x ]; then
- run_one $1 "$2"
- return $?
- fi
- echo -n "."
- return 0
- fi
- testname=EXCEPT_$1
- if [ ${!testname}x != x ]; then
- echo "skipping excluded test $1"
- return 0
- fi
- testname=EXCEPT_$base
- if [ ${!testname}x != x ]; then
- echo "skipping excluded test $1 (base $base)"
- return 0
- fi
- run_one $1 "$2"
- return $?
-}
-
-[ "$SANITYLOG" ] && rm -f $SANITYLOG || true
-
-error() {
- lctl set_param fail_loc=0
- log "FAIL: $TESTNAME $@"
- $LCTL dk $TMP/lustre-log-$TESTNAME.log
- if [ "$SANITYLOG" ]; then
- echo "FAIL: $TESTNAME $@" >> $SANITYLOG
- else
- exit 1
- fi
-}
-
-pass() {
- echo PASS $@
-}
-
-mounted_lustre_filesystems() {
- awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
-}
-
-MOUNTED="`mounted_lustre_filesystems`"
-if [ -z "$MOUNTED" ]; then
- formatall
- setupall
- MOUNTED="`mounted_lustre_filesystems`"
- [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
- I_MOUNTED=yes
-fi
-
-[ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
-
-DIR=${DIR:-$MOUNT}
-[ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
-
-LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
-OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
-STRIPECOUNT=`lctl get_param -n lov.$LOVNAME.stripecount`
-STRIPESIZE=`lctl get_param -n lov.$LOVNAME.stripesize`
-ORIGFREE=`lctl get_param -n lov.$LOVNAME.kbytesavail`
-MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
-MDS=$(lctl get_param -N mdt.* | grep -v num_refs | tail -n 1 | cut -d"." -f2)
-
-[ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
-[ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
-rm -rf $DIR/[Rdfs][1-9]*
-
-build_test_filter
-
-if [ "${ONLY}" = "MOUNT" ] ; then
- echo "Lustre is up, please go on"
- exit
-fi
-
-echo "preparing for tests involving mounts"
-EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
-touch $EXT2_DEV
-mke2fs -j -F $EXT2_DEV 8000 > /dev/null
-echo # add a newline after mke2fs.
-
-umask 077
-
-test_0a() {
- mkdir $DIR/0a0 || error
- for ((i=0;i<5000;i++)); do
- mkdir $DIR/0a0/`uuidgen -t` || error
- done
- rm -rf $DIR/0a0 || error
-}
-#run_test 0a " create random names ============================="
-
-test_1a() {
- mkdir $DIR/1a0 || error
- createmany -o $DIR/1a0/f 5000 || error
- rmdir $DIR/1a0 && error
- rm -rf $DIR/1a0 || error
-}
-run_test 1a " remove splitted dir ============================="
-
-test_1b() {
- mkdir $DIR/1b0 || error
- createmany -o $DIR/1b0/f 5000 || error
- unlinkmany $DIR/1b0/f 5000 || error
- NUM=`ls $DIR/1b0 | wc -l`
- if [ $NUM -ne 0 ] ; then
- echo "dir must be empty"
- error
- fi
-
- touch $DIR/1b0/file0 || error
- touch $DIR/1b0/file1 || error
- touch $DIR/1b0/file2 || error
-
- echo "3 files left"
- rmdir $DIR/1b0 && error
- rm -f $DIR/1b0/file0
-
- echo "2 files left"
- rmdir $DIR/1b0 && error
- rm -f $DIR/1b0/file1
-
- echo "1 files left"
- rmdir $DIR/1b0 && error
- rm -f $DIR/1b0/file2
-
- echo "0 files left"
- rmdir $DIR/1b0 || error
-}
-run_test 1b " remove splitted dir ============================="
-
-test_1c() {
- mkdir $DIR/1b1 || error
- createmany -o $DIR/1b1/f 5000 || error
- unlinkmany $DIR/1b1/f 5000 || error
- NUM=`ls $DIR/1b1 | wc -l`
- if [ $NUM -ne 0 ] ; then
- echo "dir must be empty"
- error
- fi
- touch $DIR/1b1/file0 || error
- touch $DIR/1b1/file1 || error
- touch $DIR/1b1/file2 || error
-
- ls $DIR/1b1/
- log "3 files left"
- rmdir $DIR/1b1 && error
- rm -f $DIR/1b1/file0
-
- ls $DIR/1b1/
- log "2 files left"
- rmdir $DIR/1b1 && error
- rm -f $DIR/1b1/file1
-
- ls $DIR/1b1/
- log "1 files left"
- rmdir $DIR/1b1 && error
- rm -f $DIR/1b1/file2
-
- ls $DIR/1b1/
- log "0 files left"
- rmdir $DIR/1b1 || error
-}
-run_test 1c " remove splitted cross-node dir ============================="
-
-test_2a() {
- mkdir $DIR/2a0 || error
- createmany -o $DIR/2a0/f 5000 || error
- NUM=`ls $DIR/2a0 | wc -l`
- echo "found $NUM files"
- if [ $NUM -ne 5000 ]; then
- echo "wrong number of files: $NUM"
- error
- fi
- rm -rf $DIR/2a0 || error
-}
-run_test 2a " list splitted dir ============================="
-
-test_2b() {
- mkdir $DIR/2b1 || error
- createmany -o $DIR/2b1/f 5000 || error
- $CLEAN
- $START
- statmany -l $DIR/2b1/f 5000 5000 || error
- statmany -s $DIR/2b1/f 5000 5000 || error
- rm -rf $DIR/2b1 || error
-}
-run_test 2b " list splitted dir after remount ============================="
-
-test_3a() {
- mkdir $DIR/3a0 || error
- for i in `seq 100`; do
- mkdir $DIR/3a0/d${i} || error
- done
- createmany -o $DIR/3a0/f 5000 || error
- rm -rf $DIR/3a0 || error
-}
-run_test 3a " dir splitting with cross-ref ============================="
-
-test_3b() {
- mkdir $DIR/3b1 || error
- createmany -m $DIR/3b1/f 5000 || error
- rm -rf $DIR/3b1 || error
-}
-run_test 3b " dir splitting via createmany -m ============================="
-
-test_3c() {
- mkdir $DIR/3c1 || error
- echo "MDS nodes: $MDSCOUNT"
- for j in `seq 3`; do
- for i in `seq 10`; do
- $LFS dirstripe $DIR/3c1/d-${j}-${i} $j || error
- createmany -m $DIR/3c1/d-${j}-${i}/m 200 || error
- createmany -o $DIR/3c1/d-${j}-${i}/o 200 || error
- done
- done
- rm -rf $DIR/3c1 || error
-}
-
-#run_test 3c " dir splitting via lfs stripe ============================="
-
-test_4a() {
- let rr=0
- while let "rr < 33000"; do
- if let "rr % 2000 == 0"; then
- echo "$rr"
- fi
- mkdir $DIR/4a1 || error
- rm -rf $DIR/4a1
- let "rr = rr + 1"
- done
-}
-
-## this test is very time-consuming, don't run it by default
-#run_test 4a " FIDS/ nlink overflow test ============================="
-
-test_5a() {
- mount_client $MOUNT2
- # create a cross-ref file
- mkdir -p $MOUNT/$tdir/d1
- mkdir -p $MOUNT2/$tdir/d2
- dd if=/dev/zero of=$MOUNT/$tdir/d1/f1 count=1
- mv $MOUNT2/$tdir/d1/f1 $MOUNT2/$tdir/d2/
- # XXX: a check the file is a cross-ref one is needed.
- cancel_lru_locks mdc
- cancel_lru_locks osc
- dd if=$MOUNT2/$tdir/d2/f1 of=/dev/null
- stat $MOUNT2/$tdir/d2 $MOUNT2/$tdir/d2/f1 > /dev/null
- can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
- awk '/ldlm_cancel/ {print $2}'`
- blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
- awk '/ldlm_bl_callback/ {print $2}'`
- unlink $MOUNT2/$tdir/d2/f1
- can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
- awk '/ldlm_cancel/ {print $2}'`
- blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
- awk '/ldlm_bl_callback/ {print $2}'`
- umount $MOUNT2
- [ $can1 -eq $can2 ] && error "It does not look like a cross-ref file."
- [ $[$can1+1] -eq $can2 ] || error $[$[$can2-$can1]] "cancel RPC occured."
- [ $blk1 -eq $blk2 ] || error $[$[$blk2-$blk1]] "blocking RPC occured."
-}
-run_test 5a "Early Lock Cancel: cross-ref unlink"
-
-test_5b() {
- mount_client $MOUNT2
- # create a cross-ref file
- mkdir -p $MOUNT/$tdir/d1
- mkdir -p $MOUNT2/$tdir/d2
- dd if=/dev/zero of=$MOUNT/$tdir/d1/f1 count=1
- cancel_lru_locks mdc
- cancel_lru_locks osc
- dd if=$MOUNT2/$tdir/d1/f1 of=/dev/null
- stat $MOUNT2/$tdir/d1/f1 $MOUNT2/$tdir/d2 > /dev/null
- can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
- awk '/ldlm_cancel/ {print $2}'`
- blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
- awk '/ldlm_bl_callback/ {print $2}'`
- ln $MOUNT2/$tdir/d1/f1 $MOUNT2/$tdir/d2/f2
- can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
- awk '/ldlm_cancel/ {print $2}'`
- blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
- awk '/ldlm_bl_callback/ {print $2}'`
- umount $MOUNT2
- [ $can1 -eq $can2 ] && error "It does not look like a cross-ref file."
- [ $[$can1+1] -eq $can2 ] || error $[$[$can2-$can1]] "cancel RPC occured."
- [ $blk1 -eq $blk2 ] || error $[$[$blk2-$blk1]] "blocking RPC occured."
-}
-run_test 5b "Early Lock Cancel: cross-ref link"
-
-TMPDIR=$OLDTMPDIR
-TMP=$OLDTMP
-HOME=$OLDHOME
-
-log "cleanup: ======================================================"
-if [ "`mount | grep ^$NAME`" ]; then
- rm -rf $DIR/[Rdfs][1-9]*
-fi
-if [ "$I_MOUNTED" = "yes" ]; then
- cleanupall -f || error "cleanup failed"
-fi
-
-echo '=========================== finished ==============================='
-[ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true
+++ /dev/null
-#!/bin/sh
-[ `hostname` = "uml1" ] && date --set="Mar 14 20:21:41 MDT 1973" #101010101
-[ `hostname` = "uml2" ] && date --set="May 26 22:43:22 MDT 1976" #202020202
-[ `hostname` = "uml3" ] && date --set="Aug 9 01:05:03 MDT 1979" #303030303
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <time.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define BUFSIZE (4096)
-
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
-int main(int argc, char *argv[])
-{
-
- FILE *w_str;
- int read_fd;
- int rc, iter;
- int line, delta, next;
- int sleeptime = 0;
- char *now_time;
- const char ok_chars[] = "MonTueWedThuFriSatSun"
- "JanFebMarAprMayJunJulAugSepOctNovDec"
- "Line 0123456789 of file, written at:\n";
-
- char buf_r[BUFSIZE];
-
- char pathname[256] = "/mnt/lustre/linetest_";
- char *host;
-
- if (argc > 1) {
- strncpy(pathname, argv[1], 255);
- pathname[255] = '\0';
- }
-
- host = getenv("HOSTNAME");
- if (host)
- strcat(pathname, host);
-
- if (argc > 2)
- sleeptime = strtoul(argv[2], NULL, 0);
-
- if (sleeptime == 0)
- sleeptime = 30;
-
- printf("Test file used is: %s at %ds intervals\n", pathname, sleeptime);
-
- w_str = fopen(pathname, "wb");
- if (w_str == NULL) {
- perror("fopen");
- exit(1);
- }
- read_fd = open(pathname, O_RDONLY);
- if (read_fd < 0) {
- perror("open");
- exit(1);
- }
-
- next = 1;
- delta = 17;
- iter = 1;
- while (1) {
- time_t now;
- struct tm *t;
- long offset;
-
- now = time((time_t *)NULL);
- t = localtime(&now);
- now_time = asctime(t);
-
- printf("iter: %d\n", iter);
-
- for (line=next; line<(next+delta); line++) {
- rc = fprintf(w_str, "Line %8d of file, written at: %s",
- line, now_time);
- /* \n comes from ctime() result */
- if (rc <= 0) {
- perror("fprintf");
- exit(4);
- }
- rc = fflush(w_str);
- if (rc != 0) {
- perror("fflush");
- exit(5);
- }
- }
- next += delta;
-
- /* Check for corruption */
- offset = ftell(w_str);
- rc = lseek(read_fd, offset & ~4095, SEEK_SET);
- if (rc != (offset & ~4095)) {
- perror("lseek");
- exit(7);
- }
-
- rc = read(read_fd, buf_r, min(100, offset & 4095));
- if (rc != min(100, offset & 4095)) {
- printf("rc: %d, off %lu buf: '%s'\n", rc,offset,buf_r);
- exit(8);
- }
- buf_r[rc] = 0;
- /* Chars from "C" days/months, and above Line */
- if (strspn(buf_r, ok_chars) != rc) {
- printf("Corruption detected at %lu on %s",
- offset & ~4095, now_time);
- exit(9);
- }
-
- sleep(sleeptime);
- iter++;
- }
-
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-/* Beware when setting FSROOT that I've not made any attempts to avoid buffer
- * overruns below--this is a test program, it's a static buffer. */
-#define FSROOT "/mnt"
-#define OBD_ITERATIONS 10000
-
-int main (int argc, char * argv[])
-{
- int fd, rc, err = -1;
- struct stat stat_buf;
-
- if (argc < 2) {
- printf("syntax: %s command\n", argv[0]);
- printf("Where command is one of \"setup\" or \"create\".\n");
- exit(1);
- }
-
- if (!strcmp(argv[1], "setup")) {
- printf("This is silly.\n");
- } else if (!strcmp(argv[1], "create")) {
- int i, iter;
-
- if (argc < 3) {
- printf("create requires a nonzero argument.\n");
- exit(1);
- }
-
- iter = atoi(argv[2]);
-
- if (iter < 1) {
- printf("create requires a nonzero argument.\n");
- exit(1);
- }
- printf("creating %d files...\n", iter);
-
- for (i = 0; i < iter; i++) {
- fd = creat(FSROOT "/foo123", S_IRWXU);
- close(fd);
- unlink(FSROOT "/foo123");
- }
- } else {
- printf("Invalid command, run with no arguments for help.\n");
- }
-
- return 0;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-void
-usage (char *argv0, int help)
-{
- char *progname = strrchr(argv0, '/');
-
- if (progname == NULL)
- progname = argv0;
-
- fprintf (help ? stdout : stderr,
- "Usage: %s [-e] file\n", progname);
-
- if (!help)
- {
- fprintf (stderr, " or try '-h' for help\n");
- exit (1);
- }
-
- printf ("Create the given file with O_EXCL...\n");
- printf (" -e expect EEXIST\n");
- printf (" -h print help");
- printf (" Exit status is 0 on success, 1 on failure\n");
-}
-
-int main(int argc, char **argv)
-{
- int rc;
- int want_eexist = 0;
-
- while ((rc = getopt (argc, argv, "eh")) != -1)
- switch (rc)
- {
- case 'e':
- want_eexist = 1;
- break;
- case 'h':
- usage (argv[1], 1);
- return (0);
- default:
- usage (argv[0], 0);
- }
-
- if (optind != argc - 1) {
- usage (argv[0], 0);
- return 1;
- }
-
- rc = open(argv[optind], O_CREAT|O_EXCL, 0644);
- if (rc == -1)
- {
- if (want_eexist && errno == EEXIST)
- {
- printf("open failed: %s (expected)\n", strerror(errno));
- return (0);
- }
- printf("open failed: %s\n", strerror(errno));
- return (1);
- } else {
- if (want_eexist)
- {
- printf("open success (expecting EEXIST).\n");
- return (1);
- }
- printf("open success.\n");
- return (0);
- }
-
- return ((rc == 0) ? 0 : 1);
-}