Bug 220398

Summary: lio_listio(2) never sends signal if nent==0
Product: Base System Reporter: Alan Somers <asomers>
Component: kernAssignee: Alan Somers <asomers>
Status: Closed FIXED    
Severity: Affects Some People CC: emaste, jhb
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Reproduction program none

Description Alan Somers freebsd_committer freebsd_triage 2017-06-30 21:53:05 UTC
Created attachment 183968 [details]
Reproduction program

It may seem stupid, but you can call lio_listio(2) with an empty aiocb list.  I would naively expect lio_listio to do nothing and return in that case.  Indeed, that's what it does when mode == LIO_WAIT.  However, if mode == LIO_NOWAIT, then asynchronous notifications never get delivered.  With SIGEV_KEVENT, no kevent is ever delivered, and with SIGEV_SIGNAL, no signal is ever delivered.  I haven't checked other SIGEV_ values.

The attached program demonstrates the problem: it calls lio_listio with LIO_NOWAIT and notification via SIGTERM.  But no signal ever gets delivered, so the program exits normally.

jhb feels that the Open Group's specification is ambiguous on this point, but that sending asynchronous notification immediately would be sensible.
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-07-17 18:33:53 UTC
A commit references this bug:

Author: asomers
Date: Mon Jul 17 18:33:31 UTC 2017
New revision: 321082
URL: https://svnweb.freebsd.org/changeset/base/321082

Log:
  Add regression tests for bugs 220459 and 220398

  Bug 220398 - lio_listio(2) never sends asynchronous notification if nent==0
  Bug 220459 - lio_listio(2) doesn't support SIGEV_THREAD

  PR:		220459
  PR:		220398
  Reviewed by:	cem, jhb
  MFC after:	3 weeks
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D11470

Changes:
  head/tests/sys/aio/Makefile
  head/tests/sys/aio/lio_test.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2017-08-02 09:50:44 UTC
A commit references this bug:

Author: ngie
Date: Wed Aug  2 09:49:41 UTC 2017
New revision: 321918
URL: https://svnweb.freebsd.org/changeset/base/321918

Log:
  Fix cosmetic issue with error message

  Add missing space in error message related to PR noted.

  MFC after:	2 weeks
  PR:		220398

Changes:
  head/tests/sys/aio/lio_test.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-08-25 14:38:14 UTC
A commit references this bug:

Author: asomers
Date: Fri Aug 25 14:37:23 UTC 2017
New revision: 322891
URL: https://svnweb.freebsd.org/changeset/base/322891

Log:
  MFC r321082:

  Add regression tests for bugs 220459 and 220398

  Bug 220398 - lio_listio(2) never sends asynchronous notification if nent==0
  Bug 220459 - lio_listio(2) doesn't support SIGEV_THREAD

  PR:		220459
  PR:		220398
  Reviewed by:	cem, jhb
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D11470

Changes:
_U  stable/11/
  stable/11/tests/sys/aio/Makefile
  stable/11/tests/sys/aio/lio_test.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2020-12-01 22:54:23 UTC
A commit references this bug:

Author: kib
Date: Tue Dec  1 22:53:34 UTC 2020
New revision: 368265
URL: https://svnweb.freebsd.org/changeset/base/368265

Log:
  lio_listio(2): send signal even if number of jobs is zero.

  Right now, if lio registered zero jobs, syscall frees lio job
  structure, cleaning up queued ksi.  As result, the realtime signal is
  dequeued and never delivered.

  Fix it by allowing sendsig() to copy ksi when job count is zero.

  PR: 220398
  Reported and reviewed by:	asomers
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Differential revision:	https://reviews.freebsd.org/D27421

Changes:
  head/sys/kern/vfs_aio.c
Comment 5 Alan Somers freebsd_committer freebsd_triage 2020-12-02 00:46:29 UTC
Changing the bug title, because the lack of signal notification and lack of kqueue notification turned out to be separate bugs.  Kib's commit only fixed the former.  I'll open a separate bug for kqueue notification.
Comment 6 commit-hook freebsd_committer freebsd_triage 2020-12-02 00:53:38 UTC
A commit references this bug:

Author: asomers
Date: Wed Dec  2 00:53:03 UTC 2020
New revision: 368272
URL: https://svnweb.freebsd.org/changeset/base/368272

Log:
  AIO tests: update expected failure messages after r368265

  PR:		220398, 251515
  MFC after:	1 week
  MFC-With:	r368265

Changes:
  head/tests/sys/aio/lio_test.c
Comment 7 commit-hook freebsd_committer freebsd_triage 2020-12-30 03:03:34 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0efb22eebbbbd5f164cab39dca72a78cce82afe3

commit 0efb22eebbbbd5f164cab39dca72a78cce82afe3
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2020-01-04 18:59:46 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2020-12-30 03:02:47 +0000

    MFC r356352, r368272

    lio_listio_empty_nowait_thread sometimes does *not* hang.

    The other tests consistently do hang though.

    Sponsored by:   DellEMC

    (cherry picked from commit 0cb4586a0be3b1b5909b73b24798032ddf2f4002)

    AIO tests: update expected failure messages after r368265

    PR:             220398, 251515

    (cherry picked from commit 23693bd8f3e36b4721d7b59d52154d3e3f49e3cd)

 tests/sys/aio/lio_test.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)