From owner-svn-src-projects@freebsd.org Sun Dec 13 00:04:30 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B47104C5638 for ; Sun, 13 Dec 2020 00:04:30 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CtlBQ4kvrz4cB6; Sun, 13 Dec 2020 00:04:30 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9559B26118; Sun, 13 Dec 2020 00:04:30 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BD04U1P085398; Sun, 13 Dec 2020 00:04:30 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0BD04UkV085397; Sun, 13 Dec 2020 00:04:30 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202012130004.0BD04UkV085397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 13 Dec 2020 00:04:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r368600 - projects/aio_writev/sys/kern X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/aio_writev/sys/kern X-SVN-Commit-Revision: 368600 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2020 00:04:30 -0000 Author: asomers Date: Sun Dec 13 00:04:30 2020 New Revision: 368600 URL: https://svnweb.freebsd.org/changeset/base/368600 Log: aio_writev: don't corrupt the AIO proc's td_ucred on error Modified: projects/aio_writev/sys/kern/vfs_aio.c Modified: projects/aio_writev/sys/kern/vfs_aio.c ============================================================================== --- projects/aio_writev/sys/kern/vfs_aio.c Sat Dec 12 23:59:05 2020 (r368599) +++ projects/aio_writev/sys/kern/vfs_aio.c Sun Dec 13 00:04:30 2020 (r368600) @@ -779,10 +779,8 @@ aio_process_rw(struct kaiocb *job) if (job->uaiocb.aio_lio_opcode == LIO_WRITEV) { error = copyinuio(job->uaiocb.aio_iov, job->uaiocb.aio_iovcnt, &auiop); - if (error) { - aio_complete(job, -1, error); - return; - } + if (error) + goto out; } else { aiov.iov_base = (void *)(uintptr_t)cb->aio_buf; aiov.iov_len = cb->aio_nbytes; @@ -839,9 +837,10 @@ aio_process_rw(struct kaiocb *job) } cnt -= auiop->uio_resid; - td->td_ucred = td_savedcred; if (job->uaiocb.aio_lio_opcode == LIO_WRITEV) free(auiop, M_IOV); +out: + td->td_ucred = td_savedcred; if (error) aio_complete(job, -1, error); else From owner-svn-src-projects@freebsd.org Sun Dec 13 05:34:15 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A9C44AE625 for ; Sun, 13 Dec 2020 05:34:15 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CttVv2xpvz3CFg; Sun, 13 Dec 2020 05:34:15 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 580D92252; Sun, 13 Dec 2020 05:34:15 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BD5YFkg091938; Sun, 13 Dec 2020 05:34:15 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0BD5YFM7091936; Sun, 13 Dec 2020 05:34:15 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202012130534.0BD5YFM7091936@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 13 Dec 2020 05:34:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r368605 - in projects/aio_writev/sys: kern sys X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/aio_writev/sys: kern sys X-SVN-Commit-Revision: 368605 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2020 05:34:15 -0000 Author: asomers Date: Sun Dec 13 05:34:14 2020 New Revision: 368605 URL: https://svnweb.freebsd.org/changeset/base/368605 Log: Finish the bio path for aio_writev. Still needs a few more tests Modified: projects/aio_writev/sys/kern/vfs_aio.c projects/aio_writev/sys/sys/aio.h Modified: projects/aio_writev/sys/kern/vfs_aio.c ============================================================================== --- projects/aio_writev/sys/kern/vfs_aio.c Sun Dec 13 03:58:43 2020 (r368604) +++ projects/aio_writev/sys/kern/vfs_aio.c Sun Dec 13 05:34:14 2020 (r368605) @@ -1223,21 +1223,25 @@ aio_qbio(struct proc *p, struct kaiocb *job) { struct aiocb *cb; struct file *fp; - struct bio *bp; struct buf *pbuf; struct vnode *vp; struct cdevsw *csw; struct cdev *dev; struct kaioinfo *ki; - int error, ref, poff; + struct uio *auiop = NULL; + off_t offset; + size_t nbytes = 0; + int bio_cmd, error, i, opcode, ref, poff, iovcnt; + bool vectored; vm_prot_t prot; cb = &job->uaiocb; fp = job->fd_file; + opcode = cb->aio_lio_opcode; - // TODO: handle LIO_WRITEV - if (!(cb->aio_lio_opcode == LIO_WRITE || - cb->aio_lio_opcode == LIO_READ)) + if (!(opcode == LIO_WRITE || + opcode == LIO_WRITEV || + opcode == LIO_READ)) return (-1); if (fp == NULL || fp->f_type != DTYPE_VNODE) return (-1); @@ -1247,105 +1251,141 @@ aio_qbio(struct proc *p, struct kaiocb *job) return (-1); if (vp->v_bufobj.bo_bsize == 0) return (-1); - if (cb->aio_nbytes % vp->v_bufobj.bo_bsize) - return (-1); + bio_cmd = opcode == LIO_WRITE || opcode == LIO_WRITEV ? BIO_WRITE : + BIO_READ; + vectored = opcode == LIO_WRITEV; + if (vectored) { + iovcnt = cb->aio_iovcnt; + if (iovcnt > max_buf_aio) + return (-1); + error = copyinuio(cb->aio_iov, cb->aio_iovcnt, &auiop); + if (error) + return (error); + nbytes = auiop->uio_resid; + } else { + nbytes = cb->aio_nbytes; + iovcnt = 1; + } + offset = cb->aio_offset; + + if (nbytes % vp->v_bufobj.bo_bsize) { + error = -1; + goto free_uio; + } + ref = 0; csw = devvn_refthread(vp, &dev, &ref); - if (csw == NULL) - return (ENXIO); + if (csw == NULL) { + error = ENXIO; + goto free_uio; + } if ((csw->d_flags & D_DISK) == 0) { error = -1; goto unref; } - if (cb->aio_nbytes > dev->si_iosize_max) { + if (nbytes > dev->si_iosize_max) { error = -1; goto unref; } ki = p->p_aioinfo; - poff = (vm_offset_t)cb->aio_buf & PAGE_MASK; - if ((dev->si_flags & SI_UNMAPPED) && unmapped_buf_allowed) { - if (cb->aio_nbytes > maxphys) { + job->error = 0; + atomic_store_int(&job->nbio, iovcnt); + for (i = 0; i < iovcnt; i++) { + struct vm_page** pages; + struct bio *bp; + void *buf; + size_t nbytes; + int npages; + + bp = g_alloc_bio(); + + if (vectored) { + buf = auiop->uio_iov[i].iov_base; + nbytes = auiop->uio_iov[i].iov_len; + } else { + buf = (void *)(uintptr_t)cb->aio_buf; + nbytes = cb->aio_nbytes; + } + if (nbytes > maxphys) { error = -1; goto unref; } + poff = (vm_offset_t)buf & PAGE_MASK; + if ((dev->si_flags & SI_UNMAPPED) && unmapped_buf_allowed) { + pbuf = NULL; + pages = malloc(sizeof(vm_page_t) * (atop(round_page( + nbytes)) + 1), M_TEMP, M_WAITOK | M_ZERO); + } else { + if (ki->kaio_buffer_count + iovcnt > max_buf_aio) { + error = EAGAIN; + goto unref; + } - pbuf = NULL; - job->pages = malloc(sizeof(vm_page_t) * (atop(round_page( - cb->aio_nbytes)) + 1), M_TEMP, M_WAITOK | M_ZERO); - } else { - if (cb->aio_nbytes > maxphys) { - error = -1; - goto unref; + pbuf = uma_zalloc(pbuf_zone, M_WAITOK); + BUF_KERNPROC(pbuf); + AIO_LOCK(ki); + ki->kaio_buffer_count++; + AIO_UNLOCK(ki); + pages = pbuf->b_pages; } - if (ki->kaio_buffer_count >= max_buf_aio) { - error = EAGAIN; + + bp->bio_length = nbytes; + bp->bio_bcount = nbytes; + bp->bio_done = aio_biowakeup; + bp->bio_offset = offset; + bp->bio_cmd = bio_cmd; + bp->bio_dev = dev; + bp->bio_caller1 = (void *)job; + bp->bio_caller2 = (void *)pbuf; + + prot = VM_PROT_READ; + if (cb->aio_lio_opcode == LIO_READ) + prot |= VM_PROT_WRITE; /* Less backwards than it looks */ + npages = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map, + (vm_offset_t)buf, bp->bio_length, prot, pages, + atop(maxphys) + 1); + if (npages < 0) { + if (pbuf != NULL) { + AIO_LOCK(ki); + ki->kaio_buffer_count--; + AIO_UNLOCK(ki); + uma_zfree(pbuf_zone, pbuf); + } else { + free(pages, M_TEMP); + } + g_destroy_bio(bp); + error = EFAULT; goto unref; } + if (pbuf != NULL) { + pmap_qenter((vm_offset_t)pbuf->b_data, pages, npages); + bp->bio_data = pbuf->b_data + poff; + atomic_add_int(&num_buf_aio, 1); + } else { + bp->bio_ma = pages; + bp->bio_ma_n = npages; + bp->bio_ma_offset = poff; + bp->bio_data = unmapped_buf; + bp->bio_flags |= BIO_UNMAPPED; + atomic_add_int(&num_unmapped_aio, 1); + } - job->pbuf = pbuf = uma_zalloc(pbuf_zone, M_WAITOK); - BUF_KERNPROC(pbuf); - AIO_LOCK(ki); - ki->kaio_buffer_count++; - AIO_UNLOCK(ki); - job->pages = pbuf->b_pages; - } - /* For LIO_WRITEV, create a parent bio with multiple child bios */ - job->bp = bp = g_alloc_bio(); + /* Perform transfer. */ + csw->d_strategy(bp); - bp->bio_length = cb->aio_nbytes; - bp->bio_bcount = cb->aio_nbytes; - bp->bio_done = aio_biowakeup; - bp->bio_offset = cb->aio_offset; - bp->bio_cmd = cb->aio_lio_opcode == LIO_WRITE ? BIO_WRITE : BIO_READ; - bp->bio_dev = dev; - bp->bio_caller1 = (void *)job; - - prot = VM_PROT_READ; - if (cb->aio_lio_opcode == LIO_READ) - prot |= VM_PROT_WRITE; /* Less backwards than it looks */ - job->npages = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map, - (vm_offset_t)cb->aio_buf, bp->bio_length, prot, job->pages, - atop(maxphys) + 1); - if (job->npages < 0) { - error = EFAULT; - goto doerror; + offset += nbytes; } - if (pbuf != NULL) { - pmap_qenter((vm_offset_t)pbuf->b_data, - job->pages, job->npages); - bp->bio_data = pbuf->b_data + poff; - atomic_add_int(&num_buf_aio, 1); - } else { - bp->bio_ma = job->pages; - bp->bio_ma_n = job->npages; - bp->bio_ma_offset = poff; - bp->bio_data = unmapped_buf; - bp->bio_flags |= BIO_UNMAPPED; - atomic_add_int(&num_unmapped_aio, 1); - } - - /* Perform transfer. */ - csw->d_strategy(bp); dev_relthread(dev, ref); + free(auiop, M_IOV); return (0); -doerror: - if (pbuf != NULL) { - AIO_LOCK(ki); - ki->kaio_buffer_count--; - AIO_UNLOCK(ki); - uma_zfree(pbuf_zone, pbuf); - job->pbuf = NULL; - } else { - free(job->pages, M_TEMP); - } - g_destroy_bio(bp); - job->bp = NULL; unref: dev_relthread(dev, ref); +free_uio: + free(auiop, M_IOV); return (error); } @@ -2367,44 +2407,48 @@ aio_biowakeup(struct bio *bp) { struct kaiocb *job = (struct kaiocb *)bp->bio_caller1; struct kaioinfo *ki; + struct buf *pbuf = (struct buf*)bp->bio_caller2;; size_t nbytes; int error, nblks; /* Release mapping into kernel space. */ - if (job->pbuf != NULL) { - pmap_qremove((vm_offset_t)job->pbuf->b_data, job->npages); - vm_page_unhold_pages(job->pages, job->npages); - uma_zfree(pbuf_zone, job->pbuf); - job->pbuf = NULL; + if (pbuf != NULL) { + pmap_qremove((vm_offset_t)pbuf->b_data, bp->bio_ma_n); + vm_page_unhold_pages(bp->bio_ma, bp->bio_ma_n); + uma_zfree(pbuf_zone, pbuf); atomic_subtract_int(&num_buf_aio, 1); ki = job->userproc->p_aioinfo; AIO_LOCK(ki); ki->kaio_buffer_count--; AIO_UNLOCK(ki); } else { - vm_page_unhold_pages(job->pages, job->npages); - free(job->pages, M_TEMP); + vm_page_unhold_pages(bp->bio_ma, bp->bio_ma_n); + free(bp->bio_ma, M_TEMP); atomic_subtract_int(&num_unmapped_aio, 1); } - bp = job->bp; - job->bp = NULL; - nbytes = job->uaiocb.aio_nbytes - bp->bio_resid; + nbytes = bp->bio_bcount - bp->bio_resid; + atomic_add_acq_long(&job->nbytes, nbytes); + nblks = btodb(nbytes); error = 0; + // If multiple bios experienced an error, the job will reflect the error + // of whichever failed bio completed last. if (bp->bio_flags & BIO_ERROR) - error = bp->bio_error; - nblks = btodb(nbytes); + atomic_set_int(&job->error, bp->bio_error); if (job->uaiocb.aio_lio_opcode == LIO_WRITE) - job->outblock += nblks; + atomic_add_int(&job->outblock, nblks); else - job->inblock += nblks; + atomic_add_int(&job->inblock, nblks); + atomic_subtract_int(&job->nbio, 1); - if (error) - aio_complete(job, -1, error); - else - aio_complete(job, nbytes, 0); - g_destroy_bio(bp); + + if (atomic_load_int(&job->nbio) == 0) { + if (atomic_load_int(&job->error)) + aio_complete(job, -1, job->error); + else + aio_complete(job, atomic_load_int(&job->nbytes), 0); + } } /* syscall - wait for the next completion of an aio request */ Modified: projects/aio_writev/sys/sys/aio.h ============================================================================== --- projects/aio_writev/sys/sys/aio.h Sun Dec 13 03:58:43 2020 (r368604) +++ projects/aio_writev/sys/sys/aio.h Sun Dec 13 05:34:14 2020 (r368605) @@ -146,10 +146,9 @@ struct kaiocb { aio_handle_fn_t *handle_fn; /* (c) backend handle function */ union { /* Backend-specific data fields */ struct { /* BIO backend */ - struct bio *bp; /* (*) BIO pointer */ - struct buf *pbuf; /* (*) buffer pointer */ - int npages; /* (*) number of pages */ - struct vm_page **pages; /* (*) */ + int nbio; /* Number of remaining bios */ + int error; /* Worst error of all bios */ + long nbytes; /* Bytes completed so far */ }; struct { /* fsync() requests */ int pending; /* (a) number of pending I/O */ From owner-svn-src-projects@freebsd.org Sun Dec 13 21:32:20 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D66E54C479A for ; Sun, 13 Dec 2020 21:32:20 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CvHmN5n2dz3CM6; Sun, 13 Dec 2020 21:32:20 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B9383168BB; Sun, 13 Dec 2020 21:32:20 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BDLWKAs011377; Sun, 13 Dec 2020 21:32:20 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0BDLWKPA011375; Sun, 13 Dec 2020 21:32:20 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202012132132.0BDLWKPA011375@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 13 Dec 2020 21:32:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r368618 - in projects/aio_writev: sys/kern tests/sys/aio X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/aio_writev: sys/kern tests/sys/aio X-SVN-Commit-Revision: 368618 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2020 21:32:20 -0000 Author: asomers Date: Sun Dec 13 21:32:20 2020 New Revision: 368618 URL: https://svnweb.freebsd.org/changeset/base/368618 Log: aio_writev: fall back to slow path if iovec is not sectorsize-aligned However, for most disk-like devices the I/O will eventually fail anyway. physio has the same constraints as aio_qbio. I think it might work for zols, though; I need to add a test for that. This commit also adds a few more test cases. This commit add some dtrace probes, too, though I might remove those later. Modified: projects/aio_writev/sys/kern/vfs_aio.c projects/aio_writev/tests/sys/aio/aio_test.c Modified: projects/aio_writev/sys/kern/vfs_aio.c ============================================================================== --- projects/aio_writev/sys/kern/vfs_aio.c Sun Dec 13 21:32:19 2020 (r368617) +++ projects/aio_writev/sys/kern/vfs_aio.c Sun Dec 13 21:32:20 2020 (r368618) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -74,6 +75,8 @@ __FBSDID("$FreeBSD$"); #include #include +SDT_PROVIDER_DEFINE(aio); + /* * Counter for allocating reference ids to new jobs. Wrapped to 1 on * overflow. (XXX will be removed soon.) @@ -1218,6 +1221,8 @@ aio_newproc(int *start) * structure's reference count, preventing its deallocation for the * duration of this call. */ +SDT_PROBE_DEFINE2(aio, aio, aio_qbio, entry, "struct proc*", "struct kaiocb*"); +SDT_PROBE_DEFINE2(aio, aio, aio_qbio, dev, "struct kaiocb*", "struct cdev*"); static int aio_qbio(struct proc *p, struct kaiocb *job) { @@ -1239,6 +1244,8 @@ aio_qbio(struct proc *p, struct kaiocb *job) fp = job->fd_file; opcode = cb->aio_lio_opcode; + SDT_PROBE2(aio, aio, aio_qbio, entry, p, job); + if (!(opcode == LIO_WRITE || opcode == LIO_WRITEV || opcode == LIO_READ)) @@ -1262,24 +1269,33 @@ aio_qbio(struct proc *p, struct kaiocb *job) error = copyinuio(cb->aio_iov, cb->aio_iovcnt, &auiop); if (error) return (error); + for (i = 0; i < iovcnt; i++) { + if (auiop->uio_iov[i].iov_len % vp->v_bufobj.bo_bsize) { + // TODO: are there any disk-like devices that + // would balk here but would work with + // aio_process_rw? I don't know of any. With + // md, at least, aio_process_rw calls physio, + // which has this same problem. + error = -1; + goto free_uio; + } + } nbytes = auiop->uio_resid; } else { nbytes = cb->aio_nbytes; + if (nbytes % vp->v_bufobj.bo_bsize) + return (-1); iovcnt = 1; } offset = cb->aio_offset; - if (nbytes % vp->v_bufobj.bo_bsize) { - error = -1; - goto free_uio; - } - ref = 0; csw = devvn_refthread(vp, &dev, &ref); if (csw == NULL) { error = ENXIO; goto free_uio; } + SDT_PROBE2(aio, aio, aio_qbio, dev, job, dev); if ((csw->d_flags & D_DISK) == 0) { error = -1; Modified: projects/aio_writev/tests/sys/aio/aio_test.c ============================================================================== --- projects/aio_writev/tests/sys/aio/aio_test.c Sun Dec 13 21:32:19 2020 (r368617) +++ projects/aio_writev/tests/sys/aio/aio_test.c Sun Dec 13 21:32:20 2020 (r368618) @@ -678,40 +678,11 @@ ATF_TC_BODY(pipe_waitcomplete, tc) #define MD_LEN GLOBAL_MAX #define MDUNIT_LINK "mdunit_link" -static void -aio_md_cleanup(void) +static int +aio_md_setup(void) { - struct md_ioctl mdio; - int mdctl_fd, error, n, unit; - char buf[80]; - - mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0); - ATF_REQUIRE(mdctl_fd >= 0); - n = readlink(MDUNIT_LINK, buf, sizeof(buf)); - if (n > 0) { - if (sscanf(buf, "%d", &unit) == 1 && unit >= 0) { - bzero(&mdio, sizeof(mdio)); - mdio.md_version = MDIOVERSION; - mdio.md_unit = unit; - if (ioctl(mdctl_fd, MDIOCDETACH, &mdio) == -1) { - error = errno; - close(mdctl_fd); - errno = error; - atf_tc_fail("ioctl MDIOCDETACH failed: %s", - strerror(errno)); - } - } - } - - close(mdctl_fd); -} - -static void -aio_md_test(completion comp, struct sigevent *sev, bool vectored) -{ int error, fd, mdctl_fd, unit; char pathname[PATH_MAX]; - struct aio_context ac; struct md_ioctl mdio; char buf[80]; @@ -743,7 +714,45 @@ aio_md_test(completion comp, struct sigevent *sev, boo fd = open(pathname, O_RDWR); ATF_REQUIRE_MSG(fd != -1, "opening %s failed: %s", pathname, strerror(errno)); + + return (fd); +} +static void +aio_md_cleanup(void) +{ + struct md_ioctl mdio; + int mdctl_fd, error, n, unit; + char buf[80]; + + mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0); + ATF_REQUIRE(mdctl_fd >= 0); + n = readlink(MDUNIT_LINK, buf, sizeof(buf)); + if (n > 0) { + if (sscanf(buf, "%d", &unit) == 1 && unit >= 0) { + bzero(&mdio, sizeof(mdio)); + mdio.md_version = MDIOVERSION; + mdio.md_unit = unit; + if (ioctl(mdctl_fd, MDIOCDETACH, &mdio) == -1) { + error = errno; + close(mdctl_fd); + errno = error; + atf_tc_fail("ioctl MDIOCDETACH failed: %s", + strerror(errno)); + } + } + } + + close(mdctl_fd); +} + +static void +aio_md_test(completion comp, struct sigevent *sev, bool vectored) +{ + struct aio_context ac; + int fd; + + fd = aio_md_setup(); aio_context_init(&ac, fd, fd, MD_LEN); if (vectored) aio_writev_test(&ac, comp, sev); @@ -1283,11 +1292,10 @@ ATF_TC_BODY(aio_writev_dos_iovcnt, tc) close(fd); } -ATF_TC_WITHOUT_HEAD(aio_writev_empty); -ATF_TC_BODY(aio_writev_empty, tc) +ATF_TC_WITHOUT_HEAD(aio_writev_empty_file_poll); +ATF_TC_BODY(aio_writev_empty_file_poll, tc) { struct aiocb aio; - const struct aiocb *const iocbs[] = {&aio}; int fd; ATF_REQUIRE_KERNEL_MODULE("aio"); @@ -1302,13 +1310,98 @@ ATF_TC_BODY(aio_writev_empty, tc) aio.aio_iovcnt = 0; ATF_REQUIRE_EQ(0, aio_writev(&aio)); + ATF_REQUIRE_EQ(0, suspend(&aio)); - ATF_REQUIRE_EQ(0, aio_suspend(iocbs, 1, NULL)); - ATF_REQUIRE_EQ(0, aio_return(&aio)); + close(fd); +} +ATF_TC_WITHOUT_HEAD(aio_writev_empty_file_signal); +ATF_TC_BODY(aio_writev_empty_file_signal, tc) +{ + struct aiocb aio; + int fd; + + ATF_REQUIRE_KERNEL_MODULE("aio"); + ATF_REQUIRE_UNSAFE_AIO(); + + fd = open("testfile", O_RDWR | O_CREAT, 0600); + ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); + + bzero(&aio, sizeof(aio)); + aio.aio_fildes = fd; + aio.aio_offset = 0; + aio.aio_iovcnt = 0; + aio.aio_sigevent = *setup_signal(); + + ATF_REQUIRE_EQ(0, aio_writev(&aio)); + ATF_REQUIRE_EQ(0, poll_signaled(&aio)); + close(fd); } +// aio_writev and aio_readv should still work even if the iovcnt is greater +// than the number of buffered AIO operations permitted per process. +ATF_TC_WITH_CLEANUP(vectored_big_iovcnt); +ATF_TC_HEAD(vectored_big_iovcnt, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Vectored AIO should still work even if the iovcnt is greater than " + "the number of buffered AIO operations permitted by the process"); + atf_tc_set_md_var(tc, "require.user", "root"); +} +ATF_TC_BODY(vectored_big_iovcnt, tc) +{ + struct aiocb aio; + struct iovec *iov; + ssize_t len, buflen; + char *buffer; + const char *oid = "vfs.aio.max_buf_aio"; + long seed; + int max_buf_aio; + int fd, i; + ssize_t sysctl_len = sizeof(max_buf_aio); + + ATF_REQUIRE_KERNEL_MODULE("aio"); + ATF_REQUIRE_UNSAFE_AIO(); + + if (sysctlbyname(oid, &max_buf_aio, &sysctl_len, NULL, 0) == -1) + atf_libc_error(errno, "Failed to read %s", oid); + + seed = random(); + buflen = 512 * (max_buf_aio + 1); + buffer = malloc(buflen); + aio_fill_buffer(buffer, buflen, seed); + iov = calloc(max_buf_aio + 1, sizeof(struct iovec)); + + fd = aio_md_setup(); + + bzero(&aio, sizeof(aio)); + aio.aio_fildes = fd; + aio.aio_offset = 0; + for (i = 0; i < max_buf_aio + 1; i++) { + iov[i].iov_base = &buffer[i * 512]; + iov[i].iov_len = 512; + } + aio.aio_iov = iov; + aio.aio_iovcnt = max_buf_aio + 1; + + if (aio_writev(&aio) < 0) + atf_tc_fail("aio_writev failed: %s", strerror(errno)); + + len = poll(&aio); + if (len < 0) + atf_tc_fail("aio failed: %s", strerror(errno)); + + if (len != buflen) + atf_tc_fail("aio short write (%jd)", (intmax_t)len); + // TODO: aio_readv + close(fd); +} +ATF_TC_CLEANUP(vectored_big_iovcnt, tc) +{ + aio_md_cleanup(); +} + ATF_TC_WITHOUT_HEAD(vectored_file_poll); ATF_TC_BODY(vectored_file_poll, tc) { @@ -1335,6 +1428,67 @@ ATF_TC_BODY(vectored_socket_poll, tc) aio_unix_socketpair_test(poll, NULL, true); } +// aio_writev and aio_readv should still work even if the iov contains elements +// that aren't a multiple of the device's sector size, and even if the total +// amount if I/O _is_ a multiple of the device's sector size. +ATF_TC_WITH_CLEANUP(vectored_unaligned); +ATF_TC_HEAD(vectored_unaligned, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Vectored AIO should still work even if the iov contains elements " + "that aren't a multiple of the sector size."); + atf_tc_set_md_var(tc, "require.user", "root"); +} +ATF_TC_BODY(vectored_unaligned, tc) +{ + struct aio_context ac; + struct aiocb aio; + struct iovec iov[3]; + ssize_t len, total_len; + int fd; + + ATF_REQUIRE_KERNEL_MODULE("aio"); + ATF_REQUIRE_UNSAFE_AIO(); + + fd = aio_md_setup(); + aio_context_init(&ac, fd, fd, FILE_LEN); + + /* Break the buffer into 3 parts: + * * A 4kB part, aligned to 4kB + * * Two other parts that add up to 4kB: + * - 256B + * - 4kB - 256B + */ + iov[0].iov_base = ac.ac_buffer; + iov[0].iov_len = 4096; + iov[1].iov_base = (void*)((uintptr_t)iov[0].iov_base + iov[0].iov_len); + iov[1].iov_len = 256; + iov[2].iov_base = (void*)((uintptr_t)iov[1].iov_base + iov[1].iov_len); + iov[2].iov_len = 4096 - iov[1].iov_len; + total_len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len; + bzero(&aio, sizeof(aio)); + aio.aio_fildes = ac.ac_write_fd; + aio.aio_offset = 0; + aio.aio_iov = iov; + aio.aio_iovcnt = 3; + + if (aio_writev(&aio) < 0) + atf_tc_fail("aio_writev failed: %s", strerror(errno)); + + len = poll(&aio); + if (len < 0) + atf_tc_fail("aio failed: %s", strerror(errno)); + + if (len != total_len) + atf_tc_fail("aio short write (%jd)", (intmax_t)len); + // TODO: aio_readv + close(fd); +} +ATF_TC_CLEANUP(vectored_unaligned, tc) +{ + aio_md_cleanup(); +} + ATF_TP_ADD_TCS(tp) { @@ -1376,13 +1530,12 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, aio_socket_short_write_cancel); ATF_TP_ADD_TC(tp, aio_writev_dos_iov_len); ATF_TP_ADD_TC(tp, aio_writev_dos_iovcnt); - ATF_TP_ADD_TC(tp, aio_writev_empty); + ATF_TP_ADD_TC(tp, aio_writev_empty_file_poll); + ATF_TP_ADD_TC(tp, aio_writev_empty_file_signal); + ATF_TP_ADD_TC(tp, vectored_big_iovcnt); ATF_TP_ADD_TC(tp, vectored_file_poll); - /* - * TODO: add a test for vectored I/O to a md, where the individual - * iovec elements are not sector-aligned - */ ATF_TP_ADD_TC(tp, vectored_md_poll); + ATF_TP_ADD_TC(tp, vectored_unaligned); ATF_TP_ADD_TC(tp, vectored_socket_poll); return (atf_no_error()); From owner-svn-src-projects@freebsd.org Sun Dec 13 23:32:51 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B08D4C792E for ; Sun, 13 Dec 2020 23:32:51 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CvLRR2C3wz3PXY; Sun, 13 Dec 2020 23:32:51 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3E9B517FD0; Sun, 13 Dec 2020 23:32:51 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BDNWp0P097441; Sun, 13 Dec 2020 23:32:51 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0BDNWpA6097440; Sun, 13 Dec 2020 23:32:51 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202012132332.0BDNWpA6097440@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 13 Dec 2020 23:32:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r368621 - projects/aio_writev/tests/sys/aio X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/aio_writev/tests/sys/aio X-SVN-Commit-Revision: 368621 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2020 23:32:51 -0000 Author: asomers Date: Sun Dec 13 23:32:50 2020 New Revision: 368621 URL: https://svnweb.freebsd.org/changeset/base/368621 Log: aio_writev: fix the vector_unaligned test It turns out that a zvol with volmode=dev has the correct properties for this test. While I'm here, add a vectored_zvol_poll test to test the bio path with a non-geom device. Modified: projects/aio_writev/tests/sys/aio/aio_test.c Modified: projects/aio_writev/tests/sys/aio/aio_test.c ============================================================================== --- projects/aio_writev/tests/sys/aio/aio_test.c Sun Dec 13 22:42:48 2020 (r368620) +++ projects/aio_writev/tests/sys/aio/aio_test.c Sun Dec 13 23:32:50 2020 (r368621) @@ -838,6 +838,53 @@ ATF_TC_CLEANUP(md_waitcomplete, tc) aio_md_cleanup(); } +#define ZVOL_VDEV_PATHNAME "test_vdev" +#define POOL_SIZE (1 << 28) /* 256 MB */ +#define ZVOL_SIZE "64m" +#define POOL_NAME "aio_testpool" +#define ZVOL_NAME "aio_testvol" + +static int +aio_zvol_setup(void) +{ + int fd; + + ATF_REQUIRE_KERNEL_MODULE("aio"); + ATF_REQUIRE_KERNEL_MODULE("zfs"); + + fd = open(ZVOL_VDEV_PATHNAME, O_RDWR | O_CREAT, 0600); + ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); + ATF_REQUIRE_EQ_MSG(0, + ftruncate(fd, POOL_SIZE), "ftruncate failed: %s", strerror(errno)); + close(fd); + + ATF_REQUIRE_EQ_MSG(0, + system("zpool create " POOL_NAME " $PWD/" ZVOL_VDEV_PATHNAME), + "zpool create failed: %s", strerror(errno)); + ATF_REQUIRE_EQ_MSG(0, + system("zfs create -o volblocksize=8192 -o volmode=dev -V " + ZVOL_SIZE " " POOL_NAME "/" ZVOL_NAME), + "zfs create failed: %s", strerror(errno)); + /* + * XXX Due to bug 251828, we need an extra "zfs set here" + * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251828 + */ + ATF_REQUIRE_EQ_MSG(0, + system("zfs set volmode=dev " POOL_NAME "/" ZVOL_NAME), + "zfs set failed: %s", strerror(errno)); + + fd = open("/dev/zvol/" POOL_NAME "/" ZVOL_NAME, O_RDWR); + ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); + return (fd); +} + +static void +aio_zvol_cleanup(void) +{ + system("zpool destroy " POOL_NAME); +} + + ATF_TC_WITHOUT_HEAD(aio_large_read_test); ATF_TC_BODY(aio_large_read_test, tc) { @@ -1450,7 +1497,11 @@ ATF_TC_BODY(vectored_unaligned, tc) ATF_REQUIRE_KERNEL_MODULE("aio"); ATF_REQUIRE_UNSAFE_AIO(); - fd = aio_md_setup(); + /* + * Use a zvol with volmode=dev, so it will allow .d_write with + * unaligned uio. geom devices use physio, which doesn't allow that. + */ + fd = aio_zvol_setup(); aio_context_init(&ac, fd, fd, FILE_LEN); /* Break the buffer into 3 parts: @@ -1486,9 +1537,44 @@ ATF_TC_BODY(vectored_unaligned, tc) } ATF_TC_CLEANUP(vectored_unaligned, tc) { - aio_md_cleanup(); + aio_zvol_cleanup(); } +static void +aio_zvol_test(completion comp, struct sigevent *sev, bool vectored) +{ + struct aio_context ac; + int fd; + + fd = aio_zvol_setup(); + aio_context_init(&ac, fd, fd, MD_LEN); + if (vectored) + aio_writev_test(&ac, comp, sev); + else + aio_write_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); + + close(fd); +} + +/* + * Note that unlike md, the zvol is not a geom device, does not allow unmapped + * buffers, and does not use physio. + */ +ATF_TC_WITH_CLEANUP(vectored_zvol_poll); +ATF_TC_HEAD(vectored_zvol_poll, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} +ATF_TC_BODY(vectored_zvol_poll, tc) +{ + aio_zvol_test(poll, NULL, true); +} +ATF_TC_CLEANUP(vectored_zvol_poll, tc) +{ + aio_zvol_cleanup(); +} + ATF_TP_ADD_TCS(tp) { @@ -1535,6 +1621,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, vectored_big_iovcnt); ATF_TP_ADD_TC(tp, vectored_file_poll); ATF_TP_ADD_TC(tp, vectored_md_poll); + ATF_TP_ADD_TC(tp, vectored_zvol_poll); ATF_TP_ADD_TC(tp, vectored_unaligned); ATF_TP_ADD_TC(tp, vectored_socket_poll); From owner-svn-src-projects@freebsd.org Mon Dec 14 04:52:22 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D2ACE4ADA6A for ; Mon, 14 Dec 2020 04:52:22 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CvTX65HwVz3vWw; Mon, 14 Dec 2020 04:52:22 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A891E1C400; Mon, 14 Dec 2020 04:52:22 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BE4qMxO096949; Mon, 14 Dec 2020 04:52:22 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0BE4qILC096928; Mon, 14 Dec 2020 04:52:18 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202012140452.0BE4qILC096928@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 14 Dec 2020 04:52:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r368627 - in projects/aio_writev: lib/libc/sys sys/bsm sys/compat/freebsd32 sys/kern sys/sys tests/sys/aio X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/aio_writev: lib/libc/sys sys/bsm sys/compat/freebsd32 sys/kern sys/sys tests/sys/aio X-SVN-Commit-Revision: 368627 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Dec 2020 04:52:22 -0000 Author: asomers Date: Mon Dec 14 04:52:17 2020 New Revision: 368627 URL: https://svnweb.freebsd.org/changeset/base/368627 Log: Add aio_readv Like aio_writev, it doesn't yet work for sockets, nor work with lio_listio. Modified: projects/aio_writev/lib/libc/sys/Makefile.inc projects/aio_writev/lib/libc/sys/Symbol.map projects/aio_writev/lib/libc/sys/aio_read.2 projects/aio_writev/sys/bsm/audit_kevents.h projects/aio_writev/sys/compat/freebsd32/freebsd32_proto.h projects/aio_writev/sys/compat/freebsd32/freebsd32_syscall.h projects/aio_writev/sys/compat/freebsd32/freebsd32_syscalls.c projects/aio_writev/sys/compat/freebsd32/freebsd32_sysent.c projects/aio_writev/sys/compat/freebsd32/freebsd32_systrace_args.c projects/aio_writev/sys/compat/freebsd32/syscalls.master projects/aio_writev/sys/kern/capabilities.conf projects/aio_writev/sys/kern/init_sysent.c projects/aio_writev/sys/kern/syscalls.c projects/aio_writev/sys/kern/syscalls.master projects/aio_writev/sys/kern/systrace_args.c projects/aio_writev/sys/kern/vfs_aio.c projects/aio_writev/sys/sys/aio.h projects/aio_writev/sys/sys/syscall.h projects/aio_writev/sys/sys/syscall.mk projects/aio_writev/sys/sys/sysproto.h projects/aio_writev/tests/sys/aio/aio_test.c Modified: projects/aio_writev/lib/libc/sys/Makefile.inc ============================================================================== --- projects/aio_writev/lib/libc/sys/Makefile.inc Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/lib/libc/sys/Makefile.inc Mon Dec 14 04:52:17 2020 (r368627) @@ -353,6 +353,7 @@ MAN+= sctp_generic_recvmsg.2 \ write.2 \ _umtx_op.2 +MLINKS+=aio_read.2 aio_readv.2 MLINKS+=aio_write.2 aio_writev.2 MLINKS+=accept.2 accept4.2 MLINKS+=access.2 eaccess.2 \ Modified: projects/aio_writev/lib/libc/sys/Symbol.map ============================================================================== --- projects/aio_writev/lib/libc/sys/Symbol.map Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/lib/libc/sys/Symbol.map Mon Dec 14 04:52:17 2020 (r368627) @@ -414,6 +414,7 @@ FBSD_1.6 { shm_create_largepage; shm_rename; aio_writev; + aio_readv; }; FBSDprivate_1.0 { Modified: projects/aio_writev/lib/libc/sys/aio_read.2 ============================================================================== --- projects/aio_writev/lib/libc/sys/aio_read.2 Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/lib/libc/sys/aio_read.2 Mon Dec 14 04:52:17 2020 (r368627) @@ -24,11 +24,12 @@ .\" .\" $FreeBSD$ .\" -.Dd August 19, 2016 +.Dd December 13, 2020 .Dt AIO_READ 2 .Os .Sh NAME -.Nm aio_read +.Nm aio_read , +.Nm aio_readv .Nd asynchronous read from a file (REALTIME) .Sh LIBRARY .Lb libc @@ -36,18 +37,31 @@ .In aio.h .Ft int .Fn aio_read "struct aiocb *iocb" +.Ft int +.Fn aio_readv "struct aiocb *iocb" .Sh DESCRIPTION The .Fn aio_read -system call allows the calling process to read -.Fa iocb->aio_nbytes +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_offset -into the buffer pointed to by -.Fa iocb->aio_buf . -The call returns immediately after the read request has +.Fa iocb->aio_offset . +.Fn aio_read +will read +.Fa iocb->aio_nbytes +from the buffer pointed to by +.Fa iocb->aio_buf , +whereas +.Fn aio_readv +reads the data into the +.Fa iocb->aio_iovcnt +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 @@ -61,7 +75,9 @@ The argument is ignored by the .Fn aio_read -system call. +and +.Fn aio_readv +system calls. .Pp The .Fa iocb @@ -108,13 +124,15 @@ is past the offset maximum for .Fa iocb->aio_fildes , no I/O will occur. .Sh RETURN VALUES -.Rv -std aio_read +.Rv -std aio_read aio_readv .Sh DIAGNOSTICS None. .Sh ERRORS The .Fn aio_read -system call will fail if: +and +.Fn aio_readv +system calls will fail if: .Bl -tag -width Er .It Bq Er EAGAIN The request was not queued because of system resource limitations. @@ -130,10 +148,14 @@ are unsafe and unsafe asynchronous I/O operations are .Pp The following conditions may be synchronously detected when the .Fn aio_read +or +.Fn aio_readv 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 .Va errno appropriately; otherwise the @@ -207,11 +229,18 @@ The system call is expected to conform to the .St -p1003.1 standard. +The +.Fn aio_readv +system call is a FreeBSD extension, and should not be used in portable code. .Sh HISTORY The .Fn aio_read system call first appeared in .Fx 3.0 . +The +.Fn aio_readv +system call first appeared in +.Fx 13.0 . .Sh AUTHORS This manual page was written by Modified: projects/aio_writev/sys/bsm/audit_kevents.h ============================================================================== --- projects/aio_writev/sys/bsm/audit_kevents.h Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/bsm/audit_kevents.h Mon Dec 14 04:52:17 2020 (r368627) @@ -660,6 +660,7 @@ #define AUE_REALPATHAT 43264 /* FreeBSD-specific. */ #define AUE_CLOSERANGE 43265 /* FreeBSD-specific. */ #define AUE_AIO_WRITEV 43266 /* FreeBSD-specific. */ +#define AUE_AIO_READV 43267 /* FreeBSD-specific. */ /* * Darwin BSM uses a number of AUE_O_* definitions, which are aliased to the Modified: projects/aio_writev/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- projects/aio_writev/sys/compat/freebsd32/freebsd32_proto.h Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/compat/freebsd32/freebsd32_proto.h Mon Dec 14 04:52:17 2020 (r368627) @@ -254,6 +254,9 @@ struct freebsd32_lio_listio_args { struct freebsd32_aio_writev_args { char aiocbp_l_[PADL_(struct aiocb32 *)]; struct aiocb32 * aiocbp; char aiocbp_r_[PADR_(struct aiocb32 *)]; }; +struct freebsd32_aio_readv_args { + char aiocbp_l_[PADL_(struct aiocb32 *)]; struct aiocb32 * aiocbp; char aiocbp_r_[PADR_(struct aiocb32 *)]; +}; struct freebsd32_lutimes_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; char tptr_l_[PADL_(struct timeval32 *)]; struct timeval32 * tptr; char tptr_r_[PADR_(struct timeval32 *)]; @@ -793,6 +796,7 @@ int freebsd32_aio_read(struct thread *, struct freebsd int freebsd32_aio_write(struct thread *, struct freebsd32_aio_write_args *); int freebsd32_lio_listio(struct thread *, struct freebsd32_lio_listio_args *); int freebsd32_aio_writev(struct thread *, struct freebsd32_aio_writev_args *); +int freebsd32_aio_readv(struct thread *, struct freebsd32_aio_readv_args *); int freebsd32_lutimes(struct thread *, struct freebsd32_lutimes_args *); int freebsd32_preadv(struct thread *, struct freebsd32_preadv_args *); int freebsd32_pwritev(struct thread *, struct freebsd32_pwritev_args *); @@ -1379,6 +1383,7 @@ int freebsd11_freebsd32_fstatat(struct thread *, struc #define FREEBSD32_SYS_AUE_freebsd32_aio_write AUE_AIO_WRITE #define FREEBSD32_SYS_AUE_freebsd32_lio_listio AUE_LIO_LISTIO #define FREEBSD32_SYS_AUE_freebsd32_aio_writev AUE_AIO_WRITEV +#define FREEBSD32_SYS_AUE_freebsd32_aio_readv AUE_AIO_READV #define FREEBSD32_SYS_AUE_freebsd11_freebsd32_getdents AUE_O_GETDENTS #define FREEBSD32_SYS_AUE_freebsd32_lutimes AUE_LUTIMES #define FREEBSD32_SYS_AUE_freebsd32_preadv AUE_PREADV Modified: projects/aio_writev/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- projects/aio_writev/sys/compat/freebsd32/freebsd32_syscall.h Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/compat/freebsd32/freebsd32_syscall.h Mon Dec 14 04:52:17 2020 (r368627) @@ -230,6 +230,7 @@ #define FREEBSD32_SYS_freebsd32_aio_write 256 #define FREEBSD32_SYS_freebsd32_lio_listio 257 #define FREEBSD32_SYS_freebsd32_aio_writev 258 +#define FREEBSD32_SYS_freebsd32_aio_readv 259 #define FREEBSD32_SYS_freebsd11_freebsd32_getdents 272 #define FREEBSD32_SYS_lchmod 274 /* 275 is obsolete netbsd_lchown */ Modified: projects/aio_writev/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- projects/aio_writev/sys/compat/freebsd32/freebsd32_syscalls.c Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/compat/freebsd32/freebsd32_syscalls.c Mon Dec 14 04:52:17 2020 (r368627) @@ -268,7 +268,7 @@ const char *freebsd32_syscallnames[] = { "freebsd32_aio_write", /* 256 = freebsd32_aio_write */ "freebsd32_lio_listio", /* 257 = freebsd32_lio_listio */ "freebsd32_aio_writev", /* 258 = freebsd32_aio_writev */ - "#259", /* 259 = nosys */ + "freebsd32_aio_readv", /* 259 = freebsd32_aio_readv */ "#260", /* 260 = nosys */ "#261", /* 261 = nosys */ "#262", /* 262 = nosys */ Modified: projects/aio_writev/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- projects/aio_writev/sys/compat/freebsd32/freebsd32_sysent.c Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/compat/freebsd32/freebsd32_sysent.c Mon Dec 14 04:52:17 2020 (r368627) @@ -320,8 +320,8 @@ struct sysent freebsd32_sysent[] = { { .sy_narg = AS(freebsd32_aio_read_args), .sy_call = (sy_call_t *)freebsd32_aio_read, .sy_auevent = AUE_AIO_READ, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 255 = freebsd32_aio_read */ { .sy_narg = AS(freebsd32_aio_write_args), .sy_call = (sy_call_t *)freebsd32_aio_write, .sy_auevent = AUE_AIO_WRITE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 256 = freebsd32_aio_write */ { .sy_narg = AS(freebsd32_lio_listio_args), .sy_call = (sy_call_t *)freebsd32_lio_listio, .sy_auevent = AUE_LIO_LISTIO, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 257 = freebsd32_lio_listio */ - { .sy_narg = AS(freebsd32_aio_writev_args), .sy_call = (sy_call_t *)freebsd32_aio_writev, .sy_auevent = AUE_AIO_WRITEV, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 258 = freebsd32_aio_writev */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 259 = nosys */ + { .sy_narg = AS(freebsd32_aio_writev_args), .sy_call = (sy_call_t *)freebsd32_aio_writev, .sy_auevent = AUE_AIO_WRITEV, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 258 = freebsd32_aio_writev */ + { .sy_narg = AS(freebsd32_aio_readv_args), .sy_call = (sy_call_t *)freebsd32_aio_readv, .sy_auevent = AUE_AIO_READV, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 259 = freebsd32_aio_readv */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 260 = nosys */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 261 = nosys */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 262 = nosys */ Modified: projects/aio_writev/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- projects/aio_writev/sys/compat/freebsd32/freebsd32_systrace_args.c Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/compat/freebsd32/freebsd32_systrace_args.c Mon Dec 14 04:52:17 2020 (r368627) @@ -1291,6 +1291,13 @@ systrace_args(int sysnum, void *params, uint64_t *uarg *n_args = 1; break; } + /* freebsd32_aio_readv */ + case 259: { + struct freebsd32_aio_readv_args *p = params; + uarg[0] = (intptr_t) p->aiocbp; /* struct aiocb32 * */ + *n_args = 1; + break; + } /* lchmod */ case 274: { struct lchmod_args *p = params; @@ -5428,6 +5435,16 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; }; break; + /* freebsd32_aio_readv */ + case 259: + switch(ndx) { + case 0: + p = "userland struct aiocb32 *"; + break; + default: + break; + }; + break; /* lchmod */ case 274: switch(ndx) { @@ -9887,6 +9904,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* freebsd32_aio_writev */ case 258: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* freebsd32_aio_readv */ + case 259: if (ndx == 0 || ndx == 1) p = "int"; break; Modified: projects/aio_writev/sys/compat/freebsd32/syscalls.master ============================================================================== --- projects/aio_writev/sys/compat/freebsd32/syscalls.master Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/compat/freebsd32/syscalls.master Mon Dec 14 04:52:17 2020 (r368627) @@ -495,7 +495,8 @@ int nent, struct sigevent32 *sig); } 258 AUE_AIO_WRITEV STD { int freebsd32_aio_writev( \ struct aiocb32 *aiocbp); } -259 AUE_NULL UNIMPL nosys +259 AUE_AIO_READV STD { int freebsd32_aio_readv( \ + struct aiocb32 *aiocbp); } 260 AUE_NULL UNIMPL nosys 261 AUE_NULL UNIMPL nosys 262 AUE_NULL UNIMPL nosys Modified: projects/aio_writev/sys/kern/capabilities.conf ============================================================================== --- projects/aio_writev/sys/kern/capabilities.conf Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/kern/capabilities.conf Mon Dec 14 04:52:17 2020 (r368627) @@ -96,6 +96,7 @@ aio_suspend aio_waitcomplete aio_write aio_writev +aio_readv ## ## audit(2) is a global operation, submitting to the global trail, but it is Modified: projects/aio_writev/sys/kern/init_sysent.c ============================================================================== --- projects/aio_writev/sys/kern/init_sysent.c Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/kern/init_sysent.c Mon Dec 14 04:52:17 2020 (r368627) @@ -313,8 +313,8 @@ struct sysent sysent[] = { { .sy_narg = AS(aio_read_args), .sy_call = (sy_call_t *)sys_aio_read, .sy_auevent = AUE_AIO_READ, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 255 = aio_read */ { .sy_narg = AS(aio_write_args), .sy_call = (sy_call_t *)sys_aio_write, .sy_auevent = AUE_AIO_WRITE, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 256 = aio_write */ { .sy_narg = AS(lio_listio_args), .sy_call = (sy_call_t *)sys_lio_listio, .sy_auevent = AUE_LIO_LISTIO, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 257 = lio_listio */ - { .sy_narg = AS(aio_writev_args), .sy_call = (sy_call_t *)sys_aio_writev, .sy_auevent = AUE_AIO_WRITEV, .sy_flags = 0, .sy_thrcnt = SY_THR_STATIC }, /* 258 = aio_writev */ - { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 259 = nosys */ + { .sy_narg = AS(aio_writev_args), .sy_call = (sy_call_t *)sys_aio_writev, .sy_auevent = AUE_AIO_WRITEV, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 258 = aio_writev */ + { .sy_narg = AS(aio_readv_args), .sy_call = (sy_call_t *)sys_aio_readv, .sy_auevent = AUE_AIO_READV, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 259 = aio_readv */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 260 = nosys */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 261 = nosys */ { .sy_narg = 0, .sy_call = (sy_call_t *)nosys, .sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT }, /* 262 = nosys */ Modified: projects/aio_writev/sys/kern/syscalls.c ============================================================================== --- projects/aio_writev/sys/kern/syscalls.c Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/kern/syscalls.c Mon Dec 14 04:52:17 2020 (r368627) @@ -265,7 +265,7 @@ const char *syscallnames[] = { "aio_write", /* 256 = aio_write */ "lio_listio", /* 257 = lio_listio */ "aio_writev", /* 258 = aio_writev */ - "#259", /* 259 = nosys */ + "aio_readv", /* 259 = aio_readv */ "#260", /* 260 = nosys */ "#261", /* 261 = nosys */ "#262", /* 262 = nosys */ Modified: projects/aio_writev/sys/kern/syscalls.master ============================================================================== --- projects/aio_writev/sys/kern/syscalls.master Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/kern/syscalls.master Mon Dec 14 04:52:17 2020 (r368627) @@ -1482,7 +1482,12 @@ _Inout_ struct aiocb *aiocbp ); } -259-271 AUE_NULL UNIMPL nosys +259 AUE_AIO_READV STD { + int aio_readv( + _Inout_ struct aiocb *aiocbp + ); + } +260-271 AUE_NULL UNIMPL nosys 272 AUE_O_GETDENTS COMPAT11 { int getdents( int fd, Modified: projects/aio_writev/sys/kern/systrace_args.c ============================================================================== --- projects/aio_writev/sys/kern/systrace_args.c Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/kern/systrace_args.c Mon Dec 14 04:52:17 2020 (r368627) @@ -1327,6 +1327,13 @@ systrace_args(int sysnum, void *params, uint64_t *uarg *n_args = 1; break; } + /* aio_readv */ + case 259: { + struct aio_readv_args *p = params; + uarg[0] = (intptr_t) p->aiocbp; /* struct aiocb * */ + *n_args = 1; + break; + } /* lchmod */ case 274: { struct lchmod_args *p = params; @@ -5479,6 +5486,16 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; }; break; + /* aio_readv */ + case 259: + switch(ndx) { + case 0: + p = "userland struct aiocb *"; + break; + default: + break; + }; + break; /* lchmod */ case 274: switch(ndx) { @@ -9814,6 +9831,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* aio_writev */ case 258: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* aio_readv */ + case 259: if (ndx == 0 || ndx == 1) p = "int"; break; Modified: projects/aio_writev/sys/kern/vfs_aio.c ============================================================================== --- projects/aio_writev/sys/kern/vfs_aio.c Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/kern/vfs_aio.c Mon Dec 14 04:52:17 2020 (r368627) @@ -765,9 +765,11 @@ aio_process_rw(struct kaiocb *job) long msgrcv_st, msgrcv_end; long oublock_st, oublock_end; long inblock_st, inblock_end; - int error; + int error, opcode; + bool vectored; KASSERT(job->uaiocb.aio_lio_opcode == LIO_READ || + job->uaiocb.aio_lio_opcode == LIO_READV || job->uaiocb.aio_lio_opcode == LIO_WRITE || job->uaiocb.aio_lio_opcode == LIO_WRITEV, ("%s: opcode %d", __func__, job->uaiocb.aio_lio_opcode)); @@ -779,7 +781,9 @@ aio_process_rw(struct kaiocb *job) cb = &job->uaiocb; fp = job->fd_file; - if (job->uaiocb.aio_lio_opcode == LIO_WRITEV) { + opcode = job->uaiocb.aio_lio_opcode; + vectored = opcode == LIO_WRITEV || opcode == LIO_READV; + if (vectored) { error = copyinuio(job->uaiocb.aio_iov, job->uaiocb.aio_iovcnt, &auiop); if (error) @@ -807,7 +811,7 @@ aio_process_rw(struct kaiocb *job) * aio_aqueue() acquires a reference to the file that is * released in aio_free_entry(). */ - if (cb->aio_lio_opcode == LIO_READ) { + if (opcode == LIO_READ || opcode == LIO_READV) { auiop->uio_rw = UIO_READ; if (auiop->uio_resid == 0) error = 0; @@ -832,7 +836,9 @@ aio_process_rw(struct kaiocb *job) if ((error) && (auiop->uio_resid != cnt)) { if (error == ERESTART || error == EINTR || error == EWOULDBLOCK) error = 0; - if ((error == EPIPE) && (cb->aio_lio_opcode == LIO_WRITE)) { + if ((error == EPIPE) && + (opcode == LIO_WRITE || opcode == LIO_WRITEV)) + { PROC_LOCK(job->userproc); kern_psignal(job->userproc, SIGPIPE); PROC_UNLOCK(job->userproc); @@ -840,7 +846,7 @@ aio_process_rw(struct kaiocb *job) } cnt -= auiop->uio_resid; - if (job->uaiocb.aio_lio_opcode == LIO_WRITEV) + if (vectored) free(auiop, M_IOV); out: td->td_ucred = td_savedcred; @@ -1248,7 +1254,8 @@ aio_qbio(struct proc *p, struct kaiocb *job) if (!(opcode == LIO_WRITE || opcode == LIO_WRITEV || - opcode == LIO_READ)) + opcode == LIO_READ || + opcode == LIO_READV)) return (-1); if (fp == NULL || fp->f_type != DTYPE_VNODE) return (-1); @@ -1261,7 +1268,7 @@ aio_qbio(struct proc *p, struct kaiocb *job) bio_cmd = opcode == LIO_WRITE || opcode == LIO_WRITEV ? BIO_WRITE : BIO_READ; - vectored = opcode == LIO_WRITEV; + vectored = opcode == LIO_WRITEV || opcode == LIO_READV; if (vectored) { iovcnt = cb->aio_iovcnt; if (iovcnt > max_buf_aio) @@ -1271,11 +1278,6 @@ aio_qbio(struct proc *p, struct kaiocb *job) return (error); for (i = 0; i < iovcnt; i++) { if (auiop->uio_iov[i].iov_len % vp->v_bufobj.bo_bsize) { - // TODO: are there any disk-like devices that - // would balk here but would work with - // aio_process_rw? I don't know of any. With - // md, at least, aio_process_rw calls physio, - // which has this same problem. error = -1; goto free_uio; } @@ -1358,7 +1360,7 @@ aio_qbio(struct proc *p, struct kaiocb *job) bp->bio_caller2 = (void *)pbuf; prot = VM_PROT_READ; - if (cb->aio_lio_opcode == LIO_READ) + if (opcode == LIO_READ || opcode == LIO_READV) prot |= VM_PROT_WRITE; /* Less backwards than it looks */ npages = vm_fault_quick_hold_pages(&curproc->p_vmspace->vm_map, (vm_offset_t)buf, bp->bio_length, prot, pages, @@ -1608,6 +1610,7 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, stru error = fget_write(td, fd, &cap_pwrite_rights, &fp); break; case LIO_READ: + case LIO_READV: error = fget_read(td, fd, &cap_pread_rights, &fp); break; case LIO_SYNC: @@ -1633,7 +1636,8 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, stru goto aqueue_fail; } - if ((opcode == LIO_READ || opcode == LIO_WRITE || opcode == LIO_WRITEV) + if ((opcode == LIO_READ || opcode == LIO_READV + || opcode == LIO_WRITE || opcode == LIO_WRITEV) && job->uaiocb.aio_offset < 0 && (fp->f_vnode == NULL || fp->f_vnode->v_type != VCHR)) { error = EINVAL; @@ -1691,7 +1695,7 @@ no_kqueue: error = 0; } else if (fp->f_ops->fo_aio_queue == NULL) error = aio_queue_file(fp, job); - else if (opcode == LIO_WRITEV) + else if (opcode == LIO_WRITEV || opcode == LIO_READV) error = EOPNOTSUPP; else error = fo_aio_queue(fp, job); @@ -1797,6 +1801,7 @@ aio_queue_file(struct file *fp, struct kaiocb *job) switch (job->uaiocb.aio_lio_opcode) { case LIO_READ: + case LIO_READV: case LIO_WRITE: case LIO_WRITEV: aio_schedule(job, aio_process_rw); @@ -2172,6 +2177,13 @@ sys_aio_read(struct thread *td, struct aio_read_args * return (aio_aqueue(td, uap->aiocbp, NULL, LIO_READ, &aiocb_ops)); } +int +sys_aio_readv(struct thread *td, struct aio_readv_args *uap) +{ + + return (aio_aqueue(td, uap->aiocbp, NULL, LIO_READV, &aiocb_ops)); +} + /* syscall - asynchronous write to a file (REALTIME) */ #ifdef COMPAT_FREEBSD6 int @@ -2425,8 +2437,10 @@ aio_biowakeup(struct bio *bp) struct kaioinfo *ki; struct buf *pbuf = (struct buf*)bp->bio_caller2;; size_t nbytes; - int error, nblks; + int error, opcode, nblks; + opcode = job->uaiocb.aio_lio_opcode; + /* Release mapping into kernel space. */ if (pbuf != NULL) { pmap_qremove((vm_offset_t)pbuf->b_data, bp->bio_ma_n); @@ -2451,7 +2465,7 @@ aio_biowakeup(struct bio *bp) // of whichever failed bio completed last. if (bp->bio_flags & BIO_ERROR) atomic_set_int(&job->error, bp->bio_error); - if (job->uaiocb.aio_lio_opcode == LIO_WRITE) + if (opcode == LIO_WRITE || opcode == LIO_WRITEV) atomic_add_int(&job->outblock, nblks); else atomic_add_int(&job->inblock, nblks); @@ -2923,6 +2937,14 @@ freebsd32_aio_read(struct thread *td, struct freebsd32 { return (aio_aqueue(td, (struct aiocb *)uap->aiocbp, NULL, LIO_READ, + &aiocb32_ops)); +} + +int +freebsd32_aio_readv(struct thread *td, struct freebsd32_aio_readv_args *uap) +{ + + return (aio_aqueue(td, (struct aiocb *)uap->aiocbp, NULL, LIO_READV, &aiocb32_ops)); } Modified: projects/aio_writev/sys/sys/aio.h ============================================================================== --- projects/aio_writev/sys/sys/aio.h Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/sys/aio.h Mon Dec 14 04:52:17 2020 (r368627) @@ -216,6 +216,7 @@ __BEGIN_DECLS * Asynchronously read from a file */ int aio_read(struct aiocb *); +int aio_readv(struct aiocb *); /* * Asynchronously write to file Modified: projects/aio_writev/sys/sys/syscall.h ============================================================================== --- projects/aio_writev/sys/sys/syscall.h Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/sys/syscall.h Mon Dec 14 04:52:17 2020 (r368627) @@ -235,6 +235,7 @@ #define SYS_aio_write 256 #define SYS_lio_listio 257 #define SYS_aio_writev 258 +#define SYS_aio_readv 259 #define SYS_freebsd11_getdents 272 #define SYS_lchmod 274 /* 275 is obsolete netbsd_lchown */ Modified: projects/aio_writev/sys/sys/syscall.mk ============================================================================== --- projects/aio_writev/sys/sys/syscall.mk Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/sys/syscall.mk Mon Dec 14 04:52:17 2020 (r368627) @@ -169,6 +169,7 @@ MIASM = \ aio_write.o \ lio_listio.o \ aio_writev.o \ + aio_readv.o \ freebsd11_getdents.o \ lchmod.o \ lutimes.o \ Modified: projects/aio_writev/sys/sys/sysproto.h ============================================================================== --- projects/aio_writev/sys/sys/sysproto.h Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/sys/sys/sysproto.h Mon Dec 14 04:52:17 2020 (r368627) @@ -717,6 +717,9 @@ struct lio_listio_args { struct aio_writev_args { char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)]; }; +struct aio_readv_args { + char aiocbp_l_[PADL_(struct aiocb *)]; struct aiocb * aiocbp; char aiocbp_r_[PADR_(struct aiocb *)]; +}; struct lchmod_args { char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; char mode_l_[PADL_(mode_t)]; mode_t mode; char mode_r_[PADR_(mode_t)]; @@ -1995,6 +1998,7 @@ int sys_aio_read(struct thread *, struct aio_read_args int sys_aio_write(struct thread *, struct aio_write_args *); int sys_lio_listio(struct thread *, struct lio_listio_args *); int sys_aio_writev(struct thread *, struct aio_writev_args *); +int sys_aio_readv(struct thread *, struct aio_readv_args *); int sys_lchmod(struct thread *, struct lchmod_args *); int sys_lutimes(struct thread *, struct lutimes_args *); int sys_preadv(struct thread *, struct preadv_args *); @@ -2906,6 +2910,7 @@ int freebsd12_closefrom(struct thread *, struct freebs #define SYS_AUE_aio_write AUE_AIO_WRITE #define SYS_AUE_lio_listio AUE_LIO_LISTIO #define SYS_AUE_aio_writev AUE_AIO_WRITEV +#define SYS_AUE_aio_readv AUE_AIO_READV #define SYS_AUE_freebsd11_getdents AUE_O_GETDENTS #define SYS_AUE_lchmod AUE_LCHMOD #define SYS_AUE_lutimes AUE_LUTIMES Modified: projects/aio_writev/tests/sys/aio/aio_test.c ============================================================================== --- projects/aio_writev/tests/sys/aio/aio_test.c Mon Dec 14 00:54:05 2020 (r368626) +++ projects/aio_writev/tests/sys/aio/aio_test.c Mon Dec 14 04:52:17 2020 (r368627) @@ -302,11 +302,9 @@ aio_writev_test(struct aio_context *ac, completion com aio.aio_offset = 0; len0 = ac->ac_buflen * 3 / 4; len1 = ac->ac_buflen / 4; - // TODO: once aio_readv is ready, swap the offsets of the two parts of - // the buffer. - iov[0].iov_base = ac->ac_buffer; + iov[0].iov_base = ac->ac_buffer + len1; iov[0].iov_len = len0; - iov[1].iov_base = ac->ac_buffer + len0; + iov[1].iov_base = ac->ac_buffer; iov[1].iov_len = len1; aio.aio_iov = iov; aio.aio_iovcnt = 2; @@ -357,6 +355,43 @@ aio_read_test(struct aio_context *ac, completion comp, atf_tc_fail("buffer mismatched"); } +static void +aio_readv_test(struct aio_context *ac, completion comp, struct sigevent *sev) +{ + struct aiocb aio; + struct iovec iov[2]; + size_t len0, len1; + ssize_t len; + + bzero(ac->ac_buffer, ac->ac_buflen); + bzero(&aio, sizeof(aio)); + aio.aio_fildes = ac->ac_write_fd; + aio.aio_offset = 0; + len0 = ac->ac_buflen * 3 / 4; + len1 = ac->ac_buflen / 4; + iov[0].iov_base = ac->ac_buffer + len1; + iov[0].iov_len = len0; + iov[1].iov_base = ac->ac_buffer; + iov[1].iov_len = len1; + aio.aio_iov = iov; + aio.aio_iovcnt = 2; + if (sev) + aio.aio_sigevent = *sev; + + if (aio_readv(&aio) < 0) + atf_tc_fail("aio_read failed: %s", strerror(errno)); + + len = comp(&aio); + if (len < 0) + atf_tc_fail("aio failed: %s", strerror(errno)); + + ATF_REQUIRE_EQ_MSG(len, ac->ac_buflen, + "aio short read (%jd)", (intmax_t)len); + + if (aio_test_buffer(ac->ac_buffer, ac->ac_buflen, ac->ac_seed) == 0) + atf_tc_fail("buffer mismatched"); +} + /* * Series of type-specific tests for AIO. For now, we just make sure we can * issue a write and then a read to each type. We assume that once a write @@ -383,11 +418,13 @@ aio_file_test(completion comp, struct sigevent *sev, b ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); aio_context_init(&ac, fd, fd, FILE_LEN); - if (vectored) + if (vectored) { aio_writev_test(&ac, comp, sev); - else + aio_readv_test(&ac, comp, sev); + } else { aio_write_test(&ac, comp, sev); - aio_read_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); + } close(fd); } @@ -754,11 +791,13 @@ aio_md_test(completion comp, struct sigevent *sev, boo fd = aio_md_setup(); aio_context_init(&ac, fd, fd, MD_LEN); - if (vectored) + if (vectored) { aio_writev_test(&ac, comp, sev); - else + aio_readv_test(&ac, comp, sev); + } else { aio_write_test(&ac, comp, sev); - aio_read_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); + } close(fd); } @@ -1441,7 +1480,26 @@ ATF_TC_BODY(vectored_big_iovcnt, tc) if (len != buflen) atf_tc_fail("aio short write (%jd)", (intmax_t)len); - // TODO: aio_readv + + bzero(&aio, sizeof(aio)); + aio.aio_fildes = fd; + aio.aio_offset = 0; + aio.aio_iov = iov; + aio.aio_iovcnt = max_buf_aio + 1; + + if (aio_readv(&aio) < 0) + atf_tc_fail("aio_readv failed: %s", strerror(errno)); + + len = poll(&aio); + if (len < 0) + atf_tc_fail("aio failed: %s", strerror(errno)); + + if (len != buflen) + atf_tc_fail("aio short read (%jd)", (intmax_t)len); + + if (aio_test_buffer(buffer, buflen, seed) == 0) + atf_tc_fail("buffer mismatched"); + close(fd); } ATF_TC_CLEANUP(vectored_big_iovcnt, tc) @@ -1532,7 +1590,20 @@ ATF_TC_BODY(vectored_unaligned, tc) if (len != total_len) atf_tc_fail("aio short write (%jd)", (intmax_t)len); - // TODO: aio_readv + + bzero(&aio, sizeof(aio)); + aio.aio_fildes = ac.ac_read_fd; + aio.aio_offset = 0; + aio.aio_iov = iov; + aio.aio_iovcnt = 3; + + if (aio_readv(&aio) < 0) + atf_tc_fail("aio_readv failed: %s", strerror(errno)); + len = poll(&aio); + + ATF_REQUIRE_MSG(aio_test_buffer(ac.ac_buffer, total_len, + ac.ac_seed) != 0, "aio_test_buffer: internal error"); + close(fd); } ATF_TC_CLEANUP(vectored_unaligned, tc) @@ -1548,11 +1619,13 @@ aio_zvol_test(completion comp, struct sigevent *sev, b fd = aio_zvol_setup(); aio_context_init(&ac, fd, fd, MD_LEN); - if (vectored) + if (vectored) { aio_writev_test(&ac, comp, sev); - else + aio_readv_test(&ac, comp, sev); + } else { aio_write_test(&ac, comp, sev); - aio_read_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); + } close(fd); } From owner-svn-src-projects@freebsd.org Tue Dec 15 06:31:47 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 218AA4AA02C for ; Tue, 15 Dec 2020 06:31:47 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cw7hM0Vh1z4vtL; Tue, 15 Dec 2020 06:31:47 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 04B587799; Tue, 15 Dec 2020 06:31:47 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BF6VkmR072838; Tue, 15 Dec 2020 06:31:46 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0BF6VkZN072836; Tue, 15 Dec 2020 06:31:46 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202012150631.0BF6VkZN072836@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 15 Dec 2020 06:31:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r368653 - in projects/aio_writev: sys/kern tests/sys/aio X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/aio_writev: sys/kern tests/sys/aio X-SVN-Commit-Revision: 368653 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2020 06:31:47 -0000 Author: asomers Date: Tue Dec 15 06:31:46 2020 New Revision: 368653 URL: https://svnweb.freebsd.org/changeset/base/368653 Log: aio_writev and aio_readv work on sockets now Modified: projects/aio_writev/sys/kern/sys_socket.c projects/aio_writev/sys/kern/vfs_aio.c projects/aio_writev/tests/sys/aio/aio_test.c Modified: projects/aio_writev/sys/kern/sys_socket.c ============================================================================== --- projects/aio_writev/sys/kern/sys_socket.c Tue Dec 15 01:45:19 2020 (r368652) +++ projects/aio_writev/sys/kern/sys_socket.c Tue Dec 15 06:31:46 2020 (r368653) @@ -459,7 +459,26 @@ static int soaio_lifetime; SYSCTL_INT(_kern_ipc_aio, OID_AUTO, lifetime, CTLFLAG_RW, &soaio_lifetime, 0, "Maximum lifetime for idle aiod"); +/* Advance the cursor in a uio by n bytes */ static void +soaio_advance_uio(struct uio *uio, int n) +{ + while (n > 0) { + int m = MIN(n, uio->uio_iov[0].iov_len); + n -= m; + uio->uio_iov[0].iov_base = (char*)uio->uio_iov[0].iov_base + m; + uio->uio_iov[0].iov_len -= m; + MPASS(uio->uio_resid >= m); + uio->uio_resid -= m; + if (uio->uio_iov[0].iov_len == 0) { + MPASS(uio->uio_iovcnt >= 1); + uio->uio_iov++; + uio->uio_iovcnt--; + } + } +} + +static void soaio_kproc_loop(void *arg) { struct proc *p; @@ -600,30 +619,48 @@ soaio_process_job(struct socket *so, struct sockbuf *s struct ucred *td_savedcred; struct thread *td; struct file *fp; - struct uio uio; + struct uio uio, *auiop; struct iovec iov; - size_t cnt, done; + size_t cnt, done, job_total_nbytes; long ru_before; - int error, flags; + int error, flags, opcode; + bool vectored; SOCKBUF_UNLOCK(sb); aio_switch_vmspace(job); td = curthread; fp = job->fd_file; + opcode = job->uaiocb.aio_lio_opcode; + vectored = opcode == LIO_WRITEV || opcode == LIO_READV; retry: td_savedcred = td->td_ucred; - td->td_ucred = job->cred; + if (vectored) { + error = copyinuio(job->uaiocb.aio_iov, job->uaiocb.aio_iovcnt, + &auiop); + if (error) { + aio_complete(job, -1, error); + SOCKBUF_LOCK(sb); + return; + } + } else { + iov.iov_base = (void *)((uintptr_t)job->uaiocb.aio_buf); + uio.uio_resid = job->uaiocb.aio_nbytes; + iov.iov_len = uio.uio_resid; + uio.uio_iov = &iov; + uio.uio_iovcnt = 1; + uio.uio_segflg = UIO_USERSPACE; + auiop = &uio; + } + job_total_nbytes = auiop->uio_resid; + auiop->uio_offset = 0; + auiop->uio_td = td; + + td->td_ucred = job->cred; done = job->aio_done; - cnt = job->uaiocb.aio_nbytes - done; - iov.iov_base = (void *)((uintptr_t)job->uaiocb.aio_buf + done); - iov.iov_len = cnt; - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = 0; - uio.uio_resid = cnt; - uio.uio_segflg = UIO_USERSPACE; - uio.uio_td = td; + soaio_advance_uio(auiop, done); + cnt = auiop->uio_resid; + MPASS(cnt == job_total_nbytes - done); flags = MSG_NBIO; /* @@ -633,26 +670,26 @@ retry: */ if (sb == &so->so_rcv) { - uio.uio_rw = UIO_READ; + auiop->uio_rw = UIO_READ; ru_before = td->td_ru.ru_msgrcv; #ifdef MAC error = mac_socket_check_receive(fp->f_cred, so); if (error == 0) #endif - error = soreceive(so, NULL, &uio, NULL, NULL, &flags); + error = soreceive(so, NULL, auiop, NULL, NULL, &flags); if (td->td_ru.ru_msgrcv != ru_before) job->msgrcv = 1; } else { if (!TAILQ_EMPTY(&sb->sb_aiojobq)) flags |= MSG_MORETOCOME; - uio.uio_rw = UIO_WRITE; + auiop->uio_rw = UIO_WRITE; ru_before = td->td_ru.ru_msgsnd; #ifdef MAC error = mac_socket_check_send(fp->f_cred, so); if (error == 0) #endif - error = sosend(so, NULL, &uio, NULL, NULL, flags, td); + error = sosend(so, NULL, auiop, NULL, NULL, flags, td); if (td->td_ru.ru_msgsnd != ru_before) job->msgsnd = 1; if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) { @@ -662,7 +699,7 @@ retry: } } - done += cnt - uio.uio_resid; + done += cnt - auiop->uio_resid; job->aio_done = done; td->td_ucred = td_savedcred; @@ -676,7 +713,7 @@ retry: * been made, requeue this request at the head of the * queue to try again when the socket is ready. */ - MPASS(done != job->uaiocb.aio_nbytes); + MPASS(done != job_total_nbytes); SOCKBUF_LOCK(sb); if (done == 0 || !(so->so_state & SS_NBIO)) { empty_results++; @@ -696,7 +733,7 @@ retry: } else { TAILQ_INSERT_HEAD(&sb->sb_aiojobq, job, list); } - return; + goto out; } SOCKBUF_UNLOCK(sb); } @@ -708,6 +745,10 @@ retry: else aio_complete(job, done, 0); SOCKBUF_LOCK(sb); + +out: + if (vectored) + free(auiop, M_IOV); } static void @@ -782,10 +823,10 @@ soo_aio_cancel(struct kaiocb *job) so = job->fd_file->f_data; opcode = job->uaiocb.aio_lio_opcode; - if (opcode == LIO_READ) + if (opcode == LIO_READ || opcode == LIO_READV) sb = &so->so_rcv; else { - MPASS(opcode == LIO_WRITE); + MPASS(opcode == LIO_WRITE || opcode == LIO_WRITEV); sb = &so->so_snd; } @@ -817,9 +858,11 @@ soo_aio_queue(struct file *fp, struct kaiocb *job) switch (job->uaiocb.aio_lio_opcode) { case LIO_READ: + case LIO_READV: sb = &so->so_rcv; break; case LIO_WRITE: + case LIO_WRITEV: sb = &so->so_snd; break; default: Modified: projects/aio_writev/sys/kern/vfs_aio.c ============================================================================== --- projects/aio_writev/sys/kern/vfs_aio.c Tue Dec 15 01:45:19 2020 (r368652) +++ projects/aio_writev/sys/kern/vfs_aio.c Tue Dec 15 06:31:46 2020 (r368653) @@ -1695,8 +1695,6 @@ no_kqueue: error = 0; } else if (fp->f_ops->fo_aio_queue == NULL) error = aio_queue_file(fp, job); - else if (opcode == LIO_WRITEV || opcode == LIO_READV) - error = EOPNOTSUPP; else error = fo_aio_queue(fp, job); if (error) Modified: projects/aio_writev/tests/sys/aio/aio_test.c ============================================================================== --- projects/aio_writev/tests/sys/aio/aio_test.c Tue Dec 15 01:45:19 2020 (r368652) +++ projects/aio_writev/tests/sys/aio/aio_test.c Tue Dec 15 06:31:46 2020 (r368653) @@ -365,7 +365,7 @@ aio_readv_test(struct aio_context *ac, completion comp bzero(ac->ac_buffer, ac->ac_buflen); bzero(&aio, sizeof(aio)); - aio.aio_fildes = ac->ac_write_fd; + aio.aio_fildes = ac->ac_read_fd; aio.aio_offset = 0; len0 = ac->ac_buflen * 3 / 4; len1 = ac->ac_buflen / 4; @@ -543,17 +543,16 @@ aio_unix_socketpair_test(completion comp, struct sigev aio_context_init(&ac, sockets[0], sockets[1], UNIX_SOCKETPAIR_LEN); ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_before) != -1, "getrusage failed: %s", strerror(errno)); - if (vectored) + if (vectored) { aio_writev_test(&ac, comp, sev); - else + aio_readv_test(&ac, comp, sev); + } else { aio_write_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); + } ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_after) != -1, "getrusage failed: %s", strerror(errno)); ATF_REQUIRE(ru_after.ru_msgsnd == ru_before.ru_msgsnd + 1); - ru_before = ru_after; - aio_read_test(&ac, comp, sev); - ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_after) != -1, - "getrusage failed: %s", strerror(errno)); ATF_REQUIRE(ru_after.ru_msgrcv == ru_before.ru_msgrcv + 1); close(sockets[0]); @@ -1054,14 +1053,11 @@ ATF_TC_BODY(aio_socket_two_reads, tc) close(s[0]); } -/* - * This test ensures that aio_write() on a blocking socket of a "large" - * buffer does not return a short completion. - */ -ATF_TC_WITHOUT_HEAD(aio_socket_blocking_short_write); -ATF_TC_BODY(aio_socket_blocking_short_write, tc) +static void +aio_socket_blocking_short_write_test(bool vectored) { struct aiocb iocb, *iocbp; + struct iovec iov[2]; char *buffer[2]; ssize_t done; int buffer_size, sb_size; @@ -1101,9 +1097,19 @@ ATF_TC_BODY(aio_socket_blocking_short_write, tc) memset(&iocb, 0, sizeof(iocb)); iocb.aio_fildes = s[1]; - iocb.aio_buf = buffer[1]; - iocb.aio_nbytes = buffer_size; - ATF_REQUIRE(aio_write(&iocb) == 0); + if (vectored) { + iov[0].iov_base = buffer[1]; + iov[0].iov_len = buffer_size / 2 + 1; + iov[1].iov_base = buffer[1] + buffer_size / 2 + 1; + iov[1].iov_len = buffer_size / 2 - 1; + iocb.aio_iov = iov; + iocb.aio_iovcnt = 2; + ATF_REQUIRE(aio_writev(&iocb) == 0); + } else { + iocb.aio_buf = buffer[1]; + iocb.aio_nbytes = buffer_size; + ATF_REQUIRE(aio_write(&iocb) == 0); + } done = recv(s[0], buffer[0], buffer_size, MSG_WAITALL); ATF_REQUIRE(done == buffer_size); @@ -1119,6 +1125,26 @@ ATF_TC_BODY(aio_socket_blocking_short_write, tc) } /* + * This test ensures that aio_write() on a blocking socket of a "large" + * buffer does not return a short completion. + */ +ATF_TC_WITHOUT_HEAD(aio_socket_blocking_short_write); +ATF_TC_BODY(aio_socket_blocking_short_write, tc) +{ + aio_socket_blocking_short_write_test(false); +} + +/* + * Like aio_socket_blocking_short_write, but also tests that partially + * completed vectored sends can be retried correctly. + */ +ATF_TC_WITHOUT_HEAD(aio_socket_blocking_short_write_vectored); +ATF_TC_BODY(aio_socket_blocking_short_write_vectored, tc) +{ + aio_socket_blocking_short_write_test(true); +} + +/* * This test verifies that cancelling a partially completed socket write * returns a short write rather than ECANCELED. */ @@ -1686,6 +1712,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, aio_large_read_test); ATF_TP_ADD_TC(tp, aio_socket_two_reads); ATF_TP_ADD_TC(tp, aio_socket_blocking_short_write); + ATF_TP_ADD_TC(tp, aio_socket_blocking_short_write_vectored); ATF_TP_ADD_TC(tp, aio_socket_short_write_cancel); ATF_TP_ADD_TC(tp, aio_writev_dos_iov_len); ATF_TP_ADD_TC(tp, aio_writev_dos_iovcnt); From owner-svn-src-projects@freebsd.org Tue Dec 15 07:07:31 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 131F04AB40B for ; Tue, 15 Dec 2020 07:07:31 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cw8Tb02k4z3F6J; Tue, 15 Dec 2020 07:07:31 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E896D7BB7; Tue, 15 Dec 2020 07:07:30 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BF77UIf095961; Tue, 15 Dec 2020 07:07:30 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0BF77UDE095959; Tue, 15 Dec 2020 07:07:30 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202012150707.0BF77UDE095959@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 15 Dec 2020 07:07:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r368654 - in projects/aio_writev: lib/libc/sys share/man/man4 X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in projects/aio_writev: lib/libc/sys share/man/man4 X-SVN-Commit-Revision: 368654 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2020 07:07:31 -0000 Author: asomers Date: Tue Dec 15 07:07:30 2020 New Revision: 368654 URL: https://svnweb.freebsd.org/changeset/base/368654 Log: aio.4: Link to aio_writev.2 and aio_readv.2 Also, add links to aio_error.2 and aio_return.2 Modified: projects/aio_writev/lib/libc/sys/aio_error.2 projects/aio_writev/lib/libc/sys/aio_return.2 projects/aio_writev/share/man/man4/aio.4 Modified: projects/aio_writev/lib/libc/sys/aio_error.2 ============================================================================== --- projects/aio_writev/lib/libc/sys/aio_error.2 Tue Dec 15 06:31:46 2020 (r368653) +++ projects/aio_writev/lib/libc/sys/aio_error.2 Tue Dec 15 07:07:30 2020 (r368654) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 2, 1999 +.Dd December 15, 2020 .Dt AIO_ERROR 2 .Os .Sh NAME @@ -52,7 +52,9 @@ is returned. If the request has completed unsuccessfully the error status is returned as described in .Xr read 2 , +.Xr readv 2 , .Xr write 2 , +.Xr writev 2 , or .Xr fsync 2 . On failure, @@ -76,9 +78,11 @@ does not reference an outstanding asynchronous I/O req .Sh SEE ALSO .Xr aio_cancel 2 , .Xr aio_read 2 , +.Xr aio_readv 2 , .Xr aio_return 2 , .Xr aio_suspend 2 , .Xr aio_write 2 , +.Xr aio_writev 2 , .Xr fsync 2 , .Xr read 2 , .Xr write 2 , Modified: projects/aio_writev/lib/libc/sys/aio_return.2 ============================================================================== --- projects/aio_writev/lib/libc/sys/aio_return.2 Tue Dec 15 06:31:46 2020 (r368653) +++ projects/aio_writev/lib/libc/sys/aio_return.2 Tue Dec 15 07:07:30 2020 (r368654) @@ -55,7 +55,9 @@ returns something other than If the asynchronous I/O request has completed, the status is returned as described in .Xr read 2 , +.Xr readv 2 , .Xr write 2 , +.Xr writev 2 , or .Xr fsync 2 . Otherwise, Modified: projects/aio_writev/share/man/man4/aio.4 ============================================================================== --- projects/aio_writev/share/man/man4/aio.4 Tue Dec 15 06:31:46 2020 (r368653) +++ projects/aio_writev/share/man/man4/aio.4 Tue Dec 15 07:07:30 2020 (r368654) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 22, 2017 +.Dd December 15, 2020 .Dt AIO 4 .Os .Sh NAME @@ -215,10 +215,12 @@ as described in .Xr aio_cancel 2 , .Xr aio_error 2 , .Xr aio_read 2 , +.Xr aio_readv 2 , .Xr aio_return 2 , .Xr aio_suspend 2 , .Xr aio_waitcomplete 2 , .Xr aio_write 2 , +.Xr aio_writev 2 , .Xr lio_listio 2 , .Xr sigevent 3 , .Xr sysctl 8 From owner-svn-src-projects@freebsd.org Thu Dec 17 10:25:12 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BA58E4B32E2 for ; Thu, 17 Dec 2020 10:25:12 +0000 (UTC) (envelope-from bounces+17430347-fef2-svn-src-projects=freebsd.org@em4842.fdc-k.africa) Received: from pnkfpfkc.outbound-mail.sendgrid.net (pnkfpfkc.outbound-mail.sendgrid.net [50.31.63.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CxSml6jftz3FCN for ; Thu, 17 Dec 2020 10:25:11 +0000 (UTC) (envelope-from bounces+17430347-fef2-svn-src-projects=freebsd.org@em4842.fdc-k.africa) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fdc-k.africa; h=content-transfer-encoding:content-type:from:mime-version:to:subject:list-unsubscribe; s=s1; bh=/FjpzN8JhAX9W2iiYkSwIuvLhl4fbiqhHBrVTY4BlSY=; b=eLRrIbZ s0pY7o7tsIqTIJxm74CHiOeuVeAOeE28pJjsAtA+4q9M0pWAg4yW50+3Bg8ktkiA HdMNO54DJke7nENHPgNl9Xhh6oy+t+oH7SbRMvRSh+j0Hc5FMYz5rsWgHS7mZHXz jcWCgEQfoisXYArfUQXebZ2RTMlPVrlY1m94= Received: by filter2142p1las1.sendgrid.net with SMTP id filter2142p1las1-9889-5FDADFE6-1 2020-12-17 04:34:47.005234573 +0000 UTC m=+3168.656928624 Received: from MTc0MzAzNDc (unknown) by ismtpd0003p1sjc2.sendgrid.net (SG) with HTTP id OBygwgnbQg-qhyO6V0qP_w Thu, 17 Dec 2020 04:34:45.848 +0000 (UTC) Date: Thu, 17 Dec 2020 04:36:17 +0000 (UTC) From: "FDC Training" To: svn-src-projects@freebsd.org Message-ID: Subject: Invitation to GIS for Monitoring and Evaluation training JAN 2021 X-SG-EID: 9SMAlWE7WBUQVxXUG8V9RtpC9dBd0k/WKQbq5V0ZtwbVWbovG/6KSYA8M4RXYbZjp56PeRcC2/l3FC 4HzljFsRM4muzDsVj3wwty4+zAkhiGSrOXBSVrnxqI0vGj60/XOkR3urs37pWIO1W5JQKX8bCYRD6c rTq+xMJdrcjRNr7ONupVRbBAeDAbDTj6AWbU0jwqJixeDfjlI+xqh8qwBJZ/HUTPhZS9/p/4CHyzik g= X-Entity-ID: lgZohGoWIjvYsKzlUpYsxA== X-Rspamd-Queue-Id: 4CxSml6jftz3FCN X-Spamd-Bar: ++++ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=fdc-k.africa header.s=s1 header.b=eLRrIbZ ; dmarc=pass (policy=none) header.from=fdc-k.africa; spf=pass (mx1.freebsd.org: domain of bounces@em4842.fdc-k.africa designates 50.31.63.28 as permitted sender) smtp.mailfrom=bounces@em4842.fdc-k.africa X-Spamd-Result: default: False [4.08 / 15.00]; R_SPF_ALLOW(0.00)[+ip4:50.31.32.0/19:c]; MV_CASE(0.50)[]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[fdc-k.africa:+]; DMARC_POLICY_ALLOW(0.00)[fdc-k.africa,none]; NEURAL_HAM_SHORT(-1.00)[-0.999]; FORGED_SENDER(0.30)[training@fdc-k.africa,bounces@em4842.fdc-k.africa]; RCVD_TLS_LAST(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[50.31.63.28:from]; ASN(0.00)[asn:11377, ipnet:50.31.48.0/20, country:US]; MIME_TRACE(0.00)[0:~]; TAGGED_FROM(0.00)[17430347-fef2-svn-src-projects=freebsd.org]; ARC_NA(0.00)[]; R_DKIM_ALLOW(0.00)[fdc-k.africa:s=s1]; FROM_NEQ_ENVFROM(0.00)[training@fdc-k.africa,bounces@em4842.fdc-k.africa]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[50.31.63.28:from:127.0.2.255]; NEURAL_SPAM_MEDIUM(0.99)[0.990]; BAD_REP_POLICIES(0.10)[]; NEURAL_SPAM_LONG(1.00)[1.000]; MIME_HTML_ONLY(0.20)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[50.31.63.28:from]; RBL_SENDERSCORE(2.00)[50.31.63.28:from]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[svn-src-projects] MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2020 10:25:12 -0000