All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: eguan@redhat.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH 4/4] generic/204: use available blocks to determine the number of files to create
Date: Thu, 09 Nov 2017 16:44:46 -0800	[thread overview]
Message-ID: <151027468665.13147.9686450267905584799.stgit@magnolia> (raw)
In-Reply-To: <151027466195.13147.10381301768189156101.stgit@magnolia>

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

Use the available block count to compute the number of files we think
we can create, rather than hardcoding a particular size.  This fixes
the ENOSPC failures for xfs filesystems with rmap/reflink support.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/204 |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)


diff --git a/tests/generic/204 b/tests/generic/204
index 4c203a2..71bee83 100755
--- a/tests/generic/204
+++ b/tests/generic/204
@@ -69,7 +69,7 @@ _scratch_mount
 # work out correctly. Space usages is based 22500 files and 1024 reserved blocks
 # on a 4k block size 256 byte inode size filesystem.
 resv_blks=1024
-space=97920000
+space=$(stat -f -c '%f * %S' $SCRATCH_MNT | $BC_PROG)
 
 # decrease files for inode size.
 #	22500 * (256 + 4k) = ~97MB
@@ -78,10 +78,20 @@ space=97920000
 
 files=$((space / (isize + dbsize)))
 
+# Now do it again, but factor in the filename sizes too.
+# We naïvely assume 8 bytes for inode number, 1 byte for ftype,
+# and 1 more byte for namelen, then round up to the nearest 8
+# bytes.
+
+namelen="$(echo -n "$files" | wc -c)"
+direntlen="$(echo "(10 + $namelen + 7) / 8 * 8" | $BC_PROG)"
+
+files=$((space / (direntlen + isize + dbsize)))
+
 echo files $files, resvblks $resv_blks >> $seqres.full
 _scratch_resvblks $resv_blks >> $seqres.full 2>&1
 
-for i in `seq 1 $files`; do
+for i in `seq -w 1 $files`; do
     echo -n > $SCRATCH_MNT/$i
     echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > $SCRATCH_MNT/$i
 done


      parent reply	other threads:[~2017-11-10  0:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10  0:44 [PATCH 0/4] rollup of fstests fixes Darrick J. Wong
2017-11-10  0:44 ` [PATCH 1/4] xfs/31[3-7]: hide pwrite fsync errors that are supposed to fail Darrick J. Wong
2017-11-10  0:44 ` [PATCH 2/4] common/fuzzy: ignore padding fields on xfs Darrick J. Wong
2017-11-10  0:44 ` [PATCH 3/4] xfs: test that we don't leak inodes and dquots during failed cow recovery Darrick J. Wong
2017-11-10  3:32   ` Eryu Guan
2017-11-10  0:44 ` Darrick J. Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=151027468665.13147.9686450267905584799.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=eguan@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.