Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jul 2013 14:17:20 +0400
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        Adrian Chadd <adrian@freebsd.org>
Cc:        freebsd-current <freebsd-current@freebsd.org>
Subject:   Re: hacking - aio_sendfile()
Message-ID:  <20130711101720.GZ67810@FreeBSD.org>
In-Reply-To: <CAJ-Vmo=icr6bda%2BWMNUarc3WbdqJ%2BMdauX6kByxxdTx8oSovBg@mail.gmail.com>
References:  <CAJ-Vmo=icr6bda%2BWMNUarc3WbdqJ%2BMdauX6kByxxdTx8oSovBg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
  Adrian,

On Wed, Jul 10, 2013 at 04:36:23PM -0700, Adrian Chadd wrote:
A> I've started writing an aio_sendfile() syscall.
A> 
A> http://people.freebsd.org/~adrian/ath/20130710-aio-sendfile-3.diff
A> 
A> Yes, the diff is against -HEAD and not stable/9.
A> 
A> It's totally horrible, hackish and likely bad. I've only done some
A> very, very basic testing to ensure it actually works; i haven't at all
A> stress tested it out yet. It's also very naive - I'm not at all doing
A> any checks to see whether I can short-cut to do the aio there and
A> then; I'm always queuing the sendfile() op through the worker threads.
A> That's likely stupid and inefficient in a lot of cases, but it at
A> least gets the syscall up and working.
A> 
A> I'd like some feedback and possibly some help in stress testing it to
A> make sure it's functioning well.

Apart from problem pointed out by Kostik, there is a race between
aio thread starting with aio_process_sendfile() and file descriptor
(or socket descriptor) going away.

Thus, kern_sendfile() needs to be split into two parts: kern_sendfile_pre()
and kern_sendfile() that should contain only the sending cycle.

The kern_sendfile_pre() should contain:

fgetvp_read(uap->fd, &vp)
vm_object_reference_locked(vp->v_object)

Referencing the socket is probably also required. Current synchronous
code doesn't do it.

The do_sendfile() function should call kern_sendfile_pre() and then
kern_sendfile(). The aio code should perform kern_sendfile_pre() in the
new syscall itself in context of calling process, and kern_sendfile()
in async context.

P.S. Some time ago I have started hacking on the above.

-- 
Totus tuus, Glebius.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130711101720.GZ67810>