blk-mq: move the DMA mapping code to a separate file
PATCH 1/2 blk-mq: move the DMA mapping code to a separate file
While working on the new DMA API I kept getting annoyed how it was placed right in the middle of the bio splitting code in blk-merge.c. Split it out into a separate file.
--- block/Makefile | 4 +- block/blk-merge.c | 133 --------------------------------------------- block/blk-mq-dma.c | 113 ++++++++++++++++++++++++++++++++++++++ block/blk.h | 21 +++++++ 4 files changed, 136 insertions(+), 135 deletions(-) create mode 100644 block/blk-mq-dma.c
block/Makefile +2 -2
@@ -5,8 +5,8 @@ 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-merge.o blk-timeout.o \ - blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \ + blk-merge.o blk-timeout.o blk-lib.o blk-mq.o \ + blk-mq-tag.o blk-mq-dma.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 \ disk-events.o blk-ia-ranges.o early-lookup.o
block/blk-merge.c +0 -133
151 lines not on this page · raw message
block/blk-mq-dma.c new file +113 -0
113 lines not on this page · raw message
block/blk.h +21 -0
@@ -405,6 +405,27 @@ static inline struct bio *__bio_split_to_limits(struct bio *bio, } } +/** +* get_max_segment_size() - maximum number of bytes to add as a single segment +* @lim: Request queue limits. +* @paddr: address of the range to add +* @len: maximum length available to add at @paddr +* +* Returns the maximum number of bytes of the range starting at @paddr that can +* be added to a single segment. +*/ +static inline unsigned get_max_segment_size (const struct queue_limits *lim, +phys_addr_t paddr,unsigned int len) +{ +/* +* Prevent an overflow if mask = ULONG_MAX and offset = 0 by adding 1 +* after having calculated the minimum. +*/ + return min_t(unsigned long, len, +min (lim->seg_boundary_mask - (lim->seg_boundary_mask & paddr), + (unsigned long )lim->max_segment_size -1 ) +1 ); +} +int ll_back_merge_fn (struct request *req,struct bio *bio,unsigned int nr_segs); bool blk_attempt_req_merge(struct request_queue *q, struct request *rq,
Signature · 1 line
2.47.2
PATCH 2/2 blk-mq: add a copyright notice to blk-mq-dma.c
blk-mq-dma.c was split from blk-merge.c which has no copyright notice, but except for some boilerplate code and comments left from the old version this is all my code, so add my copyright.
--- block/blk-mq-dma.c | 3 +++ 1 file changed, 3 insertions(+)
block/blk-mq-dma.c +3 -0
@@ -1,4 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2025 Christoph Hellwig +*/ #include "blk.h" struct phys_vec {
Signature · 1 line
2.47.2
Any comments? I was trying to get this out of the way before converting the metadata mapping to the iterator.
Jens Axboe
maintainerQuoted 2 lines · Christoph Hellwig
Any comments? I was trying to get this out of the way before converting the metadata mapping to the iterator.
Code shuffle looks fine, the only thing that's a bit odd is moving the code and adding the copy right. But it does look like you touched most of that last, so looks fine. I'll get it applied.
Signature · 1 line
Jens Axboe
Quoted 5 lines · Christoph Hellwig
While working on the new DMA API I kept getting annoyed how it was placed right in the middle of the bio splitting code in
blk-merge.c. Split it out into a separate file.
Applied, thanks!
[1/2] blk-mq: move the DMA mapping code to a separate file
commit: b0a4158554b9017467435069c1b327f35987b495
[2/2] blk-mq: add a copyright notice to blk-mq-dma.c
commit: 496a3bc5e46c6485a50730ffbcbc92fc53120425Best regards,
Signature · 1 line
Jens Axboe