From owner-svn-src-head@FreeBSD.ORG Sat Jun 8 13:02:43 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E2BAA26B; Sat, 8 Jun 2013 13:02:43 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D2B0A1382; Sat, 8 Jun 2013 13:02:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r58D2h6X056636; Sat, 8 Jun 2013 13:02:43 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r58D2hvh056635; Sat, 8 Jun 2013 13:02:43 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201306081302.r58D2hvh056635@svn.freebsd.org> From: Gleb Smirnoff Date: Sat, 8 Jun 2013 13:02:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251522 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jun 2013 13:02:44 -0000 Author: glebius Date: Sat Jun 8 13:02:43 2013 New Revision: 251522 URL: http://svnweb.freebsd.org/changeset/base/251522 Log: Separate LIO_SYNC processing into a separate function aio_process_sync(), and rename aio_process() into aio_process_rw(). Reviewed by: kib Sponsored by: Nginx, Inc. Modified: head/sys/kern/vfs_aio.c Modified: head/sys/kern/vfs_aio.c ============================================================================== --- head/sys/kern/vfs_aio.c Sat Jun 8 12:10:52 2013 (r251521) +++ head/sys/kern/vfs_aio.c Sat Jun 8 13:02:43 2013 (r251522) @@ -338,7 +338,8 @@ static struct unrhdr *aiod_unr; void aio_init_aioinfo(struct proc *p); static int aio_onceonly(void); static int aio_free_entry(struct aiocblist *aiocbe); -static void aio_process(struct aiocblist *aiocbe); +static void aio_process_rw(struct aiocblist *aiocbe); +static void aio_process_sync(struct aiocblist *aiocbe); static int aio_newproc(int *); int aio_aqueue(struct thread *td, struct aiocb *job, struct aioliojob *lio, int type, struct aiocb_ops *ops); @@ -855,15 +856,15 @@ drop: } /* - * The AIO processing activity. This is the code that does the I/O request for - * the non-physio version of the operations. The normal vn operations are used, - * and this code should work in all instances for every type of file, including - * pipes, sockets, fifos, and regular files. + * The AIO processing activity for LIO_READ/LIO_WRITE. This is the code that + * does the I/O request for the non-physio version of the operations. The + * normal vn operations are used, and this code should work in all instances + * for every type of file, including pipes, sockets, fifos, and regular files. * * XXX I don't think it works well for socket, pipe, and fifo. */ static void -aio_process(struct aiocblist *aiocbe) +aio_process_rw(struct aiocblist *aiocbe) { struct ucred *td_savedcred; struct thread *td; @@ -877,23 +878,16 @@ aio_process(struct aiocblist *aiocbe) int oublock_st, oublock_end; int inblock_st, inblock_end; + KASSERT(aiocbe->uaiocb.aio_lio_opcode == LIO_READ || + aiocbe->uaiocb.aio_lio_opcode == LIO_WRITE, + ("%s: opcode %d", __func__, aiocbe->uaiocb.aio_lio_opcode)); + td = curthread; td_savedcred = td->td_ucred; td->td_ucred = aiocbe->cred; cb = &aiocbe->uaiocb; fp = aiocbe->fd_file; - if (cb->aio_lio_opcode == LIO_SYNC) { - error = 0; - cnt = 0; - if (fp->f_vnode != NULL) - error = aio_fsync_vnode(td, fp->f_vnode); - cb->_aiocb_private.error = error; - cb->_aiocb_private.status = 0; - td->td_ucred = td_savedcred; - return; - } - aiov.iov_base = (void *)(uintptr_t)cb->aio_buf; aiov.iov_len = cb->aio_nbytes; @@ -954,6 +948,26 @@ aio_process(struct aiocblist *aiocbe) } static void +aio_process_sync(struct aiocblist *aiocbe) +{ + struct thread *td = curthread; + struct ucred *td_savedcred = td->td_ucred; + struct aiocb *cb = &aiocbe->uaiocb; + struct file *fp = aiocbe->fd_file; + int error = 0; + + KASSERT(aiocbe->uaiocb.aio_lio_opcode == LIO_SYNC, + ("%s: opcode %d", __func__, aiocbe->uaiocb.aio_lio_opcode)); + + td->td_ucred = aiocbe->cred; + if (fp->f_vnode != NULL) + error = aio_fsync_vnode(td, fp->f_vnode); + cb->_aiocb_private.error = error; + cb->_aiocb_private.status = 0; + td->td_ucred = td_savedcred; +} + +static void aio_bio_done_notify(struct proc *userp, struct aiocblist *aiocbe, int type) { struct aioliojob *lj; @@ -1024,7 +1038,7 @@ notification_done: } /* - * The AIO daemon, most of the actual work is done in aio_process, + * The AIO daemon, most of the actual work is done in aio_process_*, * but the setup (and address space mgmt) is done in this routine. */ static void @@ -1121,7 +1135,15 @@ aio_daemon(void *_id) ki = userp->p_aioinfo; /* Do the I/O function. */ - aio_process(aiocbe); + switch(aiocbe->uaiocb.aio_lio_opcode) { + case LIO_READ: + case LIO_WRITE: + aio_process_rw(aiocbe); + break; + case LIO_SYNC: + aio_process_sync(aiocbe); + break; + } mtx_lock(&aio_job_mtx); /* Decrement the active job count. */