xfs
[Top] [All Lists]

[PATCH 06/11] xfstests: randholes: encapsulate direct I/O setup code

To: xfs@xxxxxxxxxxx
Subject: [PATCH 06/11] xfstests: randholes: encapsulate direct I/O setup code
From: Alex Elder <aelder@xxxxxxx>
Date: Thu, 14 Oct 2010 09:50:27 -0500
Reply-to: aelder@xxxxxxx
Pull the code used to get alignment information for direct I/O into
a separate function.

Signed-off-by: Alex Elder <aelder@xxxxxxx>

---
 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");


<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH 06/11] xfstests: randholes: encapsulate direct I/O setup code, Alex Elder <=