All of lore.kernel.org
 help / color / mirror / Atom feed
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,
	Uday Shankar <ushankar@purestorage.com>,
	Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH v6.15 3/3] ublk: enhance check for register/unregister io buffer command
Date: Tue, 29 Apr 2025 09:02:11 +0800	[thread overview]
Message-ID: <aBAlEzqzx2Vmn661@fedora> (raw)
In-Reply-To: <CADUfDZrVOUE+Wweaz0pg9qfSB5Ye8FHuf-FmDjO2VOz0GU-cNg@mail.gmail.com>

On Mon, Apr 28, 2025 at 09:28:07AM -0700, Caleb Sander Mateos wrote:
> On Sun, Apr 27, 2025 at 6:50 AM Ming Lei <ming.lei@redhat.com> wrote:
> >
> > The simple check of UBLK_IO_FLAG_OWNED_BY_SRV can avoid incorrect
> > register/unregister io buffer easily, so check it before calling
> > starting to register/un-register io buffer.
> >
> > Also only allow io buffer register/unregister uring_cmd in case of
> > UBLK_F_SUPPORT_ZERO_COPY.
> >
> > Also mark argument 'ublk_queue *' of ublk_register_io_buf as const.
> >
> > Fixes: 1f6540e2aabb ("ublk: zc register/unregister bvec")
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> >  drivers/block/ublk_drv.c | 24 ++++++++++++++++++++----
> >  1 file changed, 20 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> > index 0a3a3c64316d..c624d8f653ae 100644
> > --- a/drivers/block/ublk_drv.c
> > +++ b/drivers/block/ublk_drv.c
> > @@ -201,7 +201,7 @@ struct ublk_params_header {
> >  static void ublk_stop_dev_unlocked(struct ublk_device *ub);
> >  static void ublk_abort_queue(struct ublk_device *ub, struct ublk_queue *ubq);
> >  static inline struct request *__ublk_check_and_get_req(struct ublk_device *ub,
> > -               struct ublk_queue *ubq, int tag, size_t offset);
> > +               const struct ublk_queue *ubq, int tag, size_t offset);
> >  static inline unsigned int ublk_req_build_flags(struct request *req);
> >  static inline struct ublksrv_io_desc *ublk_get_iod(struct ublk_queue *ubq,
> >                                                    int tag);
> > @@ -1949,13 +1949,20 @@ static void ublk_io_release(void *priv)
> >  }
> >
> >  static int ublk_register_io_buf(struct io_uring_cmd *cmd,
> > -                               struct ublk_queue *ubq, unsigned int tag,
> > +                               const struct ublk_queue *ubq, unsigned int tag,
> >                                 unsigned int index, unsigned int issue_flags)
> >  {
> >         struct ublk_device *ub = cmd->file->private_data;
> > +       const struct ublk_io *io = &ubq->ios[tag];
> >         struct request *req;
> >         int ret;
> >
> > +       if (!ublk_support_zero_copy(ubq))
> > +               return -EINVAL;
> > +
> > +       if (!(io->flags & UBLK_IO_FLAG_OWNED_BY_SRV))
> > +               return -EINVAL;
> 
> I would still prefer to see this common UBLK_IO_FLAG_OWNED_BY_SRV
> check moved to __ublk_ch_uring_cmd() along with the existing flag
> checks. Something like this:

This way mixes bug fix with cleanup.

We are close to v6.15-rc5, and bug fix should keep simple for minimizing
regression.

But it is fine to make it one cleanup aiming at v6.16.


thanks,
Ming


  reply	other threads:[~2025-04-29  1:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-27 13:49 [PATCH v6.15 0/3] ublk: one selftest fix and two zero copy fixes Ming Lei
2025-04-27 13:49 ` [PATCH v6.15 1/3] selftests: ublk: fix UBLK_F_NEED_GET_DATA Ming Lei
2025-04-28 15:51   ` Caleb Sander Mateos
2025-04-29  0:53     ` Ming Lei
2025-04-27 13:49 ` [PATCH v6.15 2/3] ublk: decouple zero copy from user copy Ming Lei
2025-04-28 16:01   ` Caleb Sander Mateos
2025-04-29  0:55     ` Ming Lei
2025-04-29  1:36       ` Ming Lei
2025-04-29  1:38         ` Caleb Sander Mateos
2025-04-27 13:49 ` [PATCH v6.15 3/3] ublk: enhance check for register/unregister io buffer command Ming Lei
2025-04-28 16:28   ` Caleb Sander Mateos
2025-04-29  1:02     ` Ming Lei [this message]
2025-04-29  1:03       ` Caleb Sander Mateos

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=aBAlEzqzx2Vmn661@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.