From: Eric Sandeen <sandeen@sandeen.net>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 2/4] xfstests: fsx fallocate support is b0rked
Date: Mon, 27 Jun 2011 16:16:20 -0500 [thread overview]
Message-ID: <4E08F324.5040703@sandeen.net> (raw)
In-Reply-To: <1309153722-1231-3-git-send-email-david@fromorbit.com>
On 6/27/11 12:48 AM, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> The recent fallocate/fpunch additions to fsx have not actually be
> executing fallocate/fpunch operations. The logic to select what
> operation to run is broken in such a way that fsx has been executing
> mapped writes and truncates instead of fallocate and fpunch
> operations.
>
> Remove all the (b0rken) smarty-pants selection logic from the test()
I hope I only extended that smarty-pants logic and didn't invent it.
I suppose maybe I broke it first though, damn.
> function. Replace it with a clearly defined set of operations for
> each mode and use understandable fallback logic when various
> operation types have been disabled. Then use a simple switch
> statement to execute each of the different operations, removing the
> tortured nesting of if/else statements that only serve to obfuscate
> the code.
>
> NAs a result, fsx uses fallocate/fpunch appropriately during
> operations, and uses/disableѕ the operations as defined on the
> command line correctly.
Hm we're back in the fsx maintenance business I guess.
Would it be worth doing defines or an enum for the ops/cases, to make it
a little more readable?
Otherwise looks much better.
-Eric
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
> ltp/fsx.c | 162 +++++++++++++++++++++++++++++++++++++++----------------------
> 1 files changed, 103 insertions(+), 59 deletions(-)
>
> diff --git a/ltp/fsx.c b/ltp/fsx.c
> index a37e223..66daefe 100644
> --- a/ltp/fsx.c
> +++ b/ltp/fsx.c
> @@ -955,18 +955,42 @@ docloseopen(void)
> }
> }
>
> +#define TRIM_OFF_LEN(off, len, size) \
> +do { \
> + if (file_size) \
> + offset %= size; \
> + else \
> + offset = 0; \
> + if (offset + len > size) \
> + len = size - offset; \
> +} while (0)
>
> +/*
> + * The operation matrix is complex due to conditional variables.
> + * We calculate how many different operations we can use, then
> + * map them appropriately according to how many options are enabled.
> + * The mapping is:
> + *
> + * lite !lite
> + * READ: 0 0
> + * WRITE: 1 1
> + * MAPREAD: 2 2
> + * MAPWRITE: 3 3
> + * TRUNCATE: - 4
> + * FALLOCATE: - 5
> + * PUNCH HOLE: - 6
> + *
> + * When mapped read/writes are disabled, they are simply converted to normal
> + * reads and writes. When fallocate/fpunch calls are disabled, they are
> + * converted to OP_SKIPPED.
> + */
> void
> test(void)
> {
> unsigned long offset;
> unsigned long size = maxoplen;
> unsigned long rv = random();
> - unsigned long op = rv % (3 + !lite + mapped_writes + fallocate_calls + punch_hole_calls);
> - /* turn off the map read if necessary */
> -
> - if (op == 2 && !mapped_reads)
> - op = 0;
> + unsigned long op;
>
> if (simulatedopcount > 0 && testcalls == simulatedopcount)
> writefileimage();
> @@ -982,62 +1006,82 @@ test(void)
> if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0)
> prt("%lu...\n", testcalls);
>
> - /*
> - * lite !lite
> - * READ: op = 0 0
> - * WRITE: op = 1 1
> - * MAPREAD: op = 2 2
> - * TRUNCATE: op = - 3
> - * MAPWRITE: op = 3 4
> - * FALLOCATE: op = - 5
> - * PUNCH HOLE: op = - 6
> - */
> - if (lite ? 0 : op == 3 && (style & 1) == 0) /* vanilla truncate? */
> - dotruncate(random() % maxfilelen);
> - else {
> - if (randomoplen)
> - size = random() % (maxoplen+1);
> -
> - if (lite ? 0 : op == 3) {
> - /* truncate */
> - dotruncate(size);
> - } else {
> - offset = random();
> - if (op == 5) {
> - /* fallocate */
> - offset %= maxfilelen;
> - if (offset + size > maxfilelen)
> - size = maxfilelen - offset;
> - do_preallocate(offset, size);
> - } else if (op == 6) {
> - offset %= maxfilelen;
> - if (offset + size > maxfilelen)
> - size = maxfilelen - offset;
> - do_punch_hole(offset, size);
> - } else if (op == 1 || op == (lite ? 3 : 4)) {
> - /* write / mapwrite */
> - offset %= maxfilelen;
> - if (offset + size > maxfilelen)
> - size = maxfilelen - offset;
> - if (op != 1)
> - domapwrite(offset, size);
> - else
> - dowrite(offset, size);
> - } else {
> - /* read / mapread */
> - if (file_size)
> - offset %= file_size;
> - else
> - offset = 0;
> - if (offset + size > file_size)
> - size = file_size - offset;
> - if (op != 0)
> - domapread(offset, size);
> - else
> - doread(offset, size);
> - }
> + offset = random();
> + if (randomoplen)
> + size = random() % (maxoplen + 1);
> +
> + /* calculate appropriate op to run */
> + if (lite)
> + op = rv % 4;
> + else
> + op = rv % 7;
> +
> + switch (op) {
> + case 2:
> + if (!mapped_reads)
> + op = 0;
> + break;
> + case 3:
> + if (!mapped_writes)
> + op = 1;
> + break;
> + case 5:
> + if (!fallocate_calls) {
> + log4(OP_SKIPPED, OP_FALLOCATE, offset, size);
> + goto out;
> + }
> + break;
> + case 6:
> + if (!punch_hole_calls) {
> + log4(OP_SKIPPED, OP_PUNCH_HOLE, offset, size);
> + goto out;
> }
> + break;
> }
> +
> + switch (op) {
> + case 0: /* read */
> + TRIM_OFF_LEN(offset, size, file_size);
> + doread(offset, size);
> + break;
> +
> + case 1: /* write */
> + TRIM_OFF_LEN(offset, size, maxfilelen);
> + dowrite(offset, size);
> + break;
> +
> + case 2: /* mapread */
> + TRIM_OFF_LEN(offset, size, maxfilelen);
> + domapread(offset, size);
> + break;
> +
> + case 3: /* mapwrite */
> + TRIM_OFF_LEN(offset, size, maxfilelen);
> + domapwrite(offset, size);
> + break;
> +
> + case 4: /* truncate */
> + if (!style)
> + size = random() % maxfilelen;
> + dotruncate(size);
> + break;
> +
> + case 5: /* fallocate */
> + TRIM_OFF_LEN(offset, size, maxfilelen);
> + do_preallocate(offset, size);
> + break;
> +
> + case 6: /* punch */
> + TRIM_OFF_LEN(offset, size, maxfilelen);
> + do_punch_hole(offset, size);
> + break;
> + default:
> + prterr("test: unknown operation");
> + report_failure(42);
> + break;
> + }
> +
> +out:
> if (sizechecks && testcalls > simulatedopcount)
> check_size();
> if (closeopen)
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2011-06-27 21:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-27 5:48 ***** SUSPECTED SPAM ***** [PATCH 0/4] xfstests: fsx is fallocate challenged Dave Chinner
2011-06-27 5:48 ` [PATCH 1/4] xfstests: fix fsx fpunch test to actually test for fpunch Dave Chinner
2011-06-27 18:15 ` Allison Henderson
2011-06-27 20:45 ` Eric Sandeen
2011-06-27 5:48 ` [PATCH 2/4] xfstests: fsx fallocate support is b0rked Dave Chinner
2011-06-27 21:16 ` Eric Sandeen [this message]
2011-06-27 23:07 ` Dave Chinner
2011-06-27 5:48 ` [PATCH 3/4] xfstests: fix brain-o in fallocate log dump Dave Chinner
2011-06-27 21:32 ` Eric Sandeen
2011-06-27 5:48 ` [PATCH 4/4] xfstests: add mapped write fsx operations to 091 Dave Chinner
2011-06-27 21:38 ` Eric Sandeen
-- strict thread matches above, loose matches on Subject: below --
2011-07-08 0:53 [PATCH 0/4, V2] xfstests: fsx is fallocate challenged Dave Chinner
2011-07-08 0:53 ` [PATCH 2/4] xfstests: fsx fallocate support is b0rked Dave Chinner
2011-07-08 18:58 ` Alex Elder
2011-07-11 6:14 ` 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=4E08F324.5040703@sandeen.net \
--to=sandeen@sandeen.net \
--cc=david@fromorbit.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 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.