All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Hindborg (Samsung)" <nmi@metaspace.dk>
To: Ming Lei <ming.lei@redhat.com>
Cc: Hans Holmberg <Hans.Holmberg@wdc.com>,
	Aravind Ramesh <Aravind.Ramesh@wdc.com>,
	Jens Axboe <axboe@kernel.dk>,
	"open list:BLOCK LAYER" <linux-block@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>,
	Matias Bjorling <Matias.Bjorling@wdc.com>,
	open list <linux-kernel@vger.kernel.org>,
	Damien Le Moal <dlemoal@kernel.org>,
	gost.dev@samsung.com, Minwoo Im <minwoo.im.dev@gmail.com>
Subject: Re: [PATCH v4 4/4] ublk: add zone append
Date: Thu, 29 Jun 2023 11:17:07 +0200	[thread overview]
Message-ID: <87edluy5l3.fsf@metaspace.dk> (raw)
In-Reply-To: <ZJzwcG2gIxXh8HbE@ovpn-8-18.pek2.redhat.com>


Ming Lei <ming.lei@redhat.com> writes:

> On Wed, Jun 28, 2023 at 09:06:49PM +0200, Andreas Hindborg wrote:
>> From: Andreas Hindborg <a.hindborg@samsung.com>
>> 
>> Add zone append feature to ublk. This feature uses the `addr` field of `struct
>> ublksrv_io_cmd`. Therefore ublk must be used with the user copy
>> feature (UBLK_F_USER_COPY) for zone append to be available. Without this
>> feature, ublk will fail zone append requests.
>
> Given zone append is a must, please fail to add device in case of zoned
> and !user_copy, then we can make fast IO code path clean.

I will squash the patches and reject zone support if not user copy is
enabled 👍

