git: 40734fc57ec0 - main - aio: Fix a test and set race in aio_biowakeup.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 15 Feb 2023 18:57:44 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=40734fc57ec0158690e9f03284229553b050b8ea commit 40734fc57ec0158690e9f03284229553b050b8ea Author: Keith Reynolds <keith.reynolds@hpe.com> AuthorDate: 2023-02-15 18:56:39 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2023-02-15 18:56:39 +0000 aio: Fix a test and set race in aio_biowakeup. Use atomic_fetchadd in place of separate atomic_subtract / atomic_load. Reviewed by: markj Sponsored by: HPE TidalScale Differential Revision: https://reviews.freebsd.org/D38559 --- sys/kern/vfs_aio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 43e54e1ad9bf..34671f67191f 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -2493,10 +2493,9 @@ aio_biowakeup(struct bio *bp) atomic_add_int(&job->outblock, nblks); else atomic_add_int(&job->inblock, nblks); - atomic_subtract_int(&job->nbio, 1); - if (atomic_load_int(&job->nbio) == 0) { + if (atomic_fetchadd_int(&job->nbio, -1) == 1) { if (atomic_load_int(&job->error)) aio_complete(job, -1, job->error); else