From 886578b4beea2da5040dcbf75f0b3f34ee24f9ae Mon Sep 17 00:00:00 2001 From: Lachlan McIlroy Date: Wed, 20 Dec 2006 14:34:47 +0000 Subject: [PATCH] Remove code to align direct I/Os. 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 | 1 - io/pread.c | 32 -------------------------------- io/pwrite.c | 5 ++--- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/io/io.h b/io/io.h index 4356c7fe7..43754cac8 100644 --- 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); diff --git a/io/pread.c b/io/pread.c index dcfec0339..f8b378cb5 100644 --- a/io/pread.c +++ b/io/pread.c @@ -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) { diff --git a/io/pwrite.c b/io/pwrite.c index 6e3833d10..ca12a5b82 100644 --- a/io/pwrite.c +++ b/io/pwrite.c @@ -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; } -- 2.47.2