On Thu, Dec 05, 2013 at 04:38:33PM +0100, Stefan Hajnoczi wrote:
> rbd callbacks are called from non-QEMU threads.  Up until now a pipe was
> used to signal completion back to the QEMU iothread.
> 
> The pipe writer code handles EAGAIN using select(2).  The select(2) API
> is not scalable since fd_set size is static.  FD_SET() can write beyond
> the end of fd_set if the file descriptor number is too high.  (QEMU's
> main loop uses poll(2) to avoid this issue with select(2).)
> 
> Since the pipe itself is quite clumsy to use and QEMUBH is now
> thread-safe, just schedule a BH from the rbd callback function.  This
> way we can simplify I/O completion in addition to eliminating the
> potential FD_SET() crash when file descriptor numbers become too high.
> 
> Crash scenario: QEMU already has 1024 file descriptors open.  Hotplug an
> rbd drive and get the pipe writer to take the select(2) code path.
> 
> Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com>
> ---
> Josh: This patch has not been tested.  I have just compiled it.
> 
>  block/rbd.c | 130 
> ++++++++++--------------------------------------------------
>  1 file changed, 22 insertions(+), 108 deletions(-)

Applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next

Stefan

Reply via email to