From patchwork Mon Aug 13 20:18:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 1316121 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CA829DF25A for ; Mon, 13 Aug 2012 20:48:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753383Ab2HMUr4 (ORCPT ); Mon, 13 Aug 2012 16:47:56 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]:51310 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753217Ab2HMUUO (ORCPT ); Mon, 13 Aug 2012 16:20:14 -0400 Received: by mail-ob0-f174.google.com with SMTP id uo13so7356092obb.19 for ; Mon, 13 Aug 2012 13:20:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :user-agent:x-gm-message-state; bh=hr4mSmEqSZY/VnILyNkkDuDlgqyAUz0oqwEJ9EI0nw4=; b=O7xOUvoBd0QCQ0daRpSOd2BdBLyL8o4lbh9jY/8qUJofQQcnyUtVEURII5aelwM/DB bxq0lnPbKdjwSfLR+EETY8Hn6CikcTD2uOSgRn529jHsMl0vDy6YYJXN+oysnlsTfvFK cbLb0ZDKxcchEamCapBoFUHpgSnFTRNm4D6Sqn+neGA3xNz7H/jFeV4k13FRXR7cPGP4 QU78hf6WI4gcqiz4B28tCo0VgnaY4+eoRPWpIMS+EJUw9qYRvf/RmqEUZ8waxxCfyWr5 b6dycK1XG1CPmEUYdHvZVK7m50v4+rSAdXR6VnzCKBFeLrLjWpuqsiJd679zn7H4ahA5 /Fgw== Received: by 10.60.8.8 with SMTP id n8mr16821780oea.38.1344889213650; Mon, 13 Aug 2012 13:20:13 -0700 (PDT) Received: from localhost (c-67-168-183-230.hsd1.wa.comcast.net. [67.168.183.230]) by mx.google.com with ESMTPS id o4sm429465oef.11.2012.08.13.13.20.10 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 13 Aug 2012 13:20:12 -0700 (PDT) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg KH , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Asias He , Rusty Russell , "Michael S. Tsirkin" , virtualization@lists.linux-foundation.org, kvm@vger.kernel.org Subject: [ 02/82] virtio-blk: Reset device after blk_cleanup_queue() Date: Mon, 13 Aug 2012 13:18:38 -0700 Message-Id: <20120813201746.665355912@linuxfoundation.org> X-Mailer: git-send-email 1.7.10.1.362.g242cab3 In-Reply-To: <20120813201746.448504360@linuxfoundation.org> References: <20120813201746.448504360@linuxfoundation.org> User-Agent: quilt/0.60-20.5 X-Gm-Message-State: ALoCoQmASc+w+IJCiWn1JQ2/x6eAqcVrMRvN1Bzw1592I1nub39obj6qucmKjfnkOyMUSswaQtUO Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Greg KH 3.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Asias He commit 483001c765af6892b3fc3726576cb42f17d1d6b5 upstream. blk_cleanup_queue() will call blk_drian_queue() to drain all the requests before queue DEAD marking. If we reset the device before blk_cleanup_queue() the drain would fail. 1) if the queue is stopped in do_virtblk_request() because device is full, the q->request_fn() will not be called. blk_drain_queue() { while(true) { ... if (!list_empty(&q->queue_head)) __blk_run_queue(q) { if (queue is not stoped) q->request_fn() } ... } } Do no reset the device before blk_cleanup_queue() gives the chance to start the queue in interrupt handler blk_done(). 2) In commit b79d866c8b7014a51f611a64c40546109beaf24a, We abort requests dispatched to driver before blk_cleanup_queue(). There is a race if requests are dispatched to driver after the abort and before the queue DEAD mark. To fix this, instead of aborting the requests explicitly, we can just reset the device after after blk_cleanup_queue so that the device can complete all the requests before queue DEAD marking in the drain process. Signed-off-by: Asias He Cc: Rusty Russell Cc: virtualization@lists.linux-foundation.org Cc: kvm@vger.kernel.org Acked-by: Michael S. Tsirkin Signed-off-by: Rusty Russell Signed-off-by: Greg Kroah-Hartman --- drivers/block/virtio_blk.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -576,8 +576,6 @@ static void __devexit virtblk_remove(str { struct virtio_blk *vblk = vdev->priv; int index = vblk->index; - struct virtblk_req *vbr; - unsigned long flags; /* Prevent config work handler from accessing the device. */ mutex_lock(&vblk->config_lock); @@ -585,21 +583,13 @@ static void __devexit virtblk_remove(str mutex_unlock(&vblk->config_lock); del_gendisk(vblk->disk); + blk_cleanup_queue(vblk->disk->queue); /* Stop all the virtqueues. */ vdev->config->reset(vdev); flush_work(&vblk->config_work); - /* Abort requests dispatched to driver. */ - spin_lock_irqsave(&vblk->lock, flags); - while ((vbr = virtqueue_detach_unused_buf(vblk->vq))) { - __blk_end_request_all(vbr->req, -EIO); - mempool_free(vbr, vblk->pool); - } - spin_unlock_irqrestore(&vblk->lock, flags); - - blk_cleanup_queue(vblk->disk->queue); put_disk(vblk->disk); mempool_destroy(vblk->pool); vdev->config->del_vqs(vdev);