OSDN Git Service

block: Remove bio->bi_ioc
authorDamien Le Moal <damien.lemoal@wdc.com>
Tue, 20 Nov 2018 01:52:34 +0000 (10:52 +0900)
committerJens Axboe <axboe@kernel.dk>
Tue, 20 Nov 2018 02:03:44 +0000 (19:03 -0700)
bio->bi_ioc is never set so always NULL. Remove references to it in
bio_disassociate_task() and in rq_ioc() and delete this field from
struct bio. With this change, rq_ioc() always returns
current->io_context without the need for a bio argument. Further
simplify the code and make it more readable by also removing this
helper, which also allows to simplify blk_mq_sched_assign_ioc() by
removing its bio argument.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Adam Manzanares <adam.manzanares@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c
block/blk-core.c
block/blk-mq-sched.c
block/blk-mq-sched.h
block/blk-mq.c
block/blk.h
include/linux/blk_types.h

index 4f4d988..03895cc 100644 (file)
@@ -2027,10 +2027,6 @@ int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg)
  */
 void bio_disassociate_task(struct bio *bio)
 {
-       if (bio->bi_ioc) {
-               put_io_context(bio->bi_ioc);
-               bio->bi_ioc = NULL;
-       }
        if (bio->bi_css) {
                css_put(bio->bi_css);
                bio->bi_css = NULL;
index d6e8ab9..492648c 100644 (file)
@@ -813,7 +813,7 @@ out:
 
 void blk_init_request_from_bio(struct request *req, struct bio *bio)
 {
-       struct io_context *ioc = rq_ioc(bio);
+       struct io_context *ioc = current->io_context;
 
        if (bio->bi_opf & REQ_RAHEAD)
                req->cmd_flags |= REQ_FAILFAST_MASK;
index d084f73..13b8dc3 100644 (file)
@@ -31,10 +31,10 @@ void blk_mq_sched_free_hctx_data(struct request_queue *q,
 }
 EXPORT_SYMBOL_GPL(blk_mq_sched_free_hctx_data);
 
-void blk_mq_sched_assign_ioc(struct request *rq, struct bio *bio)
+void blk_mq_sched_assign_ioc(struct request *rq)
 {
        struct request_queue *q = rq->q;
-       struct io_context *ioc = rq_ioc(bio);
+       struct io_context *ioc = current->io_context;
        struct io_cq *icq;
 
        spin_lock_irq(&q->queue_lock);
index 7ff5671..0f719c8 100644 (file)
@@ -8,7 +8,7 @@
 void blk_mq_sched_free_hctx_data(struct request_queue *q,
                                 void (*exit)(struct blk_mq_hw_ctx *));
 
-void blk_mq_sched_assign_ioc(struct request *rq, struct bio *bio);
+void blk_mq_sched_assign_ioc(struct request *rq);
 
 void blk_mq_sched_request_inserted(struct request *rq);
 bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
index 52b1c97..174384e 100644 (file)
@@ -389,8 +389,8 @@ static struct request *blk_mq_get_request(struct request_queue *q,
        if (!op_is_flush(data->cmd_flags)) {
                rq->elv.icq = NULL;
                if (e && e->type->ops.prepare_request) {
-                       if (e->type->icq_cache && rq_ioc(bio))
-                               blk_mq_sched_assign_ioc(rq, bio);
+                       if (e->type->icq_cache)
+                               blk_mq_sched_assign_ioc(rq);
 
                        e->type->ops.prepare_request(rq, bio);
                        rq->rq_flags |= RQF_ELVPRIV;
index 816a9ab..6109481 100644 (file)
@@ -255,22 +255,6 @@ void ioc_clear_queue(struct request_queue *q);
 int create_task_io_context(struct task_struct *task, gfp_t gfp_mask, int node);
 
 /**
- * rq_ioc - determine io_context for request allocation
- * @bio: request being allocated is for this bio (can be %NULL)
- *
- * Determine io_context to use for request allocation for @bio.  May return
- * %NULL if %current->io_context doesn't exist.
- */
-static inline struct io_context *rq_ioc(struct bio *bio)
-{
-#ifdef CONFIG_BLK_CGROUP
-       if (bio && bio->bi_ioc)
-               return bio->bi_ioc;
-#endif
-       return current->io_context;
-}
-
-/**
  * create_io_context - try to create task->io_context
  * @gfp_mask: allocation mask
  * @node: allocation node
index dbdbfbd..c0ba1a0 100644 (file)
@@ -174,10 +174,9 @@ struct bio {
        void                    *bi_private;
 #ifdef CONFIG_BLK_CGROUP
        /*
-        * Optional ioc and css associated with this bio.  Put on bio
+        * Optional css associated with this bio.  Put on bio
         * release.  Read comment on top of bio_associate_current().
         */
-       struct io_context       *bi_ioc;
        struct cgroup_subsys_state *bi_css;
        struct blkcg_gq         *bi_blkg;
        struct bio_issue        bi_issue;