[PATCH 6/9] xfs/{050,144,153,299,330}: update quota reports to leave out metadir files

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Remove the metadata directory tree directories from the quota reporting
in these tests so that we don't regress the golden output.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 common/filter |    7 +++++--
 common/xfs    |   23 +++++++++++++++++++++++
 tests/xfs/050 |    1 +
 tests/xfs/153 |    1 +
 tests/xfs/299 |    1 +
 tests/xfs/330 |    6 +++++-
 6 files changed, 36 insertions(+), 3 deletions(-)


diff --git a/common/filter b/common/filter
index 3e3fea7ea0..49c6859992 100644
--- a/common/filter
+++ b/common/filter
@@ -618,11 +618,14 @@ _filter_getcap()
 
 # 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.
+# bsize variables before calling this function.  The qhidden_rootfiles variable
+# (by default zero) is the number of root files to filter out of the inode
+# count part of the quota report.
 _filter_quota_report()
 {
 	test -n "$id" || echo "id must be set"
 	test -n "$bsize" || echo "block size must be set"
+	test -n "$qhidden_rootfiles" || qhidden_rootfiles=0
 
 	tr -s '[:space:]' | \
 	perl -npe '
@@ -630,7 +633,7 @@ _filter_quota_report()
 		s/^\#0 \d+ /[ROOT] 0 /g;
 		s/6 days/7 days/g' |
 	perl -npe '
-		$val = 0;
+		$val = '"$qhidden_rootfiles"';
 		if ($ENV{'LARGE_SCRATCH_DEV'}) {
 			$val = $ENV{'NUM_SPACE_FILES'};
 		}
diff --git a/common/xfs b/common/xfs
index 0f69d3eb18..99e377631b 100644
--- a/common/xfs
+++ b/common/xfs
@@ -1783,3 +1783,26 @@ _scratch_xfs_force_no_metadir()
 		MKFS_OPTIONS="-m metadir=0 $MKFS_OPTIONS"
 	fi
 }
+
+# Decide if a mount filesystem has metadata directory trees.
+_xfs_mount_has_metadir() {
+	local mount="$1"
+
+	# spaceman (and its info command) predate metadir
+	test ! -e "$XFS_SPACEMAN_PROG" && return 1
+	$XFS_SPACEMAN_PROG -c "info" "$mount" | grep -q 'metadir=1'
+}
+
+# Compute the number of files in the metadata directory tree.
+_xfs_calc_metadir_files() {
+	local mount="$1"
+
+	if ! _xfs_mount_has_metadir "$mount"; then
+		echo 0
+		return
+	fi
+
+	local regfiles="$($XFS_IO_PROG -c 'bulkstat' "$mount" | grep '^bs_ino' | wc -l)"
+	local metafiles="$($XFS_IO_PROG -c 'bulkstat -m' "$mount" 2>&1 | grep '^bs_ino' | wc -l)"
+	echo $((metafiles - regfiles))
+}
diff --git a/tests/xfs/050 b/tests/xfs/050
index 2220e47016..64fbaf687d 100755
--- a/tests/xfs/050
+++ b/tests/xfs/050
@@ -34,6 +34,7 @@ _require_xfs_quota
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
 bsize=$(_get_file_block_size $SCRATCH_MNT)
+qhidden_rootfiles=$(_xfs_calc_metadir_files $SCRATCH_MNT)
 _scratch_unmount
 
 bsoft=$(( 200 * $bsize ))
diff --git a/tests/xfs/153 b/tests/xfs/153
index dbe26b6803..fc64bf734a 100755
--- a/tests/xfs/153
+++ b/tests/xfs/153
@@ -39,6 +39,7 @@ _require_test_program "vfs/mount-idmapped"
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
 bsize=$(_get_file_block_size $SCRATCH_MNT)
+qhidden_rootfiles=$(_xfs_calc_metadir_files $SCRATCH_MNT)
 _scratch_unmount
 
 bsoft=$(( 200 * $bsize ))
diff --git a/tests/xfs/299 b/tests/xfs/299
index 4b9df3c6aa..2167c492c4 100755
--- a/tests/xfs/299
+++ b/tests/xfs/299
@@ -159,6 +159,7 @@ _qmount_option "uquota,gquota,pquota"
 _qmount
 
 bsize=$(_get_file_block_size $SCRATCH_MNT)
+qhidden_rootfiles=$(_xfs_calc_metadir_files $SCRATCH_MNT)
 
 bsoft=$(( 100 * $bsize ))
 bhard=$(( 500 * $bsize ))
diff --git a/tests/xfs/330 b/tests/xfs/330
index c6e74e67e8..e919ccc1ca 100755
--- a/tests/xfs/330
+++ b/tests/xfs/330
@@ -26,7 +26,10 @@ _require_nobody
 
 do_repquota()
 {
-	repquota $SCRATCH_MNT | grep -E '^(fsgqa|root|nobody)' | sort -r
+	repquota $SCRATCH_MNT | grep -E '^(fsgqa|root|nobody)' | sort -r | \
+	perl -npe '
+		$val = '"$qhidden_rootfiles"';
+		s/(^root\s+--\s+\S+\s+\S+\s+\S+\s+)(\S+)/$1@{[$2 - $val]}/g'
 }
 
 rm -f "$seqres.full"
@@ -35,6 +38,7 @@ echo "Format and mount"
 _scratch_mkfs > "$seqres.full" 2>&1
 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
 _scratch_mount >> "$seqres.full" 2>&1
+qhidden_rootfiles=$(_xfs_calc_metadir_files $SCRATCH_MNT)
 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
 quotaon $SCRATCH_MNT 2> /dev/null
 




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux