[PATCH 8/9] generic/465: Fix handling of DIO alignment < sizeof(long)

David Howells dhowells at redhat.com
Tue May 25 06:34:42 PDT 2021


generic/465 will fail if the minimun DIO alignment is less than the minimum
size permitted by the posix_memalign() syscall calls made in
aio-dio-append-write-read-race.  AFS has a DIO alignment of 1.

Fix this by setting the minimum alignment to sizeof(long).

Signed-off-by: David Howells <dhowells at redhat.com>
---

 .../aio-dio-append-write-read-race.c               |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/aio-dio-regress/aio-dio-append-write-read-race.c b/src/aio-dio-regress/aio-dio-append-write-read-race.c
index 911f2723..8268fb4e 100644
--- a/src/aio-dio-regress/aio-dio-append-write-read-race.c
+++ b/src/aio-dio-regress/aio-dio-append-write-read-race.c
@@ -110,7 +110,7 @@ int main(int argc, char *argv[])
 	int i, j, c;
 	int use_aio = 1;
 	int ret = 0;
-	int io_align = 4096;
+	int io_align = 4096, mem_align;
 	char *prog;
 	char *testfile;
 
@@ -146,14 +146,15 @@ int main(int argc, char *argv[])
 		goto err;
 	}
 
-	ret = posix_memalign((void **)&wbuf, io_align, blksize);
+	mem_align = (io_align >= sizeof(long) ? io_align : sizeof(long));
+	ret = posix_memalign((void **)&wbuf, mem_align, blksize);
 	if (ret) {
 		fail("failed to alloc memory: %s\n", strerror(ret));
 		ret = 1;
 		goto err;
 	}
 
-	ret = posix_memalign((void **)&rbuf, io_align, blksize);
+	ret = posix_memalign((void **)&rbuf, mem_align, blksize);
 	if (ret) {
 		fail("failed to alloc memory: %s\n", strerror(ret));
 		ret = 1;





More information about the linux-afs mailing list