* [PATCH v2 1/5] block: Export blk_init_request_from_bio()
2017-04-19 21:01 [PATCH v2 0/5] Reduce code duplication Bart Van Assche
@ 2017-04-19 21:01 ` Bart Van Assche
2017-04-20 8:30 ` Johannes Thumshirn
2017-04-19 21:01 ` [PATCH v2 2/5] null_blk: Use blk_init_request_from_bio() instead of open-coding it Bart Van Assche
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2017-04-19 21:01 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Bart Van Assche, Matias Bjørling,
Adam Manzanares
Export this function such that it becomes available to block
drivers.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Matias Bjørling <m@bjorling.me>
Cc: Adam Manzanares <adam.manzanares@wdc.com>
---
block/blk-core.c | 5 +++--
block/blk-mq.c | 2 +-
block/blk.h | 1 -
include/linux/blkdev.h | 1 +
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 8654aa0cef6d..ec2330113bea 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1628,7 +1628,7 @@ unsigned int blk_plug_queued_count(struct request_queue *q)
return ret;
}
-void init_request_from_bio(struct request *req, struct bio *bio)
+void blk_init_request_from_bio(struct request *req, struct bio *bio)
{
if (bio->bi_opf & REQ_RAHEAD)
req->cmd_flags |= REQ_FAILFAST_MASK;
@@ -1640,6 +1640,7 @@ void init_request_from_bio(struct request *req, struct bio *bio)
req->ioprio = bio_prio(bio);
blk_rq_bio_prep(req->q, req, bio);
}
+EXPORT_SYMBOL_GPL(blk_init_request_from_bio);
static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
{
@@ -1730,7 +1731,7 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
* We don't worry about that case for efficiency. It won't happen
* often, and the elevators are able to handle it.
*/
- init_request_from_bio(req, bio);
+ blk_init_request_from_bio(req, bio);
if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags))
req->cpu = raw_smp_processor_id();
diff --git a/block/blk-mq.c b/block/blk-mq.c
index e2ef7b460924..c496692ecc5b 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1424,7 +1424,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
static void blk_mq_bio_to_request(struct request *rq, struct bio *bio)
{
- init_request_from_bio(rq, bio);
+ blk_init_request_from_bio(rq, bio);
blk_account_io_start(rq, true);
}
diff --git a/block/blk.h b/block/blk.h
index 07d375183f31..cc8e61cdc229 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -60,7 +60,6 @@ void blk_free_flush_queue(struct blk_flush_queue *q);
int blk_init_rl(struct request_list *rl, struct request_queue *q,
gfp_t gfp_mask);
void blk_exit_rl(struct request_list *rl);
-void init_request_from_bio(struct request *req, struct bio *bio);
void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
struct bio *bio);
void blk_queue_bypass_start(struct request_queue *q);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index fe9c512cc6fa..be3abaee935e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -924,6 +924,7 @@ extern int blk_register_queue(struct gendisk *disk);
extern void blk_unregister_queue(struct gendisk *disk);
extern blk_qc_t generic_make_request(struct bio *bio);
extern void blk_rq_init(struct request_queue *q, struct request *rq);
+extern void blk_init_request_from_bio(struct request *req, struct bio *bio);
extern void blk_put_request(struct request *);
extern void __blk_put_request(struct request_queue *, struct request *);
extern struct request *blk_get_request(struct request_queue *, int, gfp_t);
--
2.12.2
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 1/5] block: Export blk_init_request_from_bio()
2017-04-19 21:01 ` [PATCH v2 1/5] block: Export blk_init_request_from_bio() Bart Van Assche
@ 2017-04-20 8:30 ` Johannes Thumshirn
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Thumshirn @ 2017-04-20 8:30 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Matias Bjørling, Adam Manzanares
On Wed, Apr 19, 2017 at 02:01:24PM -0700, Bart Van Assche wrote:
> Export this function such that it becomes available to block
> drivers.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Cc: Matias Bj�rling <m@bjorling.me>
> Cc: Adam Manzanares <adam.manzanares@wdc.com>
> ---
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/5] null_blk: Use blk_init_request_from_bio() instead of open-coding it
2017-04-19 21:01 [PATCH v2 0/5] Reduce code duplication Bart Van Assche
2017-04-19 21:01 ` [PATCH v2 1/5] block: Export blk_init_request_from_bio() Bart Van Assche
@ 2017-04-19 21:01 ` Bart Van Assche
2017-04-20 8:30 ` Johannes Thumshirn
2017-04-19 21:01 ` [PATCH v2 3/5] lightnvm: " Bart Van Assche
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2017-04-19 21:01 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Bart Van Assche, Matias Bjørling,
Adam Manzanares
This patch changes the behavior of the null_blk driver for the
LightNVM mode as follows:
* REQ_FAILFAST_MASK is set for read-ahead requests.
* If no I/O priority has been set in the bio, the I/O priority is
copied from the I/O context.
* The rq_disk member is initialized if bio->bi_bdev != NULL.
* req->errors is initialized to zero.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Matias Bjørling <m@bjorling.me>
Cc: Adam Manzanares <adam.manzanares@wdc.com>
---
drivers/block/null_blk.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index f93906ff31e8..e79e3d24e229 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -443,14 +443,7 @@ static int null_lnvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
if (IS_ERR(rq))
return -ENOMEM;
- rq->__sector = bio->bi_iter.bi_sector;
- rq->ioprio = bio_prio(bio);
-
- if (bio_has_data(bio))
- rq->nr_phys_segments = bio_phys_segments(q, bio);
-
- rq->__data_len = bio->bi_iter.bi_size;
- rq->bio = rq->biotail = bio;
+ blk_init_request_from_bio(rq, bio);
rq->end_io_data = rqd;
--
2.12.2
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 2/5] null_blk: Use blk_init_request_from_bio() instead of open-coding it
2017-04-19 21:01 ` [PATCH v2 2/5] null_blk: Use blk_init_request_from_bio() instead of open-coding it Bart Van Assche
@ 2017-04-20 8:30 ` Johannes Thumshirn
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Thumshirn @ 2017-04-20 8:30 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Matias Bjørling, Adam Manzanares
On Wed, Apr 19, 2017 at 02:01:25PM -0700, Bart Van Assche wrote:
> This patch changes the behavior of the null_blk driver for the
> LightNVM mode as follows:
> * REQ_FAILFAST_MASK is set for read-ahead requests.
> * If no I/O priority has been set in the bio, the I/O priority is
> copied from the I/O context.
> * The rq_disk member is initialized if bio->bi_bdev != NULL.
> * req->errors is initialized to zero.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Cc: Matias Bj�rling <m@bjorling.me>
> Cc: Adam Manzanares <adam.manzanares@wdc.com>
> ---
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/5] lightnvm: Use blk_init_request_from_bio() instead of open-coding it
2017-04-19 21:01 [PATCH v2 0/5] Reduce code duplication Bart Van Assche
2017-04-19 21:01 ` [PATCH v2 1/5] block: Export blk_init_request_from_bio() Bart Van Assche
2017-04-19 21:01 ` [PATCH v2 2/5] null_blk: Use blk_init_request_from_bio() instead of open-coding it Bart Van Assche
@ 2017-04-19 21:01 ` Bart Van Assche
2017-04-20 8:30 ` Johannes Thumshirn
2017-04-19 21:01 ` [PATCH v2 4/5] block: Inline blk_rq_set_prio() Bart Van Assche
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2017-04-19 21:01 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Bart Van Assche, Matias Bjørling,
Adam Manzanares
This patch changes the behavior of the lightnvm driver as follows:
* REQ_FAILFAST_MASK is set for read-ahead requests.
* If no I/O priority has been set in the bio, the I/O priority is
copied from the I/O context.
* The rq_disk member is initialized if bio->bi_bdev != NULL.
* The bio sector offset is copied into req->__sector instead of
retaining the value -1 set by blk_mq_alloc_request().
* req->errors is initialized to zero.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Matias Bjørling <m@bjorling.me>
Cc: Adam Manzanares <adam.manzanares@wdc.com>
---
drivers/nvme/host/lightnvm.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 4b78090518e1..b76e2e36fef4 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -511,11 +511,7 @@ static int nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
rq->cmd_flags &= ~REQ_FAILFAST_DRIVER;
if (bio) {
- rq->ioprio = bio_prio(bio);
- rq->__data_len = bio->bi_iter.bi_size;
- rq->bio = rq->biotail = bio;
- if (bio_has_data(bio))
- rq->nr_phys_segments = bio_phys_segments(q, bio);
+ blk_init_request_from_bio(rq, bio);
} else {
rq->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
rq->__data_len = 0;
--
2.12.2
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 3/5] lightnvm: Use blk_init_request_from_bio() instead of open-coding it
2017-04-19 21:01 ` [PATCH v2 3/5] lightnvm: " Bart Van Assche
@ 2017-04-20 8:30 ` Johannes Thumshirn
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Thumshirn @ 2017-04-20 8:30 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Matias Bjørling, Adam Manzanares
On Wed, Apr 19, 2017 at 02:01:26PM -0700, Bart Van Assche wrote:
> This patch changes the behavior of the lightnvm driver as follows:
> * REQ_FAILFAST_MASK is set for read-ahead requests.
> * If no I/O priority has been set in the bio, the I/O priority is
> copied from the I/O context.
> * The rq_disk member is initialized if bio->bi_bdev != NULL.
> * The bio sector offset is copied into req->__sector instead of
> retaining the value -1 set by blk_mq_alloc_request().
> * req->errors is initialized to zero.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Cc: Matias Bj�rling <m@bjorling.me>
> Cc: Adam Manzanares <adam.manzanares@wdc.com>
> ---
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 4/5] block: Inline blk_rq_set_prio()
2017-04-19 21:01 [PATCH v2 0/5] Reduce code duplication Bart Van Assche
` (2 preceding siblings ...)
2017-04-19 21:01 ` [PATCH v2 3/5] lightnvm: " Bart Van Assche
@ 2017-04-19 21:01 ` Bart Van Assche
2017-04-20 8:31 ` Johannes Thumshirn
2017-04-19 21:01 ` [PATCH v2 5/5] block: Optimize ioprio_best() Bart Van Assche
2017-04-19 23:52 ` [PATCH v2 0/5] Reduce code duplication Jens Axboe
5 siblings, 1 reply; 11+ messages in thread
From: Bart Van Assche @ 2017-04-19 21:01 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Matias Bjørling
Since only a single caller remains, inline blk_rq_set_prio(). Initialize
req->ioprio even if no I/O priority has been set in the bio nor in the
I/O context.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Adam Manzanares <adam.manzanares@wdc.com>
Tested-by: Adam Manzanares <adam.manzanares@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Matias Bjørling <m@bjorling.me>
---
block/blk-core.c | 7 ++++++-
include/linux/blkdev.h | 14 --------------
2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index ec2330113bea..4f0fd8f3328d 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1630,14 +1630,19 @@ unsigned int blk_plug_queued_count(struct request_queue *q)
void blk_init_request_from_bio(struct request *req, struct bio *bio)
{
+ struct io_context *ioc = rq_ioc(bio);
+
if (bio->bi_opf & REQ_RAHEAD)
req->cmd_flags |= REQ_FAILFAST_MASK;
req->errors = 0;
req->__sector = bio->bi_iter.bi_sector;
- blk_rq_set_prio(req, rq_ioc(bio));
if (ioprio_valid(bio_prio(bio)))
req->ioprio = bio_prio(bio);
+ else if (ioc)
+ req->ioprio = ioc->ioprio;
+ else
+ req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
blk_rq_bio_prep(req->q, req, bio);
}
EXPORT_SYMBOL_GPL(blk_init_request_from_bio);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index be3abaee935e..92894995f4b7 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1088,20 +1088,6 @@ static inline unsigned int blk_rq_count_bios(struct request *rq)
}
/*
- * blk_rq_set_prio - associate a request with prio from ioc
- * @rq: request of interest
- * @ioc: target iocontext
- *
- * Assocate request prio with ioc prio so request based drivers
- * can leverage priority information.
- */
-static inline void blk_rq_set_prio(struct request *rq, struct io_context *ioc)
-{
- if (ioc)
- rq->ioprio = ioc->ioprio;
-}
-
-/*
* Request issue related functions.
*/
extern struct request *blk_peek_request(struct request_queue *q);
--
2.12.2
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 4/5] block: Inline blk_rq_set_prio()
2017-04-19 21:01 ` [PATCH v2 4/5] block: Inline blk_rq_set_prio() Bart Van Assche
@ 2017-04-20 8:31 ` Johannes Thumshirn
0 siblings, 0 replies; 11+ messages in thread
From: Johannes Thumshirn @ 2017-04-20 8:31 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Matias Bjørling
On Wed, Apr 19, 2017 at 02:01:27PM -0700, Bart Van Assche wrote:
> Since only a single caller remains, inline blk_rq_set_prio(). Initialize
> req->ioprio even if no I/O priority has been set in the bio nor in the
> I/O context.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Reviewed-by: Adam Manzanares <adam.manzanares@wdc.com>
> Tested-by: Adam Manzanares <adam.manzanares@wdc.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Cc: Matias Bj�rling <m@bjorling.me>
> ---
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Felix Imend�rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N�rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 5/5] block: Optimize ioprio_best()
2017-04-19 21:01 [PATCH v2 0/5] Reduce code duplication Bart Van Assche
` (3 preceding siblings ...)
2017-04-19 21:01 ` [PATCH v2 4/5] block: Inline blk_rq_set_prio() Bart Van Assche
@ 2017-04-19 21:01 ` Bart Van Assche
2017-04-19 23:52 ` [PATCH v2 0/5] Reduce code duplication Jens Axboe
5 siblings, 0 replies; 11+ messages in thread
From: Bart Van Assche @ 2017-04-19 21:01 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Matias Bjørling
Since ioprio_best() translates IOPRIO_CLASS_NONE into IOPRIO_CLASS_BE
and since lower numerical priority values represent a higher priority
a simple numerical comparison is sufficient.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Adam Manzanares <adam.manzanares@wdc.com>
Tested-by: Adam Manzanares <adam.manzanares@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Matias Bjørling <m@bjorling.me>
---
block/ioprio.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/block/ioprio.c b/block/ioprio.c
index 0c47a00f92a8..4b120c9cf7e8 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -163,22 +163,12 @@ static int get_task_ioprio(struct task_struct *p)
int ioprio_best(unsigned short aprio, unsigned short bprio)
{
- unsigned short aclass;
- unsigned short bclass;
-
if (!ioprio_valid(aprio))
aprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
if (!ioprio_valid(bprio))
bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
- aclass = IOPRIO_PRIO_CLASS(aprio);
- bclass = IOPRIO_PRIO_CLASS(bprio);
- if (aclass == bclass)
- return min(aprio, bprio);
- if (aclass > bclass)
- return bprio;
- else
- return aprio;
+ return min(aprio, bprio);
}
SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
--
2.12.2
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v2 0/5] Reduce code duplication
2017-04-19 21:01 [PATCH v2 0/5] Reduce code duplication Bart Van Assche
` (4 preceding siblings ...)
2017-04-19 21:01 ` [PATCH v2 5/5] block: Optimize ioprio_best() Bart Van Assche
@ 2017-04-19 23:52 ` Jens Axboe
5 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2017-04-19 23:52 UTC (permalink / raw)
To: Bart Van Assche; +Cc: linux-block
On 04/19/2017 03:01 PM, Bart Van Assche wrote:
> Hello Jens,
>
> This series contains three patches intended to reduce code duplication
> and two patches that simplify / optimize I/O priority handling. Please
> consider these patches for kernel v4.12.
Applied, thanks Bart.
--
Jens Axboe
^ permalink raw reply [flat|nested] 11+ messages in thread