From patchwork Thu Jun 1 23:27:03 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: 9761357 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 6287A602BC for ; Thu, 1 Jun 2017 23:27:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5389428524 for ; Thu, 1 Jun 2017 23:27:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 484BA28544; Thu, 1 Jun 2017 23:27:43 +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 6B4D128524 for ; Thu, 1 Jun 2017 23:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751195AbdFAX1k (ORCPT ); Thu, 1 Jun 2017 19:27:40 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:34903 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751114AbdFAX10 (ORCPT ); Thu, 1 Jun 2017 19:27:26 -0400 X-IronPort-AV: E=Sophos;i="5.39,281,1493654400"; d="scan'208";a="119187215" Received: from mail-bn3nam01lp0183.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([216.32.180.183]) by ob1.hgst.iphmx.com with ESMTP; 02 Jun 2017 07:43:46 +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=1F4iMiWMUKsxnzQ0T1Ul9Fpqkd7VR9mAecx+w8s/eqY=; b=dNuMctiwy5WAr0mP4tuFCyYe7sbSUOkToXKzn90CGUxyHpOpWYn5Ld9QL42HWh2/iroadxhrvKBtyVlGg1USV2kNr7t+oax395+ys5RpsE8mQNhf/8oSV2rrsz7flR8L7TNDynweu1W6rSouM4AxA1MlHvNZzapMaPgm8J3VSgs= Received: from CO2PR04CA0003.namprd04.prod.outlook.com (10.166.88.13) by BN6PR04MB0386.namprd04.prod.outlook.com (10.173.198.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Thu, 1 Jun 2017 23:27:21 +0000 Received: from CO1NAM04FT047.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4d::207) by CO2PR04CA0003.outlook.office365.com (2603:10b6:102:1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10 via Frontend Transport; Thu, 1 Jun 2017 23:27:21 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; HansenPartnership.com; dkim=none (message not signed) header.d=none; HansenPartnership.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 CO1NAM04FT047.mail.protection.outlook.com (10.152.90.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1101.12 via Frontend Transport; Thu, 1 Jun 2017 23:27:18 +0000 Received: from MILHUBIP03.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 25.A8.51736.4D2A0395; Thu, 1 Jun 2017 16:27:16 -0700 (PDT) Received: from milsmgip11.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Thu, 1 Jun 2017 16:27:14 -0700 X-AuditID: 0ac94369-6dc8f9800000ca18-9c-5930a2d4c77d Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 2E.83.11415.2D2A0395; Thu, 1 Jun 2017 16:27:14 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , James Bottomley CC: , Christoph Hellwig , "Bart Van Assche" , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH v2 04/12] Protect SCSI device state changes with a mutex Date: Thu, 1 Jun 2017 16:27:03 -0700 Message-ID: <20170601232711.29062-5-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170601232711.29062-1-bart.vanassche@sandisk.com> References: <20170601232711.29062-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsXCddJ5ke6VRQaRBiePSVkseLOXzWLl6qNM Fhv7OSwed81gtei+voPNYvnxf0wObB7TJp1i89h9s4HN4+PTWywe67dcZfHYfLra4/MmuQC2 KC6blNSczLLUIn27BK6MDXc/MBd0eVacP3WKqYHxsk0XIweHhICJxIRzel2MnBxCAkuZJA58 VOxi5AKytzJKrJt0lAkkAVIz79ledojERkaJXfNXM4Ik2ASMJL69n8kCYosIFEpc2tbBCFLE LLCHUaJlXwtYkbCAh8T/nossINtYBFQkXv1XAQnzCthL/Fr1ghVigbzE2S07mUFsTgEHiX0t Z5ggLrKXaDo8mw1kpoTAIlaJ05sWskE0C0qcnPkEbDGzgITEwRcvmCEa1CVOLpnPNIFRaBaS sllIyhYwMq1iFMvNzCnOTU8tMDTVK07MS8ksztZLzs/dxAgJ/swdjHefeB9iFOBgVOLhfSBr ECnEmlhWXJl7iFGCg1lJhHfdfKAQb0piZVVqUX58UWlOavEhRmkOFiVx3nMyUyOEBNITS1Kz U1MLUotgskwcnFINjMaOXvyX1nImfSr6c82kXGhCb1nKxSupjx2Wz/e4Mpfb2XZP8fYoidb6 5E3e/w/ES6YzTv714YQS238v3rrMc+YfoxknepRaqX/yO2+0XSpr9uEnn89+Xd82I+mIXk+c JFedp73t6dmHha8K7HNoZPz2amHKw09dbBYcT7UTD8z7G6/729rCT4mlOCPRUIu5qDgRAEwc fz96AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJJMWRmVeSWpSXmKPExsXCtZGTTffSIoNIg3+nLSwO/mxjtFjwZi+b xcrVR5ksNvZzWDzumsFq0X19B5vF8uP/mBzYPaZNOsXmsftmA5vHx6e3WDymrTnP5LF+y1UW j82nqz0+b5ILYI/isklJzcksSy3St0vgythw9wNzQZdnxflTp5gaGC/bdDFyckgImEjMe7aX vYuRi0NIYD2jxOT+fawgCTYBI4lv72eygNgiAoUS90+fZgMpYhbYxyjxuPUNG0hCWMBD4n/P RbAiFgFViSufNzCD2LwC9hJHpt5lh9ggL3F2y06wOKeAg8S+ljNMILYQUE3T4dlsExi5FzAy rGIUy83MKc5NzywwNNQrTsxLySzO1kvOz93ECAmcyB2MTyeaH2Jk4uCUamBs+mcnVe8dLOgb wX9303tZJbHWs0kaFxn2vJiy88nGzuerhG5KTHYSZOjSPzxvR9x/87vpZdeXTW9hmPDyXLr9 zL+xNvnXbrTrP5ELSFsr27l/mrXi5y3nRCKPBFz8d7L6+7nvj9UC1W45PMx5/b12wXMXxfVX c3Yv88kKTl/abpzwO0t9Xk6mEktxRqKhFnNRcSIAHy9ShMwBAAA= 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)(39860400002)(39400400002)(39410400002)(39840400002)(39850400002)(2980300002)(438002)(189002)(199003)(9170700003)(72206003)(5660300001)(478600001)(54906002)(2906002)(5003940100001)(50226002)(53936002)(47776003)(38730400002)(48376002)(4326008)(8936002)(8676002)(81166006)(305945005)(77096006)(189998001)(36756003)(1076002)(50466002)(50986999)(6666003)(106466001)(2950100002)(33646002)(86362001)(356003)(76176999); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR04MB0386; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM04FT047; 1:DlF+8hWdxpp6Iro47/8R5lBCw0Ye9nxwndePOWO0uyZ3tjmocle4sn6xmU5KBubeuhrhjXcYI0JGah3erf2Hpfr/099QNGAK8mQZ3rilZLlXWOOZhGXUkgsNrcT7CwOtd/unwjFD6fUOOTnJG+yWQqPQvgJTnfxksQWmcXENbqQ1xy8ZmxkpnoRUG3jEKKuEkj+OCHxA9dW/TpBTU+TCOSdSHWx95OTACscNxPeFhkJfFzpBm+uQr9XQH/KMgsQ3N88mWMMGmBp56w6V6CJ7C77PDAlxcqJHjcqNSSkb+lIpBXgsDsrq6vp2lU98X0xCB+PfO5zDSJkTbihNaVJOBjPfp05tO+dtiNlHNVS//1UGYAEboDUfVS/J1BzPeiWaf2eg34HX/viOyBF2A4q2Opp8sbOiiX3U9lGKbACc39NdxKNVuhrOQ+d/tvgnNgDBI3aV0SO5GEeYTlD1FinkDKCqhhgexrh2aXjVTKuSlz5s+Qksgod0jcAW1dMPQ6JXkcGRbHUCeJBu3Dp6iYvhmNihEfhvdgVtnDZNEfMHMHYSKpM4dbGCGHGiEsjoBlwo X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN6PR04MB0386: X-MS-Office365-Filtering-Correlation-Id: 4f688de3-317c-4999-0f86-08d4a945c026 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:BN6PR04MB0386; X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0386; 3:fLRnE/xlnK0vLmt1y9KZb7qUiHvik/4tP3KRRBZd5qQurH0m04UnF3AxahTFSeR6hLpnrxDhAgOHMmK8JUlTtjjFMF63TAlOiAla40/njpYlTotFVuJPryKL0amjpcHIaWpgNDHQkSJ9Ld7/2J+NqgYPvTl5Wd+piN1RuKBGpEsse7tKgV/hprrfFT4abtjIL7KRbznWfFl55Vcn4TSrEDfC/Ifv1dfgz9WB5rsTntAt4Y/Os8iWiX6duZbF7aLrVY2wuQ3Z6Tdt9sNoaYhIXxxjADhhdcmZgA5oTQR0rLThGh8jbvtTwR5DjWaE/VfY6QUrVNKOaEFL6sdWk5EWjsJFoUeSlc8pJB4ZzvXbo+rE8jFoSDVFdOCULBwYpDp6nByNcwbSZZTWV48vsagSoIRmXegZg8ClX3BHqvgdUWMmExlzJk6AEbU3QUn4lusqp3KWVUZeM3MrpUjB0DfKxNV1/NwSRVyI0vKjZBvor/KmZx9Xr9gJCqaYa7ix+BF+A3zYEvuE3Hp9G2yit43DHg== X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0386; 25:947o12o/408LLcmeczjN+1Ic+pHX+0RRD16bFR0mutLeMw9b3yohfE5wobzMwQOkkjWnl5vI25uMGoSxfpWqXkfcLUdgDR0H7UC/YYy2/Go/8vZ9KcPeTj8XkUxlVfqzZj86n5US1+fXfTVvvy/bU8xfBLCFyToKMeD+CqzGhcZiy5Oe/Lx9fW0+dUEq2lp3T9iKTj07SwmOz8uCR+8DHzb/RcXNmVHBa2g0wvfwxpxdloEsL8gj+Bvj6pjYs4F0tCimxnteKvPhyZb+YnRg39ThVqVcZizgx+uaoE1D4mwBep3FOnNgudm9VdgYsrJuGrdVtltVummNJOiVDT6ogf3rPyZgcuV/PJsF2QE0Kmg+qw9gUoB8PShrN/ZXxSlgaZVvpyQancZMkCUKULFzvxTsesUBXI/029VbWbYLZmfMpqf8+vPmFb3Y/MxMYwYmllHPlvZjS5nIGx17nOkFwQzvl7214lZt8uqRfrBJfTQ=; 31:Kfz1v66uWe78+he7VY9s911uLJYEKe3438EwdRIhcl0M9gCD/SiMQG2fiTJf+YBdX9ub3dY+UPCT56OetjHGIE12ZJE94bXcx6S0IjDVHXMY8yZC8ufHN/1FMWZ3FILquIzbz7VBGJPFnatboqL4PISgM/QYS4oThrSwmoRbtijTaMFO1EHYI3TcQ8hfd33qOg4PcZiMa46y61InmfqigN2gm/IJ3djY7h877vZ695R2epuoqmnITr22+MNUU4tO WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0386; 20:aIvCq1ByZVleQ0a7+qf4xuzSyTQ4it9Bu1KN65tIV8hXB9tARj5KPN495iAoSDY3iNQo1a/BaXi5XC/Ptr/89iHB1tviXYMgQhcMyKzFnCsDXhZgP7s5aGrvKfMMaH6xfEmx3z2J0+vf6aj2//5BrJjm0inVGkzziTIOwtLBzmF3YUprvqlNXgotDdxqx9Ilpcg8DFCR/5MyeEmrsYq6LbGUhVOz9Ysb/BEvGOas/h8d1g8xp1VwDXmiQROJ3ETO33gR4MAoagKN0zqCQyE37t4X4OhcvfaUJRjDNOUSw9BJ2yNMbctsits1yb3loRPjdl2AVB8rvIlYInZEmAmt0h4G+KP10Bh8/bCEM+B5+54BMBY9N6JJC/Vmwj16WKuMmDn8IP8cCGA0zk8sxYq56kc8/YxKStQnDSLTj2T2hs45H0NIep8bZ4+YUORmYTCXKAQ4dsRplULTVuJMKnvuNxAboKH4zNrPSwkpEgayaKLU28QXiZsdMsK0OFwX0z2c X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(13016025)(5005006)(13018025)(93006095)(93004095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123564025)(20161123558100)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR04MB0386; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR04MB0386; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR04MB0386; 4:T+5D9iwAhlaZbhURThmO5WPOuTpZyUnot9FiyjLVZY?= =?us-ascii?Q?mYDnyXndZAT4r3v6wU1Gl971qOaMKwknC2unKWhfgRpOrgVYJtV+40V/94kk?= =?us-ascii?Q?x4+kM6mTNnlP3B5g1SZZSAUbOz9OSMk6BlimwxSXqGGnepX2UkV0dIylWAcv?= =?us-ascii?Q?xcRYX1/WbyFVYvtaFFlNYZkrrddnZgYE5syqOceaJtkHy3WXYemul5sPziTF?= =?us-ascii?Q?48+agaEcDZLIsx+iMT4cQcJNWqutZLAcF3k2xEXdYJsENlOG1O70MUu56Uki?= =?us-ascii?Q?ut/UciL0bQWRxV09nGLwVRY2QlU6uKlJxlSv3Z4Lzjtpi6DyE+20cP43UPtq?= =?us-ascii?Q?P4Kz6qyPTNKoxVQGo2j7ddOU0P7u431DEhsLMvJ5YzPTrr0h1LRjDjN8ibnt?= =?us-ascii?Q?UWEGAB3Aj2Ls+0aKdrVXkeYdPI/3M7Z8sldfq+sdxtI7LkDppMcqOQevD4iA?= =?us-ascii?Q?XhuZgkGBw2AqJ2NpCGvhhjJQKHt58HfybB+S0DzihT+wL7P0TZrDnGrt0YiT?= =?us-ascii?Q?uzpnYU8pNUQwPq7ohI+c4x2KLkx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OWLUWBfR7YtL56SqsOmryQ1HyTXTEJ+ULsSB+ifJmkUUeSC7GnSh7kU+ZCJ13/I64goUYAwE7glxBRTnW6P+n3gMbnCp35NkZeE8A2uNV23yDwsL63E2FiDDWmU3m8/N88zz8xtv/Cz7w1wJCdfDLF583U/aAUG7uxQeAwxBZEBO5Xjbo9V2aLuYjkss/BJuwB0XWdPQ; 24:dhJyVYgg+9Bkbg+NcZ5m9s8J3txyV/0RPi1Z/h87+5ljfxCdgXPlVD6peUZ/B4gJ86HdJOHuU3vgMyYS+T9Q6m1ODBUlClsdwbZ2m55ZMoM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR04MB0386; 7:2bTFw8860q5ejyhd7af4K638I6XQn6Vr/i9mAqWdFzja7moxCnHRBV4ktnYOSo+oT1WAgp6D9MhHgCIxNucF5e3f20lm6EZ74oXJ/FBwYbCDUGjSfCN0W6GrPqLjhH+omgZCrQ6VAZ+JUVy+o/rh2VV0mif410Ne7GHZGJKPNLB5OKQ2VFGItctfMgd9NRs7p1Dj2tU7Apyn5KKz0UWXGtrS5wkB6tJI1OH5VBAILfyz5BEXSCaMZrdEqL2XHqAT6qNNTMrxbpNpY8QRuPsta43DmVTxfRDM18iZyhXkDyXjBUQyDgL54vec9vIqeQTazugGbJxG6vtENlwYOzstNA==; 20:u20nNY3aZZczqVZXkfSJ/kkYSsRTsVZp2ONy6eBbkM/W0I2DWBcE7tqVML/CmJyF0rkO4ykaziBDlgdO4F0iEqWjkTDKKV1qjuBtEmA+thsqerGwOBMfxHhpcGsc2WbwtZcH+QOvRCdX9SQNnTN/8N0rdG/9YOQc1kf7LGIzviU= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2017 23:27:18.4510 (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: BN6PR04MB0386 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 Enable this mechanism for all scsi_target_*block() callers but not for the scsi_internal_device_unblock() calls from the mpt3sas driver because that driver can call scsi_internal_device_unblock() from atomic context. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn --- drivers/scsi/scsi_error.c | 8 +++++++- drivers/scsi/scsi_lib.c | 27 +++++++++++++++++++++------ drivers/scsi/scsi_scan.c | 16 +++++++++------- drivers/scsi/scsi_sysfs.c | 24 +++++++++++++++++++----- drivers/scsi/scsi_transport_srp.c | 7 ++++--- drivers/scsi/sd.c | 7 +++++-- include/scsi/scsi_device.h | 1 + 7 files changed, 66 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index ecc07dab893d..ac3196420435 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1628,11 +1628,17 @@ static void scsi_eh_offline_sdevs(struct list_head *work_q, struct list_head *done_q) { struct scsi_cmnd *scmd, *next; + struct scsi_device *sdev; list_for_each_entry_safe(scmd, next, work_q, eh_entry) { sdev_printk(KERN_INFO, scmd->device, "Device offlined - " "not ready after error recovery\n"); - scsi_device_set_state(scmd->device, SDEV_OFFLINE); + sdev = scmd->device; + + mutex_lock(&sdev->state_mutex); + scsi_device_set_state(sdev, SDEV_OFFLINE); + mutex_unlock(&sdev->state_mutex); + scsi_eh_finish_cmd(scmd, done_q); } return; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index aa84b77e41dc..845d47244e70 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2881,7 +2881,12 @@ static void scsi_wait_for_queuecommand(struct scsi_device *sdev) int scsi_device_quiesce(struct scsi_device *sdev) { - int err = scsi_device_set_state(sdev, SDEV_QUIESCE); + int err; + + mutex_lock(&sdev->state_mutex); + err = scsi_device_set_state(sdev, SDEV_QUIESCE); + mutex_unlock(&sdev->state_mutex); + if (err) return err; @@ -2909,10 +2914,11 @@ void scsi_device_resume(struct scsi_device *sdev) * so assume the state is being managed elsewhere (for example * device deleted during suspend) */ - if (sdev->sdev_state != SDEV_QUIESCE || - scsi_device_set_state(sdev, SDEV_RUNNING)) - return; - scsi_run_queue(sdev->request_queue); + mutex_lock(&sdev->state_mutex); + if (sdev->sdev_state == SDEV_QUIESCE && + scsi_device_set_state(sdev, SDEV_RUNNING) == 0) + scsi_run_queue(sdev->request_queue); + mutex_unlock(&sdev->state_mutex); } EXPORT_SYMBOL(scsi_device_resume); @@ -3011,6 +3017,7 @@ static int scsi_internal_device_block(struct scsi_device *sdev) struct request_queue *q = sdev->request_queue; int err; + mutex_lock(&sdev->state_mutex); err = scsi_internal_device_block_nowait(sdev); if (err == 0) { if (q->mq_ops) @@ -3018,6 +3025,8 @@ static int scsi_internal_device_block(struct scsi_device *sdev) else scsi_wait_for_queuecommand(sdev); } + mutex_unlock(&sdev->state_mutex); + return err; } @@ -3088,7 +3097,13 @@ EXPORT_SYMBOL_GPL(scsi_internal_device_unblock_nowait); static int scsi_internal_device_unblock(struct scsi_device *sdev, enum scsi_device_state new_state) { - return scsi_internal_device_unblock_nowait(sdev, new_state); + int ret; + + mutex_lock(&sdev->state_mutex); + ret = scsi_internal_device_unblock_nowait(sdev, new_state); + mutex_unlock(&sdev->state_mutex); + + return ret; } static void diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 6f7128f49c30..e6de4eee97a3 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -231,6 +231,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, sdev->id = starget->id; sdev->lun = lun; sdev->channel = starget->channel; + mutex_init(&sdev->state_mutex); sdev->sdev_state = SDEV_CREATED; INIT_LIST_HEAD(&sdev->siblings); INIT_LIST_HEAD(&sdev->same_target_siblings); @@ -943,16 +944,17 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, /* set the device running here so that slave configure * may do I/O */ + mutex_lock(&sdev->state_mutex); ret = scsi_device_set_state(sdev, SDEV_RUNNING); - if (ret) { + if (ret) ret = scsi_device_set_state(sdev, SDEV_BLOCK); + mutex_unlock(&sdev->state_mutex); - if (ret) { - sdev_printk(KERN_ERR, sdev, - "in wrong state %s to complete scan\n", - scsi_device_state_name(sdev->sdev_state)); - return SCSI_SCAN_NO_RESPONSE; - } + if (ret) { + sdev_printk(KERN_ERR, sdev, + "in wrong state %s to complete scan\n", + scsi_device_state_name(sdev->sdev_state)); + return SCSI_SCAN_NO_RESPONSE; } if (*bflags & BLIST_MS_192_BYTES_FOR_3F) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 82dfe07b1d47..a91537a3abbf 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -719,7 +719,7 @@ static ssize_t store_state_field(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int i; + int i, ret; struct scsi_device *sdev = to_scsi_device(dev); enum scsi_device_state state = 0; @@ -734,9 +734,11 @@ store_state_field(struct device *dev, struct device_attribute *attr, if (!state) return -EINVAL; - if (scsi_device_set_state(sdev, state)) - return -EINVAL; - return count; + mutex_lock(&sdev->state_mutex); + ret = scsi_device_set_state(sdev, state); + mutex_unlock(&sdev->state_mutex); + + return ret == 0 ? count : -EINVAL; } static ssize_t @@ -1272,6 +1274,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) void __scsi_remove_device(struct scsi_device *sdev) { struct device *dev = &sdev->sdev_gendev; + int res; /* * This cleanup path is not reentrant and while it is impossible @@ -1282,7 +1285,15 @@ void __scsi_remove_device(struct scsi_device *sdev) return; if (sdev->is_visible) { - if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) + /* + * If scsi_internal_target_block() is running concurrently, + * wait until it has finished before changing the device state. + */ + mutex_lock(&sdev->state_mutex); + res = scsi_device_set_state(sdev, SDEV_CANCEL); + mutex_unlock(&sdev->state_mutex); + + if (res != 0) return; bsg_unregister_queue(sdev->request_queue); @@ -1298,7 +1309,10 @@ void __scsi_remove_device(struct scsi_device *sdev) * scsi_run_queue() invocations have finished before tearing down the * device. */ + mutex_lock(&sdev->state_mutex); scsi_device_set_state(sdev, SDEV_DEL); + mutex_unlock(&sdev->state_mutex); + blk_cleanup_queue(sdev->request_queue); cancel_work_sync(&sdev->requeue_work); diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c index 3c5d89852e9f..f617021c94f7 100644 --- a/drivers/scsi/scsi_transport_srp.c +++ b/drivers/scsi/scsi_transport_srp.c @@ -554,11 +554,12 @@ int srp_reconnect_rport(struct srp_rport *rport) * invoking scsi_target_unblock() won't change the state of * these devices into running so do that explicitly. */ - spin_lock_irq(shost->host_lock); - __shost_for_each_device(sdev, shost) + shost_for_each_device(sdev, shost) { + mutex_lock(&sdev->state_mutex); if (sdev->sdev_state == SDEV_OFFLINE) sdev->sdev_state = SDEV_RUNNING; - spin_unlock_irq(shost->host_lock); + mutex_unlock(&sdev->state_mutex); + } } else if (rport->state == SRP_RPORT_RUNNING) { /* * srp_reconnect_rport() has been invoked with fast_io_fail diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f9d1432d7cc5..aea55f5afed0 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1798,8 +1798,9 @@ static void sd_eh_reset(struct scsi_cmnd *scmd) static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp) { struct scsi_disk *sdkp = scsi_disk(scmd->request->rq_disk); + struct scsi_device *sdev = scmd->device; - if (!scsi_device_online(scmd->device) || + if (!scsi_device_online(sdev) || !scsi_medium_access_command(scmd) || host_byte(scmd->result) != DID_TIME_OUT || eh_disp != SUCCESS) @@ -1825,7 +1826,9 @@ static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp) if (sdkp->medium_access_timed_out >= sdkp->max_medium_access_timeouts) { scmd_printk(KERN_ERR, scmd, "Medium access timeout failure. Offlining disk!\n"); - scsi_device_set_state(scmd->device, SDEV_OFFLINE); + mutex_lock(&sdev->state_mutex); + scsi_device_set_state(sdev, SDEV_OFFLINE); + mutex_unlock(&sdev->state_mutex); return SUCCESS; } diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 5f24dae2a8e1..d13bc80825b1 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -207,6 +207,7 @@ struct scsi_device { void *handler_data; unsigned char access_state; + struct mutex state_mutex; enum scsi_device_state sdev_state; unsigned long sdev_data[0]; } __attribute__((aligned(sizeof(unsigned long))));