linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	linux-block@vger.kernel.org, linux-scsi@vger.kernel.org
Cc: bvanassche@acm.org, osandov@fb.com, dennisszhou@gmail.com,
	sagi@grimberg.me, axboe@kernel.dk, dennis@kernel.org,
	tj@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com,
	ming.lei@redhat.com, Hannes Reinecke <hare@suse.com>,
	jthumshirn@suse.de, damien.lemoal@wdc.com
Subject: Re: [PATCH V2 2/4] blk-zoned: implement REQ_OP_ZONE_RESET_ALL
Date: Fri, 2 Aug 2019 10:25:06 +0200	[thread overview]
Message-ID: <25a389c9-88d7-43b8-44da-61331143a2b4@suse.de> (raw)
In-Reply-To: <20190801172638.4060-3-chaitanya.kulkarni@wdc.com>

On 8/1/19 7:26 PM, Chaitanya Kulkarni wrote:
> 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 <chaitanya.kulkarni@wdc.com>
> ---
>  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),

I wonder if this shouldn't be moved to the previous patch ...

> @@ -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))
> 
But anyway:

Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)

  parent reply	other threads:[~2019-08-02  8:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 17:26 [PATCH V2 0/4] block: introduce REQ_OP_ZONE_RESET_ALL Chaitanya Kulkarni
2019-08-01 17:26 ` [PATCH V2 1/4] block: add req op to reset all zones and flag Chaitanya Kulkarni
2019-08-02  8:24   ` Hannes Reinecke
2019-08-01 17:26 ` [PATCH V2 2/4] blk-zoned: implement REQ_OP_ZONE_RESET_ALL Chaitanya Kulkarni
2019-08-02  1:06   ` Damien Le Moal
2019-08-02  8:25   ` Hannes Reinecke [this message]
2019-08-01 17:26 ` [PATCH V2 3/4] scsi: " Chaitanya Kulkarni
2019-08-02  1:07   ` Damien Le Moal
2019-08-02  8:25   ` Hannes Reinecke
2019-08-02 14:15   ` Martin K. Petersen
2019-08-01 17:26 ` [PATCH V2 4/4] null_blk: " Chaitanya Kulkarni
2019-08-02  8:25   ` Hannes Reinecke
2019-08-02 13:41 ` [PATCH V2 0/4] block: introduce REQ_OP_ZONE_RESET_ALL Jens Axboe
2019-08-02 14:16   ` Martin K. Petersen
2019-08-02 14:32     ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25a389c9-88d7-43b8-44da-61331143a2b4@suse.de \
    --to=hare@suse.de \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=damien.lemoal@wdc.com \
    --cc=dennis@kernel.org \
    --cc=dennisszhou@gmail.com \
    --cc=hare@suse.com \
    --cc=jejb@linux.ibm.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --cc=osandov@fb.com \
    --cc=sagi@grimberg.me \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).