Bug 269638 - request: aio_read2() and aio_write2()
Summary: request: aio_read2() and aio_write2()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-17 20:20 UTC by vini.ipsmaker
Modified: 2024-02-11 02:45 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vini.ipsmaker 2023-02-17 20:20:23 UTC
Hi, I'd like to use AIO to read files w/o specifying an offset in the member aio_offset. Instead, I'd like for the current file offset to be used. For Linux, io_uring supports using -1 for the offset to indicate that the current file position should be used instead of passing in an explicit offset. I'd like to do the same on FreeBSD. Could a function aio_readpipe() (and aio_writepipe()) or something like that be added?
Comment 1 vini.ipsmaker 2023-11-30 09:35:56 UTC
Maybe a good name for the new aio functions would be aio_stream_read() and aio_stream_write()?

I need these functions to port Boost.Asio (part of libboost) file facilities to FreeBSD. Any software making use of Boost.Asio file facilities would then be able to work on FreeBSD.
Comment 2 vini.ipsmaker 2023-12-20 18:37:47 UTC
I think I've reached a good interface for the new functions:

int aio_read2(struct aiocb *iocb, unsigned flags);
int aio_write2(struct	aiocb *iocb, unsigned flags);

aio_read(iocb) would be equivalent to aio_read2(iocb, 0) and aio_write(iocb) would be equivalent to aio_write2(iocb, 0).

Then we would define the following flags:

AIO_USEIOV
AIO_IGNOREOFFSET

aio_readv(iocb) would be equivalent to aio_read2(iocb, AIO_USEIOV) and aio_writev(iocb) would be equivalent to aio_write2(iocb, AIO_USEIOV).

The flag AIO_IGNOREOFFSET would instruct the call to ignore aio_offset in aiocb and use the file position (lseek) if applicable.
Comment 3 vini.ipsmaker 2023-12-20 18:51:45 UTC
The flag AIO_IGNOREOFFSET should not conflict with LIO opcodes so one could OR it into aio_lio_opcode for usage with lio_listio() as well. I think that should be enough to close all ties.