summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-04-04 16:17:00 -0700
committerZorro Lang <zlang@kernel.org>2023-04-09 20:06:31 +0800
commitc7db4edfe9677f29fb6d4c012257454473974a4f (patch)
tree874e8f5f67df53b1d98cf912a42d02fe80c9a394 /src
parenta8e4eb5f7d2f2182d6574eb69319af194400ce3e (diff)
populate: create fewer subdirs when constructing directories
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@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/popdir.pl15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/popdir.pl b/src/popdir.pl
index dc0c046b..e89095aa 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");