pktcdvd: convert to bioset_init()/mempool_init()
Convert pktcdvd to embedded bio sets. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
0892fac871
commit
64c4bc4de7
@ -97,8 +97,8 @@ static int pktdev_major;
|
|||||||
static int write_congestion_on = PKT_WRITE_CONGESTION_ON;
|
static int write_congestion_on = PKT_WRITE_CONGESTION_ON;
|
||||||
static int write_congestion_off = PKT_WRITE_CONGESTION_OFF;
|
static int write_congestion_off = PKT_WRITE_CONGESTION_OFF;
|
||||||
static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
|
static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
|
||||||
static mempool_t *psd_pool;
|
static mempool_t psd_pool;
|
||||||
static struct bio_set *pkt_bio_set;
|
static struct bio_set pkt_bio_set;
|
||||||
|
|
||||||
static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */
|
static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */
|
||||||
static struct dentry *pkt_debugfs_root = NULL; /* /sys/kernel/debug/pktcdvd */
|
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)
|
|||||||
static void pkt_rbtree_erase(struct pktcdvd_device *pd, struct pkt_rb_node *node)
|
static void pkt_rbtree_erase(struct pktcdvd_device *pd, struct pkt_rb_node *node)
|
||||||
{
|
{
|
||||||
rb_erase(&node->rb_node, &pd->bio_queue);
|
rb_erase(&node->rb_node, &pd->bio_queue);
|
||||||
mempool_free(node, pd->rb_pool);
|
mempool_free(node, &pd->rb_pool);
|
||||||
pd->bio_queue_size--;
|
pd->bio_queue_size--;
|
||||||
BUG_ON(pd->bio_queue_size < 0);
|
BUG_ON(pd->bio_queue_size < 0);
|
||||||
}
|
}
|
||||||
@ -2303,14 +2303,14 @@ static void pkt_end_io_read_cloned(struct bio *bio)
|
|||||||
psd->bio->bi_status = bio->bi_status;
|
psd->bio->bi_status = bio->bi_status;
|
||||||
bio_put(bio);
|
bio_put(bio);
|
||||||
bio_endio(psd->bio);
|
bio_endio(psd->bio);
|
||||||
mempool_free(psd, psd_pool);
|
mempool_free(psd, &psd_pool);
|
||||||
pkt_bio_finished(pd);
|
pkt_bio_finished(pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pkt_make_request_read(struct pktcdvd_device *pd, struct bio *bio)
|
static void pkt_make_request_read(struct pktcdvd_device *pd, struct bio *bio)
|
||||||
{
|
{
|
||||||
struct bio *cloned_bio = bio_clone_fast(bio, GFP_NOIO, pkt_bio_set);
|
struct bio *cloned_bio = bio_clone_fast(bio, GFP_NOIO, &pkt_bio_set);
|
||||||
struct packet_stacked_data *psd = mempool_alloc(psd_pool, GFP_NOIO);
|
struct packet_stacked_data *psd = mempool_alloc(&psd_pool, GFP_NOIO);
|
||||||
|
|
||||||
psd->pd = pd;
|
psd->pd = pd;
|
||||||
psd->bio = bio;
|
psd->bio = bio;
|
||||||
@ -2381,7 +2381,7 @@ static void pkt_make_request_write(struct request_queue *q, struct bio *bio)
|
|||||||
/*
|
/*
|
||||||
* No matching packet found. Store the bio in the work queue.
|
* No matching packet found. Store the bio in the work queue.
|
||||||
*/
|
*/
|
||||||
node = mempool_alloc(pd->rb_pool, GFP_NOIO);
|
node = mempool_alloc(&pd->rb_pool, GFP_NOIO);
|
||||||
node->bio = bio;
|
node->bio = bio;
|
||||||
spin_lock(&pd->lock);
|
spin_lock(&pd->lock);
|
||||||
BUG_ON(pd->bio_queue_size < 0);
|
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)
|
|||||||
|
|
||||||
split = bio_split(bio, last_zone -
|
split = bio_split(bio, last_zone -
|
||||||
bio->bi_iter.bi_sector,
|
bio->bi_iter.bi_sector,
|
||||||
GFP_NOIO, pkt_bio_set);
|
GFP_NOIO, &pkt_bio_set);
|
||||||
bio_chain(split, bio);
|
bio_chain(split, bio);
|
||||||
} else {
|
} else {
|
||||||
split = bio;
|
split = bio;
|
||||||
@ -2707,9 +2707,9 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
|
|||||||
if (!pd)
|
if (!pd)
|
||||||
goto out_mutex;
|
goto out_mutex;
|
||||||
|
|
||||||
pd->rb_pool = mempool_create_kmalloc_pool(PKT_RB_POOL_SIZE,
|
ret = mempool_init_kmalloc_pool(&pd->rb_pool, PKT_RB_POOL_SIZE,
|
||||||
sizeof(struct pkt_rb_node));
|
sizeof(struct pkt_rb_node));
|
||||||
if (!pd->rb_pool)
|
if (ret)
|
||||||
goto out_mem;
|
goto out_mem;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&pd->cdrw.pkt_free_list);
|
INIT_LIST_HEAD(&pd->cdrw.pkt_free_list);
|
||||||
@ -2766,7 +2766,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
|
|||||||
out_mem2:
|
out_mem2:
|
||||||
put_disk(disk);
|
put_disk(disk);
|
||||||
out_mem:
|
out_mem:
|
||||||
mempool_destroy(pd->rb_pool);
|
mempool_exit(&pd->rb_pool);
|
||||||
kfree(pd);
|
kfree(pd);
|
||||||
out_mutex:
|
out_mutex:
|
||||||
mutex_unlock(&ctl_mutex);
|
mutex_unlock(&ctl_mutex);
|
||||||
@ -2817,7 +2817,7 @@ static int pkt_remove_dev(dev_t pkt_dev)
|
|||||||
blk_cleanup_queue(pd->disk->queue);
|
blk_cleanup_queue(pd->disk->queue);
|
||||||
put_disk(pd->disk);
|
put_disk(pd->disk);
|
||||||
|
|
||||||
mempool_destroy(pd->rb_pool);
|
mempool_exit(&pd->rb_pool);
|
||||||
kfree(pd);
|
kfree(pd);
|
||||||
|
|
||||||
/* This is safe: open() is still holding a reference. */
|
/* This is safe: open() is still holding a reference. */
|
||||||
@ -2914,14 +2914,14 @@ static int __init pkt_init(void)
|
|||||||
|
|
||||||
mutex_init(&ctl_mutex);
|
mutex_init(&ctl_mutex);
|
||||||
|
|
||||||
psd_pool = mempool_create_kmalloc_pool(PSD_POOL_SIZE,
|
ret = mempool_init_kmalloc_pool(&psd_pool, PSD_POOL_SIZE,
|
||||||
sizeof(struct packet_stacked_data));
|
sizeof(struct packet_stacked_data));
|
||||||
if (!psd_pool)
|
if (ret)
|
||||||
return -ENOMEM;
|
return ret;
|
||||||
pkt_bio_set = bioset_create(BIO_POOL_SIZE, 0, 0);
|
ret = bioset_init(&pkt_bio_set, BIO_POOL_SIZE, 0, 0);
|
||||||
if (!pkt_bio_set) {
|
if (ret) {
|
||||||
mempool_destroy(psd_pool);
|
mempool_exit(&psd_pool);
|
||||||
return -ENOMEM;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = register_blkdev(pktdev_major, DRIVER_NAME);
|
ret = register_blkdev(pktdev_major, DRIVER_NAME);
|
||||||
@ -2954,8 +2954,8 @@ static int __init pkt_init(void)
|
|||||||
out:
|
out:
|
||||||
unregister_blkdev(pktdev_major, DRIVER_NAME);
|
unregister_blkdev(pktdev_major, DRIVER_NAME);
|
||||||
out2:
|
out2:
|
||||||
mempool_destroy(psd_pool);
|
mempool_exit(&psd_pool);
|
||||||
bioset_free(pkt_bio_set);
|
bioset_exit(&pkt_bio_set);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2968,8 +2968,8 @@ static void __exit pkt_exit(void)
|
|||||||
pkt_sysfs_cleanup();
|
pkt_sysfs_cleanup();
|
||||||
|
|
||||||
unregister_blkdev(pktdev_major, DRIVER_NAME);
|
unregister_blkdev(pktdev_major, DRIVER_NAME);
|
||||||
mempool_destroy(psd_pool);
|
mempool_exit(&psd_pool);
|
||||||
bioset_free(pkt_bio_set);
|
bioset_exit(&pkt_bio_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE_DESCRIPTION("Packet writing layer for CD/DVD drives");
|
MODULE_DESCRIPTION("Packet writing layer for CD/DVD drives");
|
||||||
|
@ -186,7 +186,7 @@ struct pktcdvd_device
|
|||||||
sector_t current_sector; /* Keep track of where the elevator is */
|
sector_t current_sector; /* Keep track of where the elevator is */
|
||||||
atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */
|
atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */
|
||||||
/* needs to be run. */
|
/* needs to be run. */
|
||||||
mempool_t *rb_pool; /* mempool for pkt_rb_node allocations */
|
mempool_t rb_pool; /* mempool for pkt_rb_node allocations */
|
||||||
|
|
||||||
struct packet_iosched iosched;
|
struct packet_iosched iosched;
|
||||||
struct gendisk *disk;
|
struct gendisk *disk;
|
||||||
|
Loading…
Reference in New Issue
Block a user