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 06/11] xfstests: randholes: encapsulate direct I/O setup code
Date: Thu, 14 Oct 2010 09:50:27 -0500	[thread overview]
Message-ID: <1287067827.2362.218.camel@doink> (raw)

Pull the code used to get alignment information for direct I/O into
a separate function.

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

---
 src/randholes.c |   32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

Index: b/src/randholes.c
===================================================================
--- a/src/randholes.c
+++ b/src/randholes.c
@@ -271,6 +271,22 @@ readblks(int fd)
 }
 
 int
+direct_setup(char *filename, int fd)
+{
+	if (xfscntl(filename, fd, DIOINFO, &diob) < 0) {
+		perror("xfscntl(FIOINFO)");
+		return 1;
+	}
+	if (blocksize % diob.d_miniosz) {
+		fprintf(stderr, "blocksize %d must be a multiple of "
+			"%d for direct I/O\n", blocksize, diob.d_miniosz);
+		return 1;
+	}
+
+	return 0;
+}
+
+int
 main(int argc, char *argv[])
 {
 	int seed, ch, fd, oflags;
@@ -374,19 +390,9 @@ main(int argc, char *argv[])
 		}
 	}
 
-	if (direct) {
-		if (xfscntl(filename, fd, DIOINFO, &diob) < 0) {
-			perror("xfscntl(FIOINFO)");
-			return 1;
-		}
-		if (blocksize % diob.d_miniosz) {
-			fprintf(stderr,
-				"blocksize %d must be a multiple of %d for direct I/O\n",
-				blocksize,
-				diob.d_miniosz);
-			return 1;
-		}
-	}
+	if (direct && direct_setup(filename, fd))
+	    	return 1;
+
         printf(test?"write (skipped)\n":"write\n");
 	writeblks(filename, fd);
         printf("readback\n");


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

                 reply	other threads:[~2010-10-14 14:52 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=1287067827.2362.218.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