From patchwork Tue Apr 25 20:53:53 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: 9699755 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 4C67D60245 for ; Tue, 25 Apr 2017 20:54:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BC5728484 for ; Tue, 25 Apr 2017 20:54:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F14C2848F; Tue, 25 Apr 2017 20:54:14 +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 7852628484 for ; Tue, 25 Apr 2017 20:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1954553AbdDYUyM (ORCPT ); Tue, 25 Apr 2017 16:54:12 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:3120 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1950873AbdDYUyK (ORCPT ); Tue, 25 Apr 2017 16:54:10 -0400 X-IronPort-AV: E=Sophos;i="5.37,251,1488816000"; d="scan'208";a="13850808" Received: from mail-by2nam03lp0055.outbound.protection.outlook.com (HELO NAM03-BY2-obe.outbound.protection.outlook.com) ([216.32.180.55]) by ob1.hgst.iphmx.com with ESMTP; 26 Apr 2017 04:54:04 +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=pG4BTUnFjljrLzBM9IYq1o9/rl2e1qFgHkr8FnILzcM=; b=TvDFzXYV0Rg8Gq+CwPMEbqW2frdV6sQFFLoY8yAt2vWlY3LKc2zWEFR3k7zJnM3FOZIOWQzY8Zkpp4X4BEBLZL1QrbBKjndiiilsLaCJv1hY2Exz7kGJF9oSGuV1sc5Dv0+T7VMaNUe58OR17qx/j6tT5N4PdPx6L6ErZ4zz03M= Received: from CO2PR04CA0120.namprd04.prod.outlook.com (10.165.95.22) by DM2PR04MB413.namprd04.prod.outlook.com (10.141.102.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Tue, 25 Apr 2017 20:54:01 +0000 Received: from CO1NAM04FT040.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4d::200) by CO2PR04CA0120.outlook.office365.com (2603:10b6:104:7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13 via Frontend Transport; Tue, 25 Apr 2017 20:54:01 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by CO1NAM04FT040.mail.protection.outlook.com (10.152.91.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1047.9 via Frontend Transport; Tue, 25 Apr 2017 20:54:00 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 2E.7F.29323.767BFF85; Tue, 25 Apr 2017 13:53:59 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Tue, 25 Apr 2017 13:53:56 -0700 X-AuditID: 0ac94369-548749800000728b-d9-58ffb767553a Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 4C.8A.18148.467BFF85; Tue, 25 Apr 2017 13:53:56 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , James Bottomley CC: , Bart Van Assche , Israel Rukshin , "Max Gurtovoy" , Hannes Reinecke , Benjamin Block , Song Liu Subject: [PATCH v5 3/4] sd: Make synchronize cache upon shutdown asynchronous Date: Tue, 25 Apr 2017 13:53:53 -0700 Message-ID: <20170425205354.21181-4-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170425205354.21181-1-bart.vanassche@sandisk.com> References: <20170425205354.21181-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRmVeSWpSXmKPExsXCddJ5kW769v8RBsfWSlt8uXmF2WLPoklM FjcWr2Wx2NjPYdF9fQebxfLj/5gsTj86wG7x8/AZZgcOj4nN79g9pk06xebx4NBmFo9n0w8z eXx8eovFY/Ppao/Pm+QC2KO4bFJSczLLUov07RK4Mq6938BccFii4sbDScwNjO0iXYycHBIC JhIfXrezdzFycQgJLGWS6H+1kwnC2cEosaLtKTtM1cWZ66ESGxklFt9tYwFJsAkYSXx7PxPM FhEolLi0rYMRpIhZoJtJ4s3mWWwgCWEBX4me1sWsIDaLgKpE459FYDavgL3EtpbJLBAb5CXO btnJDGJz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RJLcUaioRZzUXEiALWpgHTaAQAA MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39450400003)(39840400002)(39860400002)(39410400002)(39400400002)(39850400002)(2980300002)(438002)(199003)(189002)(9170700003)(8676002)(356003)(5003940100001)(36756003)(2906002)(48376002)(8936002)(81166006)(50466002)(189998001)(50986999)(76176999)(5660300001)(4326008)(33646002)(575784001)(47776003)(54906002)(50226002)(1076002)(53936002)(106466001)(305945005)(6666003)(2950100002)(38730400002)(86362001)(77096006); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR04MB413; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM04FT040; 1:ByRH73IiM4bSGHh4X8CISdcTiplIhz7Wnf2foh1lVh6ABypLGChn/ndwTulG0oKxYhSO5Ik3hbKVL7wiymX6h/iM1pij5ffIAT0wGA1awUDyyyn1YcDkl8bLd2MnVCgZzHzk2lfRU3JDBXSQmlWV7aWWvTw1eaAFsZ7ZKNoPh+331QQDIIPnS08OJy8bzWIQfhyAXTO5zoOssmnavVAEi7sL9UQZcM+fRhI/2daEgrijlYkERoo8mCGWmKTmDVnKb403kmMuxa2+LC1e5E/ek8CiDqa4+IKGtbTAltdr7gYdjLa6u87vzfz0iALxt18EvYa772G/NCvjSsf4wV0Ja9NN0/+q704OCRmA9JKxo+p1M6xMdSudoVgcd7VgDx3ms+lW8YPgncaRI+GyAgY0FXdObCDR1fryio6yEGaqNHI53o2xb2Wlehv9SmgPG6YMcSpyIb5IJEtnAAefzLrJ6uxVH76JGFpc9Ivo7vMCP/3AG7qJRfkgHhXnQ0qcJyMK5JGNEoQzTGXlBUNCIR3PhKOim+3i0fRP/lBNptDp8J5gT9PrEzxyqGDRyHnKJzFo X-MS-Office365-Filtering-Correlation-Id: de7c2487-4537-4af3-b553-08d48c1d3375 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081); SRVR:DM2PR04MB413; X-Microsoft-Exchange-Diagnostics: 1; DM2PR04MB413; 3:LVTutf4Cggrr0T08TOhTO98OPsfPLr8vCKecXwHyZ+TdIf+dxecdmZXyBDCV8HesYqTDcF2oKopB7PBOULFOGssxah8HCPWrChZkdCRCSnq28eUbos5xw0Jnq/bhFv3n1oNFiACn7gYbk01i6QEmWH3b+3mnN5zpxi9JstRVNZR/6PLadL6556gWvJZjyvsQlGFmj/r5mituSnASMSVZ0weg49C67KNdYukhvCRUhdkA+I4c5qRSS3We3PRHmVS1sJ33Gic2WPDCN4YScqZT4219tGs08hUi9vxjcpjD8JdBpTGLdZEjbufZj+ah85Db5Dt8YDezFqU2OIbZBRPlZqRIx5PAqHYr9Y1/3e5jcKG218tKROP07h9foUdYkdnrYHk64z2QA6O1pXc5Jf5N78mmP0/gw4h+YEZEeas8E/VN37evEvlkGt7vJQzzrVpN3llZVNVQdlMVaa0nApiVzpbX0x13iDsuj9oG3qqmeN8DD+vHwVLs4VXTLBW5k4gV X-Microsoft-Exchange-Diagnostics: 1; DM2PR04MB413; 25:IH8rMnrq4NEANR2IpVJ1SMcMSSwblN/Lu3Q6rlbxgrEopi3baCe9oFC31bk8U3er0M7qLqg2lrcQ9OdXU85hqBdmp5bS6UH3MW6yru2FHyilsJRmBrQGyHRTch2GyUoY9PjfFczk59dsxdKy7SzZnrnM2FShzzwvpyp+hFE3ldEfTAfd8khwJxPJTSbF0OD/vRwp89WQKDn1icDuvmD4PjQrxfIvVkjBMnA86v77gXh0W89qM6yumxn6ZNpuKrW6Re2E73qsTxbDMBjDvQQ9VUh1hewxdWMLi+PIKNbD4d3o1dFfSRD8XGzwPK9KJeLcKFDbgLS3AfvkPeZwS/F9bR45UjNAvl4SnFNMgu+zIsb0qr2f0XXJNIunacxBOwtySUTNn7JMUDRjm2GGBUGAOJB26d4wB2fgwV6UFYV/KLiRQNN5BRG1y7GuR4mGa/yYaM8s7QSuyws4ucqMd2xrJA==; 31:1y6xErJqeidfufQJtKcU2Pb4Q3sCSgxs8JzoQRsyjCJlJnkVtBN/vWPkb3efNvv/Cu1wu/1bahOZaOUiFqNJ5Cv1ep8bCqNfyj++go+fDbKFbRDMjbR6n9/UutdQPsmstlArGmQiCG2fENm3eCM76f7O2Y/oqN2YEZjJLSdVPEyotpHKpTLL7YAHMCC0y+cCC1lmxfNBOm8M+TLrd5Gvjdb5ofO7c/cZGTbEBwGWmFzhu+damkpRkna9NyEgInk4d4DwNGjRz9zI3fho9mlsUA== WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; DM2PR04MB413; 20:lFSh+EilsmzqwUv3FEknp/ozRoFEQjaoMXtfiksuGP6vHc2/kzjeo+0bMT/S7+jCUdViNvGT7UEVyQ/m7pEL5bhbIxdsND2w3C8dL1PKN3KX42PZ0hzsS5iUQMAdmohlPEBAvfpiE61Ws6fMsFmMOGpvJpP/m/euuoG8pNQqiV8wpuQE2QzJoIUzH+ECtLhtdcmhvMIrIXBtpJiUei4QSVWCGg0FJ4t05S0nIN/eusJDYKAWxBv0m/kzkcjWcPGd/e73k9m3I/ZyeG/UsuG28LCI1jAuEhoB6an3Z1UtzcHWmxZZAJ1DVxmkANMcHQOInwrs7ZneUxh1LrpiGazKgNRg7awKtJK46XmQsP2hjUev2/aHELW++rid6GIPFxDS4LaSp3C3+2p8qM2mVScCbQkQFBDVYzQKR4f5V6RpEOgan7eVmWbH/GRBBm80HpZLgNa2UHVhCkPZthV/sx1ageAy8q/H7F3Abo1hFAOF/U55QEEUSxu4srfTjP8vGznp X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484)(104084551191319)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(13018025)(13016025)(93006095)(93004095)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(6072148); SRVR:DM2PR04MB413; BCL:0; PCL:0; RULEID:; SRVR:DM2PR04MB413; X-Microsoft-Exchange-Diagnostics: 1; DM2PR04MB413; 4:bY0z6p2U2G6ZUJLGsBPCsQ83lyngCpeLR9aRxwbDtrjiURTfdOJFxUsQTmt5mKwnUONewL8dStNZLd1Y7hlxtNhZ5630PBLeFpfuNQanBs08JNC17A4AixBGnm3ZvmNKCrqfE1oc2eQDlNwDSdJyAULh9d8Qx9GsOoULB2HUljDZsw5mwMQWChgoKzx/Mu4olry8A+ejrAYrcLO+x5jsXkbtQJmOBZdzr05hCufpr+GDgHDQ+Fi5GlV8tFnXWRYVkqatuVrFYCBNkB+kh5thJzQJAFq9y7CzA/beMLzsVTYcyK1H1Tooi72mgV5bRNpOFqMgDo1VHLqGP5GxiUISbpC4V38rV7H6B5L+2f8oJRve6l7p+UFSMbcW0ABlNN2d+I4L9WYND/7uasPIjRuBex88Zz4aeX/tWSrqzF0BgPK/2aOy9AUkuwBbxlCIsCp6cAdzV3GslCNffm6jw9iTJ+ze8x5tYQW5IffvZxZY5zd09PpkjOfPVsrlHBW9piy0JVniEu/+c5LroNwz66od0eosum0yI+VfkV9p+qZJvtkXiFRtCUuTKxBY6pDtV/6m+No889kSD086it2+yQkbiZE+eKSW3xYO4vhvdbupj4CASWhZ1+tHogNvdiYlpmrSPFO3aTP9KLvtQCMQBDjTtf78JY2bJS3It7xJmHRQ8fBY5btTHrJJHuhfIL6xiMkNevQZh+Pbj9WeXgDwZljh2ORpCTCdxFYu/uJwUGYAAusICaZysDc7VMpLH+rtHwBz19783NKxD2p83bYPBm5djrYNEJjPhjDzXONSKk03dUdeNCx6CipaxnAuINYK+AiNXNiWY2w+XUMX98njXwJgHSzc2tFouW4ownXaxK9vnSdLCeSq0YPBaOnM//MZdwTo X-Forefront-PRVS: 0288CD37D9 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR04MB413; 23:km6PEdHfDFZFPkRt+C8r2JnwCDdqwjuXKFiN+VvmPg?= =?us-ascii?Q?nyPTzZpARQw5KX1VRBPhJRjbk+kbocQacf/kmAKncGudq5IwixTVMGe/V6Ui?= =?us-ascii?Q?BLTF6NRGaoJqMcwxdqHmAHBKVUlcML2YQGPyft6lj2UpUCazGd/fiiRQncbd?= =?us-ascii?Q?2lh5gy0znj7RhLk2kT797E2A4h64Tre10DzEl1TEaARppxePSyGzaWOaJPez?= =?us-ascii?Q?PKiW8UgLssztV/zROyR6VgsDIlBSOZn3rnfCkjowYINf6ofqZaXP7MvTcNyh?= =?us-ascii?Q?kh2LrkVibUa9knus7TxDhS1b5arM4by7nUyNhTSEU1h310zGQGUPbNjXHMGi?= =?us-ascii?Q?VPWs9AOMYpuDSZ6RULP7RbDQ95yOwCSEjpvgfaYyVY8cF27Bb9aL58zV0/AL?= =?us-ascii?Q?fFW2lZLfoTnAa6IWJNfGuQxJBiaRuxe2nzX7IApo+2YQzVMBe967ZiRDBf0s?= =?us-ascii?Q?cUAF2qmDzTrDoolZyqsXcmTybzNtQ82veLGKZ4s0k0oK3uMaDfNn8WIiVDKl?= =?us-ascii?Q?V8svR4fH6YYusRRYI9t6h4342Tdd2ha44pHaSbewtyQwwsVuTkkEPX3gIk3b?= =?us-ascii?Q?c2Mgv7MaY1WdOBjYGrdeLRd4k4AEJZ77756LT+qNLzneRkr9UgEp6yKUwjoR?= =?us-ascii?Q?oT/NqApRJdQK7k6WWHqENVrt0dpJTDEEFfiMiORxnjkcxEaI/0KqxZsanCG6?= =?us-ascii?Q?98nR+5ZtTf9pcDnOI4cItO0zmyEmQyuUbdxBVxEDApu79G7+kac1mkXjMaYs?= =?us-ascii?Q?z58Savz7fDqneQbB5nGb+tzGHhYWIT9OX9Gcizf62vS8HtDXizXrF3xKRt7I?= =?us-ascii?Q?3lbn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gIR14prnmyX5rSwVxpQ4cFEahtpQAhRFqiMX5HpcrVAK8zJSDVPtkzK0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR04MB413; 7:gJTaN5nm06O0hHfRaLTAamTzuOKTxj7hQbwNuC01EcbNkOUyYAUBOoTHqBmPohybZmNW6pVjWL6M8qdI8GnEO6X9OSWaGEXzw2ySyJvn74K/gyE/hnqnPoJ5C3GCkNfV/t+YxeE/d470onWnoxHImLTR3+pO/SbeN1b9pn3wqIXOasiOUhFtYP8poXM+P+2UkvF5Yg0S1/tPQ1G3Ka2Ez/K2P4Sh6hGuqy1jD3u/dxPmpRB9peOWokNhYj5aFiyfv/PfFckSotdzL4vyjV8Q+Un8M9sXWx421pNEQGyDFurEz4iFNMBAH0G39u4Y5/9af5aRcYK+fujMw8EobjvcOQ==; 20:r4PomKEE6QZg1sR3ayLnP/jFwHRHZN/S82LgGCh68W7gXFLyS2DEwaDNTUmgZwe1XQAkA1osV0rhmo+dtfMjxSNEFSh4MzoPo5XXUIfZJqURZaRvcs1MfyIwIU01gmN/g3JkQkntbM8MB9bpL9FmdhwJ0+/0eJdNIMCadGdK8Q0= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2017 20:54:00.6687 (UTC) X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b61c8803-16f3-4c35-9b17-6f65f441df86; Ip=[63.163.107.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR04MB413 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 This patch avoids that sd_shutdown() hangs on the SYNCHRONIZE CACHE command if the block layer queue has been stopped by scsi_target_block(). Signed-off-by: Bart Van Assche Cc: Israel Rukshin Cc: Max Gurtovoy Cc: Hannes Reinecke Cc: Benjamin Block Cc: Song Liu --- drivers/scsi/sd.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index fe0f7997074e..75575fc1b2d8 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1489,6 +1489,33 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) return retval; } +/* + * Callback function called indirectly by scsi_end_request() after the + * SYNCHRONIZE CACHE command has finished. + */ +static void sd_sync_cache_done(struct request *rq, int e) +{ + struct request_queue *q = rq->q; + + __blk_put_request(q, rq); +} + +/* + * Issue a SYNCHRONIZE CACHE command asynchronously. Since blk_cleanup_queue() + * waits for all commands to finish, __scsi_remove_device() will wait for the + * SYNCHRONIZE CACHE command to finish. + */ +static int sd_sync_cache_async(struct scsi_disk *sdkp) +{ + const struct scsi_device *sdp = sdkp->device; + const int timeout = sdp->request_queue->rq_timeout * + SD_FLUSH_TIMEOUT_MULTIPLIER; + const unsigned char cmd[10] = { SYNCHRONIZE_CACHE }; + + return scsi_execute_async(sdp, NULL, cmd, DMA_NONE, NULL, 0, timeout, + SD_MAX_RETRIES, 0, 0, sd_sync_cache_done); +} + static int sd_sync_cache(struct scsi_disk *sdkp) { int retries, res; @@ -3349,13 +3376,15 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start) } /* - * Send a SYNCHRONIZE CACHE instruction down to the device through - * the normal SCSI command structure. Wait for the command to - * complete. + * Send a SYNCHRONIZE CACHE instruction down to the device through the normal + * SCSI command structure. When stopping the disk, wait for the command to + * complete. When not stopping the disk, the blk_cleanup_queue() call in + * __scsi_remove_device() will wait for this command to complete. */ static void sd_shutdown(struct device *dev) { struct scsi_disk *sdkp = dev_get_drvdata(dev); + bool stop_disk; if (!sdkp) return; /* this can happen */ @@ -3363,12 +3392,18 @@ static void sd_shutdown(struct device *dev) if (pm_runtime_suspended(dev)) return; + stop_disk = system_state != SYSTEM_RESTART && + sdkp->device->manage_start_stop; + if (sdkp->WCE && sdkp->media_present) { sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); - sd_sync_cache(sdkp); + if (stop_disk) + sd_sync_cache(sdkp); + else + sd_sync_cache_async(sdkp); } - if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) { + if (stop_disk) { sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); sd_start_stop_device(sdkp, 0); }