Skip to contentSkip to conversation

pass queue limits to alloc_disk for pktcdvd

PATCH New Christoph Hellwig 2 participants 4 messages Feb 22, 2024 Block layer

lore
Share & tools
lore
#0 lore raw

Hi Jens,

this series has the queue limits conversion for pktcdvd.

Diffstat:

 pktcdvd.c |   25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)
#1 lore raw

PATCH 1/2 pktcdvd: stop setting q->queuedata

The two users can get the private data from the gendisk with one less pointer dereference, and we can drop the useless q parameter from pkt_make_request_write.

---
 drivers/block/pktcdvd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/block/pktcdvd.c +4 -5
index abb82926b1c935..0cd65b27c19717 100644
@@ -2338,9 +2338,9 @@ static void pkt_make_request_read(struct pktcdvd_device *pd, struct bio *bio)
 	pkt_queue_bio(pd, cloned_bio);
 }
 
-static void pkt_make_request_write(struct request_queue *q, struct bio *bio)
+static void pkt_make_request_write(struct bio *bio)
 {
-	struct pktcdvd_device *pd = q->queuedata;
+	struct pktcdvd_device *pd = bio->bi_bdev->bd_disk->private_data;
 	sector_t zone;
 	struct packet_data *pkt;
 	int was_empty, blocked_bio;
@@ -2432,7 +2432,7 @@ static void pkt_make_request_write(struct request_queue *q, struct bio *bio)
 
 static void pkt_submit_bio(struct bio *bio)
 {
-	struct pktcdvd_device *pd = bio->bi_bdev->bd_disk->queue->queuedata;
+	struct pktcdvd_device *pd = bio->bi_bdev->bd_disk->private_data;
 	struct device *ddev = disk_to_dev(pd->disk);
 	struct bio *split;
 
@@ -2476,7 +2476,7 @@ static void pkt_submit_bio(struct bio *bio)
 			split = bio;
 		}
 
-		pkt_make_request_write(bio->bi_bdev->bd_disk->queue, split);
+		pkt_make_request_write(split);
 	} while (split != bio);
 
 	return;
@@ -2490,7 +2490,6 @@ static void pkt_init_queue(struct pktcdvd_device *pd)
 
 	blk_queue_logical_block_size(q, CD_FRAMESIZE);
 	blk_queue_max_hw_sectors(q, PACKET_MAX_SECTORS);
-	q->queuedata = pd;
 }
 
 static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/2 pktcdvd: set queue limits at disk allocation time

In reply to Christoph Hellwig

Remove pkt_init_queue and just pass the two parameters directly to blk_alloc_disk.

---
 drivers/block/pktcdvd.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/block/pktcdvd.c +5 -11
index 0cd65b27c19717..12fcc881b04f54 100644
@@ -2484,14 +2484,6 @@ static void pkt_submit_bio(struct bio *bio)
 	bio_io_error(bio);
 }
 
-static void pkt_init_queue(struct pktcdvd_device *pd)
-{
-	struct request_queue *q = pd->disk->queue;
-
-	blk_queue_logical_block_size(q, CD_FRAMESIZE);
-	blk_queue_max_hw_sectors(q, PACKET_MAX_SECTORS);
-}
-
 static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 {
 	struct device *ddev = disk_to_dev(pd->disk);
@@ -2535,8 +2527,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
 	pd->bdev_handle = bdev_handle;
 	set_blocksize(bdev_handle->bdev, CD_FRAMESIZE);
 
-	pkt_init_queue(pd);
-
 	atomic_set(&pd->cdrw.pending_bios, 0);
 	pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->disk->disk_name);
 	if (IS_ERR(pd->cdrw.thread)) {
@@ -2633,6 +2623,10 @@ static const struct block_device_operations pktcdvd_ops = {
  */
 static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
 {
+	struct queue_limits lim = {
+		.max_hw_sectors		= PACKET_MAX_SECTORS,
+		.logical_block_size	= CD_FRAMESIZE,
+	};
 	int idx;
 	int ret = -ENOMEM;
 	struct pktcdvd_device *pd;
@@ -2672,7 +2666,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
 	pd->write_congestion_on  = write_congestion_on;
 	pd->write_congestion_off = write_congestion_off;
 
-	disk = blk_alloc_disk(NULL, NUMA_NO_NODE);
+	disk = blk_alloc_disk(&lim, NUMA_NO_NODE);
 	if (IS_ERR(disk)) {
 		ret = PTR_ERR(disk);
 		goto out_mem;
Signature · 1 line
2.39.2
maintainer Applied
#3 lore raw
In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig

this series has the queue limits conversion for pktcdvd.

Diffstat:

 pktcdvd.c |   25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

Applied, thanks!

[1/2] pktcdvd: stop setting q->queuedata

      commit: 6f420d6a2dd8d4a795eab2839b0e08663269f9f8
[2/2] pktcdvd: set queue limits at disk allocation time
      commit: 4068550870360410261638479ffaf8364c366dd8

Best regards,

Signature · 1 line
Jens Axboe