xref: /freebsd/tools/test/stress2/misc/snap6.sh (revision 02e9120893770924227138ba49df1edb3896112a)
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
28mount | grep "on `df /var | tail -1 | awk '{print $NF}'`" |
29    grep -q 'journaled soft-updates' && exit 0
30rm -f $root/.snap/stress2 $root/big $root/big2
31trap "rm -f $root/.snap/stress2 $root/big $root/big2" 0
32free=`df $root | tail -1 | awk '{print $4}'`
33timeout 5m dd if=/dev/zero of=$root/big bs=1m count=$(( free / 1024 - 90)) \
34    status=none
35df $root
36
37start=`date +%s`
38while [ $((`date +%s` - start)) -lt 300 ]; do
39   date
40   nice -20 mksnap_ffs $root $root/.snap/stress2 &
41   timeout 5m dd if=/dev/zero of=$root/big2 bs=1m status=none
42   wait
43   [ -f $root/.snap/stress2 ] && exit 0
44   rm -f $root/.snap/stress2 $root/big2
45done
46df $root
47
48rm -f $root/.snap/stress2 $root/big $root/big2
49