Commit 46754bd0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: move ->bio_split to the gendisk

Only non-passthrough requests are split by the block layer and use the
->bio_split bio_set.  Move it from the request_queue to the gendisk.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20220727162300.3089193-4-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 51d798cd
...@@ -377,7 +377,6 @@ static void blk_timeout_work(struct work_struct *work) ...@@ -377,7 +377,6 @@ static void blk_timeout_work(struct work_struct *work)
struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu) struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu)
{ {
struct request_queue *q; struct request_queue *q;
int ret;
q = kmem_cache_alloc_node(blk_get_queue_kmem_cache(alloc_srcu), q = kmem_cache_alloc_node(blk_get_queue_kmem_cache(alloc_srcu),
GFP_KERNEL | __GFP_ZERO, node_id); GFP_KERNEL | __GFP_ZERO, node_id);
...@@ -396,13 +395,9 @@ struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu) ...@@ -396,13 +395,9 @@ struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu)
if (q->id < 0) if (q->id < 0)
goto fail_srcu; goto fail_srcu;
ret = bioset_init(&q->bio_split, BIO_POOL_SIZE, 0, 0);
if (ret)
goto fail_id;
q->stats = blk_alloc_queue_stats(); q->stats = blk_alloc_queue_stats();
if (!q->stats) if (!q->stats)
goto fail_split; goto fail_id;
q->node = node_id; q->node = node_id;
...@@ -439,8 +434,6 @@ struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu) ...@@ -439,8 +434,6 @@ struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu)
fail_stats: fail_stats:
blk_free_queue_stats(q->stats); blk_free_queue_stats(q->stats);
fail_split:
bioset_exit(&q->bio_split);
fail_id: fail_id:
ida_free(&blk_queue_ida, q->id); ida_free(&blk_queue_ida, q->id);
fail_srcu: fail_srcu:
......
...@@ -331,18 +331,19 @@ static struct bio *bio_split_rw(struct bio *bio, struct request_queue *q, ...@@ -331,18 +331,19 @@ static struct bio *bio_split_rw(struct bio *bio, struct request_queue *q,
struct bio *__bio_split_to_limits(struct bio *bio, struct request_queue *q, struct bio *__bio_split_to_limits(struct bio *bio, struct request_queue *q,
unsigned int *nr_segs) unsigned int *nr_segs)
{ {
struct bio_set *bs = &bio->bi_bdev->bd_disk->bio_split;
struct bio *split; struct bio *split;
switch (bio_op(bio)) { switch (bio_op(bio)) {
case REQ_OP_DISCARD: case REQ_OP_DISCARD:
case REQ_OP_SECURE_ERASE: case REQ_OP_SECURE_ERASE:
split = bio_split_discard(bio, q, nr_segs, &q->bio_split); split = bio_split_discard(bio, q, nr_segs, bs);
break; break;
case REQ_OP_WRITE_ZEROES: case REQ_OP_WRITE_ZEROES:
split = bio_split_write_zeroes(bio, q, nr_segs, &q->bio_split); split = bio_split_write_zeroes(bio, q, nr_segs, bs);
break; break;
default: default:
split = bio_split_rw(bio, q, nr_segs, &q->bio_split); split = bio_split_rw(bio, q, nr_segs, bs);
break; break;
} }
......
...@@ -779,8 +779,6 @@ static void blk_release_queue(struct kobject *kobj) ...@@ -779,8 +779,6 @@ static void blk_release_queue(struct kobject *kobj)
if (queue_is_mq(q)) if (queue_is_mq(q))
blk_mq_release(q); blk_mq_release(q);
bioset_exit(&q->bio_split);
if (blk_queue_has_srcu(q)) if (blk_queue_has_srcu(q))
cleanup_srcu_struct(q->srcu); cleanup_srcu_struct(q->srcu);
......
...@@ -1151,6 +1151,7 @@ static void disk_release(struct device *dev) ...@@ -1151,6 +1151,7 @@ static void disk_release(struct device *dev)
blk_mq_exit_queue(disk->queue); blk_mq_exit_queue(disk->queue);
blkcg_exit_queue(disk->queue); blkcg_exit_queue(disk->queue);
bioset_exit(&disk->bio_split);
disk_release_events(disk); disk_release_events(disk);
kfree(disk->random); kfree(disk->random);
...@@ -1342,9 +1343,12 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id, ...@@ -1342,9 +1343,12 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
if (!disk) if (!disk)
goto out_put_queue; goto out_put_queue;
if (bioset_init(&disk->bio_split, BIO_POOL_SIZE, 0, 0))
goto out_free_disk;
disk->bdi = bdi_alloc(node_id); disk->bdi = bdi_alloc(node_id);
if (!disk->bdi) if (!disk->bdi)
goto out_free_disk; goto out_free_bioset;
/* bdev_alloc() might need the queue, set before the first call */ /* bdev_alloc() might need the queue, set before the first call */
disk->queue = q; disk->queue = q;
...@@ -1382,6 +1386,8 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id, ...@@ -1382,6 +1386,8 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
iput(disk->part0->bd_inode); iput(disk->part0->bd_inode);
out_free_bdi: out_free_bdi:
bdi_put(disk->bdi); bdi_put(disk->bdi);
out_free_bioset:
bioset_exit(&disk->bio_split);
out_free_disk: out_free_disk:
kfree(disk); kfree(disk);
out_put_queue: out_put_queue:
......
...@@ -1016,7 +1016,7 @@ static void dm_wq_requeue_work(struct work_struct *work) ...@@ -1016,7 +1016,7 @@ static void dm_wq_requeue_work(struct work_struct *work)
while (io) { while (io) {
struct dm_io *next = io->next; struct dm_io *next = io->next;
dm_io_rewind(io, &md->queue->bio_split); dm_io_rewind(io, &md->disk->bio_split);
io->next = NULL; io->next = NULL;
__dm_io_complete(io, false); __dm_io_complete(io, false);
......
...@@ -140,6 +140,8 @@ struct gendisk { ...@@ -140,6 +140,8 @@ struct gendisk {
struct request_queue *queue; struct request_queue *queue;
void *private_data; void *private_data;
struct bio_set bio_split;
int flags; int flags;
unsigned long state; unsigned long state;
#define GD_NEED_PART_SCAN 0 #define GD_NEED_PART_SCAN 0
...@@ -531,7 +533,6 @@ struct request_queue { ...@@ -531,7 +533,6 @@ struct request_queue {
struct blk_mq_tag_set *tag_set; struct blk_mq_tag_set *tag_set;
struct list_head tag_set_list; struct list_head tag_set_list;
struct bio_set bio_split;
struct dentry *debugfs_dir; struct dentry *debugfs_dir;
struct dentry *sched_debugfs_dir; struct dentry *sched_debugfs_dir;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment