Received: by 10.223.164.221 with SMTP id h29csp110898wrb; Tue, 31 Oct 2017 15:00:22 -0700 (PDT) X-Google-Smtp-Source: ABhQp+S0sw+ETxu+qkGt4SF2ExC0SZuVVxby0+jAqOak1k3Kq5w+gHVy5x9/fAgEov+5octw4JZx X-Received: by 10.99.63.199 with SMTP id m190mr3289944pga.275.1509487222646; Tue, 31 Oct 2017 15:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509487222; cv=none; d=google.com; s=arc-20160816; b=zs8aApx3b/x6wB6v2hXAUXOnu1htt43uIjkgQx9ctP0M5yvzUCBcnAfuIYzjBc0dKR zLnefUpRYssOWjOZjxsgzJWLg40NVTISAzqtQwDSTiTJOLAUCoWC+ienwg2rI32xhpvx wRhPjOCZOUjRAzP9+kEJ24M6NIFihUvxzKGoh7mlvwE6z7xT0shaDpCKexP7f+zz8iut xN5vxOlFjqx3TImVPIAG6xzvd9Z/gXO0841XPycVOyQe2YvyV2BYSC7FEh5QehRGbRey HwsHKBIHjQYbWQ90N4BxCCXkb0bWeWConu8vofdvtTjHaNMv8PQT5SzbdDZlDfohKD55 DAWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=STCY+VD+ei+j4nJnWRfQXvP4ORJVUhvamhl1GunKZgs=; b=g/bAnPKDIJw7uEwNR+r927RfpXiGezkpUIrdd/HZwDF8q/RiRaZxBfIynLNyk32OXj J1s2DyPPwZrHUXPngqxsW3dyXmv3/P3DTiYVG+qDJGv6sW7dPvjhmb85vRmcINC7tXK8 j7o1C1HD/EjG9KUvnHm+tKz7Lto227ArWAHP14Fd0IiBalRi9ChqMUB1vQ4Ilye5RuAJ aZnmELuJk3PxWBC4+IMlMqmendY+mQPAKYIScoShWLKfE8Xknvp+Xibe3NUGJlOVZDsj ez6UUstBmIxcl8y3B4uCXzrltyHzN2IcgGJTIoYLu3ctJft60EqW7Yx1nMSVJALgpmgP W/FQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si2490981pgu.231.2017.10.31.15.00.09; Tue, 31 Oct 2017 15:00:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932501AbdJaV7X (ORCPT + 99 others); Tue, 31 Oct 2017 17:59:23 -0400 Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:35224 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751603AbdJaV7V (ORCPT ); Tue, 31 Oct 2017 17:59:21 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id 9eY8efd5HKv339eY8erv8w; Tue, 31 Oct 2017 14:58:20 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1e9eY8-00032H-94; Tue, 31 Oct 2017 14:58:20 -0700 From: Long Li To: "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , "James E . J . Bottomley" , "Martin K . Petersen" , devel@linuxdriverproject.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Long Li Subject: [PATCH] storvsc: Avoid excessive host scan on controller change Date: Tue, 31 Oct 2017 14:58:08 -0700 Message-Id: <20171031215808.11629-1-longli@exchange.microsoft.com> X-Mailer: git-send-email 2.14.1 X-CMAE-Envelope: MS4wfLcdQM1Vm1HTZ8xy2XziO8tJoOXX1Jqsy4AJqGxA0p9m2WsEoaRtLEb3mRzsodHfZspXv3z096t2zXhIWEmA2Klh19W2D0Kxw7xOVaqqFr1cPDGN7f45 lgCkxHN29m/WbNTnIMm3CDAtZ2mBCjW6hNNqYfMggK+0HUNJLU7ovptFANheUtsxopo6hELjw4alipBJOHyzniibu1W7pHomhYnt5wakva8czoi/7gbhMkwU Nrbo8P8DKoC/5yjMIbQrbaz4fj2Jk4IhvD8Qh94Ygw3jem6OgnTWBCZGJghe41IuXNOUc6eTmbfs/NR7Hx1Na++riBh7N9fi7saolAEMjsIPQgprYZzskCcJ Rp1oJ1MKQ7opleAzxNJ32r/c3MOQBJ97KllPTRl9NMVduqHr2umP6cYvSVC44foQuj9yYjjFTx8uSgDfmfrTJUQD+us2hb5yGimcO0nPw+PJvqfcs2h/7n9U tJOFG3t+E6y8teY7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li When there are multiple disks attached to the same SCSI controller, the host may send several VSTOR_OPERATION_REMOVE_DEVICE or VSTOR_OPERATION_ENUMERATE_BUS messages in a row, to indicate there is a change on the SCSI controller. In response, storvsc rescans the SCSI host. There is no need to do multiple scans on the same host. Fix the code to do only one scan. Signed-off-by: Long Li --- drivers/scsi/storvsc_drv.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 6febcdb..b602f52 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -488,6 +488,8 @@ struct hv_host_device { unsigned char target; struct workqueue_struct *handle_error_wq; char work_q_name[20]; + struct work_struct host_scan_work; + struct Scsi_Host *host; }; struct storvsc_scan_work { @@ -516,13 +518,12 @@ static void storvsc_device_scan(struct work_struct *work) static void storvsc_host_scan(struct work_struct *work) { - struct storvsc_scan_work *wrk; struct Scsi_Host *host; struct scsi_device *sdev; + struct hv_host_device *host_device = + container_of(work, struct hv_host_device, host_scan_work); - wrk = container_of(work, struct storvsc_scan_work, work); - host = wrk->host; - + host = host_device->host; /* * Before scanning the host, first check to see if any of the * currrently known devices have been hot removed. We issue a @@ -542,8 +543,6 @@ static void storvsc_host_scan(struct work_struct *work) * Now scan the host to discover LUNs that may have been added. */ scsi_scan_host(host); - - kfree(wrk); } static void storvsc_remove_lun(struct work_struct *work) @@ -1119,8 +1118,7 @@ static void storvsc_on_receive(struct storvsc_device *stor_device, struct vstor_packet *vstor_packet, struct storvsc_cmd_request *request) { - struct storvsc_scan_work *work; - + struct hv_host_device *host_dev; switch (vstor_packet->operation) { case VSTOR_OPERATION_COMPLETE_IO: storvsc_on_io_completion(stor_device, vstor_packet, request); @@ -1128,13 +1126,9 @@ static void storvsc_on_receive(struct storvsc_device *stor_device, case VSTOR_OPERATION_REMOVE_DEVICE: case VSTOR_OPERATION_ENUMERATE_BUS: - work = kmalloc(sizeof(struct storvsc_scan_work), GFP_ATOMIC); - if (!work) - return; - - INIT_WORK(&work->work, storvsc_host_scan); - work->host = stor_device->host; - schedule_work(&work->work); + host_dev = shost_priv(stor_device->host); + queue_work( + host_dev->handle_error_wq, &host_dev->host_scan_work); break; case VSTOR_OPERATION_FCHBA_DATA: @@ -1747,6 +1741,7 @@ static int storvsc_probe(struct hv_device *device, host_dev->port = host->host_no; host_dev->dev = device; + host_dev->host = host; stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL); @@ -1815,6 +1810,7 @@ static int storvsc_probe(struct hv_device *device, create_singlethread_workqueue(host_dev->work_q_name); if (!host_dev->handle_error_wq) goto err_out2; + INIT_WORK(&host_dev->host_scan_work, storvsc_host_scan); /* Register the HBA and start the scsi bus scan */ ret = scsi_add_host(host, &device->device); if (ret != 0) -- 2.7.4 From 1583411781402104151@xxx Tue Nov 07 12:52:28 +0000 2017 X-GM-THRID: 1583411781402104151 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread