From: Andreas Gruenbacher <agruenba@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH 4/6] fsx: Generate test parameters in test()
Date: Tue, 22 Dec 2015 14:51:10 +0100 [thread overview]
Message-ID: <1450792272-7402-5-git-send-email-agruenba@redhat.com> (raw)
In-Reply-To: <1450792272-7402-1-git-send-email-agruenba@redhat.com>
Generate all test parameters in test(), including keep_size.
The code is slightly more complicated than it could be to produce the
same sequence of operations for the same random seed.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
ltp/fsx.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/ltp/fsx.c b/ltp/fsx.c
index 0f4c49e..5385ed3 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -914,11 +914,10 @@ do_punch_hole(unsigned offset, unsigned length)
#ifdef FALLOC_FL_ZERO_RANGE
void
-do_zero_range(unsigned offset, unsigned length)
+do_zero_range(unsigned offset, unsigned length, int keep_size)
{
unsigned end_offset;
int mode = FALLOC_FL_ZERO_RANGE;
- int keep_size = 0;
if (length == 0) {
if (!quiet && testcalls > simulatedopcount)
@@ -927,9 +926,6 @@ do_zero_range(unsigned offset, unsigned length)
return;
}
- if (keep_size_calls)
- keep_size = random() % 2;
-
end_offset = keep_size ? 0 : offset + length;
if (end_offset > biggest) {
@@ -966,7 +962,7 @@ do_zero_range(unsigned offset, unsigned length)
#else
void
-do_zero_range(unsigned offset, unsigned length)
+do_zero_range(unsigned offset, unsigned length, int keep_size)
{
return;
}
@@ -1080,10 +1076,9 @@ do_insert_range(unsigned offset, unsigned length)
#ifdef HAVE_LINUX_FALLOC_H
/* fallocate is basically a no-op unless extending, then a lot like a truncate */
void
-do_preallocate(unsigned offset, unsigned length)
+do_preallocate(unsigned offset, unsigned length, int keep_size)
{
unsigned end_offset;
- int keep_size = 0;
if (length == 0) {
if (!quiet && testcalls > simulatedopcount)
@@ -1092,9 +1087,6 @@ do_preallocate(unsigned offset, unsigned length)
return;
}
- if (keep_size_calls)
- keep_size = random() % 2;
-
end_offset = keep_size ? 0 : offset + length;
if (end_offset > biggest) {
@@ -1132,7 +1124,7 @@ do_preallocate(unsigned offset, unsigned length)
}
#else
void
-do_preallocate(unsigned offset, unsigned length)
+do_preallocate(unsigned offset, unsigned length, int keep_size)
{
return;
}
@@ -1211,6 +1203,7 @@ test(void)
unsigned long size = maxoplen;
unsigned long rv = random();
unsigned long op;
+ int keep_size = 0;
if (simulatedopcount > 0 && testcalls == simulatedopcount)
writefileimage();
@@ -1236,6 +1229,17 @@ test(void)
else
op = rv % OP_MAX_FULL;
+ switch(op) {
+ case OP_FALLOCATE:
+ if (fallocate_calls && size && keep_size_calls)
+ keep_size = random() % 2;
+ break;
+ case OP_ZERO_RANGE:
+ if (zero_range_calls && size && keep_size_calls)
+ keep_size = random() % 2;
+ break;
+ }
+
switch (op) {
case OP_MAPREAD:
if (!mapped_reads)
@@ -1306,7 +1310,7 @@ test(void)
case OP_FALLOCATE:
TRIM_OFF_LEN(offset, size, maxfilelen);
- do_preallocate(offset, size);
+ do_preallocate(offset, size, keep_size);
break;
case OP_PUNCH_HOLE:
@@ -1315,7 +1319,7 @@ test(void)
break;
case OP_ZERO_RANGE:
TRIM_OFF_LEN(offset, size, file_size);
- do_zero_range(offset, size);
+ do_zero_range(offset, size, keep_size);
break;
case OP_COLLAPSE_RANGE:
TRIM_OFF_LEN(offset, size, file_size - 1);
--
2.4.3
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-12-22 13:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-22 13:51 [PATCH 0/6] fsx Andreas Gruenbacher
2015-12-22 13:51 ` [PATCH 1/6] fsx: Small improvements and fixes Andreas Gruenbacher
2015-12-22 13:51 ` [PATCH 2/6] fsx: Fix hex numbers in operation dump Andreas Gruenbacher
2015-12-22 13:51 ` [PATCH 3/6] fsx: Report number of successful operations Andreas Gruenbacher
2015-12-22 13:51 ` Andreas Gruenbacher [this message]
2015-12-22 13:51 ` [PATCH 5/6] fsx: Improve operation logging Andreas Gruenbacher
2015-12-22 13:51 ` [PATCH 6/6] fsx: Add mechanism to replay failed operations Andreas Gruenbacher
2015-12-22 20:45 ` [PATCH 0/6] fsx Dave Chinner
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=1450792272-7402-5-git-send-email-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=xfs@oss.sgi.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox