From patchwork Fri Jun 2 21:21:55 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: 9763551 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 2A4B7602F0 for ; Fri, 2 Jun 2017 21:38:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C431285DC for ; Fri, 2 Jun 2017 21:38:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10C54285E2; Fri, 2 Jun 2017 21:38:16 +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 EF520285E5 for ; Fri, 2 Jun 2017 21:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751184AbdFBViE (ORCPT ); Fri, 2 Jun 2017 17:38:04 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:45812 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966AbdFBViA (ORCPT ); Fri, 2 Jun 2017 17:38:00 -0400 X-IronPort-AV: E=Sophos;i="5.39,286,1493654400"; d="scan'208";a="23664563" Received: from mail-bl2nam02lp0086.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.86]) by ob1.hgst.iphmx.com with ESMTP; 03 Jun 2017 05:37:58 +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=rxcGg0fIvHiUcX7BFKO8Aa3AyvQJbpYAvAWTUfjwIXA=; b=jUfE8yFxylQ69gE71NKzU3ESODYnLVqOG1lPI71rLDKzeE0WOs5paLFtaApSK+kY+MX8RNYL9+jePYGDR0iJF5yW3WFJ6ProYDsaGEMbEwdv09Z7DOcW/lEsFbW2HnDXwj2bFiORDjAH7tehHcvGEJl9Kb1UAZ+jCttvsis9Kks= Received: from CO2PR04CA0113.namprd04.prod.outlook.com (10.165.95.15) by CY1PR0401MB1467.namprd04.prod.outlook.com (10.161.212.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Fri, 2 Jun 2017 21:22:19 +0000 Received: from SN1NAM04FT028.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4c::207) by CO2PR04CA0113.outlook.office365.com (2603:10b6:104:7::15) 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; Fri, 2 Jun 2017 21:22:19 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; oracle.com; dkim=none (message not signed) header.d=none;oracle.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 SN1NAM04FT028.mail.protection.outlook.com (10.152.88.113) 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; Fri, 2 Jun 2017 21:22:13 +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 82.D5.51736.307D1395; Fri, 2 Jun 2017 14:22:11 -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; Fri, 2 Jun 2017 14:22:06 -0700 X-AuditID: 0ac94369-6dc8f9800000ca18-5e-5931d703dc2d Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 3E.A4.18148.DF6D1395; Fri, 2 Jun 2017 14:22:05 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , James Bottomley CC: , Christoph Hellwig , "Bart Van Assche" , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH v3 04/12] Protect SCSI device state changes with a mutex Date: Fri, 2 Jun 2017 14:21:55 -0700 Message-ID: <20170602212203.30401-5-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170602212203.30401-1-bart.vanassche@sandisk.com> References: <20170602212203.30401-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRmVeSWpSXmKPExsXCddJ5kS7zdcNIg8PrJSwWvNnLZrFy9VEm i439HBaPu2awWnRf38Fmsfz4PyYHNo9pk06xeey+2cDm8fHpLRaP9VuusnhsPl3t8XmTXABb FJdNSmpOZllqkb5dAlfGvgM3WAs2eFc87d/M1MB4xq6LkZNDQsBEYvPXv+xdjFwcQgJLmSQW PdjACOFsZ5TY0HqGFabqc98jVojEZkaJfX+msIMk2ASMJL69n8kCYosIFEpc2tYB1s0ssIdR omVfCyNIQljAQ+L+/vPMIDaLgIrEtVPzgBo4OHgF7CVuTyuEWCAvcXbLTrASTgEHiW8dS5hB SoSASqb+1QIZKSGwiFXi7NpnYLt4BQQlTs58AmYzC0hIHHzxAqxXSEBd4uSS+UwTGIVmISmb haRsASPTKkax3Myc4tz01AJDU73ixLyUzOJsveT83E2MkPDP3MF494n3IUYBDkYlHt6MMsNI IdbEsuLK3EOMEhzMSiK8u2cBhXhTEiurUovy44tKc1KLDzFKc7AoifOek5kaISSQnliSmp2a WpBaBJNl4uCUamBcp7py9ZsgtzqJaTslG99dPCBccV022vPYYZO3/28I1fIfvvUogPuiUdXv dVNuPUjuubsmwEdS3NTjaGjORflXm2IdPpcfFDRa4vvwgILZnCmH28yme09q2P44xl/8pzdf ysaGxws0xZsUA80sz80vT/G4N4GBo95a0Mb0sn9naJ8z8/f/2tpKLMUZiYZazEXFiQAP4rLx ewIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBJMWRmVeSWpSXmKPExsXCtZEjRffvNcNIgy/7TSwO/mxjtFjwZi+b xcrVR5ksNvZzWDzumsFq0X19B5vF8uP/mBzYPaZNOsXmsftmA5vHx6e3WDymrTnP5LF+y1UW j82nqz0+b5ILYI/isklJzcksSy3St0vgyth34AZrwQbviqf9m5kaGM/YdTFyckgImEh87nvE 2sXIxSEksJFR4lDjO2aQBJuAkcS39zNZQGwRgUKJ+6dPs4EUMQvsY5R43PqGDSQhLOAhcX// ebAGFgFViRnvmllBbF4Be4kna5rYIDbIS5zdshOshlPAQeJbxxIgmwNom73E1L9aExi5FzAy rGIUy83MKc5NzywwNNIrTsxLySzO1kvOz93ECA4bzqgdjNcnmh9iZOLglGpgZH2ute24ui3X r2JbDd6+Kfs+XtrM97G/4+ZMdxvnQ/NXm/dtMWxX8lu0f1eQ8oKvVd9mPg0vOzjxGjPnK05x tdpPMnebWFimJtSpfsz70rlhYYPyidKpkXJyDcuvKd2Iy7vomrnnfaXqbWNN0Q2LqwUSjh3/ cK4ydOf636Kbr3Yuu2suXXZ3jRJLcUaioRZzUXEiABbjjAbLAQAA 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)(39840400002)(39400400002)(39410400002)(39450400003)(39850400002)(39860400002)(2980300002)(438002)(189002)(199003)(9170700003)(8676002)(33646002)(8936002)(50226002)(50466002)(2906002)(305945005)(76176999)(50986999)(5660300001)(356003)(36756003)(478600001)(72206003)(48376002)(81166006)(106466001)(1076002)(86362001)(5003940100001)(53936002)(189998001)(54906002)(4326008)(77096006)(47776003)(6666003)(38730400002)(2950100002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0401MB1467; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM04FT028; 1:xKyFwlQlF/CyyKjNEVxegXWjVjpOSOYe58xcv92iUQK4cxM2e7fHnFYLSngz3nEXMB7JFgFuuTu60U1McyiANWYP7r7QoBJn0sEZITxB8EsTqurPmgoIH7GeDrnW7OG+2NGRueLh5t5JMjc9o+xPSr2bU16WDSLiXvDUafR/DUfej3sXRhWnZrwhMd/nHbjeOtgNlQP8ElHnyMyoPL6TaNlXw0h+1NfKa/zSKKsmzGwhRyYHoVC0/ueMmio+sdK1LsAqbLTMgD806PbTx0LKKw/EgHEsohzExysOgtFv352TB2tfXwebbFpyYTcqWQJwvVxsTQ23vvWC2MSx9jWTlyYZdaZHPvH2c8C7CfvrZvwoRyzw7FcxflAa3GLzgTh03/wHcPshjn7tAkIxWmJYt6KcpuBZQka+v3oCjlfkGZVrAzaYd6mGA4WDQfSRXKFHZ7XzSPq8mLk9/UiXO1Nx+QrWwwcR7eiCMEIHlYeutBJnSjtB92NOqiS4zzi8ucpA8/bXet6k07iJNCDRIMT8/Q== X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY1PR0401MB1467: X-MS-Office365-Filtering-Correlation-Id: caf4c03c-f3f0-4e59-f718-08d4a9fd7317 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081); SRVR:CY1PR0401MB1467; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0401MB1467; 3:KKZull73NmTIES3PA1qmAMHVefXRExxmrVy1+ebiq6IrubZshqoUJUndmMHQNRijwrGwUQzlZ6E0rJSnqOrcgsu7TCVrELIago48YHb9Fa3bAOp5eM1JTQ67iNIn5OTjTr+uOfMx85WjH0x38KMqFXAeHjn+L7ZMVK91R3Gy+i3pVI2smpGcDEY5GENpms8fj5454V3YPuhxgwV+bhT0OON6CPCv9Y/mYt7qG9KmCULfI6RuD9jMlBF3rI8tpHcG3uDQnrvNdCXLofEp+F2oiNdSqpn3LYPjbUMWOnvEnXhMsjjynet3ogC4zEzXs6+HWMn1xYrbHYn7DNjDBTc6wAgzEN8//nU1YCix2FJt0ky++JfAJOp0nyovPJUn+9QIJ41qMH1Q2bMwzpzC19k1CHEQxM9LbXKlo3+c2ewbsoSY1rk1QRvomTKYkh4vw/gzdpvK2JUv1d+OB52tAy6xDH79jLTCocsnjn0f1kEwZzUUY3MZr5eXvDWxkETYSDiv X-Microsoft-Exchange-Diagnostics: 1; CY1PR0401MB1467; 25:+p5GKTGVJ3BMHcMhpNtSk8h1hO2gmdlRAPuP/eqVzFbIy4wtkthAzUx4CTFXHLROY7Rbwe0qNIyPIOIaOYAIsbubIpSgyhL/7xRlgXmuT0xyrgjGcMlsiWb/ZiKYzXJKuTHLBOLiPGfl4I/TNbl4C9EsgVtN11xTk+1mV5ZdxxtZhTMEM5ZYw8DqO+eg+ZupsH3AwU/dwo0sGuuLO3e6RAZakQAlPnHOeUGEG8seN9aLTmvX+u621zfIfUbYlgF6G5zTf9QMj9KtoCernF4pKxqoHAwp8mhPEbKzdHFiTgiudFXHjyVdpk5a+dLPXasDq/GbJlPYP2PaLnhxmzIhSQl1DCRBrY8wBYtkKyzZg0I1w/HIuhK90o4LRfV6DxgiAJdKv1m2yZ3wEIdJKE26Pm/182fZmBd1kqoRJUlRn0oTihvHegjz1iyLUa6zCP4NdUwFoRVG92L8N/rnEkNP+6oJnEd1bIwpXdWOKmnxA4E=; 31:uDnQaxWnR5Fes6f8Cd4PRK3e2pF+H0txjCzGQ8Rz7OPYCZKxDbhv24KOmcqUIZJdIsJ3+oAo0jeZCn3kUm+2Th++xFDDrH5Vg3WhV5tzcBMOhWnc1N3QT0Sn2wzxFCjkNV4aJlq2mpfWSPKvV465xbvM6qgkB9PGWbcnANaYjkLzxx+avwTprpX0fXAvZSTJ105ZAkYg02m2BG98s8C1vgSVOQz1W4J/6OoBIWDsKbYVcMjkJ1bDfRyRjEsjYqfV WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; CY1PR0401MB1467; 20:1gxz2d2QSuNST+WmUgyFKYH2Eqodav7eoyt70Hwi7cJZmkgT8r+jVVEAa2dvcuUBlptWS0h8ADz5j9Al72OuWAg/ppEfvkXWkKPZ0WF17SPo0Z7GjUwGqnQeEfBZz+GljWrksaRBNolzYuQNJjkXL6CdH+gkbG6h3fEs7/HXJWgSjm/OfcZE/MhM3S7/0K1drU4Ze2aax/APhacbW3cGv0LMIwWnccgJ90MLrMoGTfk0sdtmAGr5H9SZ5oQNy/Wf3mOEIabZ5++c51VhesHMQyeWsx8l0xEAI31hJSoqBKRfvrJQSrY8nhpj7OsVR4gYgr3A1d7vDWFUOnvnMQpjCXZRcSmbo1MJPA1+xJr+h4WKhBpZmysnZLxTmXB19oJWG8c9csS8i68U+5uH5Wty8pQcMiMRuRG88mxMpwmWOXzNPV9kxe9D0OFYlsy0MQeM3m57Rgou9dbG6NmAcYxZc3xqzQMv7DGzGJZWuKg6OIHSQRrOcmF8e/DCSViF40/C 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)(13018025)(13016025)(5005006)(8121501046)(93006095)(93004095)(100000703101)(100105400095)(10201501046)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123560025)(20161123562025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY1PR0401MB1467; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY1PR0401MB1467; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0401MB1467; 4:gRNHIq5rIroEy2dVxBPExjU4S5DZOTTAe95qVjEE?= =?us-ascii?Q?SqSj9bKoSL/094WRtjwZOOJ//ktjSF7nwZ8aohoqg8KDjY5cI43BoXEvMHoh?= =?us-ascii?Q?qAxJ4kjfID48VUp58v/Vu2c+L5Ug/Cxuu84fUN3hYSGArFVP5Y70AVAuxSXa?= =?us-ascii?Q?x7sOohNnAIn+eXlxuJTWLiH4suPFsa7OjY29IHyGa7g1C+XVbvVMiZam9LY5?= =?us-ascii?Q?nj8J6sWunYMRc0l2D8mzV0niaiofAj/ikDaDrgWmNNqwAlT6iLEH5y9MB2Q0?= =?us-ascii?Q?Zkve6aeOzxunDQvAKaabfhEArwe1UftXHDjm6WGLw4muFgotrfsbcyfN6nn1?= =?us-ascii?Q?hXbGb5z4Jq9mUat90kn4s2xKExs3S3NRSr6a1dLekrBmG3dOAU0/GmoZR/NK?= =?us-ascii?Q?dx4ld3C2jGJSrlbgB2sovRO2R9pMm5f2H5swWXgd4Wt9v53ewHh2cAJCALgt?= =?us-ascii?Q?Xx3vxfoyWM8vNUs+2x5kXTBW0IvRti2WCnRHbXlkK3xWBmnMXA0E4uUFhH2p?= =?us-ascii?Q?wpklis4PvSu8l00YDOMa4KJMEck9exkiCiilBjX4QdhtWAVl0tuhd2X5ffbc?= =?us-ascii?Q?EyxU0WruUkdzDeuNP22YKG+N0upcTdWXM8zC0iMhM/I9dUj0cG0RomboaMkW?= =?us-ascii?Q?0sGYlLg4m8tts6HVWqUMHn4hetdTNUsAaW2zfqCbUwPBNBbN3WN5Bldxboqb?= =?us-ascii?Q?w/IVpSQ6zX/u3jahP01NBcAyfM1aIpZ8VD1H705uZ1dzCZQ2UVvUwgkKSfvI?= =?us-ascii?Q?uty1meujaqGVFrza3U8WxvgBZ4gnfY9suxG48j1cKbX0O2yQF1ZKE7PoEOPF?= =?us-ascii?Q?e4R84S6zvHaOSJlj5k68cd3rQhDwAIrUF0t4NZEdArbJZMHysn5D/h7GNIxF?= =?us-ascii?Q?DAX078pJsL0B6Uri0dM4BPxiAVQy0EGffDxJud5vf6dktiZUST1EfT+CzfPW?= =?us-ascii?Q?nj0oSu4Ob1GAqpxppLFHuQDuJ5K5leM8IZdTUv6AtzKgBJXTXo2j7esiBjRy?= =?us-ascii?Q?hwIymERNG+15v5mC3+KYrw+kNVoW87hUDWghaAJbgEzacTxFgazpBnLn5bMc?= =?us-ascii?Q?aGrcP1TBwuWjRyrusZ/YoTxJdLJauccancthhndahWP2IHQbWetmc9ZnjcJt?= =?us-ascii?Q?jLir45cqTWCrmzgdhvZD/ojMtA7wLgUk4NiFt+LMoBEyPTkbIYemqagWYWz5?= =?us-ascii?Q?0ZlHYodzlQHNffTWOPQjKzeio2HNUsVjhmf4/SOkzkvQwGZ8OLaPompTZc6z?= =?us-ascii?Q?J8iQl8zERyzIQZAng0E=3D?= X-Forefront-PRVS: 03264AEA72 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0401MB1467; 23:69wqOr9KVZJ2U282AKYimyLdDo5piRKwnwMBVBR?= =?us-ascii?Q?it9HsSadfQTJkMVpzxsIjojtDWdYWz78z/A8WZ3QOodlFyvBKrbAQ033z/N/?= =?us-ascii?Q?Vd+jmCpcSObBXd9Ukb4aFfEEIJ6HtyeyO90dTbwNGoBCs902LJ2NcFwv3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HUoQKhfzzT0MyTHvkKn9on3rb2aWYggh72VtElZPY1a4BqF/qabiPorI32QAIPLxke97ujNmERFcZrequYUYT5RvOvIBmNS8h5BCO/3sddtRF2VOa8LRTE3B5; 24:N2bjLtUeECGfo9ORUau/R+gXa4VCCI93reNjraXLsgyvKWBoEvLqHROGNbXWBJBZn/Zgsk1SHHR/hlQFHyn7OrJEOnm0OMbRHF3KrXrXlMQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0401MB1467; 7:Ifu5GANdlCKVuEN6qWFqTR0Odgb8zrq9VFyLXamj6E+t5F7pef5HF1tZMnjLPbovUOoOWCUyKSnAFMRcprudY7TNkhr7Wgar7zNFRbGrN8hfYU4D0kM0TGp9S+vuBio52FMY/AMiaakDfTeMZDoz3tRoYzBBZVkB8OSPnHDnroXSSsRa+TxCpgnRjBFo9oKYWEa55ucfeXuy0LAKZpGWljUOFriM1DZI/napkYRlIdSdiy/iEYFaRx3Z81VzpVstKC6n9mKwmuWNTohWj1wFG2KCdWNZ/tSQoMhgRfjupCI+vnZlwdF45A0etHQsUSQ2Egp2WDyd2/JGUmuEiA0tfQ==; 20:z8x30WAdpVBNXVf7+Gy26g7mzSEr05QqhxkizJL750m4l1dloFpa08BQw6awU3zcVpex4VYZssBjC2a0FvoDKuM1VMZfSiIx/tMU9CIrdieOcj+ZII3A1U4+zsFbS64h/P2+ah1PKc2K4Eectm+m5WyjO0QGLaxJjBRjRmkwKZk= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2017 21:22:13.3851 (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: CY1PR0401MB1467 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 Serializing SCSI device state changes avoids that two state changes can occur concurrently, e.g. the state changes in scsi_target_block() and __scsi_remove_device(). This serialization is essential to make patch "Make __scsi_remove_device go straight from BLOCKED to DEL" work reliably. 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))));