]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Remove code to align direct I/Os.
authorLachlan McIlroy <lachlan@sgi.com>
Wed, 20 Dec 2006 14:34:47 +0000 (14:34 +0000)
committerLachlan McIlroy <lachlan@sgi.com>
Wed, 20 Dec 2006 14:34:47 +0000 (14:34 +0000)
The alignment code was aligning the boundaries of I/Os to meet the alignment
constraints of the filesystem and as a result was reading/writing more data
than requested causing corruption.  It's up to the user to get the alignment
right.
Merge of master-melb:xfs-cmds:27787a by kenmcd.

  Remove code to align direct I/Os - it was causing corruption in data integrity
  tests.

io/io.h
io/pread.c
io/pwrite.c

diff --git a/io/io.h b/io/io.h
index 4356c7fe78ae3ccd421e34c43300540ee7d6c24e..43754cac8633486d08fcebbed6968c5c2598a10a 100644 (file)
--- a/io/io.h
+++ b/io/io.h
@@ -82,7 +82,6 @@ extern unsigned int   recurse_dir;
 
 extern void            *buffer;
 extern size_t          buffersize;
-extern int             align_direct(off64_t *, long long *);
 extern int             alloc_buffer(size_t, int, unsigned int);
 extern int             read_buffer(int, off64_t, long long, long long *,
                                        int, int);
index dcfec0339d6aa7b2d9ddf428c7416a33ee29cf91..f8b378cb5ad00ec3db9ff98970956cb422bc261f 100644 (file)
@@ -105,36 +105,6 @@ dump_buffer(
        }
 }
 
-int
-align_direct(
-       off64_t         *offset,
-       long long       *count)
-{
-       struct dioattr  dio;
-       unsigned int    align;
-
-       if (!(file->flags & IO_DIRECT))
-               return 0;
-
-       if (file->flags & IO_FOREIGN) {
-               dio.d_miniosz = BBSIZE; /* punt */
-       } else if ((xfsctl(file->name, file->fd, XFS_IOC_DIOINFO, &dio)) < 0) {
-               perror("XFS_IOC_DIOINFO");
-               return 1;
-       }
-
-       align = (*offset % dio.d_miniosz);
-       if (align) {
-               *offset -= align;
-               *count += align;
-       }
-       align = (*count % dio.d_miniosz);
-       if (align) {
-               *count += (dio.d_miniosz - align);
-       }
-       return 0;
-}
-
 static int
 read_random(
        int             fd,
@@ -371,8 +341,6 @@ pread_f(
 
        if (alloc_buffer(bsize, uflag, 0xabababab) < 0)
                return 0;
-       if (align_direct(&offset, &count) < 0)
-               return 0;
 
        gettimeofday(&t1, NULL);
        switch (direction) {
index 6e3833d1045fe1ccb8dbb03c9f4d2c8b25443c69..ca12a5b8270f55ac69cbca669509e0879781bd3e 100644 (file)
@@ -291,8 +291,6 @@ pwrite_f(
 
        if (alloc_buffer(bsize, uflag, seed) < 0)
                return 0;
-       if (align_direct(&offset, &count) < 0)
-               return 0;
 
        c = IO_READONLY | (dflag ? IO_DIRECT : 0);
        if (infile && ((fd = openfile(infile, NULL, c, 0)) < 0))
@@ -340,7 +338,8 @@ pwrite_f(
                        tdiv((double)total, t2), tdiv((double)c, t2));
        }
 done:
-       close(fd);
+       if (infile)
+               close(fd);
        return 0;
 }