Skip to content

Commit 64c4bc4

Browse files
koverstreetaxboe
authored andcommitted
pktcdvd: convert to bioset_init()/mempool_init()
Convert pktcdvd to embedded bio sets. Signed-off-by: Kent Overstreet <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0892fac commit 64c4bc4

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

drivers/block/pktcdvd.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ static int pktdev_major;
9797
static int write_congestion_on = PKT_WRITE_CONGESTION_ON;
9898
static int write_congestion_off = PKT_WRITE_CONGESTION_OFF;
9999
static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
100-
static mempool_t *psd_pool;
101-
static struct bio_set *pkt_bio_set;
100+
static mempool_t psd_pool;
101+
static struct bio_set pkt_bio_set;
102102

103103
static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */
104104
static struct dentry *pkt_debugfs_root = NULL; /* /sys/kernel/debug/pktcdvd */
@@ -631,7 +631,7 @@ static inline struct pkt_rb_node *pkt_rbtree_next(struct pkt_rb_node *node)
631631
static void pkt_rbtree_erase(struct pktcdvd_device *pd, struct pkt_rb_node *node)
632632
{
633633
rb_erase(&node->rb_node, &pd->bio_queue);
634-
mempool_free(node, pd->rb_pool);
634+
mempool_free(node, &pd->rb_pool);
635635
pd->bio_queue_size--;
636636
BUG_ON(pd->bio_queue_size < 0);
637637
}
@@ -2303,14 +2303,14 @@ static void pkt_end_io_read_cloned(struct bio *bio)
23032303
psd->bio->bi_status = bio->bi_status;
23042304
bio_put(bio);
23052305
bio_endio(psd->bio);
2306-
mempool_free(psd, psd_pool);
2306+
mempool_free(psd, &psd_pool);
23072307
pkt_bio_finished(pd);
23082308
}
23092309

23102310
static void pkt_make_request_read(struct pktcdvd_device *pd, struct bio *bio)
23112311
{
2312-
struct bio *cloned_bio = bio_clone_fast(bio, GFP_NOIO, pkt_bio_set);
2313-
struct packet_stacked_data *psd = mempool_alloc(psd_pool, GFP_NOIO);
2312+
struct bio *cloned_bio = bio_clone_fast(bio, GFP_NOIO, &pkt_bio_set);
2313+
struct packet_stacked_data *psd = mempool_alloc(&psd_pool, GFP_NOIO);
23142314

23152315
psd->pd = pd;
23162316
psd->bio = bio;
@@ -2381,7 +2381,7 @@ static void pkt_make_request_write(struct request_queue *q, struct bio *bio)
23812381
/*
23822382
* No matching packet found. Store the bio in the work queue.
23832383
*/
2384-
node = mempool_alloc(pd->rb_pool, GFP_NOIO);
2384+
node = mempool_alloc(&pd->rb_pool, GFP_NOIO);
23852385
node->bio = bio;
23862386
spin_lock(&pd->lock);
23872387
BUG_ON(pd->bio_queue_size < 0);
@@ -2451,7 +2451,7 @@ static blk_qc_t pkt_make_request(struct request_queue *q, struct bio *bio)
24512451

24522452
split = bio_split(bio, last_zone -
24532453
bio->bi_iter.bi_sector,
2454-
GFP_NOIO, pkt_bio_set);
2454+
GFP_NOIO, &pkt_bio_set);
24552455
bio_chain(split, bio);
24562456
} else {
24572457
split = bio;
@@ -2707,9 +2707,9 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
27072707
if (!pd)
27082708
goto out_mutex;
27092709

2710-
pd->rb_pool = mempool_create_kmalloc_pool(PKT_RB_POOL_SIZE,
2711-
sizeof(struct pkt_rb_node));
2712-
if (!pd->rb_pool)
2710+
ret = mempool_init_kmalloc_pool(&pd->rb_pool, PKT_RB_POOL_SIZE,
2711+
sizeof(struct pkt_rb_node));
2712+
if (ret)
27132713
goto out_mem;
27142714

27152715
INIT_LIST_HEAD(&pd->cdrw.pkt_free_list);
@@ -2766,7 +2766,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
27662766
out_mem2:
27672767
put_disk(disk);
27682768
out_mem:
2769-
mempool_destroy(pd->rb_pool);
2769+
mempool_exit(&pd->rb_pool);
27702770
kfree(pd);
27712771
out_mutex:
27722772
mutex_unlock(&ctl_mutex);
@@ -2817,7 +2817,7 @@ static int pkt_remove_dev(dev_t pkt_dev)
28172817
blk_cleanup_queue(pd->disk->queue);
28182818
put_disk(pd->disk);
28192819

2820-
mempool_destroy(pd->rb_pool);
2820+
mempool_exit(&pd->rb_pool);
28212821
kfree(pd);
28222822

28232823
/* This is safe: open() is still holding a reference. */
@@ -2914,14 +2914,14 @@ static int __init pkt_init(void)
29142914

29152915
mutex_init(&ctl_mutex);
29162916

2917-
psd_pool = mempool_create_kmalloc_pool(PSD_POOL_SIZE,
2918-
sizeof(struct packet_stacked_data));
2919-
if (!psd_pool)
2920-
return -ENOMEM;
2921-
pkt_bio_set = bioset_create(BIO_POOL_SIZE, 0, 0);
2922-
if (!pkt_bio_set) {
2923-
mempool_destroy(psd_pool);
2924-
return -ENOMEM;
2917+
ret = mempool_init_kmalloc_pool(&psd_pool, PSD_POOL_SIZE,
2918+
sizeof(struct packet_stacked_data));
2919+
if (ret)
2920+
return ret;
2921+
ret = bioset_init(&pkt_bio_set, BIO_POOL_SIZE, 0, 0);
2922+
if (ret) {
2923+
mempool_exit(&psd_pool);
2924+
return ret;
29252925
}
29262926

29272927
ret = register_blkdev(pktdev_major, DRIVER_NAME);
@@ -2954,8 +2954,8 @@ static int __init pkt_init(void)
29542954
out:
29552955
unregister_blkdev(pktdev_major, DRIVER_NAME);
29562956
out2:
2957-
mempool_destroy(psd_pool);
2958-
bioset_free(pkt_bio_set);
2957+
mempool_exit(&psd_pool);
2958+
bioset_exit(&pkt_bio_set);
29592959
return ret;
29602960
}
29612961

@@ -2968,8 +2968,8 @@ static void __exit pkt_exit(void)
29682968
pkt_sysfs_cleanup();
29692969

29702970
unregister_blkdev(pktdev_major, DRIVER_NAME);
2971-
mempool_destroy(psd_pool);
2972-
bioset_free(pkt_bio_set);
2971+
mempool_exit(&psd_pool);
2972+
bioset_exit(&pkt_bio_set);
29732973
}
29742974

29752975
MODULE_DESCRIPTION("Packet writing layer for CD/DVD drives");

include/linux/pktcdvd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct pktcdvd_device
186186
sector_t current_sector; /* Keep track of where the elevator is */
187187
atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */
188188
/* needs to be run. */
189-
mempool_t *rb_pool; /* mempool for pkt_rb_node allocations */
189+
mempool_t rb_pool; /* mempool for pkt_rb_node allocations */
190190

191191
struct packet_iosched iosched;
192192
struct gendisk *disk;

0 commit comments

Comments
 (0)