From patchwork Mon Apr 24 07:51:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9695785 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 C8861601E9 for ; Mon, 24 Apr 2017 07:51:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B49D22654B for ; Mon, 24 Apr 2017 07:51:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A99C726E16; Mon, 24 Apr 2017 07:51:55 +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 2F0BD2654B for ; Mon, 24 Apr 2017 07:51:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1166273AbdDXHvy (ORCPT ); Mon, 24 Apr 2017 03:51:54 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:22840 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1166215AbdDXHvw (ORCPT ); Mon, 24 Apr 2017 03:51:52 -0400 X-IronPort-AV: E=Sophos;i="5.37,243,1488816000"; d="scan'208";a="13405454" Received: from mail-dm3nam03lp0023.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([207.46.163.23]) by ob1.hgst.iphmx.com with ESMTP; 24 Apr 2017 15:51:52 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vcp1GIquSeAyhOGbpYahZQQlMDuB4w/2BNDNPA0SPSg=; b=JTTa3eqkol8CxoeDT/4olzCmKVvRqfzOqE5+njLB2XM7nlSHRd/zWQe+ziGJGKLm1NT9SjYaBiqRWq4MhYVnukCMJZV7l01Aw1A2XKuJ8wN6cI4ed4PMTS9aPOYnrxieLL6c80ksLynDbBN4s2chc8115RILPkVgvhAhsjji5nA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=wdc.com; Received: from washi.fujisawa.hgst.com (199.255.44.173) by CY1PR04MB1980.namprd04.prod.outlook.com (10.166.191.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13; Mon, 24 Apr 2017 07:51:47 +0000 From: damien.lemoal@wdc.com To: linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: Bart Van Assche , Hannes Reinecke , Christoph Hellwig , Damien Le Moal Subject: [PATCH v2 7/7] sd_zbc: Do not write lock zones for reset Date: Mon, 24 Apr 2017 16:51:15 +0900 Message-Id: <20170424075115.30337-8-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170424075115.30337-1-damien.lemoal@wdc.com> References: <20170424075115.30337-1-damien.lemoal@wdc.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.173] X-ClientProxiedBy: BN6PR1401CA0004.namprd14.prod.outlook.com (10.174.237.142) To CY1PR04MB1980.namprd04.prod.outlook.com (10.166.191.16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b5cd4cab-f231-466e-5c7a-08d48ae6c3e7 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:CY1PR04MB1980; X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1980; 3:25eHlTJ359wFEOlqBUf0BKrW7QZUTCcgKRuYlszNqcDmTDwDtAqcnobont7J3/1n8ZUgzERvkLaA7PB7LCy2lBHJglxUSuJFSxK6BkRJoe/8+nmKuEjsh4jw630TnBDl5rRbcxMIC3BOqhdl7lNNcdzrlYiT8hEqmnT1eePYWNZIcoSS5vLVzLG8Vav2xg+Vj6apNGiFVSaMlYwn10eTQKotiTzENAQUZqUtsWK3xAC+wuu3QAl/dNjAB81H90EeQgcGWNRs25hLNvKVDs4s4u0eOPDMF1X0tzZly4xUeGEQ7qmQz1OQp4U/U7a7R34Uz8XR0StLSY1i4/BcnVxh13cia28htFB0NWN6nFRwBAg=; 25:FeKSyv/bs82FTGsvrqoPk6Lko7xvRKi7AnSoGczFihXPftbYUJa04w6kfhsALYVjBTIt060d+0oCostfx2Fm+V/zoRvr/NLH4WWGrtuDr9xX4NdfpzKh3frz2N3km5sOZMKS+ck5eM8d7dKoJB98l3BiiUJNmNxcCNgx2UNmcZtV75ZZNLuT3m2E6gY3TUKPL7NJ7qYmThNpbWINYAlI/3d75jFiUnGcReaLn11YWh+DQUqePECbMVw1FABglNYVbj2baAIUo0+JwCGDMVeJ3ZMPS9T7yS9UaUBwbikuFxFXhlLZFOLHeluBlhkYPpkLDJoKbiFBivSeAG7XlCdWvqOL7IoVtTIopZBKk1Wsa3xZMFL5IHChheFQPVgEhb6KIFMZerVnnoOxdP5iw5rbzA8lD0qXPDdHhJ3GgjbzoWBZ4VkGvvhdmOEuoRQ/OIlLeMQraA2JHk5zekMKGpPZnQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1980; 31:u4Gdmh/uTuB9QVw0hzBRSKLO5qgS1HI9KWnFyTWZCf4s6h6euptL83wECKslzK8PHTlieFrm7vTgcB9GNzoHnMk/GVg4X1TUSHHyaILcrnaNXyud+bBok1ndzS3ER5LQD4GuJmdScXXYB0hwcIvmmSRbXTWIcRBKE1Q4yfnrNzSKonPLj/pElObs6yemjnRwb0l+qJFiRXjFtKdrmbpt6b1hH7Z5iBJvmFSHh897kH8=; 20:USMXP9E9Ojv5akteksLGEqBLBzlpwP+KEOm0Iiwlpu6wyELIezYNACDUZrR+FB6lcnzrxgqFa9V8iFsXc1Y1uEfhryqm+rnzrrgVreLysigg09mYmlYvLPuU/NRpyOHDwlnudbJmcPXtmXrJY3b+GAPN9o2OT8GKFHR6q5ZK5v8vY627D70623Va4GC5GKZMt5+cJZ2zzj9cdZVQ/yFDtgw/Gk/86kpv8J2qzwAPgcQhg53jLAI2W09Sd7WgcyPBDrh598GhdhYPm9CohDsBohHX6VyVG41eB2UBeSzp0YVj77uWICjx80C/vSGsaOT+20/ph8ocObwGy9dFscdW27uiUPLRGgHPp3g2tSGgFJ+N+mHhSCgBrwwzSxnkjm5UpWGd1zPZc8gN7Vj98YDAMKUJaAuV5LU3gamx14hjis5WbwBQe5rfbcrurCbpxQaRLALad3w4DmO3zO6DGYiPZ4pFyGlPzuwaeHXbye6MRO0cTRdjYEc2A3eaeqDdtzsj WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(6072148); SRVR:CY1PR04MB1980; BCL:0; PCL:0; RULEID:; SRVR:CY1PR04MB1980; X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1980; 4:1+xpnpv3hrf3XULC0LmL2Rf7LChkWojUc/DZ7ZiJPS8iH1S2Y6QA9LriGhR50gAaVGrKgaJWF143nI+Vp7X7jCLgnGzSvfYI0/vhHyHV2vZl6a0ZQ21QyLi1EuqpSdNGsc9sD8oyeP3l99/ls3Gs1Yn635K/Ttv6p9jHOx/OQsFPWN9fywAgYdWrtWQyBSoabMW+avIU62NFCjUAZp7p5l/3KGr3d0IfFC6ObE75LiCYjo3h9kVs6ebSf+kEv43+cNLAOSInkymVgqDNlDyN0HI6AXEmEXIwjU4DorfUDXhLFdt5KDEj1IUIjAs7rzNhjkeVfks69M2zH8iQVraFj/wRrTOMho06rcgw/d4cbV7+XX0WUYhnsW0k/dE4lJey0x9F3XecqCt+R5q9AtO/urRkxm8zI6QV2BEXpt+tkIhKwFqcbUHp3L2jSCSiOt8nSBRYbwWptt0X2mi0DeQWm6egHqanygxenkATHnaG6OaY34jn2Rnlb364yBvSBngdRPhQJJtCwgPWmH8nV6U4yLFODw1DanN5G94Q83aY3qI8rnJ7iegr2oixWINIX3r8TSIt3Oz83H4SS7EbHCu0TqwwypF0QuyzGMpIGmuVnrY64KnNDY1t6pR0bNBtt4EkS53mRZF2pfEjW/pS7HyzRI9gy1Uw9Q18LV5qvG2/I4cwog+JuTvrjmc+JpifUjQfW/NjMdwPQJq1K7EEZN2PAzB9TLUxknMQxi1KjJGqL/c= X-Forefront-PRVS: 0287BBA78D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39450400003)(39840400002)(39410400002)(39850400002)(39400400002)(39860400002)(33646002)(6512007)(9686003)(6666003)(81166006)(66066001)(8676002)(76176999)(7736002)(50986999)(305945005)(189998001)(50466002)(42186005)(6486002)(2950100002)(6916009)(47776003)(48376002)(54906002)(4326008)(2906002)(38730400002)(110136004)(5003940100001)(53936002)(25786009)(36756003)(575784001)(86362001)(50226002)(1076002)(6116002)(3846002)(5660300001)(85782001)(85772001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR04MB1980; H:washi.fujisawa.hgst.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR04MB1980; 23:JxzYsJsGltIxmR9uECRQrm69rDduZlvPJxUMUhipP?= =?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tN3xZH5ZZLrn7XomjwZKWSx8tgNRFwZXmtxtMx2c0yP66A1pYZIWjBKi3qsOWVzpwwS3+A79BWz9y5p/Y7fdR70A+OY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1980; 7:T6kcajJiM4JsDr46+OUoyKFApl/Br/2JakZ12qN7ZQ2BFDiGybGB9pABE5Bl8yHNG67vO0NxNVGRC8ywQ6T5pCrTBZwu7SFdC7NMLA7R/2UFbyp3fnKX4HCQBLJZ0M3DSu4rK8nbW0nWA676JbiJkU3jM3W09/SJMi3xo0msNofhbnCIzQatH5+yNoHoPASESjpm1bDHahuX2XdXPhzO7n1lOiUE+zuTDpElq7MMYH9Wt9MVbDoqrF5cl+4MxGTW+gA8RfTwKMJa3gCVtK984ffByySa+KHgeE3m8AQz/PYW2CDim4nmYNknMx7TfhiqqD1L3di4/5ChdKYVlZHegA==; 20:2RAlJMZzIcOZb2VjjbHJsj19VT234J+QPzU4aZJNS9C441++KwzUVzQppLTyBKdviC2MyHwz3pJFNpUIYnwA687eZ+HZTVdqEquatmTVws/xp1jpfveMw3cP391ZUsIKL4TVHHPtip4kRUERCpdQYyKS4K82368qnKaIYNIt5Hs= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2017 07:51:47.8996 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR04MB1980 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 From: Damien Le Moal Resetting a zone write pointer is equivalent to discarding sectors: after a reset, the zone sectors will contain zeros (or the format pattern). So there is no need for mutual exclusion between a zone reset and write. Similarly to discard, make it the responsability of the user to properly synchronize between reset and write (as is done now for discard and write). Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig --- drivers/scsi/sd_zbc.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 29ba1d7..fcf0fad 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -237,7 +237,6 @@ int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); sector_t sector = blk_rq_pos(rq); sector_t block = sectors_to_logical(sdkp->device, sector); - unsigned int zno = block >> sdkp->zone_shift; if (!sd_is_zoned(sdkp)) /* Not a zoned device */ @@ -250,11 +249,6 @@ int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) /* Unaligned request */ return BLKPREP_KILL; - /* Do not allow concurrent reset and writes */ - if (sdkp->zones_wlock && - test_and_set_bit(zno, sdkp->zones_wlock)) - return BLKPREP_DEFER; - cmd->cmd_len = 16; memset(cmd->cmnd, 0, cmd->cmd_len); cmd->cmnd[0] = ZBC_OUT; @@ -324,38 +318,34 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, struct request *rq = cmd->request; switch (req_op(rq)) { + case REQ_OP_ZONE_RESET: + + if (result && + sshdr->sense_key == ILLEGAL_REQUEST && + sshdr->asc == 0x24) + /* + * INVALID FIELD IN CDB error: reset of a conventional + * zone was attempted. Nothing to worry about, so be + * quiet about the error. + */ + rq->rq_flags |= RQF_QUIET; + break; + case REQ_OP_WRITE: case REQ_OP_WRITE_SAME: - case REQ_OP_ZONE_RESET: /* Unlock the zone */ sd_zbc_write_unlock_zone(cmd); - if (!result || - sshdr->sense_key != ILLEGAL_REQUEST) - break; - - switch (sshdr->asc) { - case 0x24: - /* - * INVALID FIELD IN CDB error: For a zone reset, - * this means that a reset of a conventional - * zone was attempted. Nothing to worry about in - * this case, so be quiet about the error. - */ - if (req_op(rq) == REQ_OP_ZONE_RESET) - rq->rq_flags |= RQF_QUIET; - break; - case 0x21: + if (result && + sshdr->sense_key == ILLEGAL_REQUEST && + sshdr->asc == 0x21) /* * INVALID ADDRESS FOR WRITE error: It is unlikely that * retrying write requests failed with any kind of * alignement error will result in success. So don't. */ cmd->allowed = 0; - break; - } - break; case REQ_OP_ZONE_REPORT: