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 # Variable to run mdsrate
15 THREADS_PER_CLIENT=${THREADS_PER_CLIENT:-5} # thread(s) per client node
16 MACHINEFILE=${MACHINEFILE:-$TMP/$TESTSUITE.machines}
17 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
18 NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
21 ALWAYS_EXCEPT="$LARGE_LUN_EXCEPT"
24 LARGE_LUN_RESTORE_MOUNT=false
25 if is_mounted $MOUNT || is_mounted $MOUNT2; then
26 LARGE_LUN_RESTORE_MOUNT=true
28 # Unmount and cleanup the Lustre filesystem
32 FULL_MODE=${FULL_MODE:-false}
33 RUN_FSCK=${RUN_FSCK:-true}
34 # if SLOW=yes, enable the FULL_MODE
35 [[ $SLOW = yes ]] && FULL_MODE=true
36 #########################################################################
37 # Dump the super block information for the filesystem present on device.
43 log "dump the super block information on $facet device $dev"
44 local fstype=$(facet_fstype $facet)
48 cmd="$DUMPE2FS -h $dev" ;;
50 cmd="$ZDB -l $(facet_vdevice $facet)" ;;
52 error "unknown fstype!" ;;
55 do_facet $facet "$cmd"
58 # Report Lustre filesystem disk space usage and inodes usage of each MDT/OST.
67 cmd="lfs df -h $mnt_pnt"
71 cmd="lfs df -i $mnt_pnt"
76 # Cleanup the directories and files created by llverfs utility.
79 local mnt=${2:-$MOUNT}
80 local cmd="rm -rf $mnt/{*.filecount,dir*}"
81 do_facet $target "$cmd"
86 generate_machine_file $NODES_TO_USE $MACHINEFILE ||
87 error "can not generate machinefile"
89 # set the default stripe count for files in this test to one
90 local testdir=$MOUNT/mdsrate
93 $LFS setstripe $testdir -i 0 -c 1
96 local num_dirs=$THREADS_PER_CLIENT
97 [[ $num_dirs -eq 0 ]] && num_dirs=1
98 local free_inodes=$(lfs df -i $MOUNT | grep "OST:0" | awk '{print $4}')
100 num_files=$((free_inodes / num_dirs))
102 local command="$MDSRATE $MDSRATE_DEBUG --create --verbose \
103 --ndirs $num_dirs --dirfmt '$testdir/dir%d' \
104 --nfiles $num_files --filefmt 'file%%d'"
107 mpi_run -machinefile $MACHINEFILE \
108 -np $((NUM_CLIENTS * THREADS_PER_CLIENT)) $command
110 if [ ${PIPESTATUS[0]} != 0 ]; then
111 error "mdsrate create failed"
117 local fstype=$(facet_fstype $facet)
121 run_e2fsck $(facet_active_host $facet) $(facet_device $facet) \
122 "-y" || error "run e2fsck error"
125 # Could call fsck.zfs, but currently it does nothing,
126 # Could also call zpool scrub, but that could take a LONG time
127 # do_facet $facet "fsck.zfs $(facet_device $facet)"
132 # Run e2fsck on MDS and OST
136 check_fsfacet $SINGLEMDS
138 for num in $(seq $OSTCOUNT); do
139 check_fsfacet ost${num}
142 ################################## Main Flow ###################################
146 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] &&
147 skip "Only applicable to ldiskfs-based nodes" && return
149 for num in $(seq $OSTCOUNT); do
150 dev=$(ostdevname $num)
151 log "run llverdev on the OST $dev"
152 do_rpc_nodes $(facet_host ost${num}) run_llverdev $dev -vpf ||
153 error "llverdev on $dev failed!"
156 run_test 1 "run llverdev on raw LUN"
163 for num in $(seq $OSTCOUNT); do
164 dev=$(ostdevname $num)
165 ostmnt=$(facet_mntpt ost${num})
166 fstype=$(facet_fstype ost${num})
168 # Mount the OST as an ldiskfs filesystem.
169 log "mount the OST $dev as a $fstype filesystem"
170 add ost${num} $(mkfs_opts ost${num} $dev) $FSTYPE_OPT \
171 --reformat $(ostdevname $num) \
172 $(ostvdevname $num) > /dev/null ||
173 error "format ost${num} error"
174 if [ $fstype == zfs ]; then
175 import_zpool ost${num}
176 do_facet ost${num} "$ZFS set canmount=on $dev; " \
177 "$ZFS set mountpoint=legacy $dev; $ZFS list $dev"
179 run_dumpfs ost${num} $dev
180 do_facet ost${num} mount -t $fstype $dev \
181 $ostmnt "$OST_MOUNT_OPTS"
183 # Run llverfs on the mounted ldiskfs filesystem in partial mode
184 # to ensure that the kernel can perform filesystem operations
185 # on the complete device without any errors.
186 log "run llverfs in partial mode on the OST $fstype $ostmnt"
187 do_rpc_nodes $(facet_host ost${num}) run_llverfs $ostmnt -vpl \
188 "no" || error "run_llverfs error on $fstype"
191 log "unmount the OST $dev"
194 # After llverfs is run on the ldiskfs filesystem in partial
195 # mode, a full e2fsck should be run to catch any errors early.
196 $RUN_FSCK && check_fsfacet ost${num}
199 log "full mode, mount the OST $dev as a $fstype again"
200 if [ $fstype == zfs ]; then
201 import_zpool ost${num}
203 do_facet ost${num} mount -t $(facet_fstype ost${num}) \
204 $dev $ostmnt "$OST_MOUNT_OPTS"
205 cleanup_dirs ost${num} $ostmnt
206 do_facet ost${num} "sync"
208 run_dumpfs ost${num} $dev
210 # Run llverfs on the mounted ldiskfs filesystem in full
211 # mode to ensure that the kernel can perform filesystem
212 # operations on the complete device without any errors.
213 log "run llverfs in full mode on OST $fstype $ostmnt"
214 do_rpc_nodes $(facet_host ost${num}) run_llverfs \
216 error "run_llverfs error on $fstype"
219 log "unmount the OST $dev"
222 # After llverfs is run on the ldiskfs filesystem in
223 # full mode, a full e2fsck should be run to catch any
225 $RUN_FSCK && check_fsfacet ost${num}
229 run_test 2 "run llverfs on OST ldiskfs/zfs filesystem"
232 [ -z "$CLIENTS" ] && skip_env "CLIENTS not defined, skipping" && return
233 [ -z "$MPIRUN" ] && skip_env "MIPRUN not defined, skipping" && return
234 [ -z "$MDSRATE" ] && skip_env "MDSRATE not defined, skipping" && return
235 [ ! -x $MDSRATE ] && skip_env "$MDSRATE not built, skipping" && return
236 # Setup the Lustre filesystem.
237 log "setup the lustre filesystem"
238 REFORMAT="yes" check_and_setup_lustre
240 log "run mdsrate to use up the free inodes."
241 # Run the mdsrate test suite.
249 run_test 3 "use up free inodes on the OST with mdsrate"
252 # Setup the Lustre filesystem.
253 log "setup the lustre filesystem"
254 REFORMAT="yes" check_and_setup_lustre
257 for num in $(seq $OSTCOUNT); do
258 dev=$(ostdevname $num)
259 run_dumpfs ost${num} $dev
262 # Run llverfs on the mounted Lustre filesystem both in partial and
263 # full mode to to fill the filesystem and verify the file contents.
264 log "run llverfs in partial mode on the Lustre filesystem $MOUNT"
265 run_llverfs $MOUNT -vp "no" || error "run_llverfs error on lustre"
273 # Setup the Lustre filesystem again.
274 log "setup the lustre filesystem again"
277 cleanup_dirs client $MOUNT
281 for num in $(seq $OSTCOUNT); do
282 dev=$(ostdevname $num)
283 run_dumpfs ost${num} $dev
286 log "run llverfs in full mode on the Lustre filesystem $MOUNT"
287 run_llverfs $MOUNT -vl "no" ||
288 error "run_llverfs error on lustre"
296 run_test 4 "run llverfs on lustre filesystem"
299 $LARGE_LUN_RESTORE_MOUNT && setupall
300 check_and_cleanup_lustre