高级会员
- 积分
- 659
- 金钱
- 659
- 注册时间
- 2014-5-11
- 在线时间
- 87 小时
|
在5.10.61(可能在5.0之后)的内核版本中已经弃用了blk_queue_make_request, blk_init_queue等等函数,导致在调试块驱动无IO调度器的例程时出现编译错误。
刚开始有点懵,查了好多资料也没有具体的一个说明,最终还是在内核中找到相关代码借鉴,要改的地方如下:
/*
* Handler function for all zram I/O requests.
增加
*/
static blk_qc_t ramdisk_submit_bio(struct bio *bio)
{
struct ramdisk_dev *zram = bio->bi_disk->private_data;
ramdisk_make_request_fn(zram->queue, bio);
return BLK_QC_T_NONE;
error:
bio_io_error(bio);
return BLK_QC_T_NONE;
}
/*
* 块设备操作函数
*/
static struct block_device_operations ramdisk_fops =
{
.owner = THIS_MODULE,
.open = ramdisk_open,
.release = ramdisk_release,
.getgeo = ramdisk_getgeo,
.submit_bio = ramdisk_submit_bio, //增加
};
/*
* @description : 初始化队列相关操作
* @set : blk_mq_tag_set对象
* @return : request_queue的地址
*/
static struct request_queue * create_req_queue(struct ramdisk_dev *set)
{
struct request_queue *q;
#if 0
q = blk_alloc_queue(GFP_KERNEL); //(set->numa_node);
if (!q)
return ERR_PTR(-ENOMEM);
blk_queue_make_request(q, ramdisk_make_request_fn);
#else // 修改代码
q = blk_alloc_queue(NUMA_NO_NODE); //(set->numa_node);
if (!q)
return ERR_PTR(-ENOMEM);
/* zram devices sort of resembles non-rotational disks */
blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q);
/*
* To ensure that we always get PAGE_SIZE aligned
* and n*PAGE_SIZED sized I/O requests.
*/
blk_queue_physical_block_size(q, PAGE_SIZE);
blk_queue_logical_block_size(q, (1UL<<12));
blk_queue_io_min(q, PAGE_SIZE);
blk_queue_io_opt(q, PAGE_SIZE);
q->limits.discard_granularity = PAGE_SIZE;
blk_queue_max_discard_sectors(q, UINT_MAX);
blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
/*
* zram_bio_discard() will clear all logical blocks if logical block
* size is identical with physical block size(PAGE_SIZE). But if it is
* different, we will skip discarding some parts of logical blocks in
* the part of the request range which isn't aligned to physical block
* size. So we can't ensure that all discarded logical blocks are
* zeroed.
*/
//if (ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE)
blk_queue_max_write_zeroes_sectors(q, UINT_MAX);
blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, q);
#endif
q->queuedata = set;
return q;
}
|
|