1#!/bin/sh 2 3# Problem Report kern/92272 : [ffs] [hang] Filling a filesystem while creating 4# a snapshot on it locks the system 5 6# John Kozubik <john@kozubik.com> 7 8# If a filesystem is completely full (approaching 110% in `df` output on 9# most systems), mksnap_ffs will refuse to begin a snapshot for that reason. 10# There seem to be no negative consequences. 11 12# However, if the filesystem is not quite completely full, mksnap_ffs will 13# (correctly) begin creating the snapshot as expected. If, during the course 14# of snapshot creation, the filesystem being snapshotted becomes full, 15# mksnap_ffs will exit with an error exactly as it does if it is started on 16# an already full filesystem. 17 18# However, several hours later, the system will lock up completely. It still 19# responds to pings, and open connections to and from it remain in that 20# state, but they cannot be used and new connections cannot be established. 21 22# *** This script does not provoke the problem. *** 23 24[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 25 26root=/var 27 28rm -f $root/.snap/pho $root/big $root/big2 29trap "rm -f $root/.snap/pho $root/big $root/big2" 0 30free=`df $root | tail -1 | awk '{print $4}'` 31dd if=/dev/zero of=$root/big bs=1m count=$(( free / 1024 - 90)) > /dev/null 2>&1 32df $root 33 34for i in `jot 1024`; do 35 date 36 nice -20 mksnap_ffs $root $root/.snap/pho & 37 dd if=/dev/zero of=$root/big2 bs=1m > /dev/null 2>&1 38 wait 39 [ -f $root/.snap/pho ] && exit 0 40 rm -f $root/.snap/pho $root/big2 41done 42df $root 43 44rm -f $root/.snap/pho $root/big $root/big2 45