fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] generic/587: fix rounding error in quota/stat block comparison
@ 2020-03-18 15:01 Darrick J. Wong
  2020-03-18 19:35 ` Zorro Lang
  2020-03-18 20:11 ` [PATCH v2] " Darrick J. Wong
  0 siblings, 2 replies; 4+ messages in thread
From: Darrick J. Wong @ 2020-03-18 15:01 UTC (permalink / raw)
  To: Eryu Guan; +Cc: zlang, fstests, xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

It turns out that repquota (which reports in units of 1k blocks) reports
rounded up numbers when the fs blocksize is 512 bytes.  However, xfs_io
stat always reports block counts in units of 512 bytes.  If the number
of (512b) file blocks is not an even number, the "$3 / 2" expression
will round down, causing the test to fail.  Round up to the nearest 1k
to match repquota's behavior.

Reported-by: zlang@redhat.com
Fixes: 6b04ed05456fc6c ("generic: test unwritten extent conversion extent mapping quota accounting")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/587 |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/generic/587 b/tests/generic/587
index 7b07d07d..2ffa367d 100755
--- a/tests/generic/587
+++ b/tests/generic/587
@@ -57,7 +57,8 @@ check_quota_accounting()
 {
 	$XFS_IO_PROG -c stat $testfile > $tmp.out
 	cat $tmp.out >> $seqres.full
-	local stat_blocks=$(grep 'stat.blocks' $tmp.out | awk '{print $3 / 2}')
+	local stat_blocks=$(grep 'stat.blocks' $tmp.out | \
+		awk '{printf("%d\n", ($3 + 1) / 2);}')
 
 	_report_quota_blocks $SCRATCH_MNT > $tmp.out
 	cat $tmp.out >> $seqres.full

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-19  3:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 15:01 [PATCH] generic/587: fix rounding error in quota/stat block comparison Darrick J. Wong
2020-03-18 19:35 ` Zorro Lang
2020-03-18 20:11 ` [PATCH v2] " Darrick J. Wong
2020-03-19  4:05   ` Zorro Lang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).