From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: Re: [PATCH v3] virtio-blk: Fix hot-unplug race in remove method Date: Mon, 07 May 2012 14:35:28 +0930 Message-ID: <87obq0eg2v.fsf@rustcorp.com.au> References: <1336134124-14744-1-git-send-email-asias@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1336134124-14744-1-git-send-email-asias@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Asias He , virtualization@lists.linux-foundation.org, "Michael S. Tsirkin" Cc: kvm@vger.kernel.org List-Id: virtualization@lists.linuxfoundation.org On Fri, 4 May 2012 20:22:04 +0800, Asias He wrote: > If we reset the virtio-blk device before the requests already dispatched > to the virtio-blk driver from the block layer are finised, we will stuck > in blk_cleanup_queue() and the remove will fail. > > blk_cleanup_queue() calls blk_drain_queue() to drain all requests queued > before DEAD marking. However it will never success if the device is > already stopped. We'll have q->in_flight[] > 0, so the drain will not > finish. > > How to reproduce the race: > 1. hot-plug a virtio-blk device > 2. keep reading/writing the device in guest > 3. hot-unplug while the device is busy serving I/O > > Test: > ~1000 rounds of hot-plug/hot-unplug test passed with this patch. > > Changes in v3: > - Drop blk_abort_queue and blk_abort_request > - Use __blk_end_request_all to complete request dispatched to driver OK, replaced v2 with this one. Thanks, Rusty.