From: Darrick J. Wong <djwong@xxxxxxxxxx> Based on some surveys of aged filesystems, I've noticed that the proportion of directory children that are subdirectories tends to be more in the 5-10% range, not the 95% that the current code generates. Rework popdir.pl so that we can specify arbitrary percentages of children files, and lower the ratio dramatically. This shouldn't have any substantive changes in the shape of the directories that gets generated; it just gets us a more realistic sample. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- common/populate | 4 ++-- src/popdir.pl | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/common/populate b/common/populate index 144a3f5186..524e0c32cb 100644 --- a/common/populate +++ b/common/populate @@ -308,7 +308,7 @@ _scratch_xfs_populate() { # Fill up the root inode chunk echo "+ fill root ino chunk" - $here/src/popdir.pl --dir "${SCRATCH_MNT}" --start 1 --end 64 --format "dummy%u" --file-mult 1 + $here/src/popdir.pl --dir "${SCRATCH_MNT}" --start 1 --end 64 --format "dummy%u" --file-pct 100 # Regular files # - FMT_EXTENTS @@ -422,7 +422,7 @@ _scratch_xfs_populate() { local rec_per_btblock=16 local nr="$(( 2 * (blksz / rec_per_btblock) * ino_per_rec ))" local dir="${SCRATCH_MNT}/INOBT" - __populate_create_dir "${dir}" "${nr}" true --file-mult 1 + __populate_create_dir "${dir}" "${nr}" true --file-pct 100 # Reverse-mapping btree is_rmapbt="$(_xfs_has_feature "$SCRATCH_MNT" rmapbt -v)" diff --git a/src/popdir.pl b/src/popdir.pl index dc0c046b7d..e89095aafe 100755 --- a/src/popdir.pl +++ b/src/popdir.pl @@ -11,7 +11,7 @@ use File::Basename; $progname=$0; GetOptions("start=i" => \$start, "end=i" => \$end, - "file-mult=i" => \$file_mult, + "file-pct=i" => \$file_pct, "incr=i" => \$incr, "format=s" => \$format, "dir=s" => \$dir, @@ -30,8 +30,7 @@ Options: --start=num create names starting with this number (0) --incr=num increment file number by this much (1) --end=num stop at this file number (100) - --file-mult create a regular file when file number is a multiple - of this quantity (20) + --file-pct create this percentage of regular files (90 percent) --remove remove instead of creating --format=str printf formatting string for file name ("%08d") --verbose verbose output @@ -47,17 +46,23 @@ if (defined $dir) { } $start = 0 if (!defined $start); $end = 100 if (!defined $end); -$file_mult = 20 if (!defined $file_mult); +$file_pct = 90 if (!defined $file_pct); $format = "%08d" if (!defined $format); $incr = 1 if (!defined $incr); +if ($file_pct < 0) { + $file_pct = 0; +} elsif ($file_pct > 100) { + $file_pct = 100; +} + for ($i = $start; $i <= $end; $i += $incr) { $fname = sprintf($format, $i); if ($remove) { $verbose && print "rm $fname\n"; unlink($fname) or rmdir($fname) or die("unlink $fname"); - } elsif ($file_mult == 0 or ($i % $file_mult) == 0) { + } elsif (($i % 100) < $file_pct) { # create a file $verbose && print "touch $fname\n"; open(DONTCARE, ">$fname") or die("touch $fname");