From f542dfe1d69d6dbae8f9f97447747a619eb3cb17 Mon Sep 17 00:00:00 2001 From: via8 Date: Thu, 13 Oct 2022 14:10:33 +0300 Subject: remove mq --- Kbuild | 1 - readme.md | 2 -- sbdd.c | 96 --------------------------------------------------------------- 3 files changed, 99 deletions(-) diff --git a/Kbuild b/Kbuild index 65143ef..260a13a 100644 --- a/Kbuild +++ b/Kbuild @@ -32,7 +32,6 @@ ######## Kbuild ccflags-y := -Wall -# ccflags-y += -DBLK_MQ_MODE # CFLAGS_sbdd.o := -DDEBUG obj-m := sbdd.o diff --git a/readme.md b/readme.md index c3bec58..0b9ca84 100644 --- a/readme.md +++ b/readme.md @@ -4,8 +4,6 @@ Implementation of Linux Kernel 5.4.X simple block device. ## Build - regular: `$ make` -- with blk_mq support: -uncomment `ccflags-y += -DBLK_MQ_MODE` in `Kbuild` - with requests debug info: uncomment `CFLAGS_sbdd.o := -DDEBUG` in `Kbuild` diff --git a/sbdd.c b/sbdd.c index ab2e51d..dc999a6 100644 --- a/sbdd.c +++ b/sbdd.c @@ -19,9 +19,6 @@ #include #include #include -#ifdef BLK_MQ_MODE -#include -#endif #define SBDD_SECTOR_SHIFT 9 #define SBDD_SECTOR_SIZE (1 << SBDD_SECTOR_SHIFT) @@ -37,9 +34,6 @@ struct sbdd { u8 *data; struct gendisk *gd; struct request_queue *q; -#ifdef BLK_MQ_MODE - struct blk_mq_tag_set *tag_set; -#endif }; static struct sbdd __sbdd; @@ -73,52 +67,6 @@ static sector_t sbdd_xfer(struct bio_vec* bvec, sector_t pos, int dir) return len; } -#ifdef BLK_MQ_MODE - -static void sbdd_xfer_rq(struct request *rq) -{ - struct req_iterator iter; - struct bio_vec bvec; - int dir = rq_data_dir(rq); - sector_t pos = blk_rq_pos(rq); - - rq_for_each_segment(bvec, rq, iter) - pos += sbdd_xfer(&bvec, pos, dir); -} - -static blk_status_t sbdd_queue_rq(struct blk_mq_hw_ctx *hctx, - struct blk_mq_queue_data const *bd) -{ - if (atomic_read(&__sbdd.deleting)) - return BLK_STS_IOERR; - - atomic_inc(&__sbdd.refs_cnt); - - blk_mq_start_request(bd->rq); - sbdd_xfer_rq(bd->rq); - blk_mq_end_request(bd->rq, BLK_STS_OK); - - if (atomic_dec_and_test(&__sbdd.refs_cnt)) - wake_up(&__sbdd.exitwait); - - return BLK_STS_OK; -} - -static struct blk_mq_ops const __sbdd_blk_mq_ops = { - /* - The function receives requests for the device as arguments - and can use various functions to process them. The functions - used to process requests in the handler are described below: - - blk_mq_start_request() - must be called before processing a request - blk_mq_requeue_request() - to re-send the request in the queue - blk_mq_end_request() - to end request processing and notify upper layers - */ - .queue_rq = sbdd_queue_rq, -}; - -#else - static void sbdd_xfer_bio(struct bio *bio) { struct bvec_iter iter; @@ -149,8 +97,6 @@ static blk_qc_t sbdd_make_request(struct request_queue *q, struct bio *bio) return BLK_STS_OK; } -#endif /* BLK_MQ_MODE */ - /* There are no read or write operations. These operations are performed by the request() function associated with the request queue of the disk. @@ -187,37 +133,6 @@ static int sbdd_create(void) spin_lock_init(&__sbdd.datalock); init_waitqueue_head(&__sbdd.exitwait); -#ifdef BLK_MQ_MODE - pr_info("allocating tag_set\n"); - __sbdd.tag_set = kzalloc(sizeof(struct blk_mq_tag_set), GFP_KERNEL); - if (!__sbdd.tag_set) { - pr_err("unable to alloc tag_set\n"); - return -ENOMEM; - } - - /* Number of hardware dispatch queues */ - __sbdd.tag_set->nr_hw_queues = 1; - /* Depth of hardware dispatch queues */ - __sbdd.tag_set->queue_depth = 128; - __sbdd.tag_set->numa_node = NUMA_NO_NODE; - __sbdd.tag_set->ops = &__sbdd_blk_mq_ops; - - ret = blk_mq_alloc_tag_set(__sbdd.tag_set); - if (ret) { - pr_err("call blk_mq_alloc_tag_set() failed with %d\n", ret); - return ret; - } - - /* Creates both the hardware and the software queues and initializes structs */ - pr_info("initing queue\n"); - __sbdd.q = blk_mq_init_queue(__sbdd.tag_set); - if (IS_ERR(__sbdd.q)) { - ret = (int)PTR_ERR(__sbdd.q); - pr_err("call blk_mq_init_queue() failed witn %d\n", ret); - __sbdd.q = NULL; - return ret; - } -#else pr_info("allocating queue\n"); __sbdd.q = blk_alloc_queue(GFP_KERNEL); if (!__sbdd.q) { @@ -225,7 +140,6 @@ static int sbdd_create(void) return -EINVAL; } blk_queue_make_request(__sbdd.q, sbdd_make_request); -#endif /* BLK_MQ_MODE */ /* Configure queue */ blk_queue_logical_block_size(__sbdd.q, SBDD_SECTOR_SIZE); @@ -274,16 +188,6 @@ static void sbdd_delete(void) if (__sbdd.gd) put_disk(__sbdd.gd); -#ifdef BLK_MQ_MODE - if (__sbdd.tag_set && __sbdd.tag_set->tags) { - pr_info("freeing tag_set\n"); - blk_mq_free_tag_set(__sbdd.tag_set); - } - - if (__sbdd.tag_set) - kfree(__sbdd.tag_set); -#endif - if (__sbdd.data) { pr_info("freeing data\n"); vfree(__sbdd.data); -- cgit v1.2.3-18-g5258