>
>> 
>> Suggested-by: Ming Lei <ming.lei@redhat.com>
>> Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>
>> ---
>>  drivers/block/ublk_drv-zoned.c | 11 +++++++++
>>  drivers/block/ublk_drv.c       | 43 ++++++++++++++++++++++++++++++----
>>  drivers/block/ublk_drv.h       |  1 +
>>  include/uapi/linux/ublk_cmd.h  |  3 ++-
>>  4 files changed, 52 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/block/ublk_drv-zoned.c b/drivers/block/ublk_drv-zoned.c
>> index ea86bf4b3681..007e8fc7ff25 100644
>> --- a/drivers/block/ublk_drv-zoned.c
>> +++ b/drivers/block/ublk_drv-zoned.c
>> @@ -16,6 +16,16 @@ void ublk_set_nr_zones(struct ublk_device *ub)
>>  		ub->ub_disk->nr_zones = p->dev_sectors / p->chunk_sectors;
>>  }
>>  
>> +int ublk_dev_param_zoned_validate(const struct ublk_device *ub)
>> +{
>> +	const struct ublk_param_zoned *p = &ub->params.zoned;
>> +
>> +	if (! p->max_zone_append_sectors)
>> +		return -EINVAL;
>> +
>> +	return 0;
>> +}
>> +
>>  void ublk_dev_param_zoned_apply(struct ublk_device *ub)
>>  {
>>  	const struct ublk_param_zoned *p = &ub->params.zoned;
>> @@ -23,6 +33,7 @@ void ublk_dev_param_zoned_apply(struct ublk_device *ub)
>>  	if (ub->dev_info.flags & UBLK_F_ZONED) {
>>  		disk_set_max_active_zones(ub->ub_disk, p->max_active_zones);
>>  		disk_set_max_open_zones(ub->ub_disk, p->max_open_zones);
>> +		blk_queue_max_zone_append_sectors(ub->ub_disk->queue, p->max_zone_append_sectors);
>>  	}
>>  }
>>  
>> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
>> index 88fa39853c61..6a949669b47e 100644
>> --- a/drivers/block/ublk_drv.c
>> +++ b/drivers/block/ublk_drv.c
>> @@ -107,6 +107,11 @@ struct ublk_uring_cmd_pdu {
>>   */
>>  #define UBLK_IO_FLAG_NEED_GET_DATA 0x08
>>  
>> +/*
>> + * Set when IO is Zone Append
>> + */
>> +#define UBLK_IO_FLAG_ZONE_APPEND 0x10
>> +
>>  struct ublk_io {
>>  	/* userspace buffer address from io cmd */
>>  	__u64	addr;
>> @@ -230,6 +235,8 @@ static void ublk_dev_param_discard_apply(struct ublk_device *ub)
>>  
>>  static int ublk_validate_params(const struct ublk_device *ub)
>>  {
>> +	int ret = 0;
>> +
>>  	/* basic param is the only one which must be set */
>>  	if (ub->params.types & UBLK_PARAM_TYPE_BASIC) {
>>  		const struct ublk_param_basic *p = &ub->params.basic;
>> @@ -260,6 +267,13 @@ static int ublk_validate_params(const struct ublk_device *ub)
>>  	if (ub->params.types & UBLK_PARAM_TYPE_DEVT)
>>  		return -EINVAL;
>>  
>> +	if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
>> +	    (ub->params.types & UBLK_PARAM_TYPE_ZONED)) {
>> +		ret = ublk_dev_param_zoned_validate(ub);
>> +		if (ret)
>> +			return ret;
>> +	}
>> +
>>  	return 0;
>>  }
>>  
>> @@ -690,6 +704,11 @@ static blk_status_t ublk_setup_iod(struct ublk_queue *ubq, struct request *req)
>>  			return BLK_STS_IOERR;
>>  		}
>>  	case REQ_OP_ZONE_APPEND:
>> +		if (!(ubq->dev->dev_info.flags & UBLK_F_USER_COPY))
>> +			return BLK_STS_IOERR;
>> +		ublk_op = UBLK_IO_OP_ZONE_APPEND;
>> +		io->flags |= UBLK_IO_FLAG_ZONE_APPEND;
>> +		break;
>>  	case REQ_OP_ZONE_RESET_ALL:
>>  	case REQ_OP_DRV_OUT:
>>  		/* We do not support zone append or reset_all yet */
>> @@ -1112,6 +1131,12 @@ static void ublk_commit_completion(struct ublk_device *ub,
>>  	/* find the io request and complete */
>>  	req = blk_mq_tag_to_rq(ub->tag_set.tags[qid], tag);
>>  
>> +	if (IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
>> +		if (io->flags & UBLK_IO_FLAG_ZONE_APPEND)
>> +			req->__sector = ub_cmd->addr;
>> +		io->flags &= ~UBLK_IO_FLAG_ZONE_APPEND;
>> +	}
>> +
>>  	if (req && likely(!blk_should_fake_timeout(req->q)))
>>  		ublk_put_req_ref(ubq, req);
>>  }
>> @@ -1411,7 +1436,8 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
>>  			^ (_IOC_NR(cmd_op) == UBLK_IO_NEED_GET_DATA))
>>  		goto out;
>>  
>> -	if (ublk_support_user_copy(ubq) && ub_cmd->addr) {
>> +	if (ublk_support_user_copy(ubq) &&
>> +	    !(io->flags & UBLK_IO_FLAG_ZONE_APPEND) && ub_cmd->addr) {
>>  		ret = -EINVAL;
>>  		goto out;
>>  	}
>> @@ -1534,11 +1560,14 @@ static inline bool ublk_check_ubuf_dir(const struct request *req,
>>  		int ubuf_dir)
>>  {
>>  	/* copy ubuf to request pages */
>> -	if (req_op(req) == REQ_OP_READ && ubuf_dir == ITER_SOURCE)
>> +	if ((req_op(req) == REQ_OP_READ || req_op(req) == REQ_OP_DRV_IN) &&
>> +	    ubuf_dir == ITER_SOURCE)
>>  		return true;
>>  
>>  	/* copy request pages to ubuf */
>> -	if (req_op(req) == REQ_OP_WRITE && ubuf_dir == ITER_DEST)
>> +	if ((req_op(req) == REQ_OP_WRITE ||
>> +	     req_op(req) == REQ_OP_ZONE_APPEND) &&
>> +	    ubuf_dir == ITER_DEST)
>>  		return true;
>>  
>>  	return false;
>> @@ -1867,6 +1896,12 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
>>  	ub->dev_info.ublksrv_pid = ublksrv_pid;
>>  	ub->ub_disk = disk;
>>  
>> +	ub->dev_info.state = UBLK_S_DEV_LIVE;
>
> I guess the above line change isn't necessary?

It needs to go before the call to `ublk_revalidate_disk_zones()` because
that does IO to the disk in the form of a call to `report_zones()`. So I
can move it down a little bit.

Best regards,
Andreas

  reply	other threads:[~2023-06-29  9:35 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28 19:06 [PATCH v4 0/4] ublk: add zoned storage support Andreas Hindborg
2023-06-28 19:06 ` [PATCH v4 1/4] ublk: change ublk IO command defines to enum Andreas Hindborg
2023-06-28 22:47   ` Damien Le Moal
2023-06-29  0:38     ` Ming Lei
2023-06-29  1:14       ` Damien Le Moal
2023-06-29  7:09       ` Andreas Hindborg (Samsung)
2023-06-29  7:11     ` Andreas Hindborg (Samsung)
     [not found]   ` <83E5C27A-9AEF-4900-9652-78ACFF47E6B0@wdc.com>
2023-06-30 10:33     ` aravind.ramesh
2023-06-30 16:30       ` Andreas Hindborg (Samsung)
2023-06-28 19:06 ` [PATCH v4 2/4] ublk: move types to shared header file Andreas Hindborg
2023-06-28 22:49   ` Damien Le Moal
     [not found]   ` <6BEB9EA7-7445-498E-9492-21BC2B5D8B19@wdc.com>
2023-06-30 10:33     ` aravind.ramesh
2023-06-28 19:06 ` [PATCH v4 3/4] ublk: enable zoned storage support Andreas Hindborg
2023-06-28 23:16   ` Damien Le Moal
2023-06-29  7:50     ` Andreas Hindborg (Samsung)
2023-06-29  9:41       ` Damien Le Moal
2023-06-30 11:53         ` Andreas Hindborg (Samsung)
2023-06-29  2:39   ` Ming Lei
2023-06-30 16:51     ` Andreas Hindborg (Samsung)
2023-06-29  2:54   ` kernel test robot
2023-06-29  5:39   ` Christoph Hellwig
2023-06-29  7:25     ` Andreas Hindborg (Samsung)
2023-06-29  7:31       ` Christoph Hellwig
2023-06-29  7:22   ` kernel test robot
     [not found]   ` <62426D68-1E01-4804-9CFC-A1146770F362@wdc.com>
2023-06-30 10:34     ` aravind.ramesh
2023-06-30 16:37       ` Andreas Hindborg (Samsung)
2023-06-28 19:06 ` [PATCH v4 4/4] ublk: add zone append Andreas Hindborg
2023-06-28 23:17   ` Damien Le Moal
2023-06-29  2:46   ` Ming Lei
2023-06-29  9:17     ` Andreas Hindborg (Samsung) [this message]
2023-06-29  9:43       ` Damien Le Moal
     [not found]   ` <39701CAF-7AE2-4C83-A4DD-929A0A4FB8F0@wdc.com>
2023-06-30 10:35     ` aravind.ramesh
2023-06-30 16:33       ` Andreas Hindborg (Samsung)
     [not found] ` <5F597343-EC91-4698-ACBE-9111B52FC3FC@wdc.com>
2023-06-30 10:33   ` [PATCH v4 0/4] ublk: add zoned storage support aravind.ramesh
2023-06-30 14:26     ` Andreas Hindborg (Samsung)

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=87edluy5l3.fsf@metaspace.dk \
    --to=nmi@metaspace.dk \
    --cc=Aravind.Ramesh@wdc.com \
    --cc=Hans.Holmberg@wdc.com \
    --cc=Matias.Bjorling@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=gost.dev@samsung.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=minwoo.im.dev@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.