diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -14,6 +14,8 @@ _rand48.c \ _spinlock_stub.c \ _thread_init.c \ + aio_read2.c \ + aio_write2.c \ alarm.c \ arc4random.c \ arc4random-compat.c \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -458,6 +458,8 @@ }; FBSD_1.8 { + aio_read2; + aio_write2; execvpe; }; diff --git a/lib/libc/gen/aio_read2.c b/lib/libc/gen/aio_read2.c new file mode 100644 --- /dev/null +++ b/lib/libc/gen/aio_read2.c @@ -0,0 +1,56 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 The FreeBSD Foundation + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +int +aio_read2(struct aiocb *iocb, int flags) +{ + int error; + + if ((flags & ~(AIO_OP2_FOFFSET)) != 0) { + errno = EINVAL; + return (-1); + } + iocb->aio_lio_opcode = LIO_READ; + if ((flags & AIO_OP2_FOFFSET) != 0) + iocb->aio_lio_opcode |= LIO_FOFFSET; + + error = lio_listio(LIO_NOWAIT, &iocb, 1, NULL); + if (error == -1 && errno == EIO) { + error = aio_error(iocb); + if (error != -1 && error != 0) + errno = error; + error = -1; + } + return (error); +} diff --git a/lib/libc/gen/aio_write2.c b/lib/libc/gen/aio_write2.c new file mode 100644 --- /dev/null +++ b/lib/libc/gen/aio_write2.c @@ -0,0 +1,56 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 The FreeBSD Foundation + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +int +aio_write2(struct aiocb *iocb, int flags) +{ + int error; + + if ((flags & ~(AIO_OP2_FOFFSET)) != 0) { + errno = EINVAL; + return (-1); + } + iocb->aio_lio_opcode = LIO_WRITE; + if ((flags & AIO_OP2_FOFFSET) != 0) + iocb->aio_lio_opcode |= LIO_FOFFSET; + + error = lio_listio(LIO_NOWAIT, &iocb, 1, NULL); + if (error == -1 && errno == EIO) { + error = aio_error(iocb); + if (error != -1 && error != 0) + errno = error; + error = -1; + } + return (error); +} diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -355,8 +355,10 @@ write.2 \ _umtx_op.2 -MLINKS+=aio_read.2 aio_readv.2 -MLINKS+=aio_write.2 aio_writev.2 +MLINKS+=aio_read.2 aio_readv.2 \ + aio_read.2 aio_read2.2 +MLINKS+=aio_write.2 aio_writev.2 \ + aio_write.2 aio_write2.2 MLINKS+=accept.2 accept4.2 MLINKS+=access.2 eaccess.2 \ access.2 faccessat.2 diff --git a/lib/libc/sys/aio_read.2 b/lib/libc/sys/aio_read.2 --- a/lib/libc/sys/aio_read.2 +++ b/lib/libc/sys/aio_read.2 @@ -22,11 +22,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd November 15, 2023 +.Dd February 1, 2024 .Dt AIO_READ 2 .Os .Sh NAME .Nm aio_read , +.Nm aio_read2 , .Nm aio_readv .Nd asynchronous read from a file (REALTIME) .Sh LIBRARY @@ -35,20 +36,41 @@ .In aio.h .Ft int .Fn aio_read "struct aiocb *iocb" +.Ft int +.Fn aio_read2 "struct aiocb *iocb" .In sys/uio.h .Ft int .Fn aio_readv "struct aiocb *iocb" .Sh DESCRIPTION The -.Fn aio_read +.Fn aio_read , +.Fn aio_read2 and .Fn aio_readv system calls allow the calling process to read from the descriptor -.Fa iocb->aio_fildes -beginning at the offset +.Fa iocb->aio_fildes . +The syscalls return immediately after the read request has +been enqueued to the descriptor; the read may or may not have +completed at the time the call returns. +.Pp +For the +.Fn aio_read +and +.Fn aio_readv +calls, the read begins at the offset .Fa iocb->aio_offset . +For the +.Fn aio_read2 +call, the read occurs at the file descriptor offset, +which is advanced by the operation as done by the +.Xr read 2 +syscall. +.Pp +Both .Fn aio_read +and +.Fn aio_read2 will read .Fa iocb->aio_nbytes into the buffer pointed to by @@ -60,9 +82,6 @@ buffers specified by the members of the .Fa iocb->aio_iov array. -Both syscalls return immediately after the read request has -been enqueued to the descriptor; the read may or may not have -completed at the time the call returns. .Pp For .Fn aio_readv @@ -103,9 +122,8 @@ .Pp The asynchronous I/O control buffer .Fa iocb -should be zeroed before the -.Fn aio_read -call to avoid passing bogus context information to the kernel. +should be zeroed before the system +calls to avoid passing bogus context information to the kernel. .Pp Modifications of the Asynchronous I/O Control Block structure or the buffer contents are not allowed while the request is queued. @@ -116,12 +134,13 @@ .Fa iocb->aio_fildes , no I/O will occur. .Sh RETURN VALUES -.Rv -std aio_read aio_readv +.Rv -std aio_read aio_read2 aio_readv .Sh DIAGNOSTICS None. .Sh ERRORS The -.Fn aio_read +.Fn aio_read , +.Fn aio_read2 , and .Fn aio_readv system calls will fail if: @@ -149,10 +168,7 @@ system call is made, or asynchronously, at any time thereafter. If they are detected at call time, -.Fn aio_read -or -.Fn aio_readv -returns -1 and sets +The calls returns -1 and sets .Va errno appropriately; otherwise the .Fn aio_return @@ -226,8 +242,11 @@ .St -p1003.1 standard. The +.Fn aio_read2 +and .Fn aio_readv -system call is a FreeBSD extension, and should not be used in portable code. +system calls are the FreeBSD extensions, +and should not be used in portable code. .Sh HISTORY The .Fn aio_read @@ -237,6 +256,10 @@ .Fn aio_readv system call first appeared in .Fx 13.0 . +The +.Fn aio_read2 +system call first appeared in +.Fx 14.1 . .Sh AUTHORS This manual page was written by diff --git a/lib/libc/sys/aio_write.2 b/lib/libc/sys/aio_write.2 --- a/lib/libc/sys/aio_write.2 +++ b/lib/libc/sys/aio_write.2 @@ -22,11 +22,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd November 15, 2023 +.Dd February 1, 2024 .Dt AIO_WRITE 2 .Os .Sh NAME .Nm aio_write , +.Nm aio_write2 , .Nm aio_writev .Nd asynchronous write to a file (REALTIME) .Sh LIBRARY @@ -35,18 +36,27 @@ .In aio.h .Ft int .Fn aio_write "struct aiocb *iocb" +.Ft int +.Fn aio_write2 "struct aiocb *iocb" .In sys/uio.h .Ft int .Fn aio_writev "struct aiocb *iocb" .Sh DESCRIPTION The -.Fn aio_write +.Fn aio_write , +.Fn aio_write2 , and .Fn aio_writev system calls allow the calling process to write to the descriptor .Fa iocb->aio_fildes . +The syscalls return immediately after the write request has been enqueued +to the descriptor; the write may or may not have completed at the time +the call returns. +.Pp .Fn aio_write +and +.Fn aio_write2 will write .Fa iocb->aio_nbytes from the buffer pointed to by @@ -58,9 +68,7 @@ buffers specified by the members of the .Fa iocb->aio_iov array. -Both syscalls return immediately after the write request has been enqueued -to the descriptor; the write may or may not have completed at the time -the call returns. +.Pp If the request could not be enqueued, generally due to invalid arguments, the call returns without having enqueued the request. @@ -80,9 +88,13 @@ made. If .Dv O_APPEND -is not set for the file descriptor, the write operation will occur at +is not set for the file descriptor, the write operation for +.Fn aio_write will occur at the absolute position from the beginning of the file plus -.Fa iocb->aio_offset . +.Fa iocb->aio_offset , +and for +.Fn aio_write2 +the write occurs at the file descriptor offset. .Pp The .Fa iocb @@ -114,10 +126,7 @@ The asynchronous I/O control buffer .Fa iocb should be zeroed before the -.Fn aio_write -or -.Fn aio_writev -system call to avoid passing bogus context information to the kernel. +system calls to avoid passing bogus context information to the kernel. .Pp Modifications of the Asynchronous I/O Control Block structure or the buffer contents are not allowed while the request is queued. @@ -131,7 +140,8 @@ .Rv -std aio_write aio_writev .Sh ERRORS The -.Fn aio_write +.Fn aio_write , +.Fn aio_write2 , and .Fn aio_writev system calls will fail if: @@ -153,16 +163,13 @@ .El .Pp The following conditions may be synchronously detected when the -.Fn aio_write +.Fn aio_write , +.Fn aio_write2 , or .Fn aio_writev system call is made, or asynchronously, at any time thereafter. If they -are detected at call time, -.Fn aio_write -or -.Fn aio_writev -returns -1 and sets +are detected at call time, the calls returns -1 and sets .Va errno appropriately; otherwise the .Fn aio_return @@ -229,8 +236,11 @@ standard. .Pp The +.Fn aio_write2 +and .Fn aio_writev -system call is a FreeBSD extension, and should not be used in portable code. +system calls are a FreeBSD extension, +and should not be used in portable code. .Sh HISTORY The .Fn aio_write @@ -240,6 +250,10 @@ .Fn aio_writev system call first appeared in .Fx 13.0 . +The +.Fn aio_read2 +system call first appeared in +.Fx 14.1 . .Sh AUTHORS This manual page was written by .An Wes Peters Aq Mt wes@softweyr.com . diff --git a/lib/libc/sys/lio_listio.2 b/lib/libc/sys/lio_listio.2 --- a/lib/libc/sys/lio_listio.2 +++ b/lib/libc/sys/lio_listio.2 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 22, 2021 +.Dd January 13, 2024 .Dt LIO_LISTIO 2 .Os .Sh NAME @@ -78,6 +78,19 @@ .El .Pp If the +.Dv LIO_READ , +.Dv LIO_READV , +.Dv LIO_WRITE , +.Dv LIO_WRITEV +opcodes are or-ed with the +.Dv LIO_FOFFSET +flag, the correspoing read or write operation uses the current file +descriptor offset, instead of the +.Va aio_offset +from +.Vt aiocb . +.Pp +If the .Fa mode argument is .Dv LIO_WAIT , diff --git a/sys/amd64/amd64/efirt_machdep.c b/sys/amd64/amd64/efirt_machdep.c --- a/sys/amd64/amd64/efirt_machdep.c +++ b/sys/amd64/amd64/efirt_machdep.c @@ -235,7 +235,7 @@ "attributes unsupported\n", i); mode = VM_MEMATTR_UNCACHEABLE; } - bits = pmap_cache_bits(kernel_pmap, mode, false) | X86_PG_RW | + bits = pmap_cache_bits(kernel_pmap, mode, FALSE) | X86_PG_RW | X86_PG_V; VM_OBJECT_WLOCK(obj_1t1_pt); for (va = p->md_phys, idx = 0; idx < p->md_pages; idx++, diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -982,11 +982,10 @@ if (physmap[i + 1] < end) end = trunc_page(physmap[i + 1]); for (pa = round_page(physmap[i]); pa < end; pa += PAGE_SIZE) { + int tmp, page_bad, full; int *ptr = (int *)CADDR1; - int tmp; - bool full, page_bad; - full = false; + full = FALSE; /* * block out kernel memory as not available. */ @@ -1001,7 +1000,7 @@ && pa < dcons_addr + dcons_size) goto do_dump_avail; - page_bad = false; + page_bad = FALSE; if (memtest == 0) goto skip_memtest; @@ -1025,25 +1024,25 @@ */ *(volatile int *)ptr = 0xaaaaaaaa; if (*(volatile int *)ptr != 0xaaaaaaaa) - page_bad = true; + page_bad = TRUE; /* * Test for alternating 0's and 1's */ *(volatile int *)ptr = 0x55555555; if (*(volatile int *)ptr != 0x55555555) - page_bad = true; + page_bad = TRUE; /* * Test for all 1's */ *(volatile int *)ptr = 0xffffffff; if (*(volatile int *)ptr != 0xffffffff) - page_bad = true; + page_bad = TRUE; /* * Test for all 0's */ *(volatile int *)ptr = 0x0; if (*(volatile int *)ptr != 0x0) - page_bad = true; + page_bad = TRUE; /* * Restore original value. */ @@ -1053,7 +1052,7 @@ /* * Adjust array of valid/good pages. */ - if (page_bad == true) + if (page_bad == TRUE) continue; /* * If this good page is a continuation of the @@ -1074,7 +1073,7 @@ printf( "Too many holes in the physical address space, giving up\n"); pa_indx--; - full = true; + full = TRUE; goto do_dump_avail; } phys_avail[pa_indx++] = pa; /* start */ diff --git a/sys/arm/arm/db_interface.c b/sys/arm/arm/db_interface.c --- a/sys/arm/arm/db_interface.c +++ b/sys/arm/arm/db_interface.c @@ -172,7 +172,7 @@ else pmap = p->p_vmspace->vm_map.pmap; - return (pmap_extract(pmap, addr) == 0); + return (pmap_extract(pmap, addr) == FALSE); } /* diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1766,7 +1766,7 @@ pte = vtopte(va); pte_store(pte, pa | PG_RW | PG_V | pmap_cache_bits(kernel_pmap, - mode, false)); + mode, 0)); } /* @@ -1862,7 +1862,7 @@ while (pte < endpte) { m = *ma++; pa = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(kernel_pmap, - m->md.pat_mode, false); + m->md.pat_mode, 0); if ((*pte & (PG_FRAME | PG_PTE_CACHE)) != pa) { oldpte |= *pte; pte_store(pte, pa | pg_nx | PG_RW | PG_V); @@ -3918,8 +3918,8 @@ pd_entry_t newpde; PMAP_LOCK_ASSERT(pmap, MA_OWNED); - newpde = VM_PAGE_TO_PHYS(m) | - pmap_cache_bits(pmap, m->md.pat_mode, true) | PG_PS | PG_V; + newpde = VM_PAGE_TO_PHYS(m) | pmap_cache_bits(pmap, m->md.pat_mode, 1) | + PG_PS | PG_V; if ((m->oflags & VPO_UNMANAGED) == 0) newpde |= PG_MANAGED; #ifdef PMAP_PAE_COMP @@ -4233,7 +4233,7 @@ pmap->pm_stats.resident_count++; newpte = VM_PAGE_TO_PHYS(m) | PG_V | - pmap_cache_bits(pmap, m->md.pat_mode, false); + pmap_cache_bits(pmap, m->md.pat_mode, 0); if ((m->oflags & VPO_UNMANAGED) == 0) newpte |= PG_MANAGED; #ifdef PMAP_PAE_COMP @@ -4339,7 +4339,7 @@ * "pa" will not affect the termination of this loop. */ PMAP_LOCK(pmap); - for (pa = ptepa | pmap_cache_bits(pmap, pat_mode, true); + for (pa = ptepa | pmap_cache_bits(pmap, pat_mode, 1); pa < ptepa + size; pa += NBPDR) { pde = pmap_pde(pmap, addr); if (*pde == 0) { @@ -4596,7 +4596,7 @@ if (*cmap_pte2) panic("pmap_zero_page: CMAP2 busy"); *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | - pmap_cache_bits(kernel_pmap, m->md.pat_mode, false); + pmap_cache_bits(kernel_pmap, m->md.pat_mode, 0); invlcaddr(pc->pc_cmap_addr2); pagezero(pc->pc_cmap_addr2); *cmap_pte2 = 0; @@ -4627,7 +4627,7 @@ if (*cmap_pte2) panic("pmap_zero_page_area: CMAP2 busy"); *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | - pmap_cache_bits(kernel_pmap, m->md.pat_mode, false); + pmap_cache_bits(kernel_pmap, m->md.pat_mode, 0); invlcaddr(pc->pc_cmap_addr2); if (off == 0 && size == PAGE_SIZE) pagezero(pc->pc_cmap_addr2); @@ -4657,10 +4657,10 @@ if (*cmap_pte2) panic("pmap_copy_page: CMAP2 busy"); *cmap_pte1 = PG_V | VM_PAGE_TO_PHYS(src) | PG_A | - pmap_cache_bits(kernel_pmap, src->md.pat_mode, false); + pmap_cache_bits(kernel_pmap, src->md.pat_mode, 0); invlcaddr(pc->pc_cmap_addr1); *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(dst) | PG_A | PG_M | - pmap_cache_bits(kernel_pmap, dst->md.pat_mode, false); + pmap_cache_bits(kernel_pmap, dst->md.pat_mode, 0); invlcaddr(pc->pc_cmap_addr2); bcopy(pc->pc_cmap_addr1, pc->pc_cmap_addr2, PAGE_SIZE); *cmap_pte1 = 0; @@ -4697,11 +4697,10 @@ b_pg_offset = b_offset & PAGE_MASK; cnt = min(cnt, PAGE_SIZE - b_pg_offset); *cmap_pte1 = PG_V | VM_PAGE_TO_PHYS(a_pg) | PG_A | - pmap_cache_bits(kernel_pmap, a_pg->md.pat_mode, false); + pmap_cache_bits(kernel_pmap, a_pg->md.pat_mode, 0); invlcaddr(pc->pc_cmap_addr1); *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(b_pg) | PG_A | - PG_M | pmap_cache_bits(kernel_pmap, b_pg->md.pat_mode, - false); + PG_M | pmap_cache_bits(kernel_pmap, b_pg->md.pat_mode, 0); invlcaddr(pc->pc_cmap_addr2); a_cp = pc->pc_cmap_addr1 + a_pg_offset; b_cp = pc->pc_cmap_addr2 + b_pg_offset; @@ -5664,7 +5663,7 @@ panic("pmap_flush_page: CMAP2 busy"); *cmap_pte2 = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | pmap_cache_bits(kernel_pmap, m->md.pat_mode, - false); + 0); invlcaddr(pc->pc_cmap_addr2); sva = (vm_offset_t)pc->pc_cmap_addr2; eva = sva + PAGE_SIZE; @@ -5725,8 +5724,8 @@ if (base < VM_MIN_KERNEL_ADDRESS) return (EINVAL); - cache_bits_pde = pmap_cache_bits(kernel_pmap, mode, true); - cache_bits_pte = pmap_cache_bits(kernel_pmap, mode, false); + cache_bits_pde = pmap_cache_bits(kernel_pmap, mode, 1); + cache_bits_pte = pmap_cache_bits(kernel_pmap, mode, 0); changed = false; /* @@ -5940,7 +5939,7 @@ KASSERT(*pte == 0, ("pmap_quick_enter_page: PTE busy %#jx", (uintmax_t)*pte)); *pte = PG_V | PG_RW | VM_PAGE_TO_PHYS(m) | PG_A | PG_M | - pmap_cache_bits(kernel_pmap, pmap_page_get_memattr(m), false); + pmap_cache_bits(kernel_pmap, pmap_page_get_memattr(m), 0); invlpg(qaddr); return (qaddr); @@ -6086,7 +6085,7 @@ ptep = vtopte(sf->kva); opte = *ptep; *ptep = VM_PAGE_TO_PHYS(sf->m) | PG_RW | PG_V | - pmap_cache_bits(kernel_pmap, sf->m->md.pat_mode, false); + pmap_cache_bits(kernel_pmap, sf->m->md.pat_mode, 0); /* * Avoid unnecessary TLB invalidations: If the sf_buf's old diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -229,6 +229,9 @@ #define KAIOCB_CLEARED 0x10 #define KAIOCB_FINISHED 0x20 +/* ioflags */ +#define KAIOCB_IO_FOFFSET 0x01 + /* * AIO process info */ @@ -789,12 +792,14 @@ if (job->uiop->uio_resid == 0) error = 0; else - error = fo_read(fp, job->uiop, fp->f_cred, FOF_OFFSET, - td); + error = fo_read(fp, job->uiop, fp->f_cred, + (job->ioflags & KAIOCB_IO_FOFFSET) != 0 ? 0 : + FOF_OFFSET, td); } else { if (fp->f_type == DTYPE_VNODE) bwillwrite(); - error = fo_write(fp, job->uiop, fp->f_cred, FOF_OFFSET, td); + error = fo_write(fp, job->uiop, fp->f_cred, (job->ioflags & + KAIOCB_IO_FOFFSET) != 0 ? 0 : FOF_OFFSET, td); } msgrcv_end = td->td_ru.ru_msgrcv; msgsnd_end = td->td_ru.ru_msgsnd; @@ -1549,13 +1554,15 @@ /* Get the opcode. */ if (type == LIO_NOP) { - switch (job->uaiocb.aio_lio_opcode) { + switch (job->uaiocb.aio_lio_opcode & ~LIO_FOFFSET) { case LIO_WRITE: case LIO_WRITEV: case LIO_NOP: case LIO_READ: case LIO_READV: - opcode = job->uaiocb.aio_lio_opcode; + opcode = job->uaiocb.aio_lio_opcode & ~LIO_FOFFSET; + if ((job->uaiocb.aio_lio_opcode & LIO_FOFFSET) != 0) + job->ioflags |= KAIOCB_IO_FOFFSET; break; default: error = EINVAL; diff --git a/sys/sys/aio.h b/sys/sys/aio.h --- a/sys/sys/aio.h +++ b/sys/sys/aio.h @@ -51,6 +51,14 @@ #define LIO_DSYNC (0x10 | LIO_SYNC) #define LIO_MLOCK 0x20 #endif +#if __BSD_VISIBLE +#define LIO_FOFFSET 0x40 +#endif + +/* aio_read2/aio_write2 flags */ +#if __BSD_VISIBLE +#define AIO_OP2_FOFFSET 0x00000001 +#endif /* * LIO modes @@ -129,6 +137,7 @@ TAILQ_ENTRY(kaiocb) plist; /* (a) lists of pending / done jobs */ TAILQ_ENTRY(kaiocb) allist; /* (a) list of all jobs in proc */ int jobflags; /* (a) job flags */ + int ioflags; /* (*) io flags */ int inblock; /* (*) input blocks */ int outblock; /* (*) output blocks */ int msgsnd; /* (*) messages sent */ @@ -271,6 +280,8 @@ #if __BSD_VISIBLE ssize_t aio_waitcomplete(struct aiocb **, struct timespec *); +int aio_read2(struct aiocb *, int); +int aio_write2(struct aiocb *, int); #endif int aio_fsync(int op, struct aiocb *aiocbp);