]> git.proxmox.com Git - mirror_qemu.git/commit - block/rbd.c
rbd: switch from pipe to QEMUBH completion notification
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 5 Dec 2013 15:38:33 +0000 (16:38 +0100)
committerKevin Wolf <kwolf@redhat.com>
Wed, 22 Jan 2014 11:07:16 +0000 (12:07 +0100)
commite04fb07fd1676e9facd7f3f878c1bbe03bccd26b
treee1b2da9e26610cbd77f4e846c9846797bebcf020
parent732c66ce641c69702a7e7fdb73b68f0c1b583ab5
rbd: switch from pipe to QEMUBH completion notification

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.

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Tested-by: Josh Durgin <josh.durgin@inktank.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/rbd.c