Skip to content

Commit

Permalink
pktcdvd: convert to bioset_init()/mempool_init()
Browse files Browse the repository at this point in the history
Convert pktcdvd to embedded bio sets.

Signed-off-by: Kent Overstreet <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
koverstreet authored and axboe committed May 30, 2018
1 parent 0892fac commit 64c4bc4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
50 changes: 25 additions & 25 deletions drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ static int pktdev_major;
static int write_congestion_on = PKT_WRITE_CONGESTION_ON;
static int write_congestion_off = PKT_WRITE_CONGESTION_OFF;
static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
static mempool_t *psd_pool;
static struct bio_set *pkt_bio_set;
static mempool_t psd_pool;
static struct bio_set pkt_bio_set;

static struct class *class_pktcdvd = NULL; /* /sys/class/pktcdvd */
static struct dentry *pkt_debugfs_root = NULL; /* /sys/kernel/debug/pktcdvd */
Expand Down Expand Up @@ -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)
{
rb_erase(&node->rb_node, &pd->bio_queue);
mempool_free(node, pd->rb_pool);
mempool_free(node, &pd->rb_pool);
pd->bio_queue_size--;
BUG_ON(pd->bio_queue_size < 0);
}
Expand Down Expand Up @@ -2303,14 +2303,14 @@ static void pkt_end_io_read_cloned(struct bio *bio)
psd->bio->bi_status = bio->bi_status;
bio_put(bio);
bio_endio(psd->bio);
mempool_free(psd, psd_pool);
mempool_free(psd, &psd_pool);
pkt_bio_finished(pd);
}

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 packet_stacked_data *psd = mempool_alloc(psd_pool, GFP_NOIO);
struct bio *cloned_bio = bio_clone_fast(bio, GFP_NOIO, &pkt_bio_set);
struct packet_stacked_data *psd = mempool_alloc(&psd_pool, GFP_NOIO);

psd->pd = pd;
psd->bio = bio;
Expand Down Expand Up @@ -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.
*/
node = mempool_alloc(pd->rb_pool, GFP_NOIO);
node = mempool_alloc(&pd->rb_pool, GFP_NOIO);
node->bio = bio;
spin_lock(&pd->lock);
BUG_ON(pd->bio_queue_size < 0);
Expand Down Expand Up @@ -2451,7 +2451,7 @@ static blk_qc_t pkt_make_request(struct request_queue *q, struct bio *bio)

split = bio_split(bio, last_zone -
bio->bi_iter.bi_sector,
GFP_NOIO, pkt_bio_set);
GFP_NOIO, &pkt_bio_set);
bio_chain(split, bio);
} else {
split = bio;
Expand Down Expand Up @@ -2707,9 +2707,9 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
if (!pd)
goto out_mutex;

pd->rb_pool = mempool_create_kmalloc_pool(PKT_RB_POOL_SIZE,
sizeof(struct pkt_rb_node));
if (!pd->rb_pool)
ret = mempool_init_kmalloc_pool(&pd->rb_pool, PKT_RB_POOL_SIZE,
sizeof(struct pkt_rb_node));
if (ret)
goto out_mem;

INIT_LIST_HEAD(&pd->cdrw.pkt_free_list);
Expand Down Expand Up @@ -2766,7 +2766,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
out_mem2:
put_disk(disk);
out_mem:
mempool_destroy(pd->rb_pool);
mempool_exit(&pd->rb_pool);
kfree(pd);
out_mutex:
mutex_unlock(&ctl_mutex);
Expand Down Expand Up @@ -2817,7 +2817,7 @@ static int pkt_remove_dev(dev_t pkt_dev)
blk_cleanup_queue(pd->disk->queue);
put_disk(pd->disk);

mempool_destroy(pd->rb_pool);
mempool_exit(&pd->rb_pool);
kfree(pd);

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

mutex_init(&ctl_mutex);

psd_pool = mempool_create_kmalloc_pool(PSD_POOL_SIZE,
sizeof(struct packet_stacked_data));
if (!psd_pool)
return -ENOMEM;
pkt_bio_set = bioset_create(BIO_POOL_SIZE, 0, 0);
if (!pkt_bio_set) {
mempool_destroy(psd_pool);
return -ENOMEM;
ret = mempool_init_kmalloc_pool(&psd_pool, PSD_POOL_SIZE,
sizeof(struct packet_stacked_data));
if (ret)
return ret;
ret = bioset_init(&pkt_bio_set, BIO_POOL_SIZE, 0, 0);
if (ret) {
mempool_exit(&psd_pool);
return ret;
}

ret = register_blkdev(pktdev_major, DRIVER_NAME);
Expand Down Expand Up @@ -2954,8 +2954,8 @@ static int __init pkt_init(void)
out:
unregister_blkdev(pktdev_major, DRIVER_NAME);
out2:
mempool_destroy(psd_pool);
bioset_free(pkt_bio_set);
mempool_exit(&psd_pool);
bioset_exit(&pkt_bio_set);
return ret;
}

Expand All @@ -2968,8 +2968,8 @@ static void __exit pkt_exit(void)
pkt_sysfs_cleanup();

unregister_blkdev(pktdev_major, DRIVER_NAME);
mempool_destroy(psd_pool);
bioset_free(pkt_bio_set);
mempool_exit(&psd_pool);
bioset_exit(&pkt_bio_set);
}

MODULE_DESCRIPTION("Packet writing layer for CD/DVD drives");
Expand Down
2 changes: 1 addition & 1 deletion include/linux/pktcdvd.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ struct pktcdvd_device
sector_t current_sector; /* Keep track of where the elevator is */
atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */
/* 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 gendisk *disk;
Expand Down

0 comments on commit 64c4bc4

Please sign in to comment.