From patchwork Tue May 2 18:00:41 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: 9708431 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 D50F660349 for ; Tue, 2 May 2017 18:01:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F382848E for ; Tue, 2 May 2017 18:01:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC1CE284D5; Tue, 2 May 2017 18:01:01 +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 B65E52848E for ; Tue, 2 May 2017 18:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751156AbdEBSA7 (ORCPT ); Tue, 2 May 2017 14:00:59 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:46512 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbdEBSA4 (ORCPT ); Tue, 2 May 2017 14:00:56 -0400 X-IronPort-AV: E=Sophos;i="5.37,405,1488816000"; d="scan'208";a="15612770" Received: from mail-sn1nam01lp0113.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.113]) by ob1.hgst.iphmx.com with ESMTP; 03 May 2017 02:00:56 +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=FZ9Qp5CIC/w1jmu1PnEGOi2wDM2y2OMFo545Ma8CD7w=; b=N9X21E2t3IXhs71OKSUi4p+okXeFzOIIgk8RmxzDofjD5tmsyZPW18PFH/YCdiEHyrY8bVF6T4qpBdNn6oKRqNNG//3gjVjwZl++dgEfJuuvpFQmoifypjIrmtvPQ1E7pfbP25q2TsUZge6h//q5xxNxe8KpQvjPqJvtWmd4R+c= Received: from CY4PR04CA0030.namprd04.prod.outlook.com (10.172.133.16) by BN3PR0401MB1204.namprd04.prod.outlook.com (10.160.156.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.12; Tue, 2 May 2017 18:00:51 +0000 Received: from CO1NAM04FT018.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4d::207) by CY4PR04CA0030.outlook.office365.com (2603:10b6:903:c6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.12 via Frontend Transport; Tue, 2 May 2017 18:00:50 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) 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.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 CO1NAM04FT018.mail.protection.outlook.com (10.152.90.86) 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, 2 May 2017 18:00:50 +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 40.DF.29323.159C8095; Tue, 2 May 2017 11:00:49 -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, 2 May 2017 11:00:46 -0700 X-AuditID: 0ac94369-548749800000728b-9e-5908c951336e Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id A4.F9.18148.E49C8095; Tue, 2 May 2017 11:00:46 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , James Bottomley CC: , Bart Van Assche , Christoph Hellwig , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH v6 3/5] Protect SCSI device state changes with a mutex Date: Tue, 2 May 2017 11:00:41 -0700 Message-ID: <20170502180043.14734-4-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170502180043.14734-1-bart.vanassche@sandisk.com> References: <20170502180043.14734-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRmVeSWpSXmKPExsXCddJ5kW7gSY5Ig7v/9CwWvNnLZrFy9VEm i439HBaPu2awWnRf38Fmsfz4PyYHNo9pk06xeey+2cDm8fHpLRaP9VuusnhsPl3t8XmTXABb FJdNSmpOZllqkb5dAlfG9RN8BVs8K67f/czWwPjepouRk0NCwERi7fm77F2MXBxCAkuZJF68 PswE4WxnlHg/9TxLFyMHWFXbXk2I+EZGiYdz9rCDdLMJGEl8ez+TBcQWESiUuLStgxGkiFlg D6PEsVmz2EASwgJuEtPajrGC2CwCKhLf124Da+AVsJc40HyXBeIMeYmzW3YygyzjFHCQePXX CSQsBFSy8+9fZoiSRawSLScKIVoFJU7OfALWyiwgIXHwxQtmiHp1iZNL5jNNYBSahaRsFpKy BYxMqxjFcjNzinPTUwsMTfWKE/NSMouz9ZLzczcxQkI/cwfj3SfehxgFOBiVeHgtJnNECrEm lhVX5h5ilOBgVhLh9dwMFOJNSaysSi3Kjy8qzUktPsQozcGiJM57TmZqhJBAemJJanZqakFq EUyWiYNTqoHRwFhUwc/HRzHx6KugtZMZjbaJJgQuUZrd+P3iCmmfv+XFjJnu386EuFw0ljf/ VGN5oTXKf/o8/9V+etWLJr4OnN366+6BWy+UuaVsBRzmvXHr4eXn1+txjA472plQyNew6uTh 1XluGywP+a+4vtZz2gm3t/KiH6/wLYxTfyNfkL1zg/MjBlclluKMREMt5qLiRABA8eOaeQIA AA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKJMWRmVeSWpSXmKPExsXCtZGTTdfvJEekwdPF7BYHf7YxWix4s5fN YuXqo0wWG/s5LB53zWC16L6+g81i+fF/TA7sHtMmnWLz2H2zgc3j49NbLB7T1pxn8li/5SqL x+bT1R6fN8kFsEdx2aSk5mSWpRbp2yVwZVw/wVewxbPi+t3PbA2M7226GDk4JARMJNr2anYx cnIICaxnlNi+ywLEZhMwkvj2fiYLiC0iUChx//Rpti5GLg5mgX2MEpsOr2EHSQgLuElMazvG CmKzCKhKvNpzlhHE5hWwl2hf9RUsLiEgL3F2y05mkF2cAg4Sr/46Qeyyl9j59y/zBEbuBYwM qxjFcjNzinPTMwsMjfSKE/NSMouz9ZLzczcxQgImagfj9YnmhxiZODilGhiVN6t3dslPOf86 6fkVrw/eh7mbLq9w+xM46a6R+FcRrpfSMU4/VaJ61rrczDJXneLR1uy419R/d9zl0jtCm2al T1khHLJWdb1fV0K6VsrclHvsYYcm9179sZj5o3zQzUhWC7VDb288Fr569+GiU9ur33V/PFdx qKzF623FpIDNIgG+j11i6hyVWIozEg21mIuKEwG/AMAcyAEAAA== 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)(39410400002)(39400400002)(39860400002)(39850400002)(39840400002)(2980300002)(438002)(189002)(199003)(9170700003)(86362001)(38730400002)(5003940100001)(189998001)(36756003)(6666003)(33646002)(2906002)(48376002)(2950100002)(50466002)(76176999)(50986999)(1076002)(5660300001)(356003)(8676002)(4326008)(54906002)(50226002)(81166006)(77096006)(8936002)(47776003)(478600001)(53936002)(305945005); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR0401MB1204; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM04FT018; 1:njkEAc7QjVrrZ2D295oyaNXPHMQWeuZKFTjRfoPRJTzys8ZaXcDORm1uQoUPJc56fP0iBK273VaIB3UzaWIR8cFxWDlKSN1lRpNb6tE8OLT7QDqGbZSa8mINgUw29CdzXpx8Lmt4YtzfieiJTLvXjfeFsi8q1jyNbewA7c7NRoZzF4treLVVlDXrRA48xnQlJf559Wl7mF3kNOx5Vd2lf22hnqOgAXaPXB4YO+o+CFJI1yPXVJPD72t0dllSQb6cAYDlgbhWJ5hbovw0znMrgkB6SOH0p0zrOIo44hB1mvXyB3jsfaPf2zsCyKdEZ0YlF0pSekk2+ToKJWPGh20pL/oULONKa6z/3qMc5eJuOVoCxzOuxjA3O/6P724SxZM1AgakQOvQOP//FsaBUcYPVkNT8/K4UzUls3reT1Pk79mMJPgRtTnz6sRx0frH9bI8H0oUAmAfsYcn9Yd8VdtZ4YbwaQlwOab09mtBjaMbnTGtfrQ718Dgzhupxz8fYLu78pX0OFURQkm9rkxpBpmYuF2wNG6DXE3zWdu1dz7uePI= X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e7fe80e-6d06-435f-3c06-08d491852b1e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081); SRVR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:tpZ1gMhGzFKhRAH9AHajeZSQYxfJSBThZN5V+A2DTvul6jipzkdsuodqgnHtpcJ1Yptseu7Eb6JfOj5/qlp6IFAGpOK54p2n+wHYIGPIWJcS1UzIwtNv62ZmgKwDlnsdZWORt0nMDIEVtnQVLtbEcsNFfUVV6MQBcP3qAfd0Ih7PddIaSbvqkCdLIvJqNYO8x21u6PHHYrDjQGy51b7ZOyRq6MO42Vge/9aHdz0ueF/ls2/NQ8/EM1No8PeMElm/ WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1204; 20:mcZ48dxwIfW87qoOY9X+ZISEBMDYFcKvK60MWdThBW+TlIn3BeoPTswZXPfYpRt+rSO2swtnevlDzeqLPY0mHuBT8AgKGofnDd7n4JufWHLPdZ42ahMKLI6aMk0X1PG+LsaSRB+mm3yTao/xGlIXG2lsQQP2s00ejfFxgcw7rfCxEj8hMoZhoek9YejMWSfUZN8Aw1iNGnb1U/GMVIp2K0YCUdJ61nhtROlZ82fPm6V1gjrgHq+4FKfXSbB82V/8HUmpDvBdQagSZoieEXR03rua1CTnDDLMaO1NFFv+4FkmEJDhWIHPuo2PD65xRUYZGgon90qjlxf4s3NVZjXe+jduYk8cylPGPGOJ3RhHJRCIElcWPjxGkJbvh+SUvEBovMUmXvPALC6BBEdSRAYn/jDlaLr5NgZCohQ+YxsKKhmP7q4U+mnGPUtDoU7r+MCZX8WRPtoDVu19CmOQrOAEbeADWkVS0caplgzeVw84XARgIKDv+4FHnKmRSyjd0DAa 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)(13016025)(5005006)(8121501046)(13018025)(10201501046)(3002001)(93006095)(93004095)(6055026)(6041248)(20161123560025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(6072148); SRVR:BN3PR0401MB1204; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0401MB1204; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1204; 4:8klyWBQLXLNUkvay4U/ofdtvIw2Z2nW6WN/TUcoEmnlOZSAAixueVpD3tcX2MlkP0Rzekh4W1d9uaiTw8cLxrhQ6JnpRFvIgSwAGmzVmg6JpLpH0sWn02VajlQiZ90bfodxyMEZUQHDg3xtcW3fFiexVFAeatgeGZmA2ilnJ/WOEEFgE5UZzRlSznvUx2+ey6+AprIZAtWL9B9CqgwYNouA0xx38HzqbW6xN6JiOsktCintnnkBMpWlJJi/Uo3FnKrDgEYZ3SUfTE8lqv7pJOrBENW4+OwHb82KEbI3klFs9URIILX0HRwD6tsweu5JvTLX3aLoOQ5bOBxix6L6jf9nzBjE2M5UCJei6JlTNRPKGmymximJCtZooIolQWNXUKQGBH5ABLk2pzGXlByHmo/3bRxDkObO05DdHgmh3AzR6Fvv64F/cdv5qggWZrtHUW+Nz+w5aGARCIPha8pOkelSFHDRe76BvOYY9cMdU1bSgGDKAPOuOC55VNITYKtweoWvneJ8ix4OIZHhNyREXakPr/5cDglNRQjo0FVmHDpj2p10LToa3GO8QUdTxjWDKVWZuhoGblsXB8SK8c19dkYHOrLiEtg8ff4iDjsFGJOivf4pYaugDsaKL1jdQQMxC5hsLkWhJrbAts9fapVRLDBfiEfGizKoDCSW+ROWyTM1q06oCFyYbpRlx4FvT6hljYJqI2u8V5nHKBuH/Ji2WjPug72X6Glq1g6S0A2dwOoTQOmnyj0jcmn9/Svj2qgXNM07fj/LtvwzPiUm/7YKEDntV2AmATc6hoOSgWnBBJIIqRvdDF0oigv6a5zjl9DGs7NXypcAOSiallhheCJ80PMOV+pQ2KiYQfk9EBBUKMDZXbTWaVmM5l8yCl5Af8Nv+ X-Forefront-PRVS: 02951C14DC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0401MB1204; 23:/sYRsscjTGQ8K4E46cjgKvqLdThqjLFdgMMc+u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0mcivGu1Ci+A/r+YBsR0fxzzNChqKpTXXD?= =?us-ascii?Q?WIbQEzljqgAk4LgeKSgQ3CPDVDYKqosq3M1pd1Ey5exgxtbzgl1FoB9I6qee?= =?us-ascii?Q?psIwJO9yaQ3lz3RwOPf6d9K8g?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1204; 6:4NCJyFH6StW9wGIriGQ29M7lhdw/+H3ZBqL23Xtw5iTH7OU3mpmropEAhb22Vv5JQjAb/Sx+1nQhWdFJ6w6aNKmMBPLRfkCCgbL1qSzpWYQMXXER5hTN+WsGL/8OFyyN1SxEvaf5zt+HtBa9Y7bw0uEFpnydcgeLCxZdmWbKjemr4f1fqZEJotC/X6yCzfJXClVEaf4OaVc606AZYYFiFzTsbni8d3QuflhgFY7b02vix/zkjuInK04p3Z/EsSGw/f03POFbBtxXSTsDQMZa4pBw7EPKshbQY4bSQkhe67Z0+tJ61fLgbxwD4Ck+oFzudgdCcPqqfoN6uh1gyFiVXkxFkEBY1tcpu866oeA88W/TiO3lpREiCOOcLsHHWdcB910AB/qguIgKPm/RPoUGV2kr3h9JkaT9FBrsGRMQeZz54qeP+hCXuyTj4fD6cl2aKL64CWdAdMy5NmshOVmU6V/VflLb14JNS3DQm+cFV52ZyOwRA2h606vh/sbUtxn8MQRLUYnOo5mMRcF+sezh162IorF2UBbQ65smX4EKcoc=; 5:6oTwetH80tuyXUyJLSiu694MELjVKC/FkdJX4VTMPqxv5t7/wrbuadQV/RPT0OkHB8XcIUkefaxZ7f5/xIEIRWtPsy3RKkSAqVmR20gIjrarrewW6oCnXndU/T6rMh2qefM6a+ccVeW4gUgHrD4Drw==; 24:dNrDFqGdAd/q3bUYQdi5mGBJJqm6iV7jdkoGY16DwALh4TZAoyPWM+ln4S6UC818iVW9ibJHu7BZD74goO7nIS277qPjaTZsgAc/1y5cc48= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1204; 7:pimXxT/Fad1/G20HX3Kjaoug4Hb2GN7bV+Ljy3ecPNP8pvVUh/yF51gAbmda7uTeVgd4gieq1snpP8ritgrROg4GUDSiXGDoouC0onC928E4aIPB0PY2qZP1ldZuxWoyRM4euKof7qX4wpd1gNTbu3Mw/6TTRkT5LPVFqHpHZnHLAVh47LRx/gHg/165PqXu/egu0e+Qgj35FXp/ojWriafOQzIdF+0DkVfYSgxg6CEqhiYQKOGxspLzuHOH+MWY7bDh3dMjVH8KeZPHT+ofXfCh7PIFkHvvuCMr8pSlZ4vbrwnQd6TTwi0bugo88PRBXih1soUyhwteWtJcQF8+pA==; 20:7/Oc9cMg5AJHqaapP3daUMScd2c99U99yClcK9koOUYdVPNTft8VCeuz/qrAdg/qjmbkG6zY5I2eq4jMX2EFZ6HjY3xOjuHMZM/q0h9zQGbAHDkVdE9k3nMGmHiN0yTWD4e65el1auFqS0ktTKghq2NeNlAg+FGhRbGdCaXrDYQ= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2017 18:00:50.0068 (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: BN3PR0401MB1204 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 f2cafae150bc..02f5f7f49885 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1696,11 +1696,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); + if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) { /* * FIXME: Handle lost cmds. diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 79bb05fa09d5..d2854558437d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2875,7 +2875,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; @@ -2903,10 +2908,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); @@ -3005,6 +3011,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) @@ -3012,6 +3019,8 @@ static int scsi_internal_device_block(struct scsi_device *sdev) else scsi_wait_for_queuecommand(sdev); } + mutex_unlock(&sdev->state_mutex); + return err; } @@ -3082,7 +3091,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 35ad5e8a31ab..3ff6572f3cab 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1700,8 +1700,9 @@ static const struct block_device_operations sd_fops = { 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) @@ -1724,7 +1725,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 FAILED; } diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index bb784045ba71..d95735d842ba 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))));