xfs/299 and xfs/050 share the same function to filter quota reporting
into a format suitable for the golden output. Refactor this so that we
can use it in a new test.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
sed -e "s/= //" -e "s/\+/=/g"
}
sed -e "s/= //" -e "s/\+/=/g"
}
+# Filter user/group/project id numbers out of quota reports, and standardize
+# the block counts to use filesystem block size. Callers must set the id and
+# bsize variables before calling this function.
+_filter_quota_report()
+{
+ test -n "$id" || echo "id must be set"
+ test -n "$bsize" || echo "block size must be set"
+
+ tr -s '[:space:]' | \
+ perl -npe '
+ s/^\#'$id' /[NAME] /g;
+ s/^\#0 \d+ /[ROOT] 0 /g;
+ s/6 days/7 days/g' |
+ perl -npe '
+ $val = 0;
+ if ($ENV{'LARGE_SCRATCH_DEV'}) {
+ $val = $ENV{'NUM_SPACE_FILES'};
+ }
+ s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g' |
+ sed -e 's/ 65535 \[--------\]/ 00 \[--------\]/g' |
+ perl -npe '
+ s|^(.*?) (\d+) (\d+) (\d+)|$1 @{[$2 * 1024 /'$bsize']} @{[$3 * 1024 /'$bsize']} @{[$4 * 1024 /'$bsize']}|'
+}
+
# make sure this script returns success
/bin/true
# make sure this script returns success
/bin/true
-_filter_report()
-{
- tr -s '[:space:]' | \
- perl -npe '
- s/^\#'$id' /[NAME] /g;
- s/^\#0 \d+ /[ROOT] 0 /g;
- s/6 days/7 days/g' |
- perl -npe '
- $val = 0;
- if ($ENV{'LARGE_SCRATCH_DEV'}) {
- $val = $ENV{'NUM_SPACE_FILES'};
- }
- s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g' |
- sed -e 's/ 65535 \[--------\]/ 00 \[--------\]/g' |
- perl -npe '
- s|^(.*?) (\d+) (\d+) (\d+)|$1 @{[$2 * 1024 /'$bsize']} @{[$3 * 1024 /'$bsize']} @{[$4 * 1024 /'$bsize']}|'
-}
-
# The actual point at which limit enforcement takes place for the
# hard block limit is variable depending on filesystem blocksize,
# and iosize. What we want to test is that the limit is enforced
# The actual point at which limit enforcement takes place for the
# hard block limit is variable depending on filesystem blocksize,
# and iosize. What we want to test is that the limit is enforced
}
s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
}
}
s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
}
+ ' | _filter_quota_report
echo "*** report no quota settings" | tee -a $seqres.full
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
echo "*** report no quota settings" | tee -a $seqres.full
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
echo "*** report initial settings" | tee -a $seqres.full
echo
echo "*** report initial settings" | tee -a $seqres.full
$SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
$SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
echo "*** push past the soft inode limit" | tee -a $seqres.full
echo
echo "*** push past the soft inode limit" | tee -a $seqres.full
$XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
$XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
echo "*** push past the soft block limit" | tee -a $seqres.full
echo
echo "*** push past the soft block limit" | tee -a $seqres.full
-c "warn -b -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
-c "warn -b -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
-c "warn -i -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
-c "warn -i -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
_require_xfs_mkfs_crc
_require_xfs_crc
_require_xfs_mkfs_crc
_require_xfs_crc
-_filter_report()
-{
- tr -s '[:space:]' | \
- perl -npe '
- s/^\#'$id' /[NAME] /g;
- s/^\#0 \d+ /[ROOT] 0 /g;
- s/6 days/7 days/g' |
- perl -npe '
- $val = 0;
- if ($ENV{'LARGE_SCRATCH_DEV'}) {
- $val = $ENV{'NUM_SPACE_FILES'};
- }
- s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g' |
- sed -e 's/ 65535 \[--------\]/ 00 \[--------\]/g' |
- perl -npe '
- s|^(.*?) (\d+) (\d+) (\d+)|$1 @{[$2 * 1024 /'$bsize']} @{[$3 * 1024 /'$bsize']} @{[$4 * 1024 /'$bsize']}|'
-}
-
# The actual point at which limit enforcement takes place for the
# hard block limit is variable depending on filesystem blocksize,
# and iosize. What we want to test is that the limit is enforced
# The actual point at which limit enforcement takes place for the
# hard block limit is variable depending on filesystem blocksize,
# and iosize. What we want to test is that the limit is enforced
}
s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
}
}
s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
}
+ ' | _filter_quota_report
echo "*** report no quota settings" | tee -a $seqres.full
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
echo "*** report no quota settings" | tee -a $seqres.full
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
echo "*** report initial settings" | tee -a $seqres.full
echo
echo "*** report initial settings" | tee -a $seqres.full
$SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
$SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
echo "*** push past the soft inode limit" | tee -a $seqres.full
echo
echo "*** push past the soft inode limit" | tee -a $seqres.full
$XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
$XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
echo "*** push past the soft block limit" | tee -a $seqres.full
echo
echo "*** push past the soft block limit" | tee -a $seqres.full
-c "warn -b -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
-c "warn -b -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
-c "warn -i -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
-c "warn -i -$type 0 $id" $SCRATCH_DEV
$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-c "repquota -birnN -$type" $SCRATCH_DEV |
- _filter_report | LC_COLLATE=POSIX sort -ru
+ _filter_quota_report | LC_COLLATE=POSIX sort -ru
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected
echo
# Note: for quota accounting (not enforcement), EDQUOT is not expected