move all struct request releated code out of blk-core.c (rebased)
Hi Jens,
this series (against the for-5.16/passthrough-flag branch) removes the remaining struct request related code from blk-core.c and cleans up a few related bits around that.
Diffstat:
b/block/Makefile | 2 b/block/blk-core.c | 341 -------------------------- b/block/blk-mq.c | 573 ++++++++++++++++++++++++++++++++++++-------- b/block/blk-mq.h | 3 b/block/blk.h | 33 -- b/drivers/mtd/mtd_blkdevs.c | 10 b/drivers/mtd/ubi/block.c | 6 b/drivers/scsi/scsi_lib.c | 42 +++ b/include/linux/blk-mq.h | 13 block/blk-exec.c | 116 -------- 10 files changed, 552 insertions(+), 587 deletions(-)
PATCH 1/11 block: move blk_rq_err_bytes to scsi
blk_rq_err_bytes is only used by the scsi midlayer, so move it there.
--- block/blk-core.c | 41 ---------------------------------------- drivers/scsi/scsi_lib.c | 42 ++++++++++++++++++++++++++++++++++++++++- include/linux/blk-mq.h | 3 --- 3 files changed, 41 insertions(+), 45 deletions(-)
block/blk-core.c +0 -41
@@ -1173,47 +1173,6 @@ blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request * }EXPORT_SYMBOL_GPL (blk_insert_cloned_request); -/** -* blk_rq_err_bytes - determine number of bytes till the next failure boundary -* @rq: request to examine -* -* Description: -* A request could be merge of IOs which require different failure -* handling. This function determines the number of bytes which -* can be failed from the beginning of the request without -* crossing into area which need to be retried further. -* -* Return: -* The number of bytes to fail. -*/ -unsigned int blk_rq_err_bytes (const struct request *rq) -{ -unsigned int ff = rq->cmd_flags &REQ_FAILFAST_MASK ; -unsigned int bytes =0 ; -struct bio *bio; - -if (!(rq->rq_flags &RQF_MIXED_MERGE )) -return blk_rq_bytes (rq); - -/* -* Currently the only 'mixing' which can happen is between -* different fastfail types. We can safely fail portions -* which have all the failfast bits that the first one has - -* the ones which are at least as eager to fail as the first -* one. -*/ -for (bio = rq->bio; bio; bio = bio->bi_next) { -if ((bio->bi_opf & ff) != ff) -break ; - bytes += bio->bi_iter.bi_size; - } - -/* this could lead to infinite loop */ -BUG_ON (blk_rq_bytes (rq) && !bytes); -return bytes; -} -EXPORT_SYMBOL_GPL (blk_rq_err_bytes); -static void update_io_ticks (struct block_device *part,unsigned long now,bool end) {
drivers/scsi/scsi_lib.c +41 -1
54 lines not on this page · raw message
include/linux/blk-mq.h +0 -3
@@ -947,7 +947,6 @@ struct req_iterator {* blk_rq_pos() : the current sector * blk_rq_bytes() : bytes left in the entire request * blk_rq_cur_bytes() : bytes left in the current segment -* blk_rq_err_bytes() : bytes left till the next error boundary * blk_rq_sectors() : sectors left in the entire request * blk_rq_cur_sectors() : sectors left in the current segment * blk_rq_stats_sectors() : sectors of the entire request used for stats
@@ -971,8 +970,6 @@ static inline int blk_rq_cur_bytes(const struct request *rq)return bio_iovec (rq->bio).bv_len; } -unsigned int blk_rq_err_bytes (const struct request *rq); -static inline unsigned int blk_rq_sectors (const struct request *rq) {return blk_rq_bytes (rq) >>SECTOR_SHIFT ;
Signature · 1 line
2.30.2
PATCH 2/11 block: remove rq_flush_dcache_pages
In reply to Christoph HellwigThis function is trivial, and flush_dcache_page is always defined, so just open code it in the 2.5 callers.
--- block/blk-core.c | 19 ------------------- drivers/mtd/mtd_blkdevs.c | 10 ++++++++-- drivers/mtd/ubi/block.c | 6 +++++- include/linux/blk-mq.h | 10 ---------- 4 files changed, 13 insertions(+), 32 deletions(-)
block/blk-core.c +0 -19
@@ -1297,25 +1297,6 @@ void blk_steal_bios(struct bio_list *list, struct request *rq) }EXPORT_SYMBOL_GPL (blk_steal_bios); -#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE -/** -* rq_flush_dcache_pages - Helper function to flush all pages in a request -* @rq: the request to be flushed -* -* Description: -* Flush all pages in @rq. -*/ -void rq_flush_dcache_pages (struct request *rq) -{ -struct req_iterator iter; -struct bio_vec bvec; - -rq_for_each_segment (bvec, rq, iter) -flush_dcache_page (bvec.bv_page); -} -EXPORT_SYMBOL_GPL (rq_flush_dcache_pages); -#endif -/** * blk_lld_busy - Check if underlying low-level drivers of a device are busy * @q : the queue of the device being checked
drivers/mtd/mtd_blkdevs.c +8 -2
@@ -46,6 +46,8 @@ static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr,struct mtd_blktrans_dev *dev, struct request *req) { + struct req_iterator iter; +struct bio_vec bvec;unsigned long block, nsect;char *buf;
@@ -76,13 +78,17 @@ static blk_status_t do_blktrans_request(struct mtd_blktrans_ops *tr, } }kunmap (bio_page (req->bio)); -rq_flush_dcache_pages (req); + +rq_for_each_segment (bvec, req, iter) +flush_dcache_page (bvec.bv_page);return BLK_STS_OK ;case REQ_OP_WRITE :if (!tr->writesect)return BLK_STS_IOERR ; -rq_flush_dcache_pages (req); +rq_for_each_segment (bvec, req, iter) +flush_dcache_page (bvec.bv_page); + buf =kmap (bio_page (req->bio)) +bio_offset (req->bio);for (; nsect >0 ; nsect--, block++, buf += tr->blksize) {if (tr->writesect (dev, block, buf)) {
drivers/mtd/ubi/block.c +5 -1
@@ -294,6 +294,8 @@ static void ubiblock_do_work(struct work_struct *work)int ret; struct ubiblock_pdu *pdu = container_of(work, struct ubiblock_pdu, work);struct request *req =blk_mq_rq_from_pdu (pdu); +struct req_iterator iter; +struct bio_vec bvec;blk_mq_start_request (req);
@@ -305,7 +307,9 @@ static void ubiblock_do_work(struct work_struct *work)blk_rq_map_sg (req->q, req, pdu->usgl.sg); ret =ubiblock_read (pdu); -rq_flush_dcache_pages (req); + +rq_for_each_segment (bvec, req, iter) +flush_dcache_page (bvec.bv_page);blk_mq_end_request (req,errno_to_blk_status (ret)); }
include/linux/blk-mq.h +0 -10
@@ -1132,14 +1132,4 @@ static inline bool blk_req_can_dispatch_to_zone(struct request *rq) }#endif /* CONFIG_BLK_DEV_ZONED */ -#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE -# error "You should define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE for your platform" -#endif -#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE -void rq_flush_dcache_pages (struct request *rq); -#else -static inline void rq_flush_dcache_pages (struct request *rq) -{ -} -#endif /* ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE */ #endif /* BLK_MQ_H */
Signature · 1 line
2.30.2
PATCH 3/11 block: remove blk-exec.c
In reply to Christoph HellwigAll this code is tightly coupled to the blk-mq core, so move it there.
--- block/Makefile | 2 +- block/blk-exec.c | 116 ----------------------------------------------- block/blk-mq.c | 107 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 117 deletions(-) delete mode 100644 block/blk-exec.c
block/Makefile +1 -1
@@ -5,7 +5,7 @@ obj-y := bdev.o fops.o bio.o elevator.o blk-core.o blk-sysfs.o \ blk-flush.o blk-settings.o blk-ioc.o blk-map.o \ - blk-exec.o blk-merge.o blk-timeout.o \ + blk-merge.o blk-timeout.o \ blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \ blk-mq-sysfs.o blk-mq-cpumap.o blk-mq-sched.o ioctl.o \ genhd.o ioprio.o badblocks.o partitions/ blk-rq-qos.o \
block/blk-exec.c deleted +0 -116
116 lines not on this page · raw message
block/blk-mq.c +107 -0
119 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 4/11 blk-mq: move blk_mq_flush_plug_list
In reply to Christoph HellwigMove blk_mq_flush_plug_list and blk_mq_plug_issue_direct down in blk-mq.c to prepare for marking blk_mq_request_issue_directly static without the need of a forward declaration.
--- block/blk-mq.c | 184 ++++++++++++++++++++++++------------------------- 1 file changed, 92 insertions(+), 92 deletions(-)
block/blk-mq.c +92 -92
@@ -2308,98 +2308,6 @@ static void blk_mq_commit_rqs(struct blk_mq_hw_ctx *hctx, int *queued, *queued =0 ; } -static void blk_mq_plug_issue_direct (struct blk_plug *plug,bool from_schedule) -{ -struct blk_mq_hw_ctx *hctx =NULL ; -struct request *rq; -int queued =0 ; -int errors =0 ; - -while ((rq =rq_list_pop (&plug->mq_list))) { -bool last =rq_list_empty (plug->mq_list); -blk_status_t ret; - -if (hctx != rq->mq_hctx) { -if (hctx) -blk_mq_commit_rqs (hctx, &queued, from_schedule); - hctx = rq->mq_hctx; - } - - ret =blk_mq_request_issue_directly (rq, last); -switch (ret) { -case BLK_STS_OK : - queued++; -break ; -case BLK_STS_RESOURCE : -case BLK_STS_DEV_RESOURCE : -blk_mq_request_bypass_insert (rq, false, last); -blk_mq_commit_rqs (hctx, &queued, from_schedule); -return ; -default : -blk_mq_end_request (rq, ret); - errors++; -break ; - } - } - -/* -* If we didn't flush the entire list, we could have told the driver -* there was more coming, but that turned out to be a lie. -*/ -if (errors) -blk_mq_commit_rqs (hctx, &queued, from_schedule); -} - -void blk_mq_flush_plug_list (struct blk_plug *plug,bool from_schedule) -{ -struct blk_mq_hw_ctx *this_hctx; -struct blk_mq_ctx *this_ctx; -unsigned int depth; -LIST_HEAD (list); - -if (rq_list_empty (plug->mq_list)) -return ; - plug->rq_count =0 ; - -if (!plug->multiple_queues && !plug->has_elevator && !from_schedule) { -blk_mq_plug_issue_direct (plug, false); -if (rq_list_empty (plug->mq_list)) -return ; - } - - this_hctx =NULL ; - this_ctx =NULL ; - depth =0 ; -do { -struct request *rq; - - rq =rq_list_pop (&plug->mq_list); - -if (!this_hctx) { - this_hctx = rq->mq_hctx; - this_ctx = rq->mq_ctx; - }else if (this_hctx != rq->mq_hctx || this_ctx != rq->mq_ctx) { -trace_block_unplug (this_hctx->queue, depth, - !from_schedule); -blk_mq_sched_insert_requests (this_hctx, this_ctx, - &list, from_schedule); - depth =0 ; - this_hctx = rq->mq_hctx; - this_ctx = rq->mq_ctx; - - } - -list_add (&rq->queuelist, &list); - depth++; - }while (!rq_list_empty (plug->mq_list)); - -if (!list_empty (&list)) { -trace_block_unplug (this_hctx->queue, depth, !from_schedule); -blk_mq_sched_insert_requests (this_hctx, this_ctx, &list, - from_schedule); - } -} -static void blk_mq_bio_to_request (struct request *rq,struct bio *bio,unsigned int nr_segs) {
@@ -2539,6 +2447,98 @@ blk_status_t blk_mq_request_issue_directly(struct request *rq, bool last)return ret; } +static void blk_mq_plug_issue_direct (struct blk_plug *plug,bool from_schedule) +{ +struct blk_mq_hw_ctx *hctx =NULL ; +struct request *rq; +int queued =0 ; +int errors =0 ; + +while ((rq =rq_list_pop (&plug->mq_list))) { +bool last =rq_list_empty (plug->mq_list); +blk_status_t ret; + +if (hctx != rq->mq_hctx) { +if (hctx) +blk_mq_commit_rqs (hctx, &queued, from_schedule); + hctx = rq->mq_hctx; + } + + ret =blk_mq_request_issue_directly (rq, last); +switch (ret) { +case BLK_STS_OK : + queued++; +break ; +case BLK_STS_RESOURCE : +case BLK_STS_DEV_RESOURCE : +blk_mq_request_bypass_insert (rq, false, last); +blk_mq_commit_rqs (hctx, &queued, from_schedule); +return ; +default : +blk_mq_end_request (rq, ret); + errors++; +break ; + } + } + +/* +* If we didn't flush the entire list, we could have told the driver +* there was more coming, but that turned out to be a lie. +*/ +if (errors) +blk_mq_commit_rqs (hctx, &queued, from_schedule); +} + +void blk_mq_flush_plug_list (struct blk_plug *plug,bool from_schedule) +{ +struct blk_mq_hw_ctx *this_hctx; +struct blk_mq_ctx *this_ctx; +unsigned int depth; +LIST_HEAD (list); + +if (rq_list_empty (plug->mq_list)) +return ; + plug->rq_count =0 ; + +if (!plug->multiple_queues && !plug->has_elevator && !from_schedule) { +blk_mq_plug_issue_direct (plug, false); +if (rq_list_empty (plug->mq_list)) +return ; + } + + this_hctx =NULL ; + this_ctx =NULL ; + depth =0 ; +do { +struct request *rq; + + rq =rq_list_pop (&plug->mq_list); + +if (!this_hctx) { + this_hctx = rq->mq_hctx; + this_ctx = rq->mq_ctx; + }else if (this_hctx != rq->mq_hctx || this_ctx != rq->mq_ctx) { +trace_block_unplug (this_hctx->queue, depth, + !from_schedule); +blk_mq_sched_insert_requests (this_hctx, this_ctx, + &list, from_schedule); + depth =0 ; + this_hctx = rq->mq_hctx; + this_ctx = rq->mq_ctx; + + } + +list_add (&rq->queuelist, &list); + depth++; + }while (!rq_list_empty (plug->mq_list)); + +if (!list_empty (&list)) { +trace_block_unplug (this_hctx->queue, depth, !from_schedule); +blk_mq_sched_insert_requests (this_hctx, this_ctx, &list, + from_schedule); + } +} +void blk_mq_try_issue_list_directly (struct blk_mq_hw_ctx *hctx,struct list_head *list) {
Signature · 1 line
2.30.2
PATCH 5/11 block: move request based cloning helpers to blk-mq.c
In reply to Christoph HellwigKeep all the request based code together.
--- block/blk-core.c | 184 +---------------------------------------------- block/blk-mq.c | 175 +++++++++++++++++++++++++++++++++++++++++++- block/blk-mq.h | 3 - block/blk.h | 10 +++ 4 files changed, 185 insertions(+), 187 deletions(-)
block/blk-core.c +1 -183
@@ -592,7 +592,7 @@ static int __init setup_fail_make_request(char *str) }__setup ("fail_make_request=" , setup_fail_make_request); -static bool should_fail_request (struct block_device *part,unsigned int bytes) +bool should_fail_request (struct block_device *part,unsigned int bytes) {return part->bd_make_it_fail &&should_fail (&fail_make_request, bytes); }
@@ -606,15 +606,6 @@ static int __init fail_make_request_debugfs(void) }late_initcall (fail_make_request_debugfs); - -#else /* CONFIG_FAIL_MAKE_REQUEST */ - -static inline bool should_fail_request (struct block_device *part, -unsigned int bytes) -{ -return false; -} -#endif /* CONFIG_FAIL_MAKE_REQUEST */ static inline bool bio_check_ro (struct bio *bio)
@@ -1087,92 +1078,6 @@ int iocb_bio_iopoll(struct kiocb *kiocb, struct io_comp_batch *iob, }EXPORT_SYMBOL_GPL (iocb_bio_iopoll); -/** -* blk_cloned_rq_check_limits - Helper function to check a cloned request -* for the new queue limits -* @q: the queue -* @rq: the request being checked -* -* Description: -* @rq may have been made based on weaker limitations of upper-level queues -* in request stacking drivers, and it may violate the limitation of @q. -* Since the block layer and the underlying device driver trust @rq -* after it is inserted to @q, it should be checked against @q before -* the insertion using this generic function. -* -* Request stacking drivers like request-based dm may change the queue -* limits when retrying requests on other queues. Those requests need -* to be checked against the new queue limits again during dispatch. -*/ -static blk_status_t blk_cloned_rq_check_limits (struct request_queue *q, -struct request *rq) -{ -unsigned int max_sectors =blk_queue_get_max_sectors (q,req_op (rq)); - -if (blk_rq_sectors (rq) > max_sectors) { -/* -* SCSI device does not have a good way to return if -* Write Same/Zero is actually supported. If a device rejects -* a non-read/write command (discard, write same,etc.) the -* low-level device driver will set the relevant queue limit to -* 0 to prevent blk-lib from issuing more of the offending -* operations. Commands queued prior to the queue limit being -* reset need to be completed with BLK_STS_NOTSUPP to avoid I/O -* errors being propagated to upper layers. -*/ -if (max_sectors ==0 ) -return BLK_STS_NOTSUPP ; - -printk (KERN_ERR "%s: over max size limit. (%u > %u)\n" , - __func__,blk_rq_sectors (rq), max_sectors); -return BLK_STS_IOERR ; - } - -/* -* The queue settings related to segment counting may differ from the -* original queue. -*/ - rq->nr_phys_segments =blk_recalc_rq_segments (rq); -if (rq->nr_phys_segments >queue_max_segments (q)) { -printk (KERN_ERR "%s: over max segments limit. (%hu > %hu)\n" , - __func__, rq->nr_phys_segments,queue_max_segments (q)); -return BLK_STS_IOERR ; - } - -return BLK_STS_OK ; -} - -/** -* blk_insert_cloned_request - Helper for stacking drivers to submit a request -* @q: the queue to submit the request -* @rq: the request being queued -*/ -blk_status_t blk_insert_cloned_request (struct request_queue *q,struct request *rq) -{ -blk_status_t ret; - - ret =blk_cloned_rq_check_limits (q, rq); -if (ret !=BLK_STS_OK ) -return ret; - -if (rq->rq_disk && -should_fail_request (rq->rq_disk->part0,blk_rq_bytes (rq))) -return BLK_STS_IOERR ; - -if (blk_crypto_insert_cloned_request (rq)) -return BLK_STS_IOERR ; - -blk_account_io_start (rq); - -/* -* Since we have a scheduler attached on the top device, -* bypass a potential scheduler on the bottom device for -* insert. -*/ -return blk_mq_request_issue_directly (rq, true); -} -EXPORT_SYMBOL_GPL (blk_insert_cloned_request); -static void update_io_ticks (struct block_device *part,unsigned long now,bool end) {
@@ -1325,93 +1230,6 @@ int blk_lld_busy(struct request_queue *q) }EXPORT_SYMBOL_GPL (blk_lld_busy); -/** -* blk_rq_unprep_clone - Helper function to free all bios in a cloned request -* @rq: the clone request to be cleaned up -* -* Description: -* Free all bios in @rq for a cloned request. -*/ -void blk_rq_unprep_clone (struct request *rq) -{ -struct bio *bio; - -while ((bio = rq->bio) !=NULL ) { - rq->bio = bio->bi_next; - -bio_put (bio); - } -} -EXPORT_SYMBOL_GPL (blk_rq_unprep_clone); - -/** -* blk_rq_prep_clone - Helper function to setup clone request -* @rq: the request to be setup -* @rq_src: original request to be cloned -* @bs: bio_set that bios for clone are allocated from -* @gfp_mask: memory allocation mask for bio -* @bio_ctr: setup function to be called for each clone bio. -* Returns %0 for success, non %0 for failure. -* @data: private data to be passed to @bio_ctr -* -* Description: -* Clones bios in @rq_src to @rq, and copies attributes of @rq_src to @rq. -* Also, pages which the original bios are pointing to are not copied -* and the cloned bios just point same pages. -* So cloned bios must be completed before original bios, which means -* the caller must complete @rq before @rq_src. -*/ -int blk_rq_prep_clone (struct request *rq,struct request *rq_src, -struct bio_set *bs,gfp_t gfp_mask, -int (*bio_ctr)(struct bio *,struct bio *,void *), -void *data) -{ -struct bio *bio, *bio_src; - -if (!bs) - bs = &fs_bio_set; - -__rq_for_each_bio (bio_src, rq_src) { - bio =bio_clone_fast (bio_src, gfp_mask, bs); -if (!bio) - goto free_and_out; - -if (bio_ctr &&bio_ctr (bio, bio_src, data)) - goto free_and_out; - -if (rq->bio) { - rq->biotail->bi_next = bio; - rq->biotail = bio; - }else { - rq->bio = rq->biotail = bio; - } - bio =NULL ; - } - -/* Copy attributes of the original request to the clone request. */ - rq->__sector =blk_rq_pos (rq_src); - rq->__data_len =blk_rq_bytes (rq_src); -if (rq_src->rq_flags &RQF_SPECIAL_PAYLOAD ) { - rq->rq_flags |=RQF_SPECIAL_PAYLOAD ; - rq->special_vec = rq_src->special_vec; - } - rq->nr_phys_segments = rq_src->nr_phys_segments; - rq->ioprio = rq_src->ioprio; - -if (rq->bio &&blk_crypto_rq_bio_prep (rq, rq->bio, gfp_mask) <0 ) - goto free_and_out; - -return 0 ; - -free_and_out: -if (bio) -bio_put (bio); -blk_rq_unprep_clone (rq); - -return -ENOMEM ; -} -EXPORT_SYMBOL_GPL (blk_rq_prep_clone); -int kblockd_schedule_work (struct work_struct *work) {return queue_work (kblockd_workqueue, work);
block/blk-mq.c +174 -1
187 lines not on this page · raw message
block/blk-mq.h +0 -3
@@ -65,9 +65,6 @@ void blk_mq_request_bypass_insert(struct request *rq, bool at_head, bool run_queue);void blk_mq_insert_requests (struct blk_mq_hw_ctx *hctx,struct blk_mq_ctx *ctx,struct list_head *list); - -/* Used by blk_insert_cloned_request() to issue request directly */ -blk_status_t blk_mq_request_issue_directly (struct request *rq,bool last);void blk_mq_try_issue_list_directly (struct blk_mq_hw_ctx *hctx,struct list_head *list);
block/blk.h +10 -0
@@ -493,4 +493,14 @@ int disk_register_independent_access_ranges(struct gendisk *disk, struct blk_independent_access_ranges *new_iars);void disk_unregister_independent_access_ranges (struct gendisk *disk); +#ifdef CONFIG_FAIL_MAKE_REQUEST +bool should_fail_request (struct block_device *part,unsigned int bytes); +#else /* CONFIG_FAIL_MAKE_REQUEST */ +static inline bool should_fail_request (struct block_device *part, +unsigned int bytes) +{ +return false; +} +#endif /* CONFIG_FAIL_MAKE_REQUEST */ +#endif /* BLK_INTERNAL_H */
Signature · 1 line
2.30.2
PATCH 6/11 block: move blk_rq_init to blk-mq.c
In reply to Christoph Hellwigblk_rq_init deals with a request structure, so move it to blk-mq.c
--- block/blk-core.c | 17 ----------------- block/blk-mq.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-)
block/blk-core.c +0 -17
@@ -109,23 +109,6 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q) }EXPORT_SYMBOL_GPL (blk_queue_flag_test_and_set); -void blk_rq_init (struct request_queue *q,struct request *rq) -{ -memset (rq,0 ,sizeof (*rq)); - -INIT_LIST_HEAD (&rq->queuelist); - rq->q = q; - rq->__sector = (sector_t) -1 ; -INIT_HLIST_NODE (&rq->hash); -RB_CLEAR_NODE (&rq->rb_node); - rq->tag =BLK_MQ_NO_TAG ; - rq->internal_tag =BLK_MQ_NO_TAG ; - rq->start_time_ns =ktime_get_ns (); - rq->part =NULL ; -blk_crypto_rq_set_defaults (rq); -} -EXPORT_SYMBOL (blk_rq_init); -#define REQ_OP_NAME (name) [REQ_OP_##name] = #namestatic const char *const blk_op_name[] = {REQ_OP_NAME (READ ),
block/blk-mq.c +17 -0
@@ -328,6 +328,23 @@ void blk_mq_wake_waiters(struct request_queue *q)blk_mq_tag_wakeup_all (hctx->tags, true); } +void blk_rq_init (struct request_queue *q,struct request *rq) +{ +memset (rq,0 ,sizeof (*rq)); + +INIT_LIST_HEAD (&rq->queuelist); + rq->q = q; + rq->__sector = (sector_t) -1 ; +INIT_HLIST_NODE (&rq->hash); +RB_CLEAR_NODE (&rq->rb_node); + rq->tag =BLK_MQ_NO_TAG ; + rq->internal_tag =BLK_MQ_NO_TAG ; + rq->start_time_ns =ktime_get_ns (); + rq->part =NULL ; +blk_crypto_rq_set_defaults (rq); +} +EXPORT_SYMBOL (blk_rq_init); +static struct request *blk_mq_rq_ctx_init (struct blk_mq_alloc_data *data,struct blk_mq_tags *tags,unsigned int tag,u64 alloc_time_ns) {
Signature · 1 line
2.30.2
PATCH 7/11 block: move blk_steal_bios to blk-mq.c
In reply to Christoph HellwigKeep all the request based code together.
--- block/blk-core.c | 21 --------------------- block/blk-mq.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-)
block/blk-core.c +0 -21
@@ -1164,27 +1164,6 @@ void disk_end_io_acct(struct gendisk *disk, unsigned int op, }EXPORT_SYMBOL (disk_end_io_acct); -/* -* Steal bios from a request and add them to a bio list. -* The request must not have been partially completed before. -*/ -void blk_steal_bios (struct bio_list *list,struct request *rq) -{ -if (rq->bio) { -if (list->tail) - list->tail->bi_next = rq->bio; -else - list->head = rq->bio; - list->tail = rq->biotail; - - rq->bio =NULL ; - rq->biotail =NULL ; - } - - rq->__data_len =0 ; -} -EXPORT_SYMBOL_GPL (blk_steal_bios); -/** * blk_lld_busy - Check if underlying low-level drivers of a device are busy * @q : the queue of the device being checked
block/blk-mq.c +21 -0
@@ -3011,6 +3011,27 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src, }EXPORT_SYMBOL_GPL (blk_rq_prep_clone); +/* +* Steal bios from a request and add them to a bio list. +* The request must not have been partially completed before. +*/ +void blk_steal_bios (struct bio_list *list,struct request *rq) +{ +if (rq->bio) { +if (list->tail) + list->tail->bi_next = rq->bio; +else + list->head = rq->bio; + list->tail = rq->biotail; + + rq->bio =NULL ; + rq->biotail =NULL ; + } + + rq->__data_len =0 ; +} +EXPORT_SYMBOL_GPL (blk_steal_bios); +static size_t order_to_size (unsigned int order) {return (size_t )PAGE_SIZE << order;
Signature · 1 line
2.30.2
PATCH 8/11 block: move blk_account_io_{start,done} to blk-mq.c
In reply to Christoph HellwigThese are only used for request based I/O, so move them where they are used.
--- block/blk-core.c | 27 +-------------------------- block/blk-mq.c | 42 ++++++++++++++++++++++++++++++++++++++++++ block/blk.h | 21 +-------------------- 3 files changed, 44 insertions(+), 46 deletions(-)
block/blk-core.c +1 -26
@@ -1061,8 +1061,7 @@ int iocb_bio_iopoll(struct kiocb *kiocb, struct io_comp_batch *iob, }EXPORT_SYMBOL_GPL (iocb_bio_iopoll); -static void update_io_ticks (struct block_device *part,unsigned long now, -bool end) +void update_io_ticks (struct block_device *part,unsigned long now,bool end) {unsigned long stamp; again:
@@ -1077,30 +1076,6 @@ static void update_io_ticks(struct block_device *part, unsigned long now, } } -void __blk_account_io_done (struct request *req,u64 now) -{ -const int sgrp =op_stat_group (req_op (req)); - -part_stat_lock (); -update_io_ticks (req->part, jiffies, true); -part_stat_inc (req->part, ios[sgrp]); -part_stat_add (req->part, nsecs[sgrp], now - req->start_time_ns); -part_stat_unlock (); -} - -void __blk_account_io_start (struct request *rq) -{ -/* passthrough requests can hold bios that do not have ->bi_bdev set */ -if (rq->bio && rq->bio->bi_bdev) - rq->part = rq->bio->bi_bdev; -else - rq->part = rq->rq_disk->part0; - -part_stat_lock (); -update_io_ticks (rq->part, jiffies, false); -part_stat_unlock (); -} -static unsigned long __part_start_io_acct (struct block_device *part,unsigned int sectors,unsigned int op) {
block/blk-mq.c +42 -0
48 lines not on this page · raw message
block/blk.h +1 -20
@@ -257,9 +257,6 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,bool blk_bio_list_merge (struct request_queue *q,struct list_head *list,struct bio *bio,unsigned int nr_segs); -void __blk_account_io_start (struct request *req); -void __blk_account_io_done (struct request *req,u64 now); -/* * Plug flush limits */
@@ -350,23 +347,7 @@ static inline bool blk_do_io_stat(struct request *rq)return (rq->rq_flags &RQF_IO_STAT ) && rq->rq_disk; } -static inline void blk_account_io_done (struct request *req,u64 now) -{ -/* -* Account IO completion. flush_rq isn't accounted as a -* normal IO on queueing nor completion. Accounting the -* containing request is enough. -*/ -if (blk_do_io_stat (req) && req->part && - !(req->rq_flags &RQF_FLUSH_SEQ )) -__blk_account_io_done (req, now); -} - -static inline void blk_account_io_start (struct request *req) -{ -if (blk_do_io_stat (req)) -__blk_account_io_start (req); -} +void update_io_ticks (struct block_device *part,unsigned long now,bool end);static inline void req_set_nomerge (struct request_queue *q,struct request *req) {
Signature · 1 line
2.30.2
PATCH 9/11 block: move blk_dump_rq_flags to blk-mq.c
In reply to Christoph Hellwigblk_dump_rq_flags deals with a request, so move it to blk-mq.c.
--- block/blk-core.c | 14 -------------- block/blk-mq.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-)
block/blk-core.c +0 -14
@@ -217,20 +217,6 @@ void blk_print_req_error(struct request *req, blk_status_t status) IOPRIO_PRIO_CLASS(req->ioprio)); } -void blk_dump_rq_flags (struct request *rq,char *msg) -{ -printk (KERN_INFO "%s: dev %s: flags=%llx\n" , msg, - rq->rq_disk ? rq->rq_disk->disk_name :"?" , - (unsigned long long ) rq->cmd_flags); - -printk (KERN_INFO " sector %llu, nr/cnr %u/%u\n" , - (unsigned long long )blk_rq_pos (rq), -blk_rq_sectors (rq),blk_rq_cur_sectors (rq)); -printk (KERN_INFO " bio %p, biotail %p, len %u\n" , - rq->bio, rq->biotail,blk_rq_bytes (rq)); -} -EXPORT_SYMBOL (blk_dump_rq_flags); -/** * blk_sync_queue - cancel any pending callbacks on a queue * @q: the queue
block/blk-mq.c +14 -0
@@ -667,6 +667,20 @@ void blk_mq_free_plug_rqs(struct blk_plug *plug)blk_mq_free_request (rq); } +void blk_dump_rq_flags (struct request *rq,char *msg) +{ +printk (KERN_INFO "%s: dev %s: flags=%llx\n" , msg, + rq->rq_disk ? rq->rq_disk->disk_name :"?" , + (unsigned long long ) rq->cmd_flags); + +printk (KERN_INFO " sector %llu, nr/cnr %u/%u\n" , + (unsigned long long )blk_rq_pos (rq), +blk_rq_sectors (rq),blk_rq_cur_sectors (rq)); +printk (KERN_INFO " bio %p, biotail %p, len %u\n" , + rq->bio, rq->biotail,blk_rq_bytes (rq)); +} +EXPORT_SYMBOL (blk_dump_rq_flags); +static void req_bio_endio (struct request *rq,struct bio *bio,unsigned int nbytes,blk_status_t error) {
Signature · 1 line
2.30.2
PATCH 10/11 block: move blk_print_req_error to blk-mq.c
In reply to Christoph HellwigThis function is only used by the request completion path. Factor out a blk_status_to_str to keep blk_errors private in blk-core.c.
--- block/blk-core.c | 15 +++------------ block/blk-mq.c | 13 +++++++++++++ block/blk.h | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-)
block/blk-core.c +3 -12
@@ -199,22 +199,13 @@ int blk_status_to_errno(blk_status_t status) }EXPORT_SYMBOL_GPL (blk_status_to_errno); -void blk_print_req_error (struct request *req,blk_status_t status) +const char *blk_status_to_str (blk_status_t status) {int idx = (__force int )status;if (WARN_ON_ONCE (idx >=ARRAY_SIZE (blk_errors))) -return ; - -printk_ratelimited (KERN_ERR -"%s error, dev %s, sector %llu op 0x%x:(%s) flags 0x%x " -"phys_seg %u prio class %u\n" , - blk_errors[idx].name, - req->rq_disk ? req->rq_disk->disk_name :"?" , -blk_rq_pos (req),req_op (req),blk_op_str (req_op (req)), - req->cmd_flags & ~REQ_OP_MASK , - req->nr_phys_segments, -IOPRIO_PRIO_CLASS (req->ioprio)); +return "<null>" ; +return blk_errors[idx].name; }/**
block/blk-mq.c +13 -0
@@ -717,6 +717,19 @@ static void blk_account_io_completion(struct request *req, unsigned int bytes) } } +static void blk_print_req_error (struct request *req,blk_status_t status) +{ +printk_ratelimited (KERN_ERR +"%s error, dev %s, sector %llu op 0x%x:(%s) flags 0x%x " +"phys_seg %u prio class %u\n" , +blk_status_to_str (status), + req->rq_disk ? req->rq_disk->disk_name :"?" , +blk_rq_pos (req),req_op (req),blk_op_str (req_op (req)), + req->cmd_flags & ~REQ_OP_MASK , + req->nr_phys_segments, +IOPRIO_PRIO_CLASS (req->ioprio)); +} +/** * blk_update_request - Complete multiple bytes without completing the request * @req: the request being processed
block/blk.h +1 -1
@@ -250,7 +250,7 @@ static inline void blk_integrity_del(struct gendisk *disk)unsigned long blk_rq_timeout (unsigned long timeout);void blk_add_timer (struct request *req); -void blk_print_req_error (struct request *req,blk_status_t status); +const char *blk_status_to_str (blk_status_t status);bool blk_attempt_plug_merge (struct request_queue *q,struct bio *bio,unsigned int nr_segs,bool *same_queue_rq);
Signature · 1 line
2.30.2
Re: [PATCH 10/11] block: move blk_print_req_error to blk-mq.c
Quoted 6 lines · Christoph Hellwig
This function is only used by the request completion path. Factor out a
blk_status_to_strto keepblk_errorsprivate inblk-core.c.Signed-off-by Christoph Hellwig <[email protected]>---
for the whole series:-
PATCH 11/11 block: don't include blk-mq headers in blk-core.c
In reply to Christoph HellwigAll request based code is in the blk-mq files now.
--- block/blk-core.c | 3 --- 1 file changed, 3 deletions(-)
block/blk-core.c +0 -3
@@ -16,7 +16,6 @@#include <linux/module.h> #include <linux/bio.h> #include <linux/blkdev.h> -#include <linux/blk-mq.h> #include <linux/blk-pm.h> #include <linux/blk-integrity.h> #include <linux/highmem.h>
@@ -47,8 +46,6 @@#include <trace/events/block.h> #include "blk.h" -#include "blk-mq.h" -#include "blk-mq-sched.h" #include "blk-pm.h" #include "blk-throttle.h"
Signature · 1 line
2.30.2
Johannes Thumshirn
Reviewed-byQuoted 7 lines · Christoph Hellwig
Hi Jens,
this series (against the for-5.16/passthrough-flag branch) removes the remaining struct request related code from
blk-core.cand cleans up a few related bits around that.Diffstat:
Quoted 12 lines
b/block/Makefile | 2 b/block/blk-core.c | 341 -------------------------- b/block/blk-mq.c | 573 ++++++++++++++++++++++++++++++++++++-------- b/block/blk-mq.h | 3 b/block/blk.h | 33 -- b/drivers/mtd/mtd_blkdevs.c | 10 b/drivers/mtd/ubi/block.c | 6 b/drivers/scsi/scsi_lib.c | 42 +++ b/include/linux/blk-mq.h | 13 block/blk-exec.c | 116 -------- 10 files changed, 552 insertions(+), 587 deletions(-)
Looks good, for the whole series:
Quoted 17 lines · Christoph Hellwig
this series (against the for-5.16/passthrough-flag branch) removes the remaining struct request related code from
blk-core.cand cleans up a few related bits around that.Diffstat:
b/block/Makefile | 2 b/block/blk-core.c | 341 -------------------------- b/block/blk-mq.c | 573 ++++++++++++++++++++++++++++++++++++-------- b/block/blk-mq.h | 3 b/block/blk.h | 33 -- b/drivers/mtd/mtd_blkdevs.c | 10 b/drivers/mtd/ubi/block.c | 6 b/drivers/scsi/scsi_lib.c | 42 +++ b/include/linux/blk-mq.h | 13 block/blk-exec.c | 116 -------- 10 files changed, 552 insertions(+), 587 deletions(-)
Quoted 1 line
[...]
Applied, thanks!
[01/11] block: move blk_rq_err_bytes to scsi
commit: 6ace6442a37e17d56a1c54f55bea48ac796f869d
[02/11] block: remove rq_flush_dcache_pages
commit: 01ed1e78789a2e3d7a895ca38706a4fb1a6146d0
[03/11] block: remove blk-exec.c
commit: 9048707b1d8f8aebcf23e5b5b143ad1de2a93b34
[04/11] blk-mq: move blk_mq_flush_plug_list
commit: 33af852518417ed7a90703c572e58cc99bef4770
[05/11] block: move request based cloning helpers to blk-mq.c
commit: 432f3b8863dc44ac224e231dbe1b0038b5aa4239
[06/11] block: move blk_rq_init to blk-mq.c
commit: 8586ee1a36a8f690492a7b7ee8f31c514d65957d
[07/11] block: move blk_steal_bios to blk-mq.c
commit: 4ef40a1dc9ebeaa87cb53f16641d439d4ebcfdd0
[08/11] block: move blk_account_io_{start,done} to blk-mq.c
commit: 1bdc7c540b455837af9d736e5f0abb77cfce3e62
[09/11] block: move blk_dump_rq_flags to blk-mq.c
commit: 8a77648954e63f6654042567e31794bfd5ea02a5
[10/11] block: move blk_print_req_error to blk-mq.c
commit: 065c87d65d74ac24bfc3bbc43de068ba99188b1c
[11/11] block: don't include blk-mq headers in blk-core.c
commit: d94d230a3711ac85af1c3cd484419a4a81193387Best regards,
Signature · 1 line
Jens Axboe