[PATCH 8/9] generic/465: Fix handling of DIO alignment < sizeof(long)
Darrick J. Wong
djwong at kernel.org
Tue May 25 09:25:14 PDT 2021
On Tue, May 25, 2021 at 02:34:42PM +0100, David Howells wrote:
> 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>
I wonder if you ought to just change the posix_memalign call to match
(somewhat more closely) what the other directio testers do:
ret = posix_memalign((void **)&wbuf, sysconf(_SC_PAGESIZE), blksize);
Since the alignment of the memory buffer doesn't necessarily have
anything to do with the alignment of the read/write offset.
(Longer term it would be /really/ nice to hoist DIOINFO to all the
filesystems, and refactor fstests to use it consistently, but that's way
too big of a request for this patchset.)
--D
> ---
>
> .../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