Steven, I don't want to MFC that, since that will hurt performance on stable/11 due to ACCEPT_LOCK().
On Thu, Sep 14, 2017 at 08:31:57AM +0100, Steven Hartland wrote: S> Is this something that will be MFC'ed to 11 or is this 12 / CURRENT only? S> S> On 13/09/2017 23:11, Gleb Smirnoff wrote: S> > Author: glebius S> > Date: Wed Sep 13 22:11:05 2017 S> > New Revision: 323566 S> > URL: https://svnweb.freebsd.org/changeset/base/323566 S> > S> > Log: S> > Use soref() in sendfile(2) instead fhold() to reference a socket. S> > S> > The problem is that fdrop() requires syscall context, as it may S> > enter sleep in some cases. The reason to use it in the original S> > non-blocking sendfile implementation, was to avoid use of global S> > ACCEPT_LOCK() on every I/O completion. Now in head sorele() no S> > longer requires this lock. S> > S> > Modified: S> > head/sys/kern/kern_sendfile.c S> > S> > Modified: head/sys/kern/kern_sendfile.c S> > ============================================================================== S> > --- head/sys/kern/kern_sendfile.c Wed Sep 13 21:56:49 2017 (r323565) S> > +++ head/sys/kern/kern_sendfile.c Wed Sep 13 22:11:05 2017 (r323566) S> > @@ -80,7 +80,7 @@ struct sf_io { S> > volatile u_int nios; S> > u_int error; S> > int npages; S> > - struct file *sock_fp; S> > + struct socket *so; S> > struct mbuf *m; S> > vm_page_t pa[]; S> > }; S> > @@ -255,7 +255,7 @@ static void S> > sendfile_iodone(void *arg, vm_page_t *pg, int count, int error) S> > { S> > struct sf_io *sfio = arg; S> > - struct socket *so; S> > + struct socket *so = sfio->so; S> > S> > for (int i = 0; i < count; i++) S> > if (pg[i] != bogus_page) S> > @@ -267,8 +267,6 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i S> > if (!refcount_release(&sfio->nios)) S> > return; S> > S> > - so = sfio->sock_fp->f_data; S> > - S> > if (sfio->error) { S> > struct mbuf *m; S> > S> > @@ -296,8 +294,8 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i S> > CURVNET_RESTORE(); S> > } S> > S> > - /* XXXGL: curthread */ S> > - fdrop(sfio->sock_fp, curthread); S> > + SOCK_LOCK(so); S> > + sorele(so); S> > free(sfio, M_TEMP); S> > } S> > S> > @@ -724,6 +722,7 @@ retry_space: S> > sfio = malloc(sizeof(struct sf_io) + S> > npages * sizeof(vm_page_t), M_TEMP, M_WAITOK); S> > refcount_init(&sfio->nios, 1); S> > + sfio->so = so; S> > sfio->error = 0; S> > S> > nios = sendfile_swapin(obj, sfio, off, space, npages, rhpages, S> > @@ -858,9 +857,8 @@ prepend_header: S> > error = (*so->so_proto->pr_usrreqs->pru_send) S> > (so, 0, m, NULL, NULL, td); S> > } else { S> > - sfio->sock_fp = sock_fp; S> > sfio->npages = npages; S> > - fhold(sock_fp); S> > + soref(so); S> > error = (*so->so_proto->pr_usrreqs->pru_send) S> > (so, PRUS_NOTREADY, m, NULL, NULL, td); S> > sendfile_iodone(sfio, NULL, 0, 0); S> > S> -- Gleb Smirnoff _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"