2023-02-07 07:09:07

by Ziyang Zhang

[permalink] [raw]
Subject: [PATCH RESEND 0/3] cleanup for ublk

Hi, this series contain cleanup for code and comment of ublk including
removing unnecessary NULL check, unused variable and comment fix.

Ziyang Zhang (3):
ublk: remove unnecessary NULL check in ublk_rq_has_data()
ublk: mention WRITE_ZEROES in comment of ublk_complete_rq()
ublk: pass NULL to blk_mq_alloc_disk() as queuedata

drivers/block/ublk_drv.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

--
2.18.4



2023-02-07 07:09:14

by Ziyang Zhang

[permalink] [raw]
Subject: [PATCH RESEND 1/3] ublk: remove unnecessary NULL check in ublk_rq_has_data()

bio_has_data() allows a NULL bio so the NULL check in
ublk_rq_has_data() is unnecessary.

Signed-off-by: Ziyang Zhang <[email protected]>
---
drivers/block/ublk_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index c932e9ea5a0f..55fccce68a9c 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -322,7 +322,7 @@ static inline struct ublk_queue *ublk_get_queue(struct ublk_device *dev,

static inline bool ublk_rq_has_data(const struct request *rq)
{
- return rq->bio && bio_has_data(rq->bio);
+ return bio_has_data(rq->bio);
}

static inline struct ublksrv_io_desc *ublk_get_iod(struct ublk_queue *ubq,
--
2.18.4


2023-02-07 07:09:17

by Ziyang Zhang

[permalink] [raw]
Subject: [PATCH RESEND 2/3] ublk: mention WRITE_ZEROES in comment of ublk_complete_rq()

WRITE_ZEROES won't return bytes returned just like FLUSH and DISCARD,
and we can end it directly. Add missing comment for it in
ublk_complete_rq().

Signed-off-by: Ziyang Zhang <[email protected]>
---
drivers/block/ublk_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 55fccce68a9c..06eddefdf02a 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -665,7 +665,7 @@ static void ublk_complete_rq(struct request *req)
}

/*
- * FLUSH or DISCARD usually won't return bytes returned, so end them
+ * FLUSH, DISCARD or WRITE_ZEROES usually won't return bytes returned, so end them
* directly.
*
* Both the two needn't unmap.
--
2.18.4


2023-02-07 07:09:19

by Ziyang Zhang

[permalink] [raw]
Subject: [PATCH RESEND 3/3] ublk: pass NULL to blk_mq_alloc_disk() as queuedata

queuedata is not referenced in ublk_drv and we can use driver_data
instead. Pass NULL to blk_mq_alloc_disk() as queuedata while allocating
ublk's gendisk.

Signed-off-by: Ziyang Zhang <[email protected]>
---
drivers/block/ublk_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 06eddefdf02a..d83fe2c2b3ba 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1578,7 +1578,7 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
goto out_unlock;
}

- disk = blk_mq_alloc_disk(&ub->tag_set, ub);
+ disk = blk_mq_alloc_disk(&ub->tag_set, NULL);
if (IS_ERR(disk)) {
ret = PTR_ERR(disk);
goto out_unlock;
--
2.18.4


2023-02-07 14:07:59

by Ming Lei

[permalink] [raw]
Subject: Re: [PATCH RESEND 1/3] ublk: remove unnecessary NULL check in ublk_rq_has_data()

On Tue, Feb 07, 2023 at 03:08:37PM +0800, Ziyang Zhang wrote:
> bio_has_data() allows a NULL bio so the NULL check in
> ublk_rq_has_data() is unnecessary.
>
> Signed-off-by: Ziyang Zhang <[email protected]>

Reviewed-by: Ming Lei <[email protected]>


Thanks,
Ming


2023-02-07 14:08:47

by Ming Lei

[permalink] [raw]
Subject: Re: [PATCH RESEND 2/3] ublk: mention WRITE_ZEROES in comment of ublk_complete_rq()

On Tue, Feb 07, 2023 at 03:08:38PM +0800, Ziyang Zhang wrote:
> WRITE_ZEROES won't return bytes returned just like FLUSH and DISCARD,
> and we can end it directly. Add missing comment for it in
> ublk_complete_rq().
>
> Signed-off-by: Ziyang Zhang <[email protected]>
> ---
> drivers/block/ublk_drv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 55fccce68a9c..06eddefdf02a 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -665,7 +665,7 @@ static void ublk_complete_rq(struct request *req)
> }
>
> /*
> - * FLUSH or DISCARD usually won't return bytes returned, so end them
> + * FLUSH, DISCARD or WRITE_ZEROES usually won't return bytes returned, so end them
> * directly.
> *
> * Both the two needn't unmap.

Reviewed-by: Ming Lei <[email protected]>


Thanks,
Ming


2023-02-07 14:09:18

by Ming Lei

[permalink] [raw]
Subject: Re: [PATCH RESEND 3/3] ublk: pass NULL to blk_mq_alloc_disk() as queuedata

On Tue, Feb 07, 2023 at 03:08:39PM +0800, Ziyang Zhang wrote:
> queuedata is not referenced in ublk_drv and we can use driver_data
> instead. Pass NULL to blk_mq_alloc_disk() as queuedata while allocating
> ublk's gendisk.
>
> Signed-off-by: Ziyang Zhang <[email protected]>

Reviewed-by: Ming Lei <[email protected]>


Thanks,
Ming


2023-02-07 14:22:03

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH RESEND 0/3] cleanup for ublk


On Tue, 07 Feb 2023 15:08:36 +0800, Ziyang Zhang wrote:
> removing unnecessary NULL check, unused variable and comment fix.
>
> Ziyang Zhang (3):
> ublk: remove unnecessary NULL check in ublk_rq_has_data()
> ublk: mention WRITE_ZEROES in comment of ublk_complete_rq()
> ublk: pass NULL to blk_mq_alloc_disk() as queuedata
>
> [...]

Applied, thanks!

[1/3] ublk: remove unnecessary NULL check in ublk_rq_has_data()
commit: 731e208d7b4b38d2bac4b7c53403c8abbf306d01
[2/3] ublk: mention WRITE_ZEROES in comment of ublk_complete_rq()
commit: b352389e7ba34bdb5bcf4254fa1e85319ba76352
[3/3] ublk: pass NULL to blk_mq_alloc_disk() as queuedata
commit: 1972d038a5401781377d3ce2d901bf7763a43589

Best regards,
--
Jens Axboe