3 # This script is used to test large size LUN support in Lustre.
5 ################################################################################
8 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
9 . $LUSTRE/tests/test-framework.sh
11 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
14 if [ "$REFORMAT" != "yes" ]; then
15 skip_env "$0 reformats all devices,\
16 please set REFORMAT to run this test"
19 # Variable to run mdsrate
20 THREADS_PER_CLIENT=${THREADS_PER_CLIENT:-5} # thread(s) per client node
21 MACHINEFILE=${MACHINEFILE:-$TMP/$TESTSUITE.machines}
22 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
23 NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
26 ALWAYS_EXCEPT="$LARGE_LUN_EXCEPT"
29 LARGE_LUN_RESTORE_MOUNT=false
30 if is_mounted $MOUNT || is_mounted $MOUNT2; then
31 LARGE_LUN_RESTORE_MOUNT=true
33 # Unmount and cleanup the Lustre filesystem
37 FULL_MODE=${FULL_MODE:-false}
38 RUN_FSCK=${RUN_FSCK:-true}
39 # if SLOW=yes, enable the FULL_MODE
40 [[ $SLOW = yes ]] && FULL_MODE=true
41 #########################################################################
42 # Dump the super block information for the filesystem present on device.
48 log "dump the super block information on $facet device $dev"
49 local fstype=$(facet_fstype $facet)
53 cmd="$DUMPE2FS -h $dev" ;;
55 cmd="$ZDB -l $(facet_vdevice $facet)" ;;
57 error "unknown fstype!" ;;
60 do_facet $facet "$cmd"
63 # Report Lustre filesystem disk space usage and inodes usage of each MDT/OST.
72 cmd="lfs df -h $mnt_pnt"
76 cmd="lfs df -i $mnt_pnt"
81 # Cleanup the directories and files created by llverfs utility.
84 local mnt=${2:-$MOUNT}
85 local cmd="rm -rf $mnt/{llverfs,dir}*"
86 do_facet $target "$cmd"
91 generate_machine_file $NODES_TO_USE $MACHINEFILE ||
92 error "can not generate machinefile"
94 # set the default stripe count for files in this test to one
95 local testdir=$MOUNT/mdsrate
98 $LFS setstripe $testdir -i 0 -c 1
101 local num_dirs=$THREADS_PER_CLIENT
102 [[ $num_dirs -eq 0 ]] && num_dirs=1
103 local free_inodes=$(lfs df -i $MOUNT | grep "OST:0" | awk '{print $4}')
105 num_files=$((free_inodes / num_dirs))
107 local command="$MDSRATE $MDSRATE_DEBUG --create --verbose \
108 --ndirs $num_dirs --dirfmt '$testdir/dir%d' \
109 --nfiles $num_files --filefmt 'file%%d'"
112 mpi_run -machinefile $MACHINEFILE \
113 -np $((NUM_CLIENTS * THREADS_PER_CLIENT)) $command
115 if [ ${PIPESTATUS[0]} != 0 ]; then
116 error "mdsrate create failed"
122 local fstype=$(facet_fstype $facet)
126 run_e2fsck $(facet_active_host $facet) $(facet_device $facet) \
127 "-y" || error "run e2fsck error"
130 # Could call fsck.zfs, but currently it does nothing,
131 # Could also call zpool scrub, but that could take a LONG time
132 # do_facet $facet "fsck.zfs $(facet_device $facet)"
137 # Run e2fsck on MDS and OST
141 check_fsfacet $SINGLEMDS
143 for num in $(seq $OSTCOUNT); do
144 check_fsfacet ost${num}
147 ################################## Main Flow ###################################
151 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
152 skip_env "ldiskfs only test"
154 for num in $(seq $OSTCOUNT); do
155 dev=$(ostdevname $num)
156 log "run llverdev on the OST $dev"
157 do_rpc_nodes $(facet_host ost${num}) run_llverdev $dev -vpf ||
158 error "llverdev on $dev failed!"
160 # restore format overwritten by llverdev
163 run_test 1 "run llverdev on raw LUN"
170 for num in $(seq $OSTCOUNT); do
171 dev=$(ostdevname $num)
172 ostmnt=$(facet_mntpt ost${num})
173 fstype=$(facet_fstype ost${num})
175 # Mount the OST as an ldiskfs filesystem.
176 log "mount the OST $dev as a $fstype filesystem"
177 add ost${num} $(mkfs_opts ost${num} $dev) $FSTYPE_OPT \
178 --reformat $(ostdevname $num) \
179 $(ostvdevname $num) > /dev/null ||
180 error "format ost${num} error"
181 if [ $fstype == zfs ]; then
182 import_zpool ost${num}
183 do_facet ost${num} "$ZFS set canmount=on $dev; " \
184 "$ZFS set mountpoint=legacy $dev; $ZFS list $dev"
186 run_dumpfs ost${num} $dev
187 do_facet ost${num} mount -t $fstype $dev \
188 $ostmnt "$OST_MOUNT_OPTS"
190 # Run llverfs on the mounted ldiskfs filesystem in partial mode
191 # to ensure that the kernel can perform filesystem operations
192 # on the complete device without any errors.
193 log "run llverfs in partial mode on the OST $fstype $ostmnt"
194 do_rpc_nodes $(facet_host ost${num}) run_llverfs $ostmnt -vpl \
195 "no" || error "run_llverfs error on $fstype"
198 log "unmount the OST $dev"
201 # After llverfs is run on the ldiskfs filesystem in partial
202 # mode, a full e2fsck should be run to catch any errors early.
203 $RUN_FSCK && check_fsfacet ost${num}
206 log "full mode, mount the OST $dev as a $fstype again"
207 if [ $fstype == zfs ]; then
208 import_zpool ost${num}
210 do_facet ost${num} mount -t $(facet_fstype ost${num}) \
211 $dev $ostmnt "$OST_MOUNT_OPTS"
212 cleanup_dirs ost${num} $ostmnt
213 do_facet ost${num} "sync"
215 run_dumpfs ost${num} $dev
217 # Run llverfs on the mounted ldiskfs filesystem in full
218 # mode to ensure that the kernel can perform filesystem
219 # operations on the complete device without any errors.
220 log "run llverfs in full mode on OST $fstype $ostmnt"
221 do_rpc_nodes $(facet_host ost${num}) run_llverfs \
223 error "run_llverfs error on $fstype"
226 log "unmount the OST $dev"
229 # After llverfs is run on the ldiskfs filesystem in
230 # full mode, a full e2fsck should be run to catch any
232 $RUN_FSCK && check_fsfacet ost${num}
235 # there is no reason to continue using ost devices
236 # filled by llverfs as ldiskfs
239 run_test 2 "run llverfs on OST ldiskfs/zfs filesystem"
242 [ -z "$CLIENTS" ] && skip_env "CLIENTS not defined, skipping"
243 [ -z "$MPIRUN" ] && skip_env "MIPRUN not defined, skipping"
244 [ -z "$MDSRATE" ] && skip_env "MDSRATE not defined, skipping"
245 [ ! -x $MDSRATE ] && skip_env "$MDSRATE not built, skipping"
246 # Setup the Lustre filesystem.
247 log "setup the lustre filesystem"
248 REFORMAT="yes" check_and_setup_lustre
250 log "run mdsrate to use up the free inodes."
251 # Run the mdsrate test suite.
259 run_test 3 "use up free inodes on the OST with mdsrate"
262 # Setup the Lustre filesystem.
263 log "setup the lustre filesystem"
264 REFORMAT="yes" check_and_setup_lustre
267 for num in $(seq $OSTCOUNT); do
268 dev=$(ostdevname $num)
269 run_dumpfs ost${num} $dev
272 # Run llverfs on the mounted Lustre filesystem both in partial and
273 # full mode to to fill the filesystem and verify the file contents.
274 log "run llverfs in partial mode on the Lustre filesystem $MOUNT"
275 run_llverfs $MOUNT -vp "no" || error "run_llverfs error on lustre"
283 # Setup the Lustre filesystem again.
284 log "setup the lustre filesystem again"
287 cleanup_dirs client $MOUNT
291 for num in $(seq $OSTCOUNT); do
292 dev=$(ostdevname $num)
293 run_dumpfs ost${num} $dev
296 log "run llverfs in full mode on the Lustre filesystem $MOUNT"
297 run_llverfs $MOUNT -vl "no" ||
298 error "run_llverfs error on lustre"
306 run_test 4 "run llverfs on lustre filesystem"
309 $LARGE_LUN_RESTORE_MOUNT && setupall
310 check_and_cleanup_lustre