From patchwork Thu Aug 1 17:26:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11071071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9178D13A0 for ; Thu, 1 Aug 2019 17:27:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78118286C1 for ; Thu, 1 Aug 2019 17:27:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BC6A286D1; Thu, 1 Aug 2019 17:27:18 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 0D087286C1 for ; Thu, 1 Aug 2019 17:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732497AbfHAR1R (ORCPT ); Thu, 1 Aug 2019 13:27:17 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:50984 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729220AbfHAR1R (ORCPT ); Thu, 1 Aug 2019 13:27:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1564680437; x=1596216437; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Mvy1iTjx2yZ5G9ARlRidklLCeyu3cbc66p6imiUTEB4=; b=FOCAfLTE1toX0kYN7jj6e2NwVDr75EGPSgGno2WqeqlYna1lpSuYY+f4 YTyYZ8xq72sPGZMDwbreZMXUwhGpI33M3ndbIvldtXDqfy6F/X08wH7cu gwnk/5c+qQg+ZYTL4Srw8hm/DqdUYapLFr+KQLYlt+T9Z2R0ZuUZiEmEH 2NYzfT1inaJ+7bCNdILAOuDe0f+MOPtQRuozA7zBEnr6z8GWY4MzFm4Gy JROxXVdi8buBOCQ5mxCyyT9sPk2l7kN9didthRAckhVoR781Rqjv652LC J77xQpR2+q468xs3sEV6PeparEUggDrz/Tyv0fw0LZaffmDaE2xcimxcm A==; IronPort-SDR: WZPqu/nSH7YxEm1eqwSqLLTc0fV04oZLWYdhhBuBZAI8WHb286Pp94FV6DQyS39mU3ifKxtfLI uELIqFSfoODN81r7ww3B0B7t52YHbfg6MA8WXNco2CKWmAZlJQRGU20IHs8d9dJ4D/jQPsiCO5 QUraJWz4tPW750DmXUX85udLBptUTZYgH6qp/PW9OqdSwCUi6EjjxLsxWxae05WVAqELKV/MYN 1v/9XaGx8dj7LCeWMn0Ty27WJI97cf4jgHIDj914Ghrpvd+bLapp7Bhv3BaBEakgC0Nc5OLQwX QWQ= X-IronPort-AV: E=Sophos;i="5.64,334,1559491200"; d="scan'208";a="116323226" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2019 01:27:07 +0800 IronPort-SDR: SOSuLcWdPRdqx2Rqa7WQnr8GE/KtF5bVMG+ZzFRC5ylTiVRYmEmfBElk6r653kk65iBMXYZZ9F 8S5V/aa/HjcxLh/gDUL9gV5F4q5R+3NPsBKRfiIhvDqCwkixrWx8acQRUsUnApT7mGN6cDgz1W 1d2XursPbm54ksKJgoOBaaeIZdlKWs+Ds5S50cjjEI2C8enfStolZXbJjihQziRth50cNX1jGN SIF7dopMmicDicoaZpw+Z887mPDeMXzsKe12wGQv38zw+7ctayPKDAj15wI7B959ejTsf+yHY4 hNuDcTpmdJP0cMck2SKhTaoP Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2019 10:25:06 -0700 IronPort-SDR: nV8qtY4XPDj0N/iW1mPkGGi7wlvLeP87GeAYecaGLRsTHM4uQBWclabSUWHg4ThDymdMoe+PB8 VQ+24EpkQwhgQwS/UpOT3Pm38WdR15Kif5uREjEdXrwhPlOzORQ8a5atlkEFKV7+7y7yyQlNRi x+jpcvAlyMX6lvI36qLF7OCD810aRi6+7NX5NGnNlgLwbuT/pze4zBX5bOENUoTVVW3vnkcGXo Zyd6jQiKOJf0kPcFayo5/zg7OJ3UGhinUMo0rFqdIItfjhdJDicVrlacwk16sAu8c1zDsg9wUF 2uU= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Aug 2019 10:27:07 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Cc: axboe@kernel.dk, jejb@linux.ibm.com, dennis@kernel.org, hare@suse.com, damien.lemoal@wdc.com, sagi@grimberg.me, dennisszhou@gmail.com, jthumshirn@suse.de, osandov@fb.com, ming.lei@redhat.com, tj@kernel.org, bvanassche@acm.org, martin.petersen@oracle.com, Chaitanya Kulkarni Subject: [PATCH V2 1/4] block: add req op to reset all zones and flag Date: Thu, 1 Aug 2019 10:26:35 -0700 Message-Id: <20190801172638.4060-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190801172638.4060-1-chaitanya.kulkarni@wdc.com> References: <20190801172638.4060-1-chaitanya.kulkarni@wdc.com> 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 This patch introduces a new request operation REQ_OP_ZONE_RESET_ALL. This is useful for the applications like mkfs where it needs to reset all the zones present on the underlying block device. As part for this patch we also introduce new QUEUE_FLAG_ZONE_RESETALL which indicates the queue zone reset all capability and corresponding helper macro. Reviewed-by: Damien Le Moal Signed-off-by: Chaitanya Kulkarni Reviewed-by: Hannes Reinecke --- include/linux/blk_types.h | 2 ++ include/linux/blkdev.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index feff3fe4467e..3991b580d6bd 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -282,6 +282,8 @@ enum req_opf { REQ_OP_ZONE_RESET = 6, /* write the same sector many times */ REQ_OP_WRITE_SAME = 7, + /* reset all the zone present on the device */ + REQ_OP_ZONE_RESET_ALL = 8, /* write the zero filled sector many times */ REQ_OP_WRITE_ZEROES = 9, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1ef375dafb1c..474008bffee2 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -611,6 +611,7 @@ struct request_queue { #define QUEUE_FLAG_SCSI_PASSTHROUGH 23 /* queue supports SCSI commands */ #define QUEUE_FLAG_QUIESCED 24 /* queue has been quiesced */ #define QUEUE_FLAG_PCI_P2PDMA 25 /* device supports PCI p2p requests */ +#define QUEUE_FLAG_ZONE_RESETALL 26 /* supports Zone Reset All */ #define QUEUE_FLAG_MQ_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_SAME_COMP)) @@ -630,6 +631,8 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q); #define blk_queue_io_stat(q) test_bit(QUEUE_FLAG_IO_STAT, &(q)->queue_flags) #define blk_queue_add_random(q) test_bit(QUEUE_FLAG_ADD_RANDOM, &(q)->queue_flags) #define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags) +#define blk_queue_zone_resetall(q) \ + test_bit(QUEUE_FLAG_ZONE_RESETALL, &(q)->queue_flags) #define blk_queue_secure_erase(q) \ (test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags)) #define blk_queue_dax(q) test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags) From patchwork Thu Aug 1 17:26:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11071075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 729801398 for ; Thu, 1 Aug 2019 17:27:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58E5B286C0 for ; Thu, 1 Aug 2019 17:27:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CCA7286CB; Thu, 1 Aug 2019 17:27:20 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 D8BB0286C0 for ; Thu, 1 Aug 2019 17:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732608AbfHAR1T (ORCPT ); Thu, 1 Aug 2019 13:27:19 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:47187 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729220AbfHAR1T (ORCPT ); Thu, 1 Aug 2019 13:27:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1564680438; x=1596216438; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=C+H5gUGHdpr37/tOvEeOA73qgjfRJSOePkW4JUKuD5s=; b=n0YAi/xGwv6RHAPdIaD8Um1ulev5PIyPQdK5wEtREEeyeGWCtg7SqlQZ 46SdS6vCmbh4zNz/s+HYDNsDPlLIv/HNXSYRFZunyiiNdxqdPq9n85HhO YiTuCSgscD5lKQNlz3GmX70d7yk9HU1OBx/o3kJvNEINrr3GYAMN7HGHP k7JvhuLth1fMU5u34avU5EW19UHcEkq5vAAs9hfMe0A9bdcXB/8AtnZWV yUXJqKzhTaw0FPyA94ImlK2bW1vwAZ6vJlGkjQpqMXg77Z9luMsLAjRLR oMazUhMQI9zVDGZILnT7wI2+FWUzgZaKwiExmbqJlBQ7itWVokZvC2Bjp A==; IronPort-SDR: /UwQpoDUY4A7IqpnLY1+rKOT/dMJEIk7eNKtvaTK5Y6fgOtOl59DTelMc3PQe7T+1UqtiQfgOZ okJtxYWAAg/nV08zLSKEFLhhOQLi1f+HHmC/QYewTriWlxflnixWO4UzWuyAmOQL7ls0HPrclU piVA8ePVmWKAOWiuk5YW4QwesUwlxTdpRy0rz7tUbJKIAyqXsM6a7LCwOYFSBEOQyIBQryeFOp Z/3VLVOoBfsh7AaRxGuIWz36DeWGrukvMwYTDnwPcZeyPYrED9/vi3garGkJG8oD11GpDEe16w 5ow= X-IronPort-AV: E=Sophos;i="5.64,334,1559491200"; d="scan'208";a="119390131" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2019 01:27:18 +0800 IronPort-SDR: b2upGwq+GyCyrUQUrw50XZd0tc3XTJgb3R4ydCGf4pC2soprbE0EX/+KUYQ3ZVvzJwal5pbRm4 VETGmbwOnSMKVsjqtIi+3h4QRlUAp+lhrkZoA1I3/FfwxweSPg/hVHfGX6+AOX+dK9nIXhpnDx +58b97nn8oNh/7uHkjYegcEr+Tm0DHIQQJ+gmxfVn4HLDGcqV8hNobRb/HQe+YfKaZ0aTNY7sV QBx3t5gYbA8RRySesTfyA0rhyvTavAU2FnGQnYU7vec8PIkgoed9O6f6mbsbqTY/OsWasMnCy2 b/BsUQG91djlEw5ikx86Mfvr Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2019 10:25:16 -0700 IronPort-SDR: +ufA1CYTZ8W1Duj6KnJzcBk0Zb6LUDEPMdG1ySwXrqU3cBe6Cq39sSFE6LMo5lQS9TNbIu0SGQ 5Lw4pEdAl1EntNM/u/hhAKt5cgqYeveG56K57lSNuyebZzPWzNjy2OHKAooVjlJA4dnPWM5QDd NzEETOvOGRmiEHfTNw6UYhE5gWvvmz4wjp3WznMrxkuVIytFHBcbu87d/AsFbZFMPzXuxeew7h 3AAUw+yELdGYjFMyL0TP5F4EZuaEYoLnUB0sty2Kqxn5VurKLfjCTBpwqz3RQIrLv4FzWUuTsL IiQ= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Aug 2019 10:27:18 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Cc: axboe@kernel.dk, jejb@linux.ibm.com, dennis@kernel.org, hare@suse.com, damien.lemoal@wdc.com, sagi@grimberg.me, dennisszhou@gmail.com, jthumshirn@suse.de, osandov@fb.com, ming.lei@redhat.com, tj@kernel.org, bvanassche@acm.org, martin.petersen@oracle.com, Chaitanya Kulkarni Subject: [PATCH V2 2/4] blk-zoned: implement REQ_OP_ZONE_RESET_ALL Date: Thu, 1 Aug 2019 10:26:36 -0700 Message-Id: <20190801172638.4060-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190801172638.4060-1-chaitanya.kulkarni@wdc.com> References: <20190801172638.4060-1-chaitanya.kulkarni@wdc.com> 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 This implements REQ_OP_ZONE_RESET_ALL as a special case of the block device zone reset operations where we just simply issue bio with the newly introduced req op. We issue this req op when the number of sectors is equal to the device's partition's number of sectors and device has no partitions. We also add support so that blk_op_str() can print the new reset-all zone operation. This patch also adds a generic make request check for newly introduced REQ_OP_ZONE_RESET_ALL req_opf. We simply return error when queue is zoned and reset-all flag is not set for REQ_OP_ZONE_RESET_ALL. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- block/blk-core.c | 5 +++++ block/blk-zoned.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index d0cc6e14d2f0..1b53ab56228b 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -129,6 +129,7 @@ static const char *const blk_op_name[] = { REQ_OP_NAME(DISCARD), REQ_OP_NAME(SECURE_ERASE), REQ_OP_NAME(ZONE_RESET), + REQ_OP_NAME(ZONE_RESET_ALL), REQ_OP_NAME(WRITE_SAME), REQ_OP_NAME(WRITE_ZEROES), REQ_OP_NAME(SCSI_IN), @@ -931,6 +932,10 @@ generic_make_request_checks(struct bio *bio) if (!blk_queue_is_zoned(q)) goto not_supported; break; + case REQ_OP_ZONE_RESET_ALL: + if (!blk_queue_is_zoned(q) || !blk_queue_zone_resetall(q)) + goto not_supported; + break; case REQ_OP_WRITE_ZEROES: if (!q->limits.max_write_zeroes_sectors) goto not_supported; diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 6c503824ba3f..4bc5f260248a 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -202,6 +202,42 @@ int blkdev_report_zones(struct block_device *bdev, sector_t sector, } EXPORT_SYMBOL_GPL(blkdev_report_zones); +/* + * Special case of zone reset operation to reset all zones in one command, + * useful for applications like mkfs. + */ +static int __blkdev_reset_all_zones(struct block_device *bdev, gfp_t gfp_mask) +{ + struct bio *bio = bio_alloc(gfp_mask, 0); + int ret; + + /* across the zones operations, don't need any sectors */ + bio_set_dev(bio, bdev); + bio_set_op_attrs(bio, REQ_OP_ZONE_RESET_ALL, 0); + + ret = submit_bio_wait(bio); + bio_put(bio); + + return ret; +} + +static inline bool blkdev_allow_reset_all_zones(struct block_device *bdev, + sector_t nr_sectors) +{ + if (!blk_queue_zone_resetall(bdev_get_queue(bdev))) + return false; + + if (nr_sectors != part_nr_sects_read(bdev->bd_part)) + return false; + /* + * REQ_OP_ZONE_RESET_ALL can be executed only if the block device is + * the entire disk, that is, if the blocks device start offset is 0 and + * its capacity is the same as the entire disk. + */ + return get_start_sect(bdev) == 0 && + part_nr_sects_read(bdev->bd_part) == get_capacity(bdev->bd_disk); +} + /** * blkdev_reset_zones - Reset zones write pointer * @bdev: Target block device @@ -235,6 +271,9 @@ int blkdev_reset_zones(struct block_device *bdev, /* Out of range */ return -EINVAL; + if (blkdev_allow_reset_all_zones(bdev, nr_sectors)) + return __blkdev_reset_all_zones(bdev, gfp_mask); + /* Check alignment (handle eventual smaller last zone) */ zone_sectors = blk_queue_zone_sectors(q); if (sector & (zone_sectors - 1)) From patchwork Thu Aug 1 17:26:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11071079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71E5E13A0 for ; Thu, 1 Aug 2019 17:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57D09286C0 for ; Thu, 1 Aug 2019 17:27:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C1D1286CB; Thu, 1 Aug 2019 17:27:31 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 CFDB8286C0 for ; Thu, 1 Aug 2019 17:27:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732623AbfHAR1a (ORCPT ); Thu, 1 Aug 2019 13:27:30 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:47212 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729220AbfHAR1a (ORCPT ); Thu, 1 Aug 2019 13:27:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1564680449; x=1596216449; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=kr6NBKZc2Ega07jdtV+71j11WhC8y6Z4/tAAftdTck8=; b=WXNy6Q3cCaJl51jmI7f/AezC0LDvBDRs11xa0MVcYeu5cjh6hKboWDtW WtFDGm4Vz7pzHHgUwHVQ8thaoIxwb8pn++6jKqw+vprwYjqgRse5Y5D5Y xYXwZ0SXyyUuIbiWNR3qHVvdt6DoEOlGxISAZOKulPz+DjHvauEVZL+Lv Zlf37lI48SoYzBlEq61cGxI1gQsLmWF1AluevW3XeTPb6FP0dLkQW/GE8 1m6hpcA6AY3UcTQOpXHtn4dB/ix3Rb6zVnyw9ECNiepC1pu7K/iw5UOvT X0kXPSU91oNpESI0iKetHffsZ29lIFooNeFmHHeWstNRjKbwmG3t9RZkH Q==; IronPort-SDR: n1+yLOBwnIswHmBGJ/TKox/2w8/mTWP5b9ybTFKGNlssLGFcwjumt9sTgRHDdhb4NN2vUUN/je /EPzfWMB0A67sec7XwVa7aawqXEdRJXESHhlE97XXf1nH8P11v7KeME/PkliEkcfB6CaC0WGpe kwK4VWOnWrJDG3QC4fKspJGvN50dOAVoOcRj1h1+nvThwIi7nD++75SjJ7w8N35XYlwfvZyGpE usNzZFl+u3FeTSe/OhIfWwx4/6mewKHhI/hGLw+p4o1UcESizyjGel+iTMH0TJCZimmo5iqnFs ZIY= X-IronPort-AV: E=Sophos;i="5.64,334,1559491200"; d="scan'208";a="119390154" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2019 01:27:29 +0800 IronPort-SDR: Bc/r0WdCmf1fRThNnsDlV5FfXBCpPm968cUwjiX4t2sQcMOIyqOaKU4Xaf9tTg0ejfcVnIAkHR SNAy0MUGSc9BJn24zFiIyC+qar4VDIcYKmLGjtD0+F0/8/QUR+F4Ln4anJiBG2QyOiYDM+PFNG npY3Fso17wDZ/wSPqMDGEGAgchDyDGNsh8x1X1sA3AHgtaaMCWAOSrRiEoTe8Kz8hxRtjJCdyl m8D2dIeYEveQHnt5tn2c7TJ2tDFSwh21blNdVOJM67jTW/GUeVeBN9wOXXjvUb+/tCDxM/EsNF vFdWQou96zWoIimLh/vhs1za Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2019 10:25:27 -0700 IronPort-SDR: IMKp/7ZpF14OtQ62xQVbuK9VKTOf7dS+g3q7Z19dEkpTbZigNp80zYX88Y2GUrkUMcQBJUJNdz 4WM+kvsHKQyVAaLAD5zRfWM0BtLlTxnDazPT1qQpHiPfHfxGAF3f22p+/bZkLJx+rkqVwvTwR3 l2MVZzRIeZvMbyDTwTaWWuoFmxA+SgppxfimSe9j4wyC/sAtzBjzsmNX81YToGNgihmz42xTzA XwuKVuS1KtvsfWmOCHd36c9Qusl961X6Dqsvy8fvVG4rUurT+P10zvD5BoFkARJbHAfOMlji9O r6k= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Aug 2019 10:27:29 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Cc: axboe@kernel.dk, jejb@linux.ibm.com, dennis@kernel.org, hare@suse.com, damien.lemoal@wdc.com, sagi@grimberg.me, dennisszhou@gmail.com, jthumshirn@suse.de, osandov@fb.com, ming.lei@redhat.com, tj@kernel.org, bvanassche@acm.org, martin.petersen@oracle.com, Chaitanya Kulkarni Subject: [PATCH V2 3/4] scsi: implement REQ_OP_ZONE_RESET_ALL Date: Thu, 1 Aug 2019 10:26:37 -0700 Message-Id: <20190801172638.4060-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190801172638.4060-1-chaitanya.kulkarni@wdc.com> References: <20190801172638.4060-1-chaitanya.kulkarni@wdc.com> 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 This patch implements the zone reset all operation for sd_zbc.c. We add a new boolean parameter for the sd_zbc_setup_reset_cmd() to indicate REQ_OP_ZONE_RESET_ALL command setup. Along with that we add support in the completion path for the zone reset all. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke Acked-by: Martin K. Petersen --- drivers/scsi/sd.c | 5 ++++- drivers/scsi/sd.h | 5 +++-- drivers/scsi/sd_zbc.c | 10 ++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index a3406bd62391..42ef930c4df5 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1292,7 +1292,9 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd) case REQ_OP_WRITE: return sd_setup_read_write_cmnd(cmd); case REQ_OP_ZONE_RESET: - return sd_zbc_setup_reset_cmnd(cmd); + return sd_zbc_setup_reset_cmnd(cmd, false); + case REQ_OP_ZONE_RESET_ALL: + return sd_zbc_setup_reset_cmnd(cmd, true); default: WARN_ON_ONCE(1); return BLK_STS_NOTSUPP; @@ -1958,6 +1960,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) case REQ_OP_WRITE_ZEROES: case REQ_OP_WRITE_SAME: case REQ_OP_ZONE_RESET: + case REQ_OP_ZONE_RESET_ALL: if (!result) { good_bytes = blk_rq_bytes(req); scsi_set_resid(SCpnt, 0); diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 38c50946fc42..1eab779f812b 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h @@ -209,7 +209,7 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp) extern int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer); extern void sd_zbc_print_zones(struct scsi_disk *sdkp); -extern blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd); +extern blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd, bool all); extern void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, struct scsi_sense_hdr *sshdr); extern int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, @@ -225,7 +225,8 @@ static inline int sd_zbc_read_zones(struct scsi_disk *sdkp, static inline void sd_zbc_print_zones(struct scsi_disk *sdkp) {} -static inline blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) +static inline blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd, + bool all) { return BLK_STS_TARGET; } diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index db16c19e05c4..c1c7140ea787 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -209,10 +209,11 @@ static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp) /** * sd_zbc_setup_reset_cmnd - Prepare a RESET WRITE POINTER scsi command. * @cmd: the command to setup + * @all: Reset all zones control. * * Called from sd_init_command() for a REQ_OP_ZONE_RESET request. */ -blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) +blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd, bool all) { struct request *rq = cmd->request; struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); @@ -234,7 +235,10 @@ blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) memset(cmd->cmnd, 0, cmd->cmd_len); cmd->cmnd[0] = ZBC_OUT; cmd->cmnd[1] = ZO_RESET_WRITE_POINTER; - put_unaligned_be64(block, &cmd->cmnd[2]); + if (all) + cmd->cmnd[14] = 0x1; + else + put_unaligned_be64(block, &cmd->cmnd[2]); rq->timeout = SD_TIMEOUT; cmd->sc_data_direction = DMA_NONE; @@ -261,6 +265,7 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, switch (req_op(rq)) { case REQ_OP_ZONE_RESET: + case REQ_OP_ZONE_RESET_ALL: if (result && sshdr->sense_key == ILLEGAL_REQUEST && @@ -487,6 +492,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf) /* The drive satisfies the kernel restrictions: set it up */ blk_queue_chunk_sectors(sdkp->disk->queue, logical_to_sectors(sdkp->device, zone_blocks)); + blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, sdkp->disk->queue); nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks); /* READ16/WRITE16 is mandatory for ZBC disks */ From patchwork Thu Aug 1 17:26:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11071083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3E5013A0 for ; Thu, 1 Aug 2019 17:27:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7495286C8 for ; Thu, 1 Aug 2019 17:27:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB7B1286CB; Thu, 1 Aug 2019 17: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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 4E6D7286C0 for ; Thu, 1 Aug 2019 17:27:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732000AbfHAR1m (ORCPT ); Thu, 1 Aug 2019 13:27:42 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:51031 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729220AbfHAR1m (ORCPT ); Thu, 1 Aug 2019 13:27:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1564680462; x=1596216462; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=IgUzTAowEehxVPy1GjSbTQ+bVkESBVQsvVByDFqex5Q=; b=IVBqXIe8mTf3a2OSazl0XeF5+zIVUdJr9GAjJihObEKaBYcnE2XUi0dH iwvkqVec/Q7VGBadA/QWIl9rkCnpzRB0U/iQP8aFjaTToDxBcOLWqqfEs ygSVU7Fi2LfQhubKugh4/z0x1TwaV5qxSdVYoaj4kc+X8ThKY60mkLCRh O/Kcu1kndJhc95pdLcYEhZs9Fmd12YRal4hEYZzTdldN9FYajsHH7iELf tbfH5lSw8d7ynci6NvayDRYE3ZLHm61TjfuyLhIwVyQdMHugld2Di4FRb 3MU6q+xEOQ6XnO6/p3gj5D8aX8bvgIphOmW66EdzAlVYV9Kt9K47tYIfq A==; IronPort-SDR: eSYnRvgxiL+/F7P8Wqc6SDkYaknp41qWsJ31FTmfsc54wWJ1UURkflut1eAbVgOk36oarUQ8+f E59uxLfKFX/SDm0UANZyu/zxWIhVTDfw0Oq5bSviq0XnxQkZMI0ER9tB5wxGzZZ0abtlKI25kG FRvAv67DkrSYa6P4NpVuirFKPH7IbERpQtq3no+Vs9aHZxgHKg+6FxDvAsxCSYzNDVWfGQSk7Z YB+8RoXeRXqx+Pa0i98M246DD0pb9tewIEtNlcbaju5wXB29Osaa4HKhIcVlEyLIRAbwJm/1a4 RrQ= X-IronPort-AV: E=Sophos;i="5.64,334,1559491200"; d="scan'208";a="116323343" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2019 01:27:38 +0800 IronPort-SDR: gQgFn+iUy/qpOac/no4D9fBpn0XhbarUz7A3tpKAWRm1LG+2C+3NwJQmIif0o/tdCN2B2RTnIQ Kn/kCypcy67GYveNZqmTm6ny/RToRiDAiKoOVUwQLQfXC24JgXICH2v0PEmtBVdEMI+riA3de8 h069sftsyIqXyPyDOYWaW8xaR5phqaMgZVZa1VpOQHtno+qC94a1l4k72T98OJX2ikbBVh9HyM xoEldhYhUxMTh3n9GGi7zBweLoIPOCl7zNvrt+VjMfMvCrT4Om0vqq5UDo5Q1/4JA0H2fMyZT+ 2QxCkCIM1Q11ckv/sWBr5n/z Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2019 10:25:37 -0700 IronPort-SDR: Fx5zpqxzUinEvFvpUg9ulqrpVDgeXiuzbALQ9GbOllbA9p/VJ4S9rCLHO/bljnIxiZc+5C78DR fNguOp4tFzKoKcSTyaqsGk+Pjyfws9WFcFGwufEAP6L/uofwWKN2F2oiDvuBzDfLb2OtJHuvFD bBj3gREjvxlCC4uvCl8G3kYeKmffJrPSH5Waq55w3CoYJY4Fy7wq664GvaB6oQMQ163wC/RITj rbM11PLvv3tVfJ5ZEd78dVcoJDoPV7Pk0GiK4+aOVTfuwMhGChh6OeEfpXhLohGP0bexVbjyKX xDs= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 01 Aug 2019 10:27:38 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Cc: axboe@kernel.dk, jejb@linux.ibm.com, dennis@kernel.org, hare@suse.com, damien.lemoal@wdc.com, sagi@grimberg.me, dennisszhou@gmail.com, jthumshirn@suse.de, osandov@fb.com, ming.lei@redhat.com, tj@kernel.org, bvanassche@acm.org, martin.petersen@oracle.com, Chaitanya Kulkarni Subject: [PATCH V2 4/4] null_blk: implement REQ_OP_ZONE_RESET_ALL Date: Thu, 1 Aug 2019 10:26:38 -0700 Message-Id: <20190801172638.4060-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190801172638.4060-1-chaitanya.kulkarni@wdc.com> References: <20190801172638.4060-1-chaitanya.kulkarni@wdc.com> 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 This patch implements newly introduced zone reset all operation for null_blk driver. Reviewed-by: Damien Le Moal Signed-off-by: Chaitanya Kulkarni Reviewed-by: Hannes Reinecke --- drivers/block/null_blk_main.c | 3 +++ drivers/block/null_blk_zoned.c | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 99328ded60d1..99c56d72ff78 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1214,6 +1214,8 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) null_zone_write(cmd, sector, nr_sectors); else if (op == REQ_OP_ZONE_RESET) null_zone_reset(cmd, sector); + else if (op == REQ_OP_ZONE_RESET_ALL) + null_zone_reset(cmd, 0); } out: /* Complete IO by inline, softirq or timer */ @@ -1688,6 +1690,7 @@ static int null_add_dev(struct nullb_device *dev) blk_queue_chunk_sectors(nullb->q, dev->zone_size_sects); nullb->q->limits.zoned = BLK_ZONED_HM; + blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, nullb->q); } nullb->q->queuedata = nullb; diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c index cb28d93f2bd1..8c7f5bf81975 100644 --- a/drivers/block/null_blk_zoned.c +++ b/drivers/block/null_blk_zoned.c @@ -125,12 +125,28 @@ void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) struct nullb_device *dev = cmd->nq->dev; unsigned int zno = null_zone_no(dev, sector); struct blk_zone *zone = &dev->zones[zno]; + size_t i; + + switch (req_op(cmd->rq)) { + case REQ_OP_ZONE_RESET_ALL: + for (i = 0; i < dev->nr_zones; i++) { + if (zone[i].type == BLK_ZONE_TYPE_CONVENTIONAL) + continue; + zone[i].cond = BLK_ZONE_COND_EMPTY; + zone[i].wp = zone[i].start; + } + break; + case REQ_OP_ZONE_RESET: + if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { + cmd->error = BLK_STS_IOERR; + return; + } - if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { - cmd->error = BLK_STS_IOERR; - return; + zone->cond = BLK_ZONE_COND_EMPTY; + zone->wp = zone->start; + break; + default: + cmd->error = BLK_STS_NOTSUPP; + break; } - - zone->cond = BLK_ZONE_COND_EMPTY; - zone->wp = zone->start; }