From patchwork Wed Apr 19 18:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9688631 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 B255D6037F for ; Wed, 19 Apr 2017 18:42:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6AD92621B for ; Wed, 19 Apr 2017 18:42:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 991B92845D; Wed, 19 Apr 2017 18:42:11 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDFD42621B for ; Wed, 19 Apr 2017 18:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968977AbdDSSmK (ORCPT ); Wed, 19 Apr 2017 14:42:10 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:16794 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966942AbdDSSmI (ORCPT ); Wed, 19 Apr 2017 14:42:08 -0400 X-IronPort-AV: E=Sophos;i="5.37,222,1488816000"; d="scan'208,223";a="12309156" Received: from mail-sn1nam02lp0016.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([216.32.180.16]) by ob1.hgst.iphmx.com with ESMTP; 20 Apr 2017 02:42:07 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=zdkgLi+OFiaaYsiMI6xsv9KVeoqB4IEGVktolUVZoOw=; b=kpdhKjyTjbSLgoA5+go5ivlQaN/tHBJn2vGAaCOJLWh+6ma71gfVGIO+eO9YY4UWUBMuHZMFtZfIMZj0vZg7ekawI9CkFWEwXdbWqGScGKba44hFFudCDrszpx607kzD9JzDPotLW7jJwtycHBZGkLu/ms86Tv+5g5Gqv5yD9Vk= Received: from CY1PR0401MB1536.namprd04.prod.outlook.com (10.163.19.154) by CY1PR0401MB1536.namprd04.prod.outlook.com (10.163.19.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Wed, 19 Apr 2017 18:42:05 +0000 Received: from CY1PR0401MB1536.namprd04.prod.outlook.com ([10.163.19.154]) by CY1PR0401MB1536.namprd04.prod.outlook.com ([10.163.19.154]) with mapi id 15.01.1034.018; Wed, 19 Apr 2017 18:42:04 +0000 From: Bart Van Assche To: "James.Bottomley@HansenPartnership.com" , "bblock@linux.vnet.ibm.com" CC: "linux-scsi@vger.kernel.org" , "maxg@mellanox.com" , "israelr@mellanox.com" , "hare@suse.de" , "martin.petersen@oracle.com" Subject: Re: [PATCH v3 3/4] sd: Make synchronize cache upon shutdown asynchronous Thread-Topic: [PATCH v3 3/4] sd: Make synchronize cache upon shutdown asynchronous Thread-Index: AQHSt6Dnu2fwIPQi8EGD3QG5BkWsKaHLNU+AgAAUGACAAIONgIAAAoEAgAE6j4A= Date: Wed, 19 Apr 2017 18:42:04 +0000 Message-ID: <1492627323.2543.11.camel@sandisk.com> References: <20170417173436.15555-1-bart.vanassche@sandisk.com> <20170417173436.15555-4-bart.vanassche@sandisk.com> <20170418144429.GA28949@bblock-ThinkPad-W530> <1492530984.3306.25.camel@HansenPartnership.com> <1492559235.2689.27.camel@sandisk.com> <1492559772.3306.58.camel@HansenPartnership.com> In-Reply-To: <1492559772.3306.58.camel@HansenPartnership.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: authentication-results: HansenPartnership.com; dkim=none (message not signed) header.d=none; HansenPartnership.com; dmarc=none action=none header.from=sandisk.com; x-originating-ip: [63.163.107.100] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY1PR0401MB1536; 7:/5u5B7uEMFEFCMcqRpFlgkPFMT+v7+WB7ufGoYL87FEO5bT+I/J0fzvrxMYSQQhr5cV2Y4GYmh5c1xicQ4Iqr/8XzvmBx7h/d7ZUDfNThN+3dmeIv7bPBKIT1XcDEQZY170r3e6n+0OehyYFGJmZg5E8htsfNln2BpM1Igz14lq7ulfVYtstVcwCfz0Qp/azdFOA8AkZHaa9wIzzWB45BvedtGELlH0AHE+FUX3D/2XNoBNrY798m/5Ee93W+qwNlcDyZLSC8TO7zydCjXIy1ZEj7VF23D5KH27qqLfn5n+F7YvUoYyOXFNUhzy4Py0Cqdvc3VtI+PaTXQOCTdOQEg==; 20:LL6WF7rcMlK2jXy/DTcmZQiqyhURpcxCADjV9qCT59b07az/NgkPgFFBENQEEH3aY5Duivf8Ave4kyr/o4zFWRPDGjYe/0ojxqqeWqGCB0AaB7bofDAaXnMtujvgxvGmydnPFCsFiarKvCZnO96CgPOw/JMVwH/nkt2/8hYoshk= x-ms-office365-filtering-correlation-id: a3c5dd5d-41ac-4ee5-c6a9-08d48753c687 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081); SRVR:CY1PR0401MB1536; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415395)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123555025)(20161123564025)(6072148); SRVR:CY1PR0401MB1536; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0401MB1536; x-forefront-prvs: 028256169F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(39400400002)(39410400002)(39850400002)(39860400002)(39450400003)(39840400002)(377424004)(24454002)(54906002)(86362001)(99286003)(6246003)(38730400002)(53936002)(66066001)(2900100001)(6512007)(103116003)(81166006)(8936002)(8676002)(122556002)(3660700001)(2906002)(33646002)(3280700002)(6506006)(6436002)(5660300001)(305945005)(2950100002)(76176999)(77096006)(6486002)(99936001)(50986999)(54356999)(189998001)(36756003)(229853002)(25786009)(102836003)(4326008)(6116002)(2501003)(3846002)(93886004)(5890100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0401MB1536; H:CY1PR0401MB1536.namprd04.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Apr 2017 18:42:04.6152 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1536 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 2017-04-18 at 16:56 -0700, James Bottomley wrote: > This means the combined 1/3 3/3 patch looks like this: > [ ... ] Hello James, The two attached patches pass my tests. How would you like to proceed with patch 1/2? Would you like to submit it yourself or is it OK for you if I mention you as author and add your Signed-off-by? Bart. From 540cd36d79a46c634368365d3f0f5b8adf4fd687 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 18 Apr 2017 10:11:02 -0700 Subject: [PATCH 2/2] Make __scsi_remove_device go straight from BLOCKED to DEL If a device is blocked, make __scsi_remove_device() cause it to transition to the DEL state. This means that all the commands issued in .shutdown() will error in the mid-layer, thus making the removal proceed without being stopped. This patch is a slightly modified version of a patch from James Bottomley. Signed-off-by: Bart Van Assche Cc: James Bottomley Cc: Israel Rukshin Cc: Max Gurtovoy Cc: Hannes Reinecke Cc: Benjamin Block --- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/scsi_sysfs.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ffa6e61299a9..376cd1da102c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2611,7 +2611,6 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) case SDEV_QUIESCE: case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: - case SDEV_BLOCK: break; default: goto illegal; @@ -2625,6 +2624,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: case SDEV_CANCEL: + case SDEV_BLOCK: case SDEV_CREATED_BLOCK: break; default: diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 82dfe07b1d47..732f1873f2fb 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1282,8 +1282,19 @@ void __scsi_remove_device(struct scsi_device *sdev) return; if (sdev->is_visible) { - if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) - return; + /* + * If blocked, we go straight to DEL and restart the queue so + * any commands issued during driver shutdown (like sync + * cache) are errored immediately. + */ + if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) { + if (scsi_device_set_state(sdev, SDEV_DEL) != 0) + return; + + scsi_start_queue(sdev); + sdev_printk(KERN_DEBUG, sdev, + "Changed state from BLOCKED to DEL\n"); + } bsg_unregister_queue(sdev->request_queue); device_unregister(&sdev->sdev_dev); -- 2.12.2