git: 3904e7966eb3 - main - Fix aio_readv(2), aio_writev(2) with SIGEV_THREAD.

Konstantin Belousov kostikbel at gmail.com
Sun Aug 22 14:18:55 UTC 2021


On Sun, Aug 22, 2021 at 05:15:22PM +0300, Konstantin Belousov wrote:
> On Sun, Aug 22, 2021 at 12:16:12PM +0000, Thomas Munro wrote:
> > The branch main has been updated by tmunro:
> > 
> > URL: https://cgit.FreeBSD.org/src/commit/?id=3904e7966eb353c636c6aa638a6fdf1489ee514c
> > 
> > commit 3904e7966eb353c636c6aa638a6fdf1489ee514c
> > Author:     Thomas Munro <tmunro at FreeBSD.org>
> > AuthorDate: 2021-08-22 11:34:07 +0000
> > Commit:     Thomas Munro <tmunro at FreeBSD.org>
> > CommitDate: 2021-08-22 11:49:23 +0000
> > 
> >     Fix aio_readv(2), aio_writev(2) with SIGEV_THREAD.
> >     
> >     Add missing wrapper code to librt for these new functions so that
> >     SIGEV_THREAD works.  Without machinery to convert it to SIGEV_THREAD_ID,
> >     you got EINVAL.
> >     
> >     Reviewed by:    asomers
> >     MFC after:      2 weeks
> >     Differential Revision:  https://reviews.freebsd.org/D31618
> > ---
> >  lib/libc/sys/Symbol.map  |  2 ++
> >  lib/librt/Symbol.map     |  5 +++++
> >  lib/librt/aio.c          | 18 ++++++++++++++++++
> >  tests/sys/aio/aio_test.c |  7 +++++++
> >  4 files changed, 32 insertions(+)
> > 
> > diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
> > index 93fbc947a7e1..764d712958be 100644
> > --- a/lib/libc/sys/Symbol.map
> > +++ b/lib/libc/sys/Symbol.map
> > @@ -495,10 +495,12 @@ FBSDprivate_1.0 {
> >  	__sys_aio_error;
> >  	__sys_aio_fsync;
> >  	__sys_aio_read;
> > +	__sys_aio_readv;
> >  	__sys_aio_return;
> >  	__sys_aio_suspend;
> >  	__sys_aio_waitcomplete;
> >  	__sys_aio_write;
> > +	__sys_aio_writev;
> >  	_audit;
> >  	__sys_audit;
> >  	_auditctl;
> > diff --git a/lib/librt/Symbol.map b/lib/librt/Symbol.map
> > index c11b88397afd..b8fde3dd33b8 100644
> > --- a/lib/librt/Symbol.map
> > +++ b/lib/librt/Symbol.map
> > @@ -31,6 +31,11 @@ FBSD_1.5 {
> >  	timer_oshandle_np;
> >  };
> >  
> > +FBSD_1.6 {
> > +	aio_readv;
> > +	aio_writev;
> > +};
> This must be FBSD_1.7.
No, I was wrong and the commit as is is right, assuming that the intent
is to interpose libc symbols with librt functionality.

Of course this is very fragile and would not work if e.g. librt is loaded
after libc is linked in and symbols resolved.  I fixed this (mostly) for
libthr, but librt is not.

> 
> > +
> >  FBSDprivate_1.0 {
> >  	_mq_open;
> >  	_mq_close;
> > diff --git a/lib/librt/aio.c b/lib/librt/aio.c
> > index 9c35644ecf3d..8e819a002613 100644
> > --- a/lib/librt/aio.c
> > +++ b/lib/librt/aio.c
> > @@ -42,7 +42,9 @@
> >  #include "un-namespace.h"
> >  
> >  __weak_reference(__aio_read, aio_read);
> > +__weak_reference(__aio_readv, aio_readv);
> >  __weak_reference(__aio_write, aio_write);
> > +__weak_reference(__aio_writev, aio_writev);
> >  __weak_reference(__aio_return, aio_return);
> >  __weak_reference(__aio_waitcomplete, aio_waitcomplete);
> >  __weak_reference(__aio_fsync, aio_fsync);
> > @@ -51,7 +53,9 @@ __weak_reference(__lio_listio, lio_listio);
> >  typedef void (*aio_func)(union sigval val, struct aiocb *iocb);
> >  
> >  extern int __sys_aio_read(struct aiocb *iocb);
> > +extern int __sys_aio_readv(struct aiocb *iocb);
> >  extern int __sys_aio_write(struct aiocb *iocb);
> > +extern int __sys_aio_writev(struct aiocb *iocb);
> >  extern ssize_t __sys_aio_waitcomplete(struct aiocb **iocbp, struct timespec *timeout);
> >  extern ssize_t __sys_aio_return(struct aiocb *iocb);
> >  extern int __sys_aio_error(struct aiocb *iocb);
> > @@ -130,6 +134,13 @@ __aio_read(struct aiocb *iocb)
> >  	return aio_io(iocb, &__sys_aio_read);
> >  }
> >  
> > +int
> > +__aio_readv(struct aiocb *iocb)
> > +{
> > +
> > +	return aio_io(iocb, &__sys_aio_readv);
> > +}
> > +
> >  int
> >  __aio_write(struct aiocb *iocb)
> >  {
> > @@ -137,6 +148,13 @@ __aio_write(struct aiocb *iocb)
> >  	return aio_io(iocb, &__sys_aio_write);
> >  }
> >  
> > +int
> > +__aio_writev(struct aiocb *iocb)
> > +{
> > +
> > +	return aio_io(iocb, &__sys_aio_writev);
> > +}
> > +
> >  ssize_t
> >  __aio_waitcomplete(struct aiocb **iocbp, struct timespec *timeout)
> >  {
> > diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c
> > index 35bd5dc1264b..1c694ad0c18b 100644
> > --- a/tests/sys/aio/aio_test.c
> > +++ b/tests/sys/aio/aio_test.c
> > @@ -1627,6 +1627,12 @@ ATF_TC_BODY(vectored_file_poll, tc)
> >  	aio_file_test(poll, NULL, true);
> >  }
> >  
> > +ATF_TC_WITHOUT_HEAD(vectored_thread);
> > +ATF_TC_BODY(vectored_thread, tc)
> > +{
> > +	aio_file_test(poll_signaled, setup_thread(), true);
> > +}
> > +
> >  ATF_TC_WITH_CLEANUP(vectored_md_poll);
> >  ATF_TC_HEAD(vectored_md_poll, tc)
> >  {
> > @@ -1814,6 +1820,7 @@ ATF_TP_ADD_TCS(tp)
> >  	ATF_TP_ADD_TC(tp, vectored_zvol_poll);
> >  	ATF_TP_ADD_TC(tp, vectored_unaligned);
> >  	ATF_TP_ADD_TC(tp, vectored_socket_poll);
> > +	ATF_TP_ADD_TC(tp, vectored_thread);
> >  
> >  	return (atf_no_error());
> >  }


More information about the dev-commits-src-all mailing list