Skip to contentSkip to conversation

cleanup for ublk

PATCH RESEND Applied Ziyang Zhang 3 participants 8 messages Feb 7, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.18.4
#1 lore raw

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.

---
 drivers/block/ublk_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/ublk_drv.c +1 -1
index c932e9ea5a0f..55fccce68a9c 100644
@@ -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,
Signature · 1 line
2.18.4
#3 lore raw

PATCH RESEND 2/3 ublk: mention WRITE_ZEROES in comment of ublk_complete_rq()

In reply to Ziyang Zhang

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().

---
 drivers/block/ublk_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/ublk_drv.c +1 -1
index 55fccce68a9c..06eddefdf02a 100644
@@ -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.
Signature · 1 line
2.18.4
Reviewed-by on v1 2/3
#4 lore raw

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

Quoted 14 lines · Ziyang Zhang

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().

---
 drivers/block/ublk_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/ublk_drv.c +0 -0
index 55fccce68a9c..06eddefdf02a 100644

drivers/block/ublk_drv.c static void ublk_complete_rq(struct request *req) · line 671

Quoted 8 lines
drivers/block/ublk_drv.c +1 -1
@@ -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.

Thanks,
Ming

#5 lore raw

PATCH RESEND 3/3 ublk: pass NULL to blk_mq_alloc_disk() as queuedata

In reply to Ziyang Zhang

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.

---
 drivers/block/ublk_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/ublk_drv.c +1 -1
index 06eddefdf02a..d83fe2c2b3ba 100644
@@ -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;
Signature · 1 line
2.18.4
Reviewed-by on v1 3/3
#6 lore raw

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

Quoted 5 lines · Ziyang Zhang

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.

Thanks,
Ming

maintainer Applied
#7 lore raw
In reply to Ziyang Zhang
Quoted 8 lines · Ziyang Zhang

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,

Signature · 1 line
Jens Axboe