From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
"Md. Haris Iqbal" <haris.iqbal@ionos.com>,
Jack Wang <jinpu.wang@ionos.com>, Coly Li <colyli@kernel.org>,
Kent Overstreet <kent.overstreet@linux.dev>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>, Chris Mason <clm@fb.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
Andreas Gruenbacher <agruenba@redhat.com>,
Carlos Maiolino <cem@kernel.org>,
Damien Le Moal <dlemoal@kernel.org>,
Naohiro Aota <naohiro.aota@wdc.com>,
Johannes Thumshirn <jth@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@kernel.org>,
linux-bcache@vger.kernel.org, dm-devel@lists.linux.dev,
linux-btrfs@vger.kernel.org, gfs2@lists.linux.dev,
linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-pm@vger.kernel.org
Subject: [PATCH 04/17] block: remove the q argument from blk_rq_map_kern
Date: Tue, 22 Apr 2025 16:26:05 +0200 [thread overview]
Message-ID: <20250422142628.1553523-5-hch@lst.de> (raw)
In-Reply-To: <20250422142628.1553523-1-hch@lst.de>
Remove the q argument from blk_rq_map_kern and the internal helpers
called by it as the queue can trivially be derived from the request.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-map.c | 24 ++++++++++--------------
drivers/block/pktcdvd.c | 2 +-
drivers/block/ublk_drv.c | 3 +--
drivers/block/virtio_blk.c | 4 ++--
drivers/nvme/host/core.c | 2 +-
drivers/scsi/scsi_ioctl.c | 2 +-
drivers/scsi/scsi_lib.c | 3 +--
include/linux/blk-mq.h | 4 ++--
8 files changed, 19 insertions(+), 25 deletions(-)
diff --git a/block/blk-map.c b/block/blk-map.c
index d2f22744b3d1..0cbceb2671c9 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -319,7 +319,6 @@ static void bio_map_kern_endio(struct bio *bio)
/**
* bio_map_kern - map kernel address into bio
- * @q: the struct request_queue for the bio
* @data: pointer to buffer to map
* @len: length in bytes
* @gfp_mask: allocation flags for bio allocation
@@ -327,8 +326,7 @@ static void bio_map_kern_endio(struct bio *bio)
* Map the kernel address into a bio suitable for io to a block
* device. Returns an error pointer in case of error.
*/
-static struct bio *bio_map_kern(struct request_queue *q, void *data,
- unsigned int len, gfp_t gfp_mask)
+static struct bio *bio_map_kern(void *data, unsigned int len, gfp_t gfp_mask)
{
unsigned long kaddr = (unsigned long)data;
unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -402,7 +400,6 @@ static void bio_copy_kern_endio_read(struct bio *bio)
/**
* bio_copy_kern - copy kernel address into bio
- * @q: the struct request_queue for the bio
* @data: pointer to buffer to copy
* @len: length in bytes
* @gfp_mask: allocation flags for bio and page allocation
@@ -411,8 +408,8 @@ static void bio_copy_kern_endio_read(struct bio *bio)
* copy the kernel address into a bio suitable for io to a block
* device. Returns an error pointer in case of error.
*/
-static struct bio *bio_copy_kern(struct request_queue *q, void *data,
- unsigned int len, gfp_t gfp_mask, int reading)
+static struct bio *bio_copy_kern(void *data, unsigned int len, gfp_t gfp_mask,
+ int reading)
{
unsigned long kaddr = (unsigned long)data;
unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -689,7 +686,6 @@ EXPORT_SYMBOL(blk_rq_unmap_user);
/**
* blk_rq_map_kern - map kernel data to a request, for passthrough requests
- * @q: request queue where request should be inserted
* @rq: request to fill
* @kbuf: the kernel buffer
* @len: length of user data
@@ -700,24 +696,24 @@ EXPORT_SYMBOL(blk_rq_unmap_user);
* buffer is used. Can be called multiple times to append multiple
* buffers.
*/
-int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
- unsigned int len, gfp_t gfp_mask)
+int blk_rq_map_kern(struct request *rq, void *kbuf, unsigned int len,
+ gfp_t gfp_mask)
{
int reading = rq_data_dir(rq) == READ;
unsigned long addr = (unsigned long) kbuf;
struct bio *bio;
int ret;
- if (len > (queue_max_hw_sectors(q) << 9))
+ if (len > (queue_max_hw_sectors(rq->q) << SECTOR_SHIFT))
return -EINVAL;
if (!len || !kbuf)
return -EINVAL;
- if (!blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf) ||
- blk_queue_may_bounce(q))
- bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
+ if (!blk_rq_aligned(rq->q, addr, len) || object_is_on_stack(kbuf) ||
+ blk_queue_may_bounce(rq->q))
+ bio = bio_copy_kern(kbuf, len, gfp_mask, reading);
else
- bio = bio_map_kern(q, kbuf, len, gfp_mask);
+ bio = bio_map_kern(kbuf, len, gfp_mask);
if (IS_ERR(bio))
return PTR_ERR(bio);
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 65b96c083b3c..d5cc7bd2875c 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -725,7 +725,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
scmd = blk_mq_rq_to_pdu(rq);
if (cgc->buflen) {
- ret = blk_rq_map_kern(q, rq, cgc->buffer, cgc->buflen,
+ ret = blk_rq_map_kern(rq, cgc->buffer, cgc->buflen,
GFP_NOIO);
if (ret)
goto out;
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 03653bd7a1df..0bc77d4634fd 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -363,8 +363,7 @@ static int ublk_report_zones(struct gendisk *disk, sector_t sector,
if (ret)
goto free_req;
- ret = blk_rq_map_kern(disk->queue, req, buffer, buffer_length,
- GFP_KERNEL);
+ ret = blk_rq_map_kern(req, buffer, buffer_length, GFP_KERNEL);
if (ret)
goto erase_desc;
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 7cffea01d868..30bca8cb7106 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -571,7 +571,7 @@ static int virtblk_submit_zone_report(struct virtio_blk *vblk,
vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_ZONE_REPORT);
vbr->out_hdr.sector = cpu_to_virtio64(vblk->vdev, sector);
- err = blk_rq_map_kern(q, req, report_buf, report_len, GFP_KERNEL);
+ err = blk_rq_map_kern(req, report_buf, report_len, GFP_KERNEL);
if (err)
goto out;
@@ -817,7 +817,7 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str)
vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_GET_ID);
vbr->out_hdr.sector = 0;
- err = blk_rq_map_kern(q, req, id_str, VIRTIO_BLK_ID_BYTES, GFP_KERNEL);
+ err = blk_rq_map_kern(req, id_str, VIRTIO_BLK_ID_BYTES, GFP_KERNEL);
if (err)
goto out;
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index eb6ea8acb3cc..34d2abdb2f89 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1157,7 +1157,7 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
req->cmd_flags &= ~REQ_FAILFAST_DRIVER;
if (buffer && bufflen) {
- ret = blk_rq_map_kern(q, req, buffer, bufflen, GFP_KERNEL);
+ ret = blk_rq_map_kern(req, buffer, bufflen, GFP_KERNEL);
if (ret)
goto out;
}
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 2fa45556e1ea..0ddc95bafc71 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -601,7 +601,7 @@ static int sg_scsi_ioctl(struct request_queue *q, bool open_for_write,
}
if (bytes) {
- err = blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO);
+ err = blk_rq_map_kern(rq, buffer, bytes, GFP_NOIO);
if (err)
goto error;
}
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0d29470e86b0..f313fcd30269 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -313,8 +313,7 @@ int scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd,
return PTR_ERR(req);
if (bufflen) {
- ret = blk_rq_map_kern(sdev->request_queue, req,
- buffer, bufflen, GFP_NOIO);
+ ret = blk_rq_map_kern(req, buffer, bufflen, GFP_NOIO);
if (ret)
goto out;
}
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 8eb9b3310167..8901347c778b 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -1031,8 +1031,8 @@ int blk_rq_map_user_io(struct request *, struct rq_map_data *,
int blk_rq_map_user_iov(struct request_queue *, struct request *,
struct rq_map_data *, const struct iov_iter *, gfp_t);
int blk_rq_unmap_user(struct bio *);
-int blk_rq_map_kern(struct request_queue *, struct request *, void *,
- unsigned int, gfp_t);
+int blk_rq_map_kern(struct request *rq, void *kbuf, unsigned int len,
+ gfp_t gfp);
int blk_rq_append_bio(struct request *rq, struct bio *bio);
void blk_execute_rq_nowait(struct request *rq, bool at_head);
blk_status_t blk_execute_rq(struct request *rq, bool at_head);
--
2.47.2
next prev parent reply other threads:[~2025-04-22 14:26 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 14:26 add more bio helper Christoph Hellwig
2025-04-22 14:26 ` [PATCH 01/17] block: add a bio_add_virt_nofail helper Christoph Hellwig
2025-04-23 6:05 ` Hannes Reinecke
2025-04-24 5:56 ` Damien Le Moal
2025-04-29 11:02 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 02/17] block: add a bdev_rw_virt helper Christoph Hellwig
2025-04-23 6:07 ` Hannes Reinecke
2025-04-23 9:36 ` Christoph Hellwig
2025-04-24 5:59 ` Damien Le Moal
2025-04-24 6:26 ` John Garry
2025-04-29 11:03 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 03/17] block: add a bio_add_vmalloc helper Christoph Hellwig
2025-04-23 6:09 ` Hannes Reinecke
2025-04-24 6:06 ` Damien Le Moal
2025-04-29 11:05 ` Johannes Thumshirn
2025-04-22 14:26 ` Christoph Hellwig [this message]
2025-04-23 6:10 ` [PATCH 04/17] block: remove the q argument from blk_rq_map_kern Hannes Reinecke
2025-04-29 11:24 ` Johannes Thumshirn
2025-04-29 12:28 ` hch
2025-04-24 6:09 ` Damien Le Moal
2025-04-22 14:26 ` [PATCH 05/17] block: pass the operation to bio_{map,copy}_kern Christoph Hellwig
2025-04-23 6:11 ` Hannes Reinecke
2025-04-24 6:11 ` Damien Le Moal
2025-04-29 11:29 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 06/17] block: simplify bio_map_kern Christoph Hellwig
2025-04-23 6:14 ` Hannes Reinecke
2025-04-24 6:13 ` Damien Le Moal
2025-04-29 11:31 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 07/17] bcache: use bio_add_virt_nofail Christoph Hellwig
2025-04-24 6:14 ` Damien Le Moal
2025-04-29 2:06 ` Coly Li
2025-04-29 11:32 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 08/17] dm-bufio: " Christoph Hellwig
2025-04-24 6:14 ` Damien Le Moal
2025-04-29 11:33 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 09/17] dm-integrity: " Christoph Hellwig
2025-04-24 6:16 ` Damien Le Moal
2025-04-29 11:34 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 10/17] rnbd-srv: " Christoph Hellwig
2025-04-24 6:16 ` Damien Le Moal
2025-04-24 6:16 ` Damien Le Moal
2025-04-24 7:14 ` Jinpu Wang
2025-04-29 11:34 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 11/17] xfs: simplify xfs_buf_submit_bio Christoph Hellwig
2025-04-24 6:18 ` Damien Le Moal
2025-04-29 14:53 ` Darrick J. Wong
2025-04-22 14:26 ` [PATCH 12/17] xfs: simplify xfs_rw_bdev Christoph Hellwig
2025-04-24 6:20 ` Damien Le Moal
2025-04-29 14:53 ` Darrick J. Wong
2025-04-22 14:26 ` [PATCH 13/17] btrfs: use bdev_rw_virt in scrub_one_super Christoph Hellwig
2025-04-24 6:20 ` Damien Le Moal
2025-04-28 9:18 ` Johannes Thumshirn
2025-04-28 9:22 ` Qu Wenruo
2025-04-22 14:26 ` [PATCH 14/17] hfsplus: use bdev_rw_virt in hfsplus_submit_bio Christoph Hellwig
2025-04-24 6:21 ` Damien Le Moal
2025-04-29 11:39 ` Johannes Thumshirn
2025-04-22 14:26 ` [PATCH 15/17] gfs2: use bdev_rw_virt in gfs2_read_super Christoph Hellwig
2025-04-24 6:23 ` Damien Le Moal
2025-04-24 8:08 ` Andreas Gruenbacher
2025-04-22 14:26 ` [PATCH 16/17] zonefs: use bdev_rw_virt in zonefs_read_super Christoph Hellwig
2025-04-24 6:24 ` Damien Le Moal
2025-04-29 11:44 ` Johannes Thumshirn
2025-04-29 12:31 ` hch
2025-04-22 14:26 ` [PATCH 17/17] PM: hibernate: split and simplify hib_submit_io Christoph Hellwig
2025-04-24 6:26 ` Damien Le Moal
2025-04-29 11:12 ` Rafael J. Wysocki
2025-04-22 14:47 ` add more bio helper Kent Overstreet
2025-04-23 9:36 ` Christoph Hellwig
2025-04-23 10:37 ` Kent Overstreet
2025-04-23 16:07 ` Christoph Hellwig
2025-04-23 18:02 ` Kent Overstreet
2025-04-24 8:37 ` Christoph Hellwig
2025-04-24 12:01 ` Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250422142628.1553523-5-hch@lst.de \
--to=hch@lst.de \
--cc=agruenba@redhat.com \
--cc=axboe@kernel.dk \
--cc=cem@kernel.org \
--cc=clm@fb.com \
--cc=colyli@kernel.org \
--cc=dlemoal@kernel.org \
--cc=dm-devel@lists.linux.dev \
--cc=dsterba@suse.com \
--cc=gfs2@lists.linux.dev \
--cc=haris.iqbal@ionos.com \
--cc=jinpu.wang@ionos.com \
--cc=josef@toxicpanda.com \
--cc=jth@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=naohiro.aota@wdc.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=snitzer@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).