Skip to content

Commit

Permalink
bcache: pass the make_request methods to blk_queue_make_request
Browse files Browse the repository at this point in the history
bcache is the only driver not actually passing its make_request
methods to blk_queue_make_request, but instead just sets them up
manually a little later.  Make bcache follow the common way of
setting up make_request based queues.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Mar 27, 2020
1 parent 8d96a11 commit ff27668
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
7 changes: 2 additions & 5 deletions drivers/md/bcache/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,8 +1161,7 @@ static void quit_max_writeback_rate(struct cache_set *c,

/* Cached devices - read & write stuff */

static blk_qc_t cached_dev_make_request(struct request_queue *q,
struct bio *bio)
blk_qc_t cached_dev_make_request(struct request_queue *q, struct bio *bio)
{
struct search *s;
struct bcache_device *d = bio->bi_disk->private_data;
Expand Down Expand Up @@ -1266,7 +1265,6 @@ void bch_cached_dev_request_init(struct cached_dev *dc)
{
struct gendisk *g = dc->disk.disk;

g->queue->make_request_fn = cached_dev_make_request;
g->queue->backing_dev_info->congested_fn = cached_dev_congested;
dc->disk.cache_miss = cached_dev_cache_miss;
dc->disk.ioctl = cached_dev_ioctl;
Expand Down Expand Up @@ -1301,8 +1299,7 @@ static void flash_dev_nodata(struct closure *cl)
continue_at(cl, search_free, NULL);
}

static blk_qc_t flash_dev_make_request(struct request_queue *q,
struct bio *bio)
blk_qc_t flash_dev_make_request(struct request_queue *q, struct bio *bio)
{
struct search *s;
struct closure *cl;
Expand Down
3 changes: 3 additions & 0 deletions drivers/md/bcache/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ unsigned int bch_get_congested(const struct cache_set *c);
void bch_data_insert(struct closure *cl);

void bch_cached_dev_request_init(struct cached_dev *dc);
blk_qc_t cached_dev_make_request(struct request_queue *q, struct bio *bio);

void bch_flash_dev_request_init(struct bcache_device *d);
blk_qc_t flash_dev_make_request(struct request_queue *q, struct bio *bio);

extern struct kmem_cache *bch_search_cache;

Expand Down
10 changes: 6 additions & 4 deletions drivers/md/bcache/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ static void bcache_device_free(struct bcache_device *d)
}

static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
sector_t sectors)
sector_t sectors, make_request_fn make_request_fn)
{
struct request_queue *q;
const size_t max_stripes = min_t(size_t, INT_MAX,
Expand Down Expand Up @@ -870,7 +870,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
if (!q)
return -ENOMEM;

blk_queue_make_request(q, NULL);
blk_queue_make_request(q, make_request_fn);
d->disk->queue = q;
q->queuedata = d;
q->backing_dev_info->congested_data = d;
Expand Down Expand Up @@ -1339,7 +1339,8 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
q->limits.raid_partial_stripes_expensive;

ret = bcache_device_init(&dc->disk, block_size,
dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
dc->bdev->bd_part->nr_sects - dc->sb.data_offset,
cached_dev_make_request);
if (ret)
return ret;

Expand Down Expand Up @@ -1451,7 +1452,8 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)

kobject_init(&d->kobj, &bch_flash_dev_ktype);

if (bcache_device_init(d, block_bytes(c), u->sectors))
if (bcache_device_init(d, block_bytes(c), u->sectors,
flash_dev_make_request))
goto err;

bcache_device_attach(d, c, u - c->uuids);
Expand Down

0 comments on commit ff27668

Please sign in to comment.