From patchwork Wed Jul 31 21:00:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11069491 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 A1DEE746 for ; Wed, 31 Jul 2019 21:01:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91E7E27F17 for ; Wed, 31 Jul 2019 21:01:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85A1627F3E; Wed, 31 Jul 2019 21:01:39 +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=unavailable 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 1BE2327F81 for ; Wed, 31 Jul 2019 21:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727872AbfGaVBg (ORCPT ); Wed, 31 Jul 2019 17:01:36 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:17945 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbfGaVBg (ORCPT ); Wed, 31 Jul 2019 17:01:36 -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=1564606895; x=1596142895; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Uc9TthtR9NnaW61L0kXW7vaDMv3lHgKYDZLVYJi5404=; b=GrylOnjMEN56GCaLffUkA8ojymIZQ79I+VyQ2OckgLtjJca+FOh9NHG4 /vwtfM9AAfyg3pHXqGo/cAm2eT4rr20hLc+jWAma4dW3y9/4g8pf5lp5W 2c0NuCKRdTO0CTz9MAshTtdG5BySLJmYElg4wwER8K3wvFHZopaqvrrIR D7v3FAV5DqwlbGypH55W7a4cBM0zuSSEzHkX9mygYGZ5btR2WEPD5hrmP gg8mVFZsc8k3dbNG+kOaM5PDOgSMwW2o7TkwRRznh3rl3X9IGYTPBQAkP HIAtaxnzTBgaH2QMAGYyteuWyW0yewlPHE7CLcuskYKHR5mQ/0YuJOZJ/ w==; IronPort-SDR: YaJUD6/VIEsevjYw0jsqVG4PiFJhobkkohVj3TPT9mvn1vHpUbSQDOH1vfrbKX6aAS262vZmbt 13cI4PIHrspRfm/w3AsipNQPwA86Uz+Zk81kLxGAp69+cHDwnhTQIJ32xt0OCAU3itDtOs7/P4 vGDfL5s8IwnLGpYThaReJ0vL6XZVcFg6VIcZABbO24gIgylyVG6jY6dFHz/NKT9lDU4LG0bHp6 6RZ/RnKhz7RY9Eejje0VaIh/NtOYU5IMRn1ZrmRuPs9c022KG6saDTo1b8CIHLltv4ZWk4Ylau MmU= X-IronPort-AV: E=Sophos;i="5.64,331,1559491200"; d="scan'208";a="221104959" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 01 Aug 2019 05:01:31 +0800 IronPort-SDR: iszyYmGP4yl5R0LNhtzM34BDmtyjOTaCW//GnYYSWQz/SRAV1PTQAvJcdnuDH0WeMhXj/Eiij7 hol2MJa8JE6ouuN38AaZNpuskRKlgRH/+boPL/BJnGA1N5G2c2i0SeJSZ943uFmUByJGPT91fz xDaU2Gfj6dSQxhScW0tFEsynitXy2zVW+TX1D1UbHnhuJPrjC0kJfe0ahV5KrvPTfqWx3nmvCZ 6q4kocNidWF/VrdV6DTDwBqF/0+ZXbJXRbYE5gVKnxQsyOJHwrnvqtpfiCiTjTlnWjGcG9klWw HgOdEKAwDD+FdhvagEqzb4WP 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; 31 Jul 2019 13:59:32 -0700 IronPort-SDR: jcTMF2wgp01/wp9D91MD+1rWgcw8U4Sf2Nkhjuwc5/gKuAc42SrAjy3kCy/K/iOu+jePn/PlDD 0kkguQjDx6rY2F7LO3TLr+4YKiHOutb8YvyX164qBUFqTFsr2YKnI0zHC+Ee7a0EyL+ClqKETr oQD1kN6ofx1kTUfk186PEc7aypDISDh2bCsx6kLoqiqwHc8bNRJaB3Cgs/FSGfePWBU1hm9uRl 9qXUjC6VdZvHGKHjhuNvIlPrtINWGFD0ieI1V7IzOFDWHLWUgSXlP7dD24qZ0XpsggxMco2xAc eKc= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 31 Jul 2019 14:01:31 -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 1/4] block: add req op to reset all zones and flag Date: Wed, 31 Jul 2019 14:00:59 -0700 Message-Id: <20190731210102.3472-2-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com> References: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com> 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 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. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Damien Le Moal --- 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 Wed Jul 31 21:01:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11069495 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 37A32912 for ; Wed, 31 Jul 2019 21:01:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 278C727F17 for ; Wed, 31 Jul 2019 21:01:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BCE827F3E; Wed, 31 Jul 2019 21:01:52 +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=unavailable 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 A94D827F81 for ; Wed, 31 Jul 2019 21:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728748AbfGaVBu (ORCPT ); Wed, 31 Jul 2019 17:01:50 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:43351 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbfGaVBu (ORCPT ); Wed, 31 Jul 2019 17:01:50 -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=1564606946; x=1596142946; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=xXRosNBom12mbtTqvIaHnPn0dojKd2BQd5wS5bKFIJ8=; b=E/zCpMvKZQpmz1QDzv1HQft8AesVAQaCtD+8jvWMS7DnycQScKzKiEnQ cIlM7UKKP2GvJ2eZwIdGN0ZAXvNJDfq1BahCQnRLrHL5qEQjJj4d/diD9 WpMCZIc67gl/TmONqYQfF0ZCoIbqLGAUgYcrQ8mnYtHHqdlxxH1fofYNT XF3iwxb1dDHNqphEta6e+OK8A8i9ZgZBHbBG5lCse4Bpx1MxlZlcS5HN5 QG1QwYd0Fi52G5EJNNrmIMEkfHK/ogSbSURvM3moPSkQVKUi01FojD0Wh hhjDFKvXG6RqVgAXHXmBzpTDghXcVnp827IKqLxl1kJ4LFhOecm5NyxZT g==; IronPort-SDR: pNwUQG4hG3Qlb4mn7YIeVOAMyrS+nbG+wVrDEmvgqp138qf3VbuOn53MkjqqwcwUmit+JkgDSa Q1Ti8ZXP5tlkCJCLunCfJV2H1lAAz8lFNdAMFkPZ4kdZEm/K8ccJ0/zPpDPutRkXTJSRghGiNw Ic3qPCaYmOR+K58BooWIqyf8R3BulEPec2k64IgUONWIllLfbgvgSVyeLYA4HOBfJFo9kAd3iU Wt3OUPySXi2oJKUEe7E7ENVq4u3Dp7nODegWnv9Y7mO8JgfaCsrW1NcXkHr5HEOAq0qJCzAYKb GGc= X-IronPort-AV: E=Sophos;i="5.64,331,1559491200"; d="scan'208";a="214835129" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 01 Aug 2019 05:02:14 +0800 IronPort-SDR: uwUuUOFRD/TdPYPjTZBrcscYv9RJO3lPurnKk/J27oSCoBW3Q5HrAxn/N91cZ7c9mV5QLv2y9h TvdbWOO5alVjUTuJr8SK/DXxnXM/rRGJMdp47J2Rk8JoiPjkRzrhvpzygi0A7I8RnEjgzQoulP a3DJ1fC1XbBNgPI/gkvx3C1L4Honti6d/So1wmocKYG25pNaZqHw0e5mJidW9V13G1nLvAtjd1 k5s9laMS2YonlfMe7CZIqWR/8OnqBQDv1lIAJeHPFUYxilivput+WGHm2Ru/Pfdtik7fvKgbKN rt5NunTv4YTx0TV/Kf6om0zg 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; 31 Jul 2019 13:59:42 -0700 IronPort-SDR: ej4UU8wzu99DbkrE3CX7QsAXE9xPZeJwNOA5PwTw8iz+LfCOLz/mEcMP3wAHYQgjv3KTxvcUAD Qm0+bm6U24UN4Lgh+NM0y0AEs+u7wVW3xBmGZwDDPPhq7Sb6siHu1kQBpu0gLJMUKeCTCkzry6 oJUo/7t5k8CZW2Bq8IM1e9OU+6dC/BC1H6puIXXxrwinr3dbRTPUy4d33gkglrwM1Sp8pZHoOd N8oDcX8H/XmdO/bTVl2/Czrnrxc+S5QoSlzcnFwgIjedXQDzyoNg2pmPeaXYW75DPmmQSNTcos buE= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 31 Jul 2019 14:01:42 -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 2/4] blk-zoned: implement REQ_OP_ZONE_RESET_ALL Date: Wed, 31 Jul 2019 14:01:00 -0700 Message-Id: <20190731210102.3472-3-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com> References: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com> 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 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 --- block/blk-core.c | 5 +++++ block/blk-zoned.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 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..d1ed728b7464 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -202,6 +202,43 @@ 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 = NULL; + int ret; + + /* across the zones operations, don't need any sectors */ + bio = bio_alloc(gfp_mask, 0); + 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 +272,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 Wed Jul 31 21:01:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11069499 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 396721399 for ; Wed, 31 Jul 2019 21:01:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 255EC27F17 for ; Wed, 31 Jul 2019 21:01:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17F4527F81; Wed, 31 Jul 2019 21:01:56 +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=unavailable 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 AA1A327F3E for ; Wed, 31 Jul 2019 21:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728974AbfGaVBz (ORCPT ); Wed, 31 Jul 2019 17:01:55 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:56740 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbfGaVBy (ORCPT ); Wed, 31 Jul 2019 17:01:54 -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=1564606913; x=1596142913; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=pQBm1c2isaDkQpGZVuJLwH7GcVWpg75894VS20D5BE8=; b=pii71/Qcnd17LSVr1zMCeKwBJTwSyFibbWX+twuHMBaQcNxkc0w7P2u5 Xlscvau2PkitG9ZTa+8ec5vQk6suN89HG/5kiubcxwTYqhOzkebKOoz+J 8q8OwVAa+KbIYXnG3muojJWAI0W+KJOKIEqAGfI81tJPS3uINreyKAEtY vunz+um4USk6C32RiA3Ktqkec9CJ3dOrxtX2oE3lUGLuUtyKDHfz+xVI4 /lWLCuZB7+PK4HAXtuaYRXTf2RU+2mGN4uU8NQYtmqzVSKumo3atxlcCs XaaRZIoc7nhT0s0lCS8Yf89cwDhBi9hvMZVZeEzm56h57HyIDTYjxm2l+ w==; IronPort-SDR: i9Fbjs8tijzZk7rdNqh4wv4tHPfLa4ewEBL3Evh+6v8Ki5PlDHsArO0uQPWv6Q3l3/HT1t/pD1 6O1FQqYIJOolAMLSqI6UGqhEP+QNx1V3hBu8xhhwe8h5L6Pxh+o09SsoHsD5Y98OzNzWYGburz GSQBJbVI3yDnminXykclLTP2flxAt1y9BY0XDjgwdeKcCkSTaDlCmu95eiC89SsMVozgczVXOc fhagV66u/qvgU0X38MLgvNcu7PT1KBWdhoojuC5AVxDbAszO2E18ZxoIg1M21OSOX/zbi7wGoW ysw= X-IronPort-AV: E=Sophos;i="5.64,331,1559491200"; d="scan'208";a="114637466" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 01 Aug 2019 05:01:53 +0800 IronPort-SDR: M26nqZN3lX1hMwr1YnexKxLfEiu+gLU2FfFuarniex0SAdS+hXYIY1rJo8Y6HRKTg0IqmRpJfa UKzAvsxVE6hStsNhT7bAaEEhmtcwLGCzWEK1gEzg+u/knhrWG9ZSLjVzdQuJMWozHdf3uEsT1y BXTUh5uF6oQp8qxhEqdwDr7xblHAFuFD0vnR6qqyolLXPPgjiISutIjKiSMR0vDjsGs96rniUT DoLmIr8kgQJtVKr6+i5yX0u2tN5e6x94XMpC3BJRfNd/Fr0Z9sv67x4lVgd83uJzT7v4sQoXFk mYu08GLZLgK6z47+uXK/jxAF 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; 31 Jul 2019 13:59:53 -0700 IronPort-SDR: U+NZCvs3trVgxAdGAS9nxoOFfSwLdUdcP2Qys0wlo20YU5wxF755qmE33357NatlxhcER91FHd 8YMO0iREoAUifpbccIgL/xNj7XeQFVCeCBMJEyjBLR1WY4dVarYUPPVR2ASB+oplL7SPaRrglS XHCQVFv96htt1nrPuEL5zcnBZXiFOEaao++LOXJi3/MEkLOGKDLM0kDevb7av6rLEuui+KO8KI 1oErFLvBD5Izoc4bJ63n8Q1cDtchPsZntx57dOP81XGItVEaFlYsVx8nAIwwI66XsfPM/AC0pY P5U= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 31 Jul 2019 14:01:52 -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 3/4] scsi: implement REQ_OP_ZONE_RESET_ALL Date: Wed, 31 Jul 2019 14:01:01 -0700 Message-Id: <20190731210102.3472-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com> References: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com> 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 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 --- drivers/scsi/sd.c | 7 ++++++- drivers/scsi/sd.h | 5 +++-- drivers/scsi/sd_zbc.c | 9 +++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index a3406bd62391..620a6d743952 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); @@ -2948,6 +2951,8 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) */ q->limits.zoned = BLK_ZONED_NONE; } + if (q->limits.zoned != BLK_ZONED_NONE) + blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); if (blk_queue_is_zoned(q) && sdkp->first_scan) sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n", q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware"); 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..538216b9e1f4 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: flag to prepare a RESET ALL WRITE POINTER scsi command. * * 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 && From patchwork Wed Jul 31 21:01:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11069503 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 0929C1399 for ; Wed, 31 Jul 2019 21:02:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDCBD27F17 for ; Wed, 31 Jul 2019 21:02:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E13AC27F8C; Wed, 31 Jul 2019 21:02:11 +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=unavailable 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 9182527F3E for ; Wed, 31 Jul 2019 21:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbfGaVCK (ORCPT ); Wed, 31 Jul 2019 17:02:10 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41878 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbfGaVCK (ORCPT ); Wed, 31 Jul 2019 17:02:10 -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=1564606931; x=1596142931; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=NSomUKo7kGp1ISvH1icFd6X5WQMDjpWSwgevf/PzYy0=; b=pJ83vmctxZaJomgd1VFVSo5KKWWchYnh+pT5+DToNcanP2J1IzTWrLBd mrBz2PAQyR/MwjQjH8mfLbZ1FAT+SEcFxm7DVFZ4AcxEjcpQy2vfeHE4P yuhgflFJUQAuklui/i+lG4ZA051n6/nSrZIP1W+uBgIHXbOTFymEpA7vZ muV6KUSgVk7eHDHpC8wd0bwG+11FT9W7ckiIV/MwVhWyM/ANYFDfYb00/ P8Ilo73WYvVRmanfVFL9IFvr2EDC70Vl6VWnyxdTU74zaASJebkHaQ0ue irLnIekIrbvk6XbdiHvEPz9maPUBCB/4zqVMOXH425WF8J67dJzOxzs2k A==; IronPort-SDR: v51SlOvX79Tp5a6YYZKzN2d6NF4pGXx2a1UdcdmA5+9U+mbc1uy95kqvNVy8Mv7VIDRE0EpviD 7J0k0lzAEwEXHqeOBinrgD9NoEnRzFs80bxg94UwiQLzoMvmqSPVf2r6vWGrA4yXs5HdJ1PXQU pr/FEqXGDs4LpWzrau+0xmrl2gkKpOHw/mVz2iytzgiNkX73P3Qw+HUw0lL9TcCEcvvXzPrZam kUJsrLSMK8jnk71MhLICM/gcOYRWMVmIYaBh3LdbQsm9yXxO2OYljK47J7aAzTjIfoWy7zwwKG AwI= X-IronPort-AV: E=Sophos;i="5.64,331,1559491200"; d="scan'208";a="119303865" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 01 Aug 2019 05:02:07 +0800 IronPort-SDR: luzbxR8g/CenbYOAkcDZZFORQgqlEhOO7DljDf6Pmps2aQAXDVxP/4IzhhXLizpt0Ai+xU0/m7 D+3l0/+TYkwKlh+5jY7OMGHO6NX5096Tps4ti4kNoqrf/jhtLDX/npSEGHh2GkK0UZgz8spz0x y5ZTeQ+ngidH/3BPlYUc5T52+YCuJXOjOGpE2mVhqPLXNGGn0Pg3zwh8vb4VpeRjwv1sKMirce aw5WAFk/YFuP23HviNhEsbBu48e4CKQjxDrYvFhrh+73yAMevoMQc9kuwlbUxI9K65vRYddGaP cb2C9AF+f2WD8+ibGRq38nfR 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; 31 Jul 2019 14:00:06 -0700 IronPort-SDR: EIf/bz18sWQ5oKgdcNXtK/+/6sB3XfeDvjnP+iV/h4SdMlQBJ4AK0O+9oUBHmGf5YCOnr/iAn+ 3KUx9r4eCSeKO35hri4x6vu5A05BDe64+dHtnXplehg9cZOKwkZJcgQlB27CttGUJHTxqZO1h1 1ZGejDYuV1GcC288RWYFpPgn1erkkRIMfw61ERNiiIRtfn78AL42aM7byyAPTwb0Hx+DGucVGU 2npTa9S8dA77EBLbBrzZRlowZB6GWegMV8kA6U3Vjq7ZyERqk1olRy74HsT5mRSUbYYn8mSFpA g44= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 31 Jul 2019 14:02:05 -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 4/4] null_blk: implement REQ_OP_ZONE_RESET_ALL Date: Wed, 31 Jul 2019 14:01:02 -0700 Message-Id: <20190731210102.3472-5-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com> References: <20190731210102.3472-1-chaitanya.kulkarni@wdc.com> 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 This patch implements newly introduced zone reset all operation for null_blk driver. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Damien Le Moal --- 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; }