From patchwork Tue May 31 08:59:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Liu X-Patchwork-Id: 9143863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5D65460757 for ; Tue, 31 May 2016 09:02:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 521C028185 for ; Tue, 31 May 2016 09:02:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 469C12821C; Tue, 31 May 2016 09:02:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8AE2C28185 for ; Tue, 31 May 2016 09:02:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7fWn-0005kI-Us; Tue, 31 May 2016 08:59:57 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7fWm-0005kC-NY for xen-devel@lists.xenproject.org; Tue, 31 May 2016 08:59:56 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 41/A2-06230-C825D475; Tue, 31 May 2016 08:59:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsUyZ7p8oG53kG+ 4wYtNChbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bLO/uYC2YLVXw5tIOtgfEAfxcjF4eQQAeT xI0ju5ggnG+MEtu37WSEcDYyShx438kM4fQySrxvucfaxcjBwSagJDH/fnoXIyeHiICCxObeZ 2BhZoEyicl/hUFMYQEToLA9SAWLgKrEkUtLWEFsXgEniZ2NP8BsCQFFie5nE9hAbE4BZ4kHm3 6ygNhCQDUPWt+zQdQYS7S/vcg2gZFvASPDKkb14tSistQiXWO9pKLM9IyS3MTMHF1DAzO93NT i4sT01JzEpGK95PzcTYzAIGEAgh2MHf+cDjFKcjApifJa/fYJF+JLyk+pzEgszogvKs1JLT7E KMPBoSTBmxToGy4kWJSanlqRlpkDDFeYtAQHj5II7waQNG9xQWJucWY6ROoUo6KUOG85SEIAJ JFRmgfXBouRS4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBLm3QQyhSczrwRu+iugxUxAi+MzfE AWlyQipKQaGEPzZqsd/NzjdPyMbfnsY7/YDYo3xO/UyI/s4jVTS51/4r73rNmWctxC+WJpSjY /72SsjHve9nhq/En3+fcOHLb+fP/qlzVPPKuSyvp8RI2r/4W7bfwe9tM54tLbHfe0T3xmZFmS bf74hVlC7+lp/2WkJnemGT7aUnL6o92xa68jlJ8+CA201VdiKc5INNRiLipOBAAGfK72jAIAA A== X-Env-Sender: bob.liu@oracle.com X-Msg-Ref: server-12.tower-21.messagelabs.com!1464685193!16747635!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43529 invoked from network); 31 May 2016 08:59:55 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-12.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 31 May 2016 08:59:55 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4V8xpvU022389 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 31 May 2016 08:59:52 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u4V8xpau002156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 31 May 2016 08:59:51 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u4V8xneJ017372; Tue, 31 May 2016 08:59:50 GMT Received: from boliuliu.jp.oracle.com (/10.191.11.12) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 31 May 2016 01:59:48 -0700 From: Bob Liu To: linux-kernel@vger.kernel.org Date: Tue, 31 May 2016 16:59:17 +0800 Message-Id: <1464685157-30738-2-git-send-email-bob.liu@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1464685157-30738-1-git-send-email-bob.liu@oracle.com> References: <1464685157-30738-1-git-send-email-bob.liu@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: xen-devel@lists.xenproject.org, Bob Liu , roger.pau@citrix.com Subject: [Xen-devel] [PATCH 2/2] xen-blkfront: fix resume issues X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP After migrate to another host, the number of rings(block hardware queues) may be changed and the ring info structure will also be reallocated. This patch fix two related place: * call blk_mq_update_nr_hw_queues() to make blk-core knows the number of hardware queues have been changed. * Don't store rinfo pointer to hctx->driver_data, because rinfo may be * reallocated so using hctx->queue_num to get the rinfo structure instead. Signed-off-by: Bob Liu --- drivers/block/xen-blkfront.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 01aa460..83e36c5 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -874,8 +874,12 @@ static int blkif_queue_rq(struct blk_mq_hw_ctx *hctx, const struct blk_mq_queue_data *qd) { unsigned long flags; - struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)hctx->driver_data; + int qid = hctx->queue_num; + struct blkfront_info *info = hctx->queue->queuedata; + struct blkfront_ring_info *rinfo = NULL; + BUG_ON(info->nr_rings <= qid); + rinfo = &info->rinfo[qid]; blk_mq_start_request(qd->rq); spin_lock_irqsave(&rinfo->ring_lock, flags); if (RING_FULL(&rinfo->ring)) @@ -901,20 +905,9 @@ out_busy: return BLK_MQ_RQ_QUEUE_BUSY; } -static int blk_mq_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, - unsigned int index) -{ - struct blkfront_info *info = (struct blkfront_info *)data; - - BUG_ON(info->nr_rings <= index); - hctx->driver_data = &info->rinfo[index]; - return 0; -} - static struct blk_mq_ops blkfront_mq_ops = { .queue_rq = blkif_queue_rq, .map_queue = blk_mq_map_queue, - .init_hctx = blk_mq_init_hctx, }; static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, @@ -950,6 +943,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, return PTR_ERR(rq); } + rq->queuedata = info; queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq); if (info->feature_discard) { @@ -2149,6 +2143,8 @@ static int blkfront_resume(struct xenbus_device *dev) return err; err = talk_to_blkback(dev, info); + if (!err) + blk_mq_update_nr_hw_queues(&info->tag_set, info->nr_rings); /* * We have to wait for the backend to switch to