public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Keith Busch <[email protected]>,
	[email protected], [email protected],
	[email protected]
Cc: [email protected], [email protected], [email protected],
	Keith Busch <[email protected]>
Subject: Re: [PATCHv3 2/5] block: bio-integrity: directly map user buffers
Date: Mon, 20 Nov 2023 16:19:00 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 11/20/23 3:40 PM, Keith Busch wrote:
> From: Keith Busch <[email protected]>
> 
> Passthrough commands that utilize metadata currently bounce the user
> space buffer through the kernel. Add support for mapping user space
> directly so that we can avoid this costly overhead. This is similiar to
> how the normal bio data payload utilizes user addresses with
> bio_map_user_iov().
> 
> If the user address can't directly be used for reasons like too many
> segments or address unalignement, fallback to a copy of the user vec
> while keeping the user address pinned for the IO duration so that it
> can safely be copied on completion in any process context.
> 
> Signed-off-by: Keith Busch <[email protected]>
> ---
>  block/bio-integrity.c | 212 ++++++++++++++++++++++++++++++++++++++++++
>  include/linux/bio.h   |  12 +++
>  2 files changed, 224 insertions(+)
> 
> diff --git a/block/bio-integrity.c b/block/bio-integrity.c
> index ec8ac8cf6e1b9..b761058bfb92f 100644
> --- a/block/bio-integrity.c
> +++ b/block/bio-integrity.c
> @@ -91,6 +91,37 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
>  }
>  EXPORT_SYMBOL(bio_integrity_alloc);
>  
> +static void bio_integrity_unmap_user(struct bio_integrity_payload *bip)
> +{
> +	bool dirty = bio_data_dir(bip->bip_bio) == READ;
> +	struct bvec_iter iter;
> +	struct bio_vec bv;
> +
> +	if (bip->bip_flags & BIP_COPY_USER) {
> +		unsigned short nr_vecs = bip->bip_max_vcnt - 1;
> +		struct bio_vec *copy = bvec_virt(&bip->bip_vec[nr_vecs]);
> +		size_t bytes = bip->bip_iter.bi_size;
> +		void *buf = bvec_virt(bip->bip_vec);
> +
> +		if (dirty) {
> +			struct iov_iter iter;
> +
> +			iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes);
> +			WARN_ON_ONCE(copy_to_iter(buf, bytes, &iter) != bytes);
> +		}

Minor nit, but I don't like hiding functions with side effects inside
potentially debug statements. Would be better to do:

	ret = copy_to_iter(buf, bytes, &iter);
	WARN_ON_ONCE(ret != bytes);

which is also easier to read, imho.

Apart from that, looks good to me.

-- 
Jens Axboe


  reply	other threads:[~2023-11-20 23:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 22:40 [PATCHv3 0/5] block integrity: directly map user space addresses Keith Busch
2023-11-20 22:40 ` [PATCHv3 1/5] bvec: introduce multi-page bvec iterating Keith Busch
2023-11-21  5:01   ` Christoph Hellwig
2023-11-21  8:37   ` Ming Lei
2023-11-21 15:49     ` Keith Busch
2023-11-22  0:43       ` Ming Lei
2023-11-22  0:54         ` Keith Busch
2023-11-20 22:40 ` [PATCHv3 2/5] block: bio-integrity: directly map user buffers Keith Busch
2023-11-20 23:19   ` Jens Axboe [this message]
2023-11-21  5:04   ` Christoph Hellwig
2023-11-21 16:10   ` Anuj gupta
2023-11-20 22:40 ` [PATCHv3 3/5] nvme: use bio_integrity_map_user Keith Busch
2023-11-21  5:05   ` Christoph Hellwig
2023-11-20 22:40 ` [PATCHv3 4/5] iouring: remove IORING_URING_CMD_POLLED Keith Busch
2023-11-21  5:05   ` Christoph Hellwig
2023-11-20 22:40 ` [PATCHv3 5/5] io_uring: remove uring_cmd cookie Keith Busch
2023-11-21  5:05   ` Christoph Hellwig

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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