From patchwork Wed May 24 00:33:52 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: 9744695 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 DC695602A7 for ; Wed, 24 May 2017 00:34:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF02428867 for ; Wed, 24 May 2017 00:34:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3CFC2886B; Wed, 24 May 2017 00:34:50 +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 E681628867 for ; Wed, 24 May 2017 00:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763432AbdEXAet (ORCPT ); Tue, 23 May 2017 20:34:49 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:31040 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760498AbdEXAea (ORCPT ); Tue, 23 May 2017 20:34:30 -0400 X-IronPort-AV: E=Sophos;i="5.38,383,1491235200"; d="scan'208";a="116871008" Received: from mail-by2nam03lp0053.outbound.protection.outlook.com (HELO NAM03-BY2-obe.outbound.protection.outlook.com) ([216.32.180.53]) by ob1.hgst.iphmx.com with ESMTP; 24 May 2017 08:35:35 +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=UdKikTmWF5MpD2KpRmw5P355RjACbdFoT/UjtNBlE/8=; b=OJI8tHLjI1BRcOmv4mlXBW5l+T1o52YIQX3M/q/pqGBsOusjWigKgAvA8/eQxm7dzPHyUsKoR/TP4/Mbljm4mXoPjQfTcjr7CJE75TN2BBo2LzWZwrvG9O2ls89kMFICHBp+bboQLNccw2KleLXSGxRApkMHII5YXpfy+odSkSg= Received: from MWHPR04CA0033.namprd04.prod.outlook.com (10.172.163.19) by DM5PR04MB0362.namprd04.prod.outlook.com (10.173.169.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Wed, 24 May 2017 00:34:27 +0000 Received: from CO1NAM04FT032.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4d::201) by MWHPR04CA0033.outlook.office365.com (2603:10b6:300:ee::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9 via Frontend Transport; Wed, 24 May 2017 00:34:26 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.225) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.225 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.225; helo=milsmgep14.sandisk.com; Received: from milsmgep14.sandisk.com (63.163.107.225) by CO1NAM04FT032.mail.protection.outlook.com (10.152.90.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1075.5 via Frontend Transport; Wed, 24 May 2017 00:34:25 +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 65.55.19026.015D4295; Tue, 23 May 2017 17:34:25 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Tue, 23 May 2017 17:34:22 -0700 X-AuditID: 0ac94371-0a7ff70000004a52-28-5924d510f2ec Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 8D.93.18148.E05D4295; Tue, 23 May 2017 17:34:22 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , James Bottomley CC: , , "Bart Van Assche" , Christoph Hellwig , "Hannes Reinecke" , Johannes Thumshirn Subject: [PATCH 03/31] Protect SCSI device state changes with a mutex Date: Tue, 23 May 2017 17:33:52 -0700 Message-ID: <20170524003420.5381-4-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170524003420.5381-1-bart.vanassche@sandisk.com> References: <20170524003420.5381-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsXCddJ5ka7gVZVIg50ndCwWvNnLZrFy9VEm i439HBaPu2awWuy9pW3RfX0Hm8Xy4/+YHNg9pk06xeax+2YDm8fHp7dYPNZvucrisfl0tcfn TXIBbFFcNimpOZllqUX6dglcGRcuzGYu6PKs2Nm8n72B8bJNFyMnh4SAicT9VfNYuxi5OIQE ljJJbFy4iRnC2cEose/3evYuRg6wqu3XVCDiGxkl9h5YxgrSzSZgJPHt/UwWEFtEoFDi0rYO RpAiZoHbQM1r25lAEsICrhLtP5+ANbAIqEr8b7wLZvMK2Ekc7PjJAnGGvMTZLTuZQWxOAXuJ rlcTwBYLAdUs2l4BMlNCYBmrRMfFNkaIXkGJkzOfgPUyC0hIHHzxAqxXSEBd4uSS+UwTGIVm ISmbhaRsASPTKkax3Myc4tz01AJDE73ixLyUzOJsveT83E2MkDgo3MH4+rb3IUYBDkYlHt4E B5VIIdbEsuLK3EOMEhzMSiK8yzcAhXhTEiurUovy44tKc1KLDzFKc7AoifNmyU6NEBJITyxJ zU5NLUgtgskycXBKNTBqrt3vFbjJy7hh89yd86uNq+WP2nne8efi9Lhm/f6Q5h1lExfPEp84 nfidpjHTWJMqoz//zFJp+FdTJjbJ6nd2W4jculfx3iKsHuwHN0dnNR+rLF+wtTNL339S5Den 12eaOhT3RTr5vnAIe3pJOm9P9eXXywOdNp9d9HflqQrhM4tCXxnmPlViKc5INNRiLipOBAAq z0bzfwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNJMWRmVeSWpSXmKPExsXCtZGTTZfvqkqkwdpeY4uDP9sYLRa82ctm sXL1USaLjf0cFo+7ZrBa7L2lbdF9fQebxfLj/5gcODymTTrF5rH7ZgObx8ent1g8pq05z+Sx fstVFo/Np6s9Pm+SC2CP4rJJSc3JLEst0rdL4Mq4cGE2c0GXZ8XO5v3sDYyXbboYOTgkBEwk tl9T6WLk4hASWM8osWrtBNYuRk4ONgEjiW/vZ7KA2CIChRL3T59mAyliFrjLKDH16T52kISw gKtE+88nYA0sAqoS/xvvgtm8AnYS8+49ArMlBOQlzm7ZyQxicwrYS3S9msAOslgIqGbR9ooJ jNwLGBlWMYrlZuYU56ZnFhga6RUn5qVkFmfrJefnbmKEBE/UDsbrE80PMTJxcEo1MPouknf7 ftxuhcHX2Z3l84wPtt2rf5iqc/X/PlMF/s23Odg0+bhYrRi8dA4dfbyhLOxSZ+2pTXF5B3aW nV7HuGnGg/aZJxKt7rreudkh7fpvbr2puUXWRcuOXbNF8lVtP3paVxkt51v7X0m2tTLjio/J 5Krdl4xnxBpduR031WNfkgr3z6DXskosxRmJhlrMRcWJAE3a7QrOAQAA MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.225; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(39410400002)(39400400002)(39850400002)(39840400002)(39450400003)(2980300002)(438002)(189002)(199003)(9170700003)(77096006)(36756003)(5660300001)(1076002)(4326008)(5003940100001)(38730400002)(33646002)(53936002)(2906002)(2950100002)(106466001)(54906002)(6666003)(8936002)(50226002)(50466002)(47776003)(86362001)(81166006)(72206003)(8676002)(305945005)(478600001)(189998001)(76176999)(50986999)(356003)(48376002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR04MB0362; H:milsmgep14.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM04FT032; 1:cH6w2poh07J3wK8fwG1oK6Xuq0AOEGW5ZuwpT6L1eelZ6DKMqb1eRZrgz30lFeHxqj7wTaiAR/G9aSqjSnj9pcNwHszLEt9dqW76cFia5D1dStQF3LkZM+xRiXESt93fPHcqerCvN7VikRdmilxlezbVXPx+OSPzf6Jku6gnOfoZnig6jol6YPwrxL0Yug35NHJZsoY9h7Xl0ZmWSHinhutTUEGQFGYYRaNskefXkJGa9/WRjcVJxvjKtr9rwQFF42R9g1Ka24D8H/HUV0e5wB780eJN2MXBu6lzg1c6rWDv7SwJpSufKz8GtflrE2unqJpsf6f20lnpNf4maRWRB407B5xS8uWFJ5mYP6A7XMJM5/MrbHjI+lCFs88kRxijLEeoDKXgfuT51tCt3fSl8rbDAoD31GX+cFST7rb1Eh2TlJLG1vIfrlIpxOnwAAA7YVQhkeoHqn8CcJa/rCNr+hvaLgCAeHlNPJxgGa3eVRgbSAnnPYcpQIeSasCynJXSiu137wuDwVEkXF/xtmeWjktt3935OkElcG3u/Y7+MAY= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR04MB0362: X-MS-Office365-Filtering-Correlation-Id: 2866ebfe-bc04-4c96-6f7a-08d4a23ca1c7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081); SRVR:DM5PR04MB0362; X-Microsoft-Exchange-Diagnostics: 1; DM5PR04MB0362; 3:DYq4yCATxQAHv0psbxV0Ey0ENAd4NcxlN9PrN6cCp2wF7Jjg2k+1T8Tn1x9nkFRl4wHtinV4Q7XhDTftwc3PUYA+St+Q62lGVmWkIOyYJ03AXtVSYtBLCOqTjCLYV5q6cU2TKi94vTC6WyLhPfBIY+gVpuw7Tn/i7ttcrM0zYGrA7SR2+pdrqcaqrTrrqv24XCIQ7tqe9pK62CbK9CSanvUGIj+Kk75j4jpnzg8kAT34M0m/4owhWRDXx8FqqVf71cg4FOa7DcI527GABujkzWvBMEJBs1jKVtqtYBMpFKWgAHOYPkdaliXolU3TLdJ/D60Wo0obYs+Ax7vu1i+W0iHWzE4Of7MRjNYervpoRYu2agZ5XY+PGzEPOsG5+WmMjQGsfZzf+Nxl84X5rvwPP9SCyT8JYH16Ykk8Ye/5iTIrWASE/joNnNxYjtF6Q8D3qJ6udupzyAXcm/4EmE9HU2IHL7xHDRQJbR5fyfD1TlEdbBzviGoLlOEWkf1BxfUd X-Microsoft-Exchange-Diagnostics: 1; DM5PR04MB0362; 25:bvMl5pLv6tGNfnMSEHSeUohL1q/aaC0UUde9uvJk8ntDbPERK8SdhspkJkDgztKWvYwPpn332f8kjHGNfMpW8IyXBZvkWJRvzjBmGUPHZFxIlEE1Oy5riNBR2pU1uIpJ7MA1qj5kutuNOxD1SKZ15rRfDiwsjyvTLg7kcV18V/BN4I1sS3bZAZZUJxT9ZTHKh82V64jbv+fVMluD80k/fuo8VBmMzPRJzjYUdzqpNCT542rpyFoCD3MWSjCDwzvlBzMBUi3cy/XWn9LSG+sJUnCFTYsBq/pR6BilhBKDHwC1VoiluIHUgulA/UtwQdj909oiBkzKBUnbBUjyqwmq/R08h3Bhg5R02/fpz2QB/NKksnjX2a6sQuZye/5SA2fSoHPAmnXXti7Xs1b6hfJsgsWx7M3GGYdROJkoYa2BuU+IQ6aQZEYcGh9S2dFjFJ/VzYFBZ17gx3PfEZu2TaiTOGOXuEVDBlnZqgvf9F+ISdA=; 31:BnADnYfAOIxX6QFWNbD4zqnfvyxF+rXVJfOl9nXEKthVY8iuXHwJBd9s55YL7XZdYsoIrxDww3zz50EC2/EvxSDqJBIeHsasCHpuCDRmfv8xxv9QdxWfFwIaItY/sZiErRWYqbEeHUu1xn6lJIjOY+bCD0USqmQM53vMoF0l5UZyKD22oKc4CpfOVExJ0P4QXmbPL+dPUamGJs0wjr36kpRzyen8pfIM1n06XHXtEB9guEyEb5epdGtHBcGZG7dM WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; DM5PR04MB0362; 20:zpUL4v3wK5kaljAmJpxHCs1jca+PqdOcUOCd/QAKLxr379W/k9wfLEomIZnLIUFsLzo20yL60pWEtCgVx0lUQznwyfOKKo/Q/SfYO5X8nXTQArXgu0XJqdliaD2P3vOuBokjTB57vMPEa0j8K2tB/kZTYACPpMgU82CC+Wnm0e6Nx+vd6fVVKjqTKzF2FJd5VdgvsU3bA6W3hXG1R3Up271zuC/q+EL6XqynKeQaxYG/7bbGn0nMwQ/EoQh8WNWdxikvHl3VBPv37VmNv2iZ3Wj9LEs64STZC+0g7fgExpmoP3LdPXz93yO/5wRg8R7OlMbbfbXO836jb56NDPcNyEiTXYaWWd3wbmVYwB41bOOx715cYoHPPvAYRwhlSBN3qucmSpcEiO5HjTl0aTJyRv4ic4ISzd8Kg7bbE+vw8W5r0tCE11FPn9eXy6PskVlgz6eptl7IDJ8sNqryVj28fpj5C3PLPipHuNQuqpNrkpzvem5HltbVgBehT1Yklnvj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(13018025)(5005006)(13016025)(8121501046)(3002001)(93006095)(93004095)(10201501046)(6055026)(6041248)(20161123562025)(20161123560025)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148); SRVR:DM5PR04MB0362; BCL:0; PCL:0; RULEID:; SRVR:DM5PR04MB0362; X-Microsoft-Exchange-Diagnostics: 1; DM5PR04MB0362; 4:XIbLHVIqBq/ZZbhAM0BySVpikIzkAjd+DriHfdSNjuiDe0tiQn5oZpzb5EgxiKnY5Z9W+7GnY8GYEZWLOV7OdhMJfE48BM36RzB2XwlfEmaz98QxqjIn2O7sFHXlGmTkq9yg7rpt+ugEvBCbUg1LGP5QIHuNLVRdl0Njd0CSam9UDZ/HkDRlD8Yjcm5hZE8dwpucBLmLM8jHGl0qusvBXaGGhEEXizMnZlOHDMbewoisQkIwo0WkIzHbPadNMY09/W0zV2OqpxXHkXQFDfqaEJ0SODAwg/b8CSIhlql+VvLXPxF7IH/uDpqQ1PE448EmfGPuPjYtfa4kXGrflKTG1QwJsIfp2ehqWXym8JuXscfgyohW9T7W+MdvI9sUzUheixhniFNnpsL6o+4J0eDZoNKW15n4rCyv5bpQTAXIosZxh3xJhUePNkv2l7tpWAuebng1I7aR/m5raaCtxZc1fc/aEqjxVrDpubo739srlMxw5gcWXmvbCZFCaWkbZLnoE9uDADgn152Lkoe7h4PBsiAxZRB4c0bfYt3X1rfyYI76NFY07BTxy1L7iLguhswhsmHbEslQhp8wNTk8d08sZrDF2se1T8RmXRHVC9U0Fc411WNJrN2m0gmZ+HWAFNoaIrOmNanWukddoH9Qtr8ZTnn2Ynf7+cjeJyzlzeH1Vfn1LiN/a+OMQrsdN/9gSR48iij3hDZfSlxQFhYoXSYq1R3A7maEpr8Vpz31D9LRwDJtUNi6s8A2dw8OvMeMc3Q/gL+dUcP4mNxVkPT+ehcIQvKy99PuhP5vr23qojc1U/i93rmz58hM48Qv4ZaHWwrue+6DtKvoMV42Fasw70Hqc+mdxQVW6L9Kt/qJIhI9LDHpNPsz7JMhf7ChUd4v1wqF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U4ySt8fOe8nPg==; 24:GtltnN7PZFslry/nmIcNpXbDDTHpWEY1vuGdELORj9kbcUsgnrSKupGO8sqGMqJhGD1SaK7krdXBUY6VXJy7wckOJYAaLEaSnt3eQr19xaI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR04MB0362; 7:6RdqvGJJdDAQfJWbgaOPzJ2OMB4jIyTfnD3I/LVt1hKgGCZ5T/YyThwPBPAUtmWdxDecv895KRTfg7MB5kCUET/ZySiVvQA4pR9wEUlRO4dkvB859Zt6lDyce9IZ62zJyJMFFs0kiEH2Xv0z8BBmdPgUoDlyMk7ONHsPfPMpwUi7p4nbTMu8zCwdA6K0Tym3smJfmNyttBcDyxSuuch9pjnrG0ahjHecYQYllKzk2H8Vm4fmdTFvbhLASwhsLTW1h2Aw0af+SJsfj7UnNN29Q7DW6F5XeUuk2y5+dTwcvc1H2dMzwCQvQwFY+48k/cGCJnDkGOMMhjPTCeKac8Se6A==; 20:I6asL1yBXQ4/uklQEGcRkrHziPW0HPqNVPr0h5BDWSd6TKHWiJjV1gMd4PKTU3KWV69AvEedv9Hm1EyvOREoxWgnJtGYpsP9GU1I4vBfLPdV77abxwQDvIwPIm4+LEGQhrgwKJTC4mY4Dk/eSqCO9raTnfBQrvpEzwmmkLm4IXk= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2017 00:34:25.7646 (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.225]; Helo=[milsmgep14.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR04MB0362 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@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 7ed71db8c38a..3d82cbe605cd 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2870,7 +2870,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; @@ -2898,10 +2903,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); @@ -3000,6 +3006,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) @@ -3007,6 +3014,8 @@ static int scsi_internal_device_block(struct scsi_device *sdev) else scsi_wait_for_queuecommand(sdev); } + mutex_unlock(&sdev->state_mutex); + return err; } @@ -3077,7 +3086,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))));