public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req()
@ 2025-11-08 22:17 Caleb Sander Mateos
  2025-11-09 14:10 ` Ming Lei
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Caleb Sander Mateos @ 2025-11-08 22:17 UTC (permalink / raw)
  To: Ming Lei, Jens Axboe; +Cc: Caleb Sander Mateos, linux-block, linux-kernel

ub = iocb->ki_filp->private_data cannot be NULL, as it's set in
ublk_ch_open() before it returns succesfully. req->mq_hctx cannot be
NULL as any inflight ublk request must belong to some queue. And
req->mq_hctx->driver_data cannot be NULL as it's set to the ublk_queue
pointer in ublk_init_hctx(). So drop the unnecessary checks.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 drivers/block/ublk_drv.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 5cf288809226..30e798f062ef 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2506,13 +2506,10 @@ static struct request *ublk_check_and_get_req(struct kiocb *iocb,
 	struct ublk_queue *ubq;
 	struct request *req;
 	size_t buf_off;
 	u16 tag, q_id;
 
-	if (!ub)
-		return ERR_PTR(-EACCES);
-
 	if (!user_backed_iter(iter))
 		return ERR_PTR(-EACCES);
 
 	if (ub->dev_info.state == UBLK_S_DEV_DEAD)
 		return ERR_PTR(-EACCES);
@@ -2534,13 +2531,10 @@ static struct request *ublk_check_and_get_req(struct kiocb *iocb,
 	*io = &ubq->ios[tag];
 	req = __ublk_check_and_get_req(ub, q_id, tag, *io, buf_off);
 	if (!req)
 		return ERR_PTR(-EINVAL);
 
-	if (!req->mq_hctx || !req->mq_hctx->driver_data)
-		goto fail;
-
 	if (!ublk_check_ubuf_dir(req, dir))
 		goto fail;
 
 	*off = buf_off;
 	return req;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req()
  2025-11-08 22:17 [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req() Caleb Sander Mateos
@ 2025-11-09 14:10 ` Ming Lei
  2025-11-09 17:58 ` Chaitanya Kulkarni
  2025-11-11 14:59 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Ming Lei @ 2025-11-09 14:10 UTC (permalink / raw)
  To: Caleb Sander Mateos; +Cc: Jens Axboe, linux-block, linux-kernel

On Sat, Nov 08, 2025 at 03:17:45PM -0700, Caleb Sander Mateos wrote:
> ub = iocb->ki_filp->private_data cannot be NULL, as it's set in
> ublk_ch_open() before it returns succesfully. req->mq_hctx cannot be
> NULL as any inflight ublk request must belong to some queue. And
> req->mq_hctx->driver_data cannot be NULL as it's set to the ublk_queue
> pointer in ublk_init_hctx(). So drop the unnecessary checks.
> 
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>

Looks fine,

Reviewed-by: Ming Lei <ming.lei@redhat.com>


Thanks,
Ming


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req()
  2025-11-08 22:17 [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req() Caleb Sander Mateos
  2025-11-09 14:10 ` Ming Lei
@ 2025-11-09 17:58 ` Chaitanya Kulkarni
  2025-11-11 14:59 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2025-11-09 17:58 UTC (permalink / raw)
  To: Caleb Sander Mateos, Ming Lei, Jens Axboe
  Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org

On 11/8/25 14:17, Caleb Sander Mateos wrote:
> ub = iocb->ki_filp->private_data cannot be NULL, as it's set in
> ublk_ch_open() before it returns succesfully. req->mq_hctx cannot be
> NULL as any inflight ublk request must belong to some queue. And
> req->mq_hctx->driver_data cannot be NULL as it's set to the ublk_queue
> pointer in ublk_init_hctx(). So drop the unnecessary checks.
>
> Signed-off-by: Caleb Sander Mateos<csander@purestorage.com>
> ---

Indeed, Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req()
  2025-11-08 22:17 [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req() Caleb Sander Mateos
  2025-11-09 14:10 ` Ming Lei
  2025-11-09 17:58 ` Chaitanya Kulkarni
@ 2025-11-11 14:59 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-11-11 14:59 UTC (permalink / raw)
  To: Ming Lei, Caleb Sander Mateos; +Cc: linux-block, linux-kernel


On Sat, 08 Nov 2025 15:17:45 -0700, Caleb Sander Mateos wrote:
> ub = iocb->ki_filp->private_data cannot be NULL, as it's set in
> ublk_ch_open() before it returns succesfully. req->mq_hctx cannot be
> NULL as any inflight ublk request must belong to some queue. And
> req->mq_hctx->driver_data cannot be NULL as it's set to the ublk_queue
> pointer in ublk_init_hctx(). So drop the unnecessary checks.
> 
> 
> [...]

Applied, thanks!

[1/1] ublk: remove unnecessary checks in ublk_check_and_get_req()
      commit: 6b0a29933f688a284e8869da0f63a93acf893757

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-11 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-08 22:17 [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req() Caleb Sander Mateos
2025-11-09 14:10 ` Ming Lei
2025-11-09 17:58 ` Chaitanya Kulkarni
2025-11-11 14:59 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox