From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Ming Lei <ming.lei@redhat.com>,
John Garry <john.garry@huawei.com>,
Bart Van Assche <bvanassche@acm.org>,
Hannes Reinecke <hare@suse.com>, Christoph Hellwig <hch@lst.de>,
Thomas Gleixner <tglx@linutronix.de>,
Mike Snitzer <snitzer@redhat.com>,
dm-devel@redhat.com, Hannes Reinecke <hare@suse.de>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: [PATCH V9 02/11] block: add helper for copying request
Date: Sun, 3 May 2020 07:54:45 +0800 [thread overview]
Message-ID: <20200502235454.1118520-3-ming.lei@redhat.com> (raw)
In-Reply-To: <20200502235454.1118520-1-ming.lei@redhat.com>
Add one new helper of blk_rq_copy_request() to copy request, and the helper
will be used in this patch for re-submitting request, so make it as a block
layer internal helper.
Cc: John Garry <john.garry@huawei.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: dm-devel@redhat.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-core.c | 31 ++++++++++++++++++-------------
block/blk.h | 2 ++
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 1fe73051fec3..ec50d7e6be21 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1581,6 +1581,23 @@ void blk_rq_unprep_clone(struct request *rq)
}
EXPORT_SYMBOL_GPL(blk_rq_unprep_clone);
+void blk_rq_copy_request(struct request *rq, struct request *rq_src)
+{
+ /* 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;
+ }
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+ rq->nr_integrity_segments = rq_src->nr_integrity_segments;
+#endif
+ rq->nr_phys_segments = rq_src->nr_phys_segments;
+ rq->ioprio = rq_src->ioprio;
+ rq->write_hint = rq_src->write_hint;
+}
+
/**
* blk_rq_prep_clone - Helper function to setup clone request
* @rq: the request to be setup
@@ -1623,19 +1640,7 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
rq->bio = rq->biotail = bio;
}
- /* 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;
- }
-#ifdef CONFIG_BLK_DEV_INTEGRITY
- rq->nr_integrity_segments = rq_src->nr_integrity_segments;
-#endif
- rq->nr_phys_segments = rq_src->nr_phys_segments;
- rq->ioprio = rq_src->ioprio;
- rq->write_hint = rq_src->write_hint;
+ blk_rq_copy_request(rq, rq_src);
return 0;
diff --git a/block/blk.h b/block/blk.h
index 73bd3b1c6938..73dd86dc8f47 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -120,6 +120,8 @@ static inline void blk_rq_bio_prep(struct request *rq, struct bio *bio,
rq->rq_disk = bio->bi_disk;
}
+void blk_rq_copy_request(struct request *rq, struct request *rq_src);
+
#ifdef CONFIG_BLK_DEV_INTEGRITY
void blk_flush_integrity(void);
bool __bio_integrity_endio(struct bio *);
--
2.25.2
next prev parent reply other threads:[~2020-05-02 23:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-02 23:54 [PATCH V9 00/11] blk-mq: improvement CPU hotplug Ming Lei
2020-05-02 23:54 ` [PATCH V9 01/11] block: clone nr_integrity_segments and write_hint in blk_rq_prep_clone Ming Lei
2020-05-02 23:54 ` Ming Lei [this message]
2020-05-02 23:54 ` [PATCH V9 03/11] blk-mq: mark blk_mq_get_driver_tag as static Ming Lei
2020-05-02 23:54 ` [PATCH V9 04/11] blk-mq: assign rq->tag in blk_mq_get_driver_tag Ming Lei
2020-05-02 23:54 ` [PATCH V9 05/11] blk-mq: support rq filter callback when iterating rqs Ming Lei
2020-05-04 7:04 ` Hannes Reinecke
2020-05-02 23:54 ` [PATCH V9 06/11] blk-mq: prepare for draining IO when hctx's all CPUs are offline Ming Lei
2020-05-02 23:54 ` [PATCH V9 07/11] blk-mq: stop to handle IO and drain IO before hctx becomes inactive Ming Lei
2020-05-02 23:54 ` [PATCH V9 08/11] block: add blk_end_flush_machinery Ming Lei
2020-05-02 23:54 ` [PATCH V9 09/11] blk-mq: add blk_mq_hctx_handle_dead_cpu for handling cpu dead Ming Lei
2020-05-02 23:54 ` [PATCH V9 10/11] blk-mq: re-submit IO in case that hctx is inactive Ming Lei
2020-05-02 23:54 ` [PATCH V9 11/11] block: deactivate hctx when the hctx is actually inactive Ming Lei
2020-05-04 8:14 ` [PATCH V9 00/11] blk-mq: improvement CPU hotplug John Garry
2020-05-04 8:38 ` Ming Lei
2020-05-04 9:07 ` John Garry
2020-05-04 9:57 ` John Garry
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=20200502235454.1118520-3-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=dm-devel@redhat.com \
--cc=hare@suse.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=john.garry@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=snitzer@redhat.com \
--cc=tglx@linutronix.de \
/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