From: Christoph Hellwig <hch@lst.de>
To: Anuj Gupta <anuj20.g@samsung.com>
Cc: axboe@kernel.dk, hch@lst.de, kbusch@kernel.org,
martin.petersen@oracle.com, asml.silence@gmail.com,
anuj1072538@gmail.com, krisman@suse.de, io-uring@vger.kernel.org,
linux-nvme@lists.infradead.org, linux-block@vger.kernel.org,
gost.dev@samsung.com, linux-scsi@vger.kernel.org,
vishak.g@samsung.com
Subject: Re: [PATCH v4 02/11] block: copy back bounce buffer to user-space correctly in case of split
Date: Thu, 17 Oct 2024 09:53:54 +0200 [thread overview]
Message-ID: <20241017075354.GA25343@lst.de> (raw)
In-Reply-To: <20241016112912.63542-3-anuj20.g@samsung.com>
On Wed, Oct 16, 2024 at 04:59:03PM +0530, Anuj Gupta wrote:
> Copy back the bounce buffer to user-space in entirety when the parent
> bio completes.
This commit message is a bit sparse..
> --- a/block/bio-integrity.c
> +++ b/block/bio-integrity.c
> @@ -119,8 +119,8 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs,
> static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
> {
> unsigned short nr_vecs = bip->bip_max_vcnt - 1;
> - struct bio_vec *copy = &bip->bip_vec[1];
> - size_t bytes = bip->bip_iter.bi_size;
> + struct bio_vec *copy = &bip->bip_vec[1], *bvec = &bip->bip_vec[0];
> + size_t bytes = bvec->bv_len;
> struct iov_iter iter;
> int ret;
And while trying to understand what this code does I keep getting
confused by what bio_integrity_uncopy_user actually does.
And I think a bit part of that is the "creative" abuse of bip_vec
by the copy-based integrity code, where bip_vec[0] is the vector
passed to the block layer, and the rest contains the user buffer.
Maybe it's just me, but not stashing the user pages in the bvecs
but just stasing away the actual iov_iter would be much preferable
for this code?
Either way, back to the code. The existing code uses
bip_iter.bi_size for sizing the copy, and that can be modified when
the bio is cloned (or at least by the rules for the bio data) be
modified by the driver. So yes, switching away from that is
good and the change looks correct. That being said, even if we
aren't going to fix up the logic as mentioned above instantly,
can we pick better names for the variables?
static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
{
unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1;
struct bio_vec *orig_bvecs = &bip->bip_vec[1];
struct bio_vec *bounce_bvec = &bip->bip_vec[0];
size_t bytes = boune_bvec->bv_len;
struct iov_iter orig_iter;
int ret;
iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes);
ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter);
WARN_ON_ONCE(ret != bytes);
bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true);
}
?
Also please add a Fixes tag.
next prev parent reply other threads:[~2024-10-17 7:53 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20241016113705epcas5p1edc284b347de99bc34802b0b0c5e1b27@epcas5p1.samsung.com>
2024-10-16 11:29 ` [PATCH v4 00/11] Read/Write with meta/integrity Anuj Gupta
2024-10-16 11:29 ` [PATCH v4 01/11] block: define set of integrity flags to be inherited by cloned bip Anuj Gupta
2024-10-16 18:03 ` Keith Busch
2024-10-16 11:29 ` [PATCH v4 02/11] block: copy back bounce buffer to user-space correctly in case of split Anuj Gupta
2024-10-16 18:04 ` Keith Busch
2024-10-17 7:53 ` Christoph Hellwig [this message]
2024-10-16 11:29 ` [PATCH v4 03/11] block: modify bio_integrity_map_user to accept iov_iter as argument Anuj Gupta
2024-10-16 11:29 ` [PATCH v4 04/11] block: define meta io descriptor Anuj Gupta
2024-10-16 19:35 ` Keith Busch
2024-10-17 5:49 ` Anuj Gupta
2024-10-17 7:57 ` Christoph Hellwig
2024-10-22 2:11 ` Martin K. Petersen
2024-10-22 6:04 ` Christoph Hellwig
2024-10-23 1:20 ` Martin K. Petersen
2024-10-28 3:46 ` Anuj Gupta
2024-10-16 11:29 ` [PATCH v4 05/11] fs: introduce IOCB_HAS_METADATA for metadata Anuj Gupta
2024-10-17 7:58 ` Christoph Hellwig
2024-10-16 11:29 ` [PATCH v4 06/11] block: add flags for integrity meta Anuj Gupta
2024-10-17 8:00 ` Christoph Hellwig
2024-10-17 10:45 ` Anuj Gupta
2024-10-17 12:01 ` Christoph Hellwig
2024-10-17 12:59 ` Anuj gupta
2024-10-17 14:34 ` Christoph Hellwig
2024-10-16 11:29 ` [PATCH v4 07/11] io_uring/rw: add support to send meta along with read/write Anuj Gupta
2024-10-17 8:10 ` Christoph Hellwig
2024-10-17 22:51 ` Jens Axboe
2024-10-21 5:31 ` Anuj Gupta
2024-10-22 6:02 ` Christoph Hellwig
2024-10-22 1:50 ` Martin K. Petersen
2024-10-16 11:29 ` [PATCH v4 08/11] block: introduce BIP_CHECK_GUARD/REFTAG/APPTAG bip_flags Anuj Gupta
2024-10-17 8:12 ` Christoph Hellwig
2024-10-17 10:46 ` Anuj Gupta
2024-10-17 14:37 ` Christoph Hellwig
2024-10-16 11:29 ` [PATCH v4 09/11] block: add support to pass user meta buffer Anuj Gupta
2024-10-17 8:15 ` Christoph Hellwig
2024-10-17 8:24 ` Christoph Hellwig
2024-10-16 11:29 ` [PATCH v4 10/11] nvme: add support for passing on the application tag Anuj Gupta
2024-10-17 8:14 ` Christoph Hellwig
2024-10-16 11:29 ` [PATCH v4 11/11] scsi: add support for user-meta interface Anuj Gupta
2024-10-17 8:15 ` Christoph Hellwig
2024-10-17 11:39 ` Anuj Gupta
2024-10-17 14:39 ` Christoph Hellwig
2024-10-18 8:26 ` Anuj Gupta
2024-10-18 9:02 ` Christoph Hellwig
2024-10-22 1:58 ` Martin K. Petersen
2024-10-28 7:36 ` Anuj Gupta
2024-10-29 2:24 ` Martin K. Petersen
2024-10-22 2:04 ` [PATCH v4 00/11] Read/Write with meta/integrity Martin K. Petersen
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=20241017075354.GA25343@lst.de \
--to=hch@lst.de \
--cc=anuj1072538@gmail.com \
--cc=anuj20.g@samsung.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=gost.dev@samsung.com \
--cc=io-uring@vger.kernel.org \
--cc=kbusch@kernel.org \
--cc=krisman@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=vishak.g@samsung.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 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).