From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyZMR-00030Z-Ik for qemu-devel@nongnu.org; Wed, 01 Jan 2014 22:54:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VyZMK-0007Gz-2q for qemu-devel@nongnu.org; Wed, 01 Jan 2014 22:54:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyZMJ-0007Gp-Qf for qemu-devel@nongnu.org; Wed, 01 Jan 2014 22:54:11 -0500 Date: Thu, 2 Jan 2014 11:54:02 +0800 From: Stefan Hajnoczi Message-ID: <20140102035402.GA17580@stefanha-thinkpad.redhat.com> References: <1386257913-13700-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1386257913-13700-1-git-send-email-stefanha@redhat.com> Subject: Re: [Qemu-devel] [PATCH] rbd: switch from pipe to QEMUBH completion notification List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Josh Durgin 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 > --- > 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