4 # This test checks the project quota values reported by the quota
5 # "df" and "report" subcommands to ensure they match what they
6 # should be. There was a bug (fixed by xfsprogs commit 7cb2d41b)
7 # where the values reported were double what they should have been.
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2011 SGI. All Rights Reserved.
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
38 my_projects=$tmp.projects
40 proj_name=test_project
43 qlimit_meg=500 # 500M limit imposed = 500 * 1024 * 1024 bytes
45 status=1 # failure is the default!
46 trap "_cleanup; exit \$status" 0 1 2 3 15
54 # get standard environment, filters and checks
59 echo "Silence is golden."
61 # real QA test starts here
63 proj_dir="$SCRATCH_MNT/test"
65 # Modify as appropriate.
72 # Make sure the hard limits reported are what was set.
73 # It is entirely too clever...
74 # It exploits the fact that we've set the soft and hard limits to
75 # the same value, and as a result the value in the fourth field in
76 # both the "df" and the "report" output. For "report", the line we're
77 # interested in contains our project name in the first field. For "df"
78 # it contains our project directory in the last field.
82 proj_name = "'${proj_name}'";
83 proj_dir = "'${proj_dir}'";
84 qlimit_meg = '${qlimit_meg}';
85 qlimit = qlimit_meg * 1024 * 1024;
87 # This function parses the human-readable values produced
89 function byte_size(value, result) {
90 result = strtonum(value);
92 gsub("[0-9][0-9]*", "", unit);
93 shift = index("KMGTPE", unit);
99 if ($1 !~ proj_name && $nf !~ proj_dir)
101 bsize = byte_size($4);
103 printf("hard limit %d bytes, expected %d\n",
110 xfs_quota -P "$my_projid" -D "$my_projects" -x \
111 -c "$@" "$SCRATCH_MNT"
114 # Set up--mount scratch and create the project directory
116 echo $proj_name:$proj_num > "$my_projid"
117 echo $proj_num:$proj_dir > "$my_projects"
119 _scratch_mkfs >> "$seqres.full" 2>&1
121 export MOUNT_OPTIONS="-opquota"
123 mkdir -p "${proj_dir}"
125 # Setup the project quota directory
126 _quota_cmd "project -s ${proj_name}" >> "$seqres.full" 2>&1
128 # Assign block quota limits
129 _quota_cmd "limit -p bhard=${qlimit_meg}m bsoft=${qlimit_meg}m ${proj_name}" \
130 2>> "$seqres.full" 1>&2
132 # See what gets reported
133 _quota_cmd "report" | _filter_quota_rpt 2>> "$seqres.full"
134 _quota_cmd "df" | _filter_quota_rpt 2>> "$seqres.full"
136 # This time using "human readable" output
137 _quota_cmd "report -h" | _filter_quota_rpt 2>> "$seqres.full"
138 _quota_cmd "df -h" | _filter_quota_rpt 2>> "$seqres.full"
144 status=0 # success, all done