diff mbox series

[6/6] aio-dio-append-write-fallocate-race: fix directio buffer alignment bugs

Message ID 162146863667.2500122.9363433713420860828.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series fstests: miscellaneous fixes | expand

Commit Message

Darrick J. Wong May 19, 2021, 11:57 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

This program fails on filesystems where the stat() block size isn't a
strict power of two because it foolishly feeds that to posix_memalign to
allocate an aligned memory buffer for directio.  posix_memalign requires
the alignment value to be a power of two, so generic/586 fails.

The system page size generally works well for directio buffers, so use
that instead.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 .../aio-dio-append-write-fallocate-race.c          |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig May 21, 2021, 8:08 a.m. UTC | #1
On Wed, May 19, 2021 at 04:57:16PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> This program fails on filesystems where the stat() block size isn't a
> strict power of two because it foolishly feeds that to posix_memalign to
> allocate an aligned memory buffer for directio.  posix_memalign requires
> the alignment value to be a power of two, so generic/586 fails.
> 
> The system page size generally works well for directio buffers, so use
> that instead.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/src/aio-dio-regress/aio-dio-append-write-fallocate-race.c b/src/aio-dio-regress/aio-dio-append-write-fallocate-race.c
index 091b047d..d3a2e5fc 100644
--- a/src/aio-dio-regress/aio-dio-append-write-fallocate-race.c
+++ b/src/aio-dio-regress/aio-dio-append-write-fallocate-race.c
@@ -65,7 +65,7 @@  test(
 	}
 	blocksize = sbuf.st_blksize;
 
-	ret = posix_memalign((void **)&buf, blocksize, blocksize);
+	ret = posix_memalign((void **)&buf, sysconf(_SC_PAGESIZE), blocksize);
 	if (ret) {
 		errno = ret;
 		perror("buffer");