public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <aelder@sgi.com>
To: xfs@oss.sgi.com
Subject: [PATCH 01/11] xfstests: randholes: Fix two bugs
Date: Thu, 14 Oct 2010 09:49:43 -0500	[thread overview]
Message-ID: <1287067783.2362.203.camel@doink> (raw)

This patch fixes two bugs in the "randholes" test program.

First, it is possible for findblock() to return -1 if the random
block number it picks is at or above the highest in-range block
that's already been selected.  But this case isn't checked and
the value is blindly used thereafter as if it were valid.  Just
exit if this ever occurs.

Second, when the "alloconly" option is is set, blocks are
preallocated in the target file rather than actually writing them.
But unlike when the blocks are written and subsequently read, the
preallocated blocks are *not* offset by the fileoffset parameter.

I'm pretty sure nobody every noticed this because the program itself
doesn't do any verification when blocks are only preallocated.  But
it's an inconsistency and I think it ought to be fixed.

Signed-off-by: Alex Elder <aelder@sgi.com>

---
 src/randholes.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: b/src/randholes.c
===================================================================
--- a/src/randholes.c
+++ b/src/randholes.c
@@ -249,11 +249,16 @@ writeblks(char *fname, int fd)
 			fflush(stdout);
 		}
 		block = findblock();
-		offset = (__uint64_t)block * blocksize;
+		if (block < 0) {
+		    perror("findblock");
+		    exit(1);
+		}
+
+		offset = (__uint64_t) block * blocksize;
 		if (alloconly) {
                         if (test) continue;
                         
-			fl.l_start = offset;
+			fl.l_start = fileoffset + offset;
 			fl.l_len = blocksize;
 			fl.l_whence = 0;
 


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

                 reply	other threads:[~2010-10-14 14:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1287067783.2362.203.camel@doink \
    --to=aelder@sgi.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