generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / ext4 / 042
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2012 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. ext4/042 (was shared/289)
6 #
7 # Test overhead & df output for extN filesystems
8 #
9 . ./common/preamble
10 _begin_fstest auto quick
11
12 # Import common functions.
13 . ./common/filter
14
15 # real QA test starts here
16
17 # Modify as appropriate.
18 _supported_fs ext2 ext3 ext4
19 _require_scratch
20
21 _scratch_mkfs >> $seqres.full 2>&1
22
23 # Get the honest truth about block counts straight from metadata on disk
24 TOTAL_BLOCKS=`dumpe2fs -h $SCRATCH_DEV 2>/dev/null \
25                 | awk '/Block count:/{print $3}'`
26
27 FREE_BLOCKS=`dumpe2fs -h $SCRATCH_DEV 2>/dev/null \
28                 | awk '/Free blocks:/{print $3}'`
29
30 OVERHEAD=$(($TOTAL_BLOCKS-$FREE_BLOCKS))
31
32 #  bsddf|minixdf
33 #         Set the behaviour  for  the  statfs  system  call.  The  minixdf
34 #         behaviour is to return in the f_blocks field the total number of
35 #         blocks of the filesystem, while the bsddf  behaviour  (which  is
36 #         the default) is to subtract the overhead blocks used by the ext2
37 #         filesystem and not available for file storage.
38
39 # stat -f output looks like this; we get f_blocks from that, which
40 # varies depending on the df mount options used below:
41
42 #   File: "/mnt/test"
43 #    ID: affc5f2b2f57652 Namelen: 255     Type: ext2/ext3
44 # Block size: 4096       Fundamental block size: 4096
45 # Blocks: Total: 5162741    Free: 5118725    Available: 4856465
46 # Inodes: Total: 1313760    Free: 1313749
47
48 _scratch_mount "-o minixdf"
49 MINIX_F_BLOCKS=`stat -f $SCRATCH_MNT | awk '/^Blocks/{print $3}'`
50 _scratch_unmount
51
52 _scratch_mount "-o bsddf"
53 BSD_F_BLOCKS=`stat -f $SCRATCH_MNT | awk '/^Blocks/{print $3}'`
54 _scratch_unmount
55
56 # Echo data to $seqres.full for analysis
57 echo "Overhead is $OVERHEAD blocks out of $TOTAL_BLOCKS ($FREE_BLOCKS free)" >> $seqres.full
58 echo "MINIX free blocks $MINIX_F_BLOCKS" >> $seqres.full
59 echo "BSD free blocks $BSD_F_BLOCKS" >> $seqres.full
60
61 # minix should be exactly equal (hence tolerance of 0)
62 _within_tolerance "minix f_blocks" $MINIX_F_BLOCKS $TOTAL_BLOCKS 0 -v
63 # bsd should be within ... we'll say 1% for some slop
64 _within_tolerance "bsd f_blocks" $BSD_F_BLOCKS $(($TOTAL_BLOCKS-$OVERHEAD)) 1% -v
65
66 # success, all done
67 status=0
68 exit