From: Ming Lei <ming.lei@redhat.com>
To: Caleb Sander Mateos <csander@purestorage.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Keith Busch <kbusch@kernel.org>,
Uday Shankar <ushankar@purestorage.com>
Subject: Re: [PATCH 3/8] ublk: truncate io command result
Date: Tue, 25 Mar 2025 08:50:40 +0800 [thread overview]
Message-ID: <Z-H94M9hrFd4b3Lt@fedora> (raw)
In-Reply-To: <CADUfDZrRqyPkG2cQdsfvjXBS9Y4aU7ETPv3T1t=K4NGqvRzH2Q@mail.gmail.com>
On Mon, Mar 24, 2025 at 08:51:20AM -0700, Caleb Sander Mateos wrote:
> On Mon, Mar 24, 2025 at 6:49 AM Ming Lei <ming.lei@redhat.com> wrote:
> >
> > If io command result is bigger than request bytes, truncate it to request
> > bytes. This way is more reliable, and avoids potential risk, even though
> > both blk_update_request() and ublk_copy_user_pages() works fine in this
> > way.
> >
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> > drivers/block/ublk_drv.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> > index 6fa1384c6436..acb6aed7be75 100644
> > --- a/drivers/block/ublk_drv.c
> > +++ b/drivers/block/ublk_drv.c
> > @@ -1071,6 +1071,10 @@ static inline void __ublk_complete_rq(struct request *req)
> > goto exit;
> > }
> >
> > + /* truncate result in case it is bigger than request bytes */
> > + if (io->res > blk_rq_bytes(req))
> > + io->res = blk_rq_bytes(req);
>
> Is this not already handled by the code below that caps io->res?
>
> unmapped_bytes = ublk_unmap_io(ubq, req, io);
> // ...
> if (unlikely(unmapped_bytes < io->res))
> io->res = unmapped_bytes;
>
> ublk_unmap_io() returns either blk_rq_bytes(req) or the result of
> ublk_copy_user_pages(), which should be at most blk_rq_bytes(req)?
Indeed, this patch can be dropped.
thanks,
Ming
next prev parent reply other threads:[~2025-03-25 0:50 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 13:48 [PATCH 0/8] ublk: cleanup & improvement & zc follow-up Ming Lei
2025-03-24 13:48 ` [PATCH 1/8] ublk: remove two unused fields from 'struct ublk_queue' Ming Lei
2025-03-24 14:32 ` Caleb Sander Mateos
2025-03-24 13:48 ` [PATCH 2/8] ublk: add helper of ublk_need_map_io() Ming Lei
2025-03-24 15:01 ` Caleb Sander Mateos
2025-03-24 13:48 ` [PATCH 3/8] ublk: truncate io command result Ming Lei
2025-03-24 15:51 ` Caleb Sander Mateos
2025-03-25 0:50 ` Ming Lei [this message]
2025-03-24 13:48 ` [PATCH 4/8] ublk: add segment parameter Ming Lei
2025-03-24 22:26 ` Caleb Sander Mateos
2025-03-25 1:15 ` Ming Lei
2025-03-25 19:43 ` Caleb Sander Mateos
2025-03-26 2:17 ` Ming Lei
2025-03-26 16:43 ` Caleb Sander Mateos
2025-03-27 1:49 ` Ming Lei
2025-03-24 13:49 ` [PATCH 5/8] ublk: document zero copy feature Ming Lei
2025-03-25 15:26 ` Caleb Sander Mateos
2025-03-26 2:29 ` Ming Lei
2025-03-26 16:48 ` Caleb Sander Mateos
2025-03-24 13:49 ` [PATCH 6/8] ublk: implement ->queue_rqs() Ming Lei
2025-03-24 17:07 ` Uday Shankar
2025-03-25 1:02 ` Ming Lei
2025-03-26 21:30 ` Caleb Sander Mateos
2025-03-27 9:15 ` Ming Lei
2025-03-24 13:49 ` [PATCH 7/8] selftests: ublk: add more tests for covering MQ Ming Lei
2025-03-24 13:49 ` [PATCH 8/8] selftests: ublk: add test for checking zero copy related parameter Ming Lei
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=Z-H94M9hrFd4b3Lt@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=ushankar@purestorage.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.