Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-linus-20181102' of git://git.kernel.dk/linux-block

Pull block layer fixes from Jens Axboe:
"The biggest part of this pull request is the revert of the blkcg
cleanup series. It had one fix earlier for a stacked device issue, but
another one was reported. Rather than play whack-a-mole with this,
revert the entire series and try again for the next kernel release.

Apart from that, only small fixes/changes.

Summary:

- Indentation fixup for mtip32xx (Colin Ian King)

- The blkcg cleanup series revert (Dennis Zhou)

- Two NVMe fixes. One fixing a regression in the nvme request
initialization in this merge window, causing nvme-fc to not work.
The other is a suspend/resume p2p resource issue (James, Keith)

- Fix sg discard merge, allowing us to merge in cases where we didn't
before (Jianchao Wang)

- Call rq_qos_exit() after the queue is frozen, preventing a hang
(Ming)

- Fix brd queue setup, fixing an oops if we fail setting up all
devices (Ming)"

* tag 'for-linus-20181102' of git://git.kernel.dk/linux-block:
nvme-pci: fix conflicting p2p resource adds
nvme-fc: fix request private initialization
blkcg: revert blkcg cleanups series
block: brd: associate with queue until adding disk
block: call rq_qos_exit() after queue is frozen
mtip32xx: clean an indentation issue, remove extraneous tabs
block: fix the DISCARD request merge

+283 -442
+3 -5
Documentation/admin-guide/cgroup-v2.rst
··· 1879 1879 1880 1880 wbc_init_bio(@wbc, @bio) 1881 1881 Should be called for each bio carrying writeback data and 1882 - associates the bio with the inode's owner cgroup and the 1883 - corresponding request queue. This must be called after 1884 - a queue (device) has been associated with the bio and 1885 - before submission. 1882 + associates the bio with the inode's owner cgroup. Can be 1883 + called anytime between bio allocation and submission. 1886 1884 1887 1885 wbc_account_io(@wbc, @page, @bytes) 1888 1886 Should be called for each data segment being written out. ··· 1899 1901 the writeback session is holding shared resources, e.g. a journal 1900 1902 entry, may lead to priority inversion. There is no one easy solution 1901 1903 for the problem. Filesystems can try to work around specific problem 1902 - cases by skipping wbc_init_bio() or using bio_associate_create_blkg() 1904 + cases by skipping wbc_init_bio() or using bio_associate_blkcg() 1903 1905 directly. 1904 1906 1905 1907
+2 -2
block/bfq-cgroup.c
··· 642 642 uint64_t serial_nr; 643 643 644 644 rcu_read_lock(); 645 - serial_nr = __bio_blkcg(bio)->css.serial_nr; 645 + serial_nr = bio_blkcg(bio)->css.serial_nr; 646 646 647 647 /* 648 648 * Check whether blkcg has changed. The condition may trigger ··· 651 651 if (unlikely(!bfqd) || likely(bic->blkcg_serial_nr == serial_nr)) 652 652 goto out; 653 653 654 - bfqg = __bfq_bic_change_cgroup(bfqd, bic, __bio_blkcg(bio)); 654 + bfqg = __bfq_bic_change_cgroup(bfqd, bic, bio_blkcg(bio)); 655 655 /* 656 656 * Update blkg_path for bfq_log_* functions. We cache this 657 657 * path, and update it here, for the following
+1 -1
block/bfq-iosched.c
··· 4384 4384 4385 4385 rcu_read_lock(); 4386 4386 4387 - bfqg = bfq_find_set_group(bfqd, __bio_blkcg(bio)); 4387 + bfqg = bfq_find_set_group(bfqd, bio_blkcg(bio)); 4388 4388 if (!bfqg) { 4389 4389 bfqq = &bfqd->oom_bfqq; 4390 4390 goto out;
+63 -143
block/bio.c
··· 609 609 bio->bi_iter = bio_src->bi_iter; 610 610 bio->bi_io_vec = bio_src->bi_io_vec; 611 611 612 - bio_clone_blkg_association(bio, bio_src); 613 - 614 - blkcg_bio_issue_init(bio); 612 + bio_clone_blkcg_association(bio, bio_src); 615 613 } 616 614 EXPORT_SYMBOL(__bio_clone_fast); 617 615 ··· 1954 1956 1955 1957 #ifdef CONFIG_BLK_CGROUP 1956 1958 1959 + #ifdef CONFIG_MEMCG 1957 1960 /** 1958 - * bio_associate_blkg - associate a bio with the a blkg 1961 + * bio_associate_blkcg_from_page - associate a bio with the page's blkcg 1962 + * @bio: target bio 1963 + * @page: the page to lookup the blkcg from 1964 + * 1965 + * Associate @bio with the blkcg from @page's owning memcg. This works like 1966 + * every other associate function wrt references. 1967 + */ 1968 + int bio_associate_blkcg_from_page(struct bio *bio, struct page *page) 1969 + { 1970 + struct cgroup_subsys_state *blkcg_css; 1971 + 1972 + if (unlikely(bio->bi_css)) 1973 + return -EBUSY; 1974 + if (!page->mem_cgroup) 1975 + return 0; 1976 + blkcg_css = cgroup_get_e_css(page->mem_cgroup->css.cgroup, 1977 + &io_cgrp_subsys); 1978 + bio->bi_css = blkcg_css; 1979 + return 0; 1980 + } 1981 + #endif /* CONFIG_MEMCG */ 1982 + 1983 + /** 1984 + * bio_associate_blkcg - associate a bio with the specified blkcg 1985 + * @bio: target bio 1986 + * @blkcg_css: css of the blkcg to associate 1987 + * 1988 + * Associate @bio with the blkcg specified by @blkcg_css. Block layer will 1989 + * treat @bio as if it were issued by a task which belongs to the blkcg. 1990 + * 1991 + * This function takes an extra reference of @blkcg_css which will be put 1992 + * when @bio is released. The caller must own @bio and is responsible for 1993 + * synchronizing calls to this function. 1994 + */ 1995 + int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css) 1996 + { 1997 + if (unlikely(bio->bi_css)) 1998 + return -EBUSY; 1999 + css_get(blkcg_css); 2000 + bio->bi_css = blkcg_css; 2001 + return 0; 2002 + } 2003 + EXPORT_SYMBOL_GPL(bio_associate_blkcg); 2004 + 2005 + /** 2006 + * bio_associate_blkg - associate a bio with the specified blkg 1959 2007 * @bio: target bio 1960 2008 * @blkg: the blkg to associate 1961 2009 * 1962 - * This tries to associate @bio with the specified blkg. Association failure 1963 - * is handled by walking up the blkg tree. Therefore, the blkg associated can 1964 - * be anything between @blkg and the root_blkg. This situation only happens 1965 - * when a cgroup is dying and then the remaining bios will spill to the closest 1966 - * alive blkg. 1967 - * 1968 - * A reference will be taken on the @blkg and will be released when @bio is 1969 - * freed. 2010 + * Associate @bio with the blkg specified by @blkg. This is the queue specific 2011 + * blkcg information associated with the @bio, a reference will be taken on the 2012 + * @blkg and will be freed when the bio is freed. 1970 2013 */ 1971 2014 int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg) 1972 2015 { 1973 2016 if (unlikely(bio->bi_blkg)) 1974 2017 return -EBUSY; 1975 - bio->bi_blkg = blkg_tryget_closest(blkg); 2018 + if (!blkg_try_get(blkg)) 2019 + return -ENODEV; 2020 + bio->bi_blkg = blkg; 1976 2021 return 0; 1977 - } 1978 - 1979 - /** 1980 - * __bio_associate_blkg_from_css - internal blkg association function 1981 - * 1982 - * This in the core association function that all association paths rely on. 1983 - * A blkg reference is taken which is released upon freeing of the bio. 1984 - */ 1985 - static int __bio_associate_blkg_from_css(struct bio *bio, 1986 - struct cgroup_subsys_state *css) 1987 - { 1988 - struct request_queue *q = bio->bi_disk->queue; 1989 - struct blkcg_gq *blkg; 1990 - int ret; 1991 - 1992 - rcu_read_lock(); 1993 - 1994 - if (!css || !css->parent) 1995 - blkg = q->root_blkg; 1996 - else 1997 - blkg = blkg_lookup_create(css_to_blkcg(css), q); 1998 - 1999 - ret = bio_associate_blkg(bio, blkg); 2000 - 2001 - rcu_read_unlock(); 2002 - return ret; 2003 - } 2004 - 2005 - /** 2006 - * bio_associate_blkg_from_css - associate a bio with a specified css 2007 - * @bio: target bio 2008 - * @css: target css 2009 - * 2010 - * Associate @bio with the blkg found by combining the css's blkg and the 2011 - * request_queue of the @bio. This falls back to the queue's root_blkg if 2012 - * the association fails with the css. 2013 - */ 2014 - int bio_associate_blkg_from_css(struct bio *bio, 2015 - struct cgroup_subsys_state *css) 2016 - { 2017 - if (unlikely(bio->bi_blkg)) 2018 - return -EBUSY; 2019 - return __bio_associate_blkg_from_css(bio, css); 2020 - } 2021 - EXPORT_SYMBOL_GPL(bio_associate_blkg_from_css); 2022 - 2023 - #ifdef CONFIG_MEMCG 2024 - /** 2025 - * bio_associate_blkg_from_page - associate a bio with the page's blkg 2026 - * @bio: target bio 2027 - * @page: the page to lookup the blkcg from 2028 - * 2029 - * Associate @bio with the blkg from @page's owning memcg and the respective 2030 - * request_queue. If cgroup_e_css returns NULL, fall back to the queue's 2031 - * root_blkg. 2032 - * 2033 - * Note: this must be called after bio has an associated device. 2034 - */ 2035 - int bio_associate_blkg_from_page(struct bio *bio, struct page *page) 2036 - { 2037 - struct cgroup_subsys_state *css; 2038 - int ret; 2039 - 2040 - if (unlikely(bio->bi_blkg)) 2041 - return -EBUSY; 2042 - if (!page->mem_cgroup) 2043 - return 0; 2044 - 2045 - rcu_read_lock(); 2046 - 2047 - css = cgroup_e_css(page->mem_cgroup->css.cgroup, &io_cgrp_subsys); 2048 - 2049 - ret = __bio_associate_blkg_from_css(bio, css); 2050 - 2051 - rcu_read_unlock(); 2052 - return ret; 2053 - } 2054 - #endif /* CONFIG_MEMCG */ 2055 - 2056 - /** 2057 - * bio_associate_create_blkg - associate a bio with a blkg from q 2058 - * @q: request_queue where bio is going 2059 - * @bio: target bio 2060 - * 2061 - * Associate @bio with the blkg found from the bio's css and the request_queue. 2062 - * If one is not found, bio_lookup_blkg creates the blkg. This falls back to 2063 - * the queue's root_blkg if association fails. 2064 - */ 2065 - int bio_associate_create_blkg(struct request_queue *q, struct bio *bio) 2066 - { 2067 - struct cgroup_subsys_state *css; 2068 - int ret = 0; 2069 - 2070 - /* someone has already associated this bio with a blkg */ 2071 - if (bio->bi_blkg) 2072 - return ret; 2073 - 2074 - rcu_read_lock(); 2075 - 2076 - css = blkcg_css(); 2077 - 2078 - ret = __bio_associate_blkg_from_css(bio, css); 2079 - 2080 - rcu_read_unlock(); 2081 - return ret; 2082 - } 2083 - 2084 - /** 2085 - * bio_reassociate_blkg - reassociate a bio with a blkg from q 2086 - * @q: request_queue where bio is going 2087 - * @bio: target bio 2088 - * 2089 - * When submitting a bio, multiple recursive calls to make_request() may occur. 2090 - * This causes the initial associate done in blkcg_bio_issue_check() to be 2091 - * incorrect and reference the prior request_queue. This performs reassociation 2092 - * when this situation happens. 2093 - */ 2094 - int bio_reassociate_blkg(struct request_queue *q, struct bio *bio) 2095 - { 2096 - if (bio->bi_blkg) { 2097 - blkg_put(bio->bi_blkg); 2098 - bio->bi_blkg = NULL; 2099 - } 2100 - 2101 - return bio_associate_create_blkg(q, bio); 2102 2022 } 2103 2023 2104 2024 /** ··· 2029 2113 put_io_context(bio->bi_ioc); 2030 2114 bio->bi_ioc = NULL; 2031 2115 } 2116 + if (bio->bi_css) { 2117 + css_put(bio->bi_css); 2118 + bio->bi_css = NULL; 2119 + } 2032 2120 if (bio->bi_blkg) { 2033 2121 blkg_put(bio->bi_blkg); 2034 2122 bio->bi_blkg = NULL; ··· 2040 2120 } 2041 2121 2042 2122 /** 2043 - * bio_clone_blkg_association - clone blkg association from src to dst bio 2123 + * bio_clone_blkcg_association - clone blkcg association from src to dst bio 2044 2124 * @dst: destination bio 2045 2125 * @src: source bio 2046 2126 */ 2047 - void bio_clone_blkg_association(struct bio *dst, struct bio *src) 2127 + void bio_clone_blkcg_association(struct bio *dst, struct bio *src) 2048 2128 { 2049 - if (src->bi_blkg) 2050 - bio_associate_blkg(dst, src->bi_blkg); 2129 + if (src->bi_css) 2130 + WARN_ON(bio_associate_blkcg(dst, src->bi_css)); 2051 2131 } 2052 - EXPORT_SYMBOL_GPL(bio_clone_blkg_association); 2132 + EXPORT_SYMBOL_GPL(bio_clone_blkcg_association); 2053 2133 #endif /* CONFIG_BLK_CGROUP */ 2054 2134 2055 2135 static void __init biovec_init_slabs(void)
+37 -84
block/blk-cgroup.c
··· 84 84 kfree(blkg); 85 85 } 86 86 87 - static void __blkg_release(struct rcu_head *rcu) 88 - { 89 - struct blkcg_gq *blkg = container_of(rcu, struct blkcg_gq, rcu_head); 90 - 91 - percpu_ref_exit(&blkg->refcnt); 92 - 93 - /* release the blkcg and parent blkg refs this blkg has been holding */ 94 - css_put(&blkg->blkcg->css); 95 - if (blkg->parent) 96 - blkg_put(blkg->parent); 97 - 98 - wb_congested_put(blkg->wb_congested); 99 - 100 - blkg_free(blkg); 101 - } 102 - 103 - /* 104 - * A group is RCU protected, but having an rcu lock does not mean that one 105 - * can access all the fields of blkg and assume these are valid. For 106 - * example, don't try to follow throtl_data and request queue links. 107 - * 108 - * Having a reference to blkg under an rcu allows accesses to only values 109 - * local to groups like group stats and group rate limits. 110 - */ 111 - static void blkg_release(struct percpu_ref *ref) 112 - { 113 - struct blkcg_gq *blkg = container_of(ref, struct blkcg_gq, refcnt); 114 - 115 - call_rcu(&blkg->rcu_head, __blkg_release); 116 - } 117 - 118 87 /** 119 88 * blkg_alloc - allocate a blkg 120 89 * @blkcg: block cgroup the new blkg is associated with ··· 110 141 blkg->q = q; 111 142 INIT_LIST_HEAD(&blkg->q_node); 112 143 blkg->blkcg = blkcg; 144 + atomic_set(&blkg->refcnt, 1); 113 145 114 146 /* root blkg uses @q->root_rl, init rl only for !root blkgs */ 115 147 if (blkcg != &blkcg_root) { ··· 217 247 blkg_get(blkg->parent); 218 248 } 219 249 220 - ret = percpu_ref_init(&blkg->refcnt, blkg_release, 0, 221 - GFP_NOWAIT | __GFP_NOWARN); 222 - if (ret) 223 - goto err_cancel_ref; 224 - 225 250 /* invoke per-policy init */ 226 251 for (i = 0; i < BLKCG_MAX_POLS; i++) { 227 252 struct blkcg_policy *pol = blkcg_policy[i]; ··· 249 284 blkg_put(blkg); 250 285 return ERR_PTR(ret); 251 286 252 - err_cancel_ref: 253 - percpu_ref_exit(&blkg->refcnt); 254 287 err_put_congested: 255 288 wb_congested_put(wb_congested); 256 289 err_put_css: ··· 259 296 } 260 297 261 298 /** 262 - * __blkg_lookup_create - lookup blkg, try to create one if not there 299 + * blkg_lookup_create - lookup blkg, try to create one if not there 263 300 * @blkcg: blkcg of interest 264 301 * @q: request_queue of interest 265 302 * ··· 268 305 * that all non-root blkg's have access to the parent blkg. This function 269 306 * should be called under RCU read lock and @q->queue_lock. 270 307 * 271 - * Returns the blkg or the closest blkg if blkg_create fails as it walks 272 - * down from root. 308 + * Returns pointer to the looked up or created blkg on success, ERR_PTR() 309 + * value on error. If @q is dead, returns ERR_PTR(-EINVAL). If @q is not 310 + * dead and bypassing, returns ERR_PTR(-EBUSY). 273 311 */ 274 - struct blkcg_gq *__blkg_lookup_create(struct blkcg *blkcg, 275 - struct request_queue *q) 312 + struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, 313 + struct request_queue *q) 276 314 { 277 315 struct blkcg_gq *blkg; 278 316 ··· 285 321 * we shouldn't allow anything to go through for a bypassing queue. 286 322 */ 287 323 if (unlikely(blk_queue_bypass(q))) 288 - return q->root_blkg; 324 + return ERR_PTR(blk_queue_dying(q) ? -ENODEV : -EBUSY); 289 325 290 326 blkg = __blkg_lookup(blkcg, q, true); 291 327 if (blkg) ··· 293 329 294 330 /* 295 331 * Create blkgs walking down from blkcg_root to @blkcg, so that all 296 - * non-root blkgs have access to their parents. Returns the closest 297 - * blkg to the intended blkg should blkg_create() fail. 332 + * non-root blkgs have access to their parents. 298 333 */ 299 334 while (true) { 300 335 struct blkcg *pos = blkcg; 301 336 struct blkcg *parent = blkcg_parent(blkcg); 302 - struct blkcg_gq *ret_blkg = q->root_blkg; 303 337 304 - while (parent) { 305 - blkg = __blkg_lookup(parent, q, false); 306 - if (blkg) { 307 - /* remember closest blkg */ 308 - ret_blkg = blkg; 309 - break; 310 - } 338 + while (parent && !__blkg_lookup(parent, q, false)) { 311 339 pos = parent; 312 340 parent = blkcg_parent(parent); 313 341 } 314 342 315 343 blkg = blkg_create(pos, q, NULL); 316 - if (IS_ERR(blkg)) 317 - return ret_blkg; 318 - if (pos == blkcg) 344 + if (pos == blkcg || IS_ERR(blkg)) 319 345 return blkg; 320 346 } 321 - } 322 - 323 - /** 324 - * blkg_lookup_create - find or create a blkg 325 - * @blkcg: target block cgroup 326 - * @q: target request_queue 327 - * 328 - * This looks up or creates the blkg representing the unique pair 329 - * of the blkcg and the request_queue. 330 - */ 331 - struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, 332 - struct request_queue *q) 333 - { 334 - struct blkcg_gq *blkg = blkg_lookup(blkcg, q); 335 - unsigned long flags; 336 - 337 - if (unlikely(!blkg)) { 338 - spin_lock_irqsave(q->queue_lock, flags); 339 - 340 - blkg = __blkg_lookup_create(blkcg, q); 341 - 342 - spin_unlock_irqrestore(q->queue_lock, flags); 343 - } 344 - 345 - return blkg; 346 347 } 347 348 348 349 static void blkg_destroy(struct blkcg_gq *blkg) ··· 353 424 * Put the reference taken at the time of creation so that when all 354 425 * queues are gone, group can be destroyed. 355 426 */ 356 - percpu_ref_kill(&blkg->refcnt); 427 + blkg_put(blkg); 357 428 } 358 429 359 430 /** ··· 379 450 q->root_blkg = NULL; 380 451 q->root_rl.blkg = NULL; 381 452 } 453 + 454 + /* 455 + * A group is RCU protected, but having an rcu lock does not mean that one 456 + * can access all the fields of blkg and assume these are valid. For 457 + * example, don't try to follow throtl_data and request queue links. 458 + * 459 + * Having a reference to blkg under an rcu allows accesses to only values 460 + * local to groups like group stats and group rate limits. 461 + */ 462 + void __blkg_release_rcu(struct rcu_head *rcu_head) 463 + { 464 + struct blkcg_gq *blkg = container_of(rcu_head, struct blkcg_gq, rcu_head); 465 + 466 + /* release the blkcg and parent blkg refs this blkg has been holding */ 467 + css_put(&blkg->blkcg->css); 468 + if (blkg->parent) 469 + blkg_put(blkg->parent); 470 + 471 + wb_congested_put(blkg->wb_congested); 472 + 473 + blkg_free(blkg); 474 + } 475 + EXPORT_SYMBOL_GPL(__blkg_release_rcu); 382 476 383 477 /* 384 478 * The next function used by blk_queue_for_each_rl(). It's a bit tricky ··· 1748 1796 blkg = blkg_lookup(blkcg, q); 1749 1797 if (!blkg) 1750 1798 goto out; 1751 - if (!blkg_tryget(blkg)) 1799 + blkg = blkg_try_get(blkg); 1800 + if (!blkg) 1752 1801 goto out; 1753 1802 rcu_read_unlock(); 1754 1803
+3 -1
block/blk-core.c
··· 785 785 * prevent that q->request_fn() gets invoked after draining finished. 786 786 */ 787 787 blk_freeze_queue(q); 788 + 789 + rq_qos_exit(q); 790 + 788 791 spin_lock_irq(lock); 789 792 queue_flag_set(QUEUE_FLAG_DEAD, q); 790 793 spin_unlock_irq(lock); ··· 2435 2432 if (q) 2436 2433 blk_queue_exit(q); 2437 2434 q = bio->bi_disk->queue; 2438 - bio_reassociate_blkg(q, bio); 2439 2435 flags = 0; 2440 2436 if (bio->bi_opf & REQ_NOWAIT) 2441 2437 flags = BLK_MQ_REQ_NOWAIT;
+24 -2
block/blk-iolatency.c
··· 482 482 spinlock_t *lock) 483 483 { 484 484 struct blk_iolatency *blkiolat = BLKIOLATENCY(rqos); 485 - struct blkcg_gq *blkg = bio->bi_blkg; 485 + struct blkcg *blkcg; 486 + struct blkcg_gq *blkg; 487 + struct request_queue *q = rqos->q; 486 488 bool issue_as_root = bio_issue_as_root_blkg(bio); 487 489 488 490 if (!blk_iolatency_enabled(blkiolat)) 489 491 return; 490 492 493 + rcu_read_lock(); 494 + blkcg = bio_blkcg(bio); 495 + bio_associate_blkcg(bio, &blkcg->css); 496 + blkg = blkg_lookup(blkcg, q); 497 + if (unlikely(!blkg)) { 498 + if (!lock) 499 + spin_lock_irq(q->queue_lock); 500 + blkg = blkg_lookup_create(blkcg, q); 501 + if (IS_ERR(blkg)) 502 + blkg = NULL; 503 + if (!lock) 504 + spin_unlock_irq(q->queue_lock); 505 + } 506 + if (!blkg) 507 + goto out; 508 + 509 + bio_issue_init(&bio->bi_issue, bio_sectors(bio)); 510 + bio_associate_blkg(bio, blkg); 511 + out: 512 + rcu_read_unlock(); 491 513 while (blkg && blkg->parent) { 492 514 struct iolatency_grp *iolat = blkg_to_lat(blkg); 493 515 if (!iolat) { ··· 730 708 * We could be exiting, don't access the pd unless we have a 731 709 * ref on the blkg. 732 710 */ 733 - if (!blkg_tryget(blkg)) 711 + if (!blkg_try_get(blkg)) 734 712 continue; 735 713 736 714 iolat = blkg_to_lat(blkg);
+36 -10
block/blk-merge.c
··· 714 714 part_stat_unlock(); 715 715 } 716 716 } 717 + /* 718 + * Two cases of handling DISCARD merge: 719 + * If max_discard_segments > 1, the driver takes every bio 720 + * as a range and send them to controller together. The ranges 721 + * needn't to be contiguous. 722 + * Otherwise, the bios/requests will be handled as same as 723 + * others which should be contiguous. 724 + */ 725 + static inline bool blk_discard_mergable(struct request *req) 726 + { 727 + if (req_op(req) == REQ_OP_DISCARD && 728 + queue_max_discard_segments(req->q) > 1) 729 + return true; 730 + return false; 731 + } 732 + 733 + enum elv_merge blk_try_req_merge(struct request *req, struct request *next) 734 + { 735 + if (blk_discard_mergable(req)) 736 + return ELEVATOR_DISCARD_MERGE; 737 + else if (blk_rq_pos(req) + blk_rq_sectors(req) == blk_rq_pos(next)) 738 + return ELEVATOR_BACK_MERGE; 739 + 740 + return ELEVATOR_NO_MERGE; 741 + } 717 742 718 743 /* 719 744 * For non-mq, this has to be called with the request spinlock acquired. ··· 754 729 return NULL; 755 730 756 731 if (req_op(req) != req_op(next)) 757 - return NULL; 758 - 759 - /* 760 - * not contiguous 761 - */ 762 - if (blk_rq_pos(req) + blk_rq_sectors(req) != blk_rq_pos(next)) 763 732 return NULL; 764 733 765 734 if (rq_data_dir(req) != rq_data_dir(next) ··· 779 760 * counts here. Handle DISCARDs separately, as they 780 761 * have separate settings. 781 762 */ 782 - if (req_op(req) == REQ_OP_DISCARD) { 763 + 764 + switch (blk_try_req_merge(req, next)) { 765 + case ELEVATOR_DISCARD_MERGE: 783 766 if (!req_attempt_discard_merge(q, req, next)) 784 767 return NULL; 785 - } else if (!ll_merge_requests_fn(q, req, next)) 768 + break; 769 + case ELEVATOR_BACK_MERGE: 770 + if (!ll_merge_requests_fn(q, req, next)) 771 + return NULL; 772 + break; 773 + default: 786 774 return NULL; 775 + } 787 776 788 777 /* 789 778 * If failfast settings disagree or any of the two is already ··· 915 888 916 889 enum elv_merge blk_try_merge(struct request *rq, struct bio *bio) 917 890 { 918 - if (req_op(rq) == REQ_OP_DISCARD && 919 - queue_max_discard_segments(rq->q) > 1) 891 + if (blk_discard_mergable(rq)) 920 892 return ELEVATOR_DISCARD_MERGE; 921 893 else if (blk_rq_pos(rq) + blk_rq_sectors(rq) == bio->bi_iter.bi_sector) 922 894 return ELEVATOR_BACK_MERGE;
-2
block/blk-sysfs.c
··· 1007 1007 kobject_del(&q->kobj); 1008 1008 blk_trace_remove_sysfs(disk_to_dev(disk)); 1009 1009 1010 - rq_qos_exit(q); 1011 - 1012 1010 mutex_lock(&q->sysfs_lock); 1013 1011 if (q->request_fn || (q->mq_ops && q->elevator)) 1014 1012 elv_unregister_queue(q);
+12 -1
block/blk-throttle.c
··· 2115 2115 } 2116 2116 #endif 2117 2117 2118 + static void blk_throtl_assoc_bio(struct throtl_grp *tg, struct bio *bio) 2119 + { 2120 + #ifdef CONFIG_BLK_DEV_THROTTLING_LOW 2121 + /* fallback to root_blkg if we fail to get a blkg ref */ 2122 + if (bio->bi_css && (bio_associate_blkg(bio, tg_to_blkg(tg)) == -ENODEV)) 2123 + bio_associate_blkg(bio, bio->bi_disk->queue->root_blkg); 2124 + bio_issue_init(&bio->bi_issue, bio_sectors(bio)); 2125 + #endif 2126 + } 2127 + 2118 2128 bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg, 2119 2129 struct bio *bio) 2120 2130 { 2121 2131 struct throtl_qnode *qn = NULL; 2122 - struct throtl_grp *tg = blkg_to_tg(blkg); 2132 + struct throtl_grp *tg = blkg_to_tg(blkg ?: q->root_blkg); 2123 2133 struct throtl_service_queue *sq; 2124 2134 bool rw = bio_data_dir(bio); 2125 2135 bool throttled = false; ··· 2148 2138 if (unlikely(blk_queue_bypass(q))) 2149 2139 goto out_unlock; 2150 2140 2141 + blk_throtl_assoc_bio(tg, bio); 2151 2142 blk_throtl_update_idletime(tg); 2152 2143 2153 2144 sq = &tg->service_queue;
+1 -3
block/bounce.c
··· 276 276 } 277 277 } 278 278 279 - bio_clone_blkg_association(bio, bio_src); 280 - 281 - blkcg_bio_issue_init(bio); 279 + bio_clone_blkcg_association(bio, bio_src); 282 280 283 281 return bio; 284 282 }
+2 -2
block/cfq-iosched.c
··· 3759 3759 uint64_t serial_nr; 3760 3760 3761 3761 rcu_read_lock(); 3762 - serial_nr = __bio_blkcg(bio)->css.serial_nr; 3762 + serial_nr = bio_blkcg(bio)->css.serial_nr; 3763 3763 rcu_read_unlock(); 3764 3764 3765 3765 /* ··· 3824 3824 struct cfq_group *cfqg; 3825 3825 3826 3826 rcu_read_lock(); 3827 - cfqg = cfq_lookup_cfqg(cfqd, __bio_blkcg(bio)); 3827 + cfqg = cfq_lookup_cfqg(cfqd, bio_blkcg(bio)); 3828 3828 if (!cfqg) { 3829 3829 cfqq = &cfqd->oom_cfqq; 3830 3830 goto out;
+11 -5
drivers/block/brd.c
··· 396 396 disk->first_minor = i * max_part; 397 397 disk->fops = &brd_fops; 398 398 disk->private_data = brd; 399 - disk->queue = brd->brd_queue; 400 399 disk->flags = GENHD_FL_EXT_DEVT; 401 400 sprintf(disk->disk_name, "ram%d", i); 402 401 set_capacity(disk, rd_size * 2); 403 - disk->queue->backing_dev_info->capabilities |= BDI_CAP_SYNCHRONOUS_IO; 402 + brd->brd_queue->backing_dev_info->capabilities |= BDI_CAP_SYNCHRONOUS_IO; 404 403 405 404 /* Tell the block layer that this is not a rotational device */ 406 - blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); 407 - blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); 405 + blk_queue_flag_set(QUEUE_FLAG_NONROT, brd->brd_queue); 406 + blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, brd->brd_queue); 408 407 409 408 return brd; 410 409 ··· 435 436 436 437 brd = brd_alloc(i); 437 438 if (brd) { 439 + brd->brd_disk->queue = brd->brd_queue; 438 440 add_disk(brd->brd_disk); 439 441 list_add_tail(&brd->brd_list, &brd_devices); 440 442 } ··· 503 503 504 504 /* point of no return */ 505 505 506 - list_for_each_entry(brd, &brd_devices, brd_list) 506 + list_for_each_entry(brd, &brd_devices, brd_list) { 507 + /* 508 + * associate with queue just before adding disk for 509 + * avoiding to mess up failure path 510 + */ 511 + brd->brd_disk->queue = brd->brd_queue; 507 512 add_disk(brd->brd_disk); 513 + } 508 514 509 515 blk_register_region(MKDEV(RAMDISK_MAJOR, 0), 1UL << MINORBITS, 510 516 THIS_MODULE, brd_probe, NULL, NULL);
+2 -3
drivers/block/loop.c
··· 77 77 #include <linux/falloc.h> 78 78 #include <linux/uio.h> 79 79 #include <linux/ioprio.h> 80 - #include <linux/blk-cgroup.h> 81 80 82 81 #include "loop.h" 83 82 ··· 1759 1760 1760 1761 /* always use the first bio's css */ 1761 1762 #ifdef CONFIG_BLK_CGROUP 1762 - if (cmd->use_aio && rq->bio && rq->bio->bi_blkg) { 1763 - cmd->css = &bio_blkcg(rq->bio)->css; 1763 + if (cmd->use_aio && rq->bio && rq->bio->bi_css) { 1764 + cmd->css = rq->bio->bi_css; 1764 1765 css_get(cmd->css); 1765 1766 } else 1766 1767 #endif
+2 -2
drivers/block/mtip32xx/mtip32xx.c
··· 1942 1942 dev_warn(&dd->pdev->dev, 1943 1943 "data movement but " 1944 1944 "sect_count is 0\n"); 1945 - err = -EINVAL; 1946 - goto abort; 1945 + err = -EINVAL; 1946 + goto abort; 1947 1947 } 1948 1948 } 1949 1949 }
+1 -1
drivers/md/raid0.c
··· 542 542 !discard_bio) 543 543 continue; 544 544 bio_chain(discard_bio, bio); 545 - bio_clone_blkg_association(discard_bio, bio); 545 + bio_clone_blkcg_association(discard_bio, bio); 546 546 if (mddev->gendisk) 547 547 trace_block_bio_remap(bdev_get_queue(rdev->bdev), 548 548 discard_bio, disk_devt(mddev->gendisk),
+1 -1
drivers/nvme/host/fc.c
··· 1704 1704 op->fcp_req.rspaddr = &op->rsp_iu; 1705 1705 op->fcp_req.rsplen = sizeof(op->rsp_iu); 1706 1706 op->fcp_req.done = nvme_fc_fcpio_done; 1707 - op->fcp_req.private = &op->fcp_req.first_sgl[SG_CHUNK_SIZE]; 1708 1707 op->ctrl = ctrl; 1709 1708 op->queue = queue; 1710 1709 op->rq = rq; ··· 1751 1752 if (res) 1752 1753 return res; 1753 1754 op->op.fcp_req.first_sgl = &op->sgl[0]; 1755 + op->op.fcp_req.private = &op->priv[0]; 1754 1756 return res; 1755 1757 } 1756 1758
+4 -1
drivers/nvme/host/pci.c
··· 1663 1663 struct pci_dev *pdev = to_pci_dev(dev->dev); 1664 1664 int bar; 1665 1665 1666 + if (dev->cmb_size) 1667 + return; 1668 + 1666 1669 dev->cmbsz = readl(dev->bar + NVME_REG_CMBSZ); 1667 1670 if (!dev->cmbsz) 1668 1671 return; ··· 2150 2147 { 2151 2148 struct pci_dev *pdev = to_pci_dev(dev->dev); 2152 2149 2153 - nvme_release_cmb(dev); 2154 2150 pci_free_irq_vectors(pdev); 2155 2151 2156 2152 if (pci_is_enabled(pdev)) { ··· 2597 2595 nvme_stop_ctrl(&dev->ctrl); 2598 2596 nvme_remove_namespaces(&dev->ctrl); 2599 2597 nvme_dev_disable(dev, true); 2598 + nvme_release_cmb(dev); 2600 2599 nvme_free_host_mem(dev); 2601 2600 nvme_dev_remove_admin(dev); 2602 2601 nvme_free_queues(dev, 0);
+5 -5
fs/buffer.c
··· 3060 3060 */ 3061 3061 bio = bio_alloc(GFP_NOIO, 1); 3062 3062 3063 + if (wbc) { 3064 + wbc_init_bio(wbc, bio); 3065 + wbc_account_io(wbc, bh->b_page, bh->b_size); 3066 + } 3067 + 3063 3068 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); 3064 3069 bio_set_dev(bio, bh->b_bdev); 3065 3070 bio->bi_write_hint = write_hint; ··· 3083 3078 if (buffer_prio(bh)) 3084 3079 op_flags |= REQ_PRIO; 3085 3080 bio_set_op_attrs(bio, op, op_flags); 3086 - 3087 - if (wbc) { 3088 - wbc_init_bio(wbc, bio); 3089 - wbc_account_io(wbc, bh->b_page, bh->b_size); 3090 - } 3091 3081 3092 3082 submit_bio(bio); 3093 3083 return 0;
+1 -1
fs/ext4/page-io.c
··· 374 374 bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES); 375 375 if (!bio) 376 376 return -ENOMEM; 377 + wbc_init_bio(io->io_wbc, bio); 377 378 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); 378 379 bio_set_dev(bio, bh->b_bdev); 379 380 bio->bi_end_io = ext4_end_bio; 380 381 bio->bi_private = ext4_get_io_end(io->io_end); 381 382 io->io_bio = bio; 382 383 io->io_next_block = bh->b_blocknr; 383 - wbc_init_bio(io->io_wbc, bio); 384 384 return 0; 385 385 } 386 386
+9 -17
include/linux/bio.h
··· 503 503 disk_devt((bio)->bi_disk) 504 504 505 505 #if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP) 506 - int bio_associate_blkg_from_page(struct bio *bio, struct page *page); 506 + int bio_associate_blkcg_from_page(struct bio *bio, struct page *page); 507 507 #else 508 - static inline int bio_associate_blkg_from_page(struct bio *bio, 509 - struct page *page) { return 0; } 508 + static inline int bio_associate_blkcg_from_page(struct bio *bio, 509 + struct page *page) { return 0; } 510 510 #endif 511 511 512 512 #ifdef CONFIG_BLK_CGROUP 513 + int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css); 513 514 int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg); 514 - int bio_associate_blkg_from_css(struct bio *bio, 515 - struct cgroup_subsys_state *css); 516 - int bio_associate_create_blkg(struct request_queue *q, struct bio *bio); 517 - int bio_reassociate_blkg(struct request_queue *q, struct bio *bio); 518 515 void bio_disassociate_task(struct bio *bio); 519 - void bio_clone_blkg_association(struct bio *dst, struct bio *src); 516 + void bio_clone_blkcg_association(struct bio *dst, struct bio *src); 520 517 #else /* CONFIG_BLK_CGROUP */ 521 - static inline int bio_associate_blkg_from_css(struct bio *bio, 522 - struct cgroup_subsys_state *css) 523 - { return 0; } 524 - static inline int bio_associate_create_blkg(struct request_queue *q, 525 - struct bio *bio) { return 0; } 526 - static inline int bio_reassociate_blkg(struct request_queue *q, struct bio *bio) 527 - { return 0; } 518 + static inline int bio_associate_blkcg(struct bio *bio, 519 + struct cgroup_subsys_state *blkcg_css) { return 0; } 528 520 static inline void bio_disassociate_task(struct bio *bio) { } 529 - static inline void bio_clone_blkg_association(struct bio *dst, 530 - struct bio *src) { } 521 + static inline void bio_clone_blkcg_association(struct bio *dst, 522 + struct bio *src) { } 531 523 #endif /* CONFIG_BLK_CGROUP */ 532 524 533 525 #ifdef CONFIG_HIGHMEM
+48 -103
include/linux/blk-cgroup.h
··· 126 126 struct request_list rl; 127 127 128 128 /* reference count */ 129 - struct percpu_ref refcnt; 129 + atomic_t refcnt; 130 130 131 131 /* is this blkg online? protected by both blkcg and q locks */ 132 132 bool online; ··· 184 184 185 185 struct blkcg_gq *blkg_lookup_slowpath(struct blkcg *blkcg, 186 186 struct request_queue *q, bool update_hint); 187 - struct blkcg_gq *__blkg_lookup_create(struct blkcg *blkcg, 188 - struct request_queue *q); 189 187 struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg, 190 188 struct request_queue *q); 191 189 int blkcg_init_queue(struct request_queue *q); ··· 230 232 char *input, struct blkg_conf_ctx *ctx); 231 233 void blkg_conf_finish(struct blkg_conf_ctx *ctx); 232 234 233 - /** 234 - * blkcg_css - find the current css 235 - * 236 - * Find the css associated with either the kthread or the current task. 237 - * This may return a dying css, so it is up to the caller to use tryget logic 238 - * to confirm it is alive and well. 239 - */ 240 - static inline struct cgroup_subsys_state *blkcg_css(void) 241 - { 242 - struct cgroup_subsys_state *css; 243 - 244 - css = kthread_blkcg(); 245 - if (css) 246 - return css; 247 - return task_css(current, io_cgrp_id); 248 - } 249 235 250 236 static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css) 251 237 { 252 238 return css ? container_of(css, struct blkcg, css) : NULL; 253 239 } 254 240 255 - /** 256 - * __bio_blkcg - internal version of bio_blkcg for bfq and cfq 257 - * 258 - * DO NOT USE. 259 - * There is a flaw using this version of the function. In particular, this was 260 - * used in a broken paradigm where association was called on the given css. It 261 - * is possible though that the returned css from task_css() is in the process 262 - * of dying due to migration of the current task. So it is improper to assume 263 - * *_get() is going to succeed. Both BFQ and CFQ rely on this logic and will 264 - * take additional work to handle more gracefully. 265 - */ 266 - static inline struct blkcg *__bio_blkcg(struct bio *bio) 267 - { 268 - if (bio && bio->bi_blkg) 269 - return bio->bi_blkg->blkcg; 270 - return css_to_blkcg(blkcg_css()); 271 - } 272 - 273 - /** 274 - * bio_blkcg - grab the blkcg associated with a bio 275 - * @bio: target bio 276 - * 277 - * This returns the blkcg associated with a bio, NULL if not associated. 278 - * Callers are expected to either handle NULL or know association has been 279 - * done prior to calling this. 280 - */ 281 241 static inline struct blkcg *bio_blkcg(struct bio *bio) 282 242 { 283 - if (bio && bio->bi_blkg) 284 - return bio->bi_blkg->blkcg; 285 - return NULL; 243 + struct cgroup_subsys_state *css; 244 + 245 + if (bio && bio->bi_css) 246 + return css_to_blkcg(bio->bi_css); 247 + css = kthread_blkcg(); 248 + if (css) 249 + return css_to_blkcg(css); 250 + return css_to_blkcg(task_css(current, io_cgrp_id)); 286 251 } 287 252 288 253 static inline bool blk_cgroup_congested(void) ··· 451 490 */ 452 491 static inline void blkg_get(struct blkcg_gq *blkg) 453 492 { 454 - percpu_ref_get(&blkg->refcnt); 493 + WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0); 494 + atomic_inc(&blkg->refcnt); 455 495 } 456 496 457 497 /** 458 - * blkg_tryget - try and get a blkg reference 498 + * blkg_try_get - try and get a blkg reference 459 499 * @blkg: blkg to get 460 500 * 461 501 * This is for use when doing an RCU lookup of the blkg. We may be in the midst 462 502 * of freeing this blkg, so we can only use it if the refcnt is not zero. 463 503 */ 464 - static inline bool blkg_tryget(struct blkcg_gq *blkg) 504 + static inline struct blkcg_gq *blkg_try_get(struct blkcg_gq *blkg) 465 505 { 466 - return percpu_ref_tryget(&blkg->refcnt); 506 + if (atomic_inc_not_zero(&blkg->refcnt)) 507 + return blkg; 508 + return NULL; 467 509 } 468 510 469 - /** 470 - * blkg_tryget_closest - try and get a blkg ref on the closet blkg 471 - * @blkg: blkg to get 472 - * 473 - * This walks up the blkg tree to find the closest non-dying blkg and returns 474 - * the blkg that it did association with as it may not be the passed in blkg. 475 - */ 476 - static inline struct blkcg_gq *blkg_tryget_closest(struct blkcg_gq *blkg) 477 - { 478 - while (!percpu_ref_tryget(&blkg->refcnt)) 479 - blkg = blkg->parent; 480 511 481 - return blkg; 482 - } 512 + void __blkg_release_rcu(struct rcu_head *rcu); 483 513 484 514 /** 485 515 * blkg_put - put a blkg reference ··· 478 526 */ 479 527 static inline void blkg_put(struct blkcg_gq *blkg) 480 528 { 481 - percpu_ref_put(&blkg->refcnt); 529 + WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0); 530 + if (atomic_dec_and_test(&blkg->refcnt)) 531 + call_rcu(&blkg->rcu_head, __blkg_release_rcu); 482 532 } 483 533 484 534 /** ··· 533 579 534 580 rcu_read_lock(); 535 581 536 - if (bio && bio->bi_blkg) { 537 - blkcg = bio->bi_blkg->blkcg; 538 - if (blkcg == &blkcg_root) 539 - goto rl_use_root; 582 + blkcg = bio_blkcg(bio); 540 583 541 - blkg_get(bio->bi_blkg); 542 - rcu_read_unlock(); 543 - return &bio->bi_blkg->rl; 544 - } 545 - 546 - blkcg = css_to_blkcg(blkcg_css()); 584 + /* bypass blkg lookup and use @q->root_rl directly for root */ 547 585 if (blkcg == &blkcg_root) 548 - goto rl_use_root; 549 - 550 - blkg = blkg_lookup(blkcg, q); 551 - if (unlikely(!blkg)) 552 - blkg = __blkg_lookup_create(blkcg, q); 553 - 554 - if (blkg->blkcg == &blkcg_root || !blkg_tryget(blkg)) 555 - goto rl_use_root; 556 - 557 - rcu_read_unlock(); 558 - return &blkg->rl; 586 + goto root_rl; 559 587 560 588 /* 561 - * Each blkg has its own request_list, however, the root blkcg 562 - * uses the request_queue's root_rl. This is to avoid most 563 - * overhead for the root blkcg. 589 + * Try to use blkg->rl. blkg lookup may fail under memory pressure 590 + * or if either the blkcg or queue is going away. Fall back to 591 + * root_rl in such cases. 564 592 */ 565 - rl_use_root: 593 + blkg = blkg_lookup(blkcg, q); 594 + if (unlikely(!blkg)) 595 + goto root_rl; 596 + 597 + blkg_get(blkg); 598 + rcu_read_unlock(); 599 + return &blkg->rl; 600 + root_rl: 566 601 rcu_read_unlock(); 567 602 return &q->root_rl; 568 603 } ··· 797 854 struct bio *bio) { return false; } 798 855 #endif 799 856 800 - 801 - static inline void blkcg_bio_issue_init(struct bio *bio) 802 - { 803 - bio_issue_init(&bio->bi_issue, bio_sectors(bio)); 804 - } 805 - 806 857 static inline bool blkcg_bio_issue_check(struct request_queue *q, 807 858 struct bio *bio) 808 859 { 860 + struct blkcg *blkcg; 809 861 struct blkcg_gq *blkg; 810 862 bool throtl = false; 811 863 812 864 rcu_read_lock(); 865 + blkcg = bio_blkcg(bio); 813 866 814 - bio_associate_create_blkg(q, bio); 815 - blkg = bio->bi_blkg; 867 + /* associate blkcg if bio hasn't attached one */ 868 + bio_associate_blkcg(bio, &blkcg->css); 869 + 870 + blkg = blkg_lookup(blkcg, q); 871 + if (unlikely(!blkg)) { 872 + spin_lock_irq(q->queue_lock); 873 + blkg = blkg_lookup_create(blkcg, q); 874 + if (IS_ERR(blkg)) 875 + blkg = NULL; 876 + spin_unlock_irq(q->queue_lock); 877 + } 816 878 817 879 throtl = blk_throtl_bio(q, blkg, bio); 818 880 819 881 if (!throtl) { 882 + blkg = blkg ?: q->root_blkg; 820 883 /* 821 884 * If the bio is flagged with BIO_QUEUE_ENTERED it means this 822 885 * is a split bio and we would have already accounted for the ··· 833 884 bio->bi_iter.bi_size); 834 885 blkg_rwstat_add(&blkg->stat_ios, bio->bi_opf, 1); 835 886 } 836 - 837 - blkcg_bio_issue_init(bio); 838 887 839 888 rcu_read_unlock(); 840 889 return !throtl; ··· 930 983 static inline void blkcg_deactivate_policy(struct request_queue *q, 931 984 const struct blkcg_policy *pol) { } 932 985 933 - static inline struct blkcg *__bio_blkcg(struct bio *bio) { return NULL; } 934 986 static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; } 935 987 936 988 static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg, ··· 945 999 static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl) { } 946 1000 static inline struct request_list *blk_rq_rl(struct request *rq) { return &rq->q->root_rl; } 947 1001 948 - static inline void blkcg_bio_issue_init(struct bio *bio) { } 949 1002 static inline bool blkcg_bio_issue_check(struct request_queue *q, 950 1003 struct bio *bio) { return true; } 951 1004
+1
include/linux/blk_types.h
··· 178 178 * release. Read comment on top of bio_associate_current(). 179 179 */ 180 180 struct io_context *bi_ioc; 181 + struct cgroup_subsys_state *bi_css; 181 182 struct blkcg_gq *bi_blkg; 182 183 struct bio_issue bi_issue; 183 184 #endif
-2
include/linux/cgroup.h
··· 93 93 94 94 bool css_has_online_children(struct cgroup_subsys_state *css); 95 95 struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss); 96 - struct cgroup_subsys_state *cgroup_e_css(struct cgroup *cgroup, 97 - struct cgroup_subsys *ss); 98 96 struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgroup, 99 97 struct cgroup_subsys *ss); 100 98 struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
+2 -3
include/linux/writeback.h
··· 246 246 * 247 247 * @bio is a part of the writeback in progress controlled by @wbc. Perform 248 248 * writeback specific initialization. This is used to apply the cgroup 249 - * writeback context. Must be called after the bio has been associated with 250 - * a device. 249 + * writeback context. 251 250 */ 252 251 static inline void wbc_init_bio(struct writeback_control *wbc, struct bio *bio) 253 252 { ··· 257 258 * regular writeback instead of writing things out itself. 258 259 */ 259 260 if (wbc->wb) 260 - bio_associate_blkg_from_css(bio, wbc->wb->blkcg_css); 261 + bio_associate_blkcg(bio, wbc->wb->blkcg_css); 261 262 } 262 263 263 264 #else /* CONFIG_CGROUP_WRITEBACK */
+9 -39
kernel/cgroup/cgroup.c
··· 493 493 } 494 494 495 495 /** 496 - * cgroup_e_css_by_mask - obtain a cgroup's effective css for the specified ss 496 + * cgroup_e_css - obtain a cgroup's effective css for the specified subsystem 497 497 * @cgrp: the cgroup of interest 498 498 * @ss: the subsystem of interest (%NULL returns @cgrp->self) 499 499 * ··· 502 502 * enabled. If @ss is associated with the hierarchy @cgrp is on, this 503 503 * function is guaranteed to return non-NULL css. 504 504 */ 505 - static struct cgroup_subsys_state *cgroup_e_css_by_mask(struct cgroup *cgrp, 506 - struct cgroup_subsys *ss) 505 + static struct cgroup_subsys_state *cgroup_e_css(struct cgroup *cgrp, 506 + struct cgroup_subsys *ss) 507 507 { 508 508 lockdep_assert_held(&cgroup_mutex); 509 509 ··· 521 521 } 522 522 523 523 return cgroup_css(cgrp, ss); 524 - } 525 - 526 - /** 527 - * cgroup_e_css - obtain a cgroup's effective css for the specified subsystem 528 - * @cgrp: the cgroup of interest 529 - * @ss: the subsystem of interest 530 - * 531 - * Find and get the effective css of @cgrp for @ss. The effective css is 532 - * defined as the matching css of the nearest ancestor including self which 533 - * has @ss enabled. If @ss is not mounted on the hierarchy @cgrp is on, 534 - * the root css is returned, so this function always returns a valid css. 535 - * 536 - * The returned css is not guaranteed to be online, and therefore it is the 537 - * callers responsiblity to tryget a reference for it. 538 - */ 539 - struct cgroup_subsys_state *cgroup_e_css(struct cgroup *cgrp, 540 - struct cgroup_subsys *ss) 541 - { 542 - struct cgroup_subsys_state *css; 543 - 544 - do { 545 - css = cgroup_css(cgrp, ss); 546 - 547 - if (css) 548 - return css; 549 - cgrp = cgroup_parent(cgrp); 550 - } while (cgrp); 551 - 552 - return init_css_set.subsys[ss->id]; 553 524 } 554 525 555 526 /** ··· 605 634 * 606 635 * Should be called under cgroup_[tree_]mutex. 607 636 */ 608 - #define for_each_e_css(css, ssid, cgrp) \ 609 - for ((ssid) = 0; (ssid) < CGROUP_SUBSYS_COUNT; (ssid)++) \ 610 - if (!((css) = cgroup_e_css_by_mask(cgrp, \ 611 - cgroup_subsys[(ssid)]))) \ 612 - ; \ 637 + #define for_each_e_css(css, ssid, cgrp) \ 638 + for ((ssid) = 0; (ssid) < CGROUP_SUBSYS_COUNT; (ssid)++) \ 639 + if (!((css) = cgroup_e_css(cgrp, cgroup_subsys[(ssid)]))) \ 640 + ; \ 613 641 else 614 642 615 643 /** ··· 1007 1037 * @ss is in this hierarchy, so we want the 1008 1038 * effective css from @cgrp. 1009 1039 */ 1010 - template[i] = cgroup_e_css_by_mask(cgrp, ss); 1040 + template[i] = cgroup_e_css(cgrp, ss); 1011 1041 } else { 1012 1042 /* 1013 1043 * @ss is not in this hierarchy, so we don't want ··· 3024 3054 return ret; 3025 3055 3026 3056 /* 3027 - * At this point, cgroup_e_css_by_mask() results reflect the new csses 3057 + * At this point, cgroup_e_css() results reflect the new csses 3028 3058 * making the following cgroup_update_dfl_csses() properly update 3029 3059 * css associations of all tasks in the subtree. 3030 3060 */
+2 -2
kernel/trace/blktrace.c
··· 764 764 if (!bt || !(blk_tracer_flags.val & TRACE_BLK_OPT_CGROUP)) 765 765 return NULL; 766 766 767 - if (!bio->bi_blkg) 767 + if (!bio->bi_css) 768 768 return NULL; 769 - return cgroup_get_kernfs_id(bio_blkcg(bio)->css.cgroup); 769 + return cgroup_get_kernfs_id(bio->bi_css->cgroup); 770 770 } 771 771 #else 772 772 static union kernfs_node_id *
+1 -1
mm/page_io.c
··· 339 339 goto out; 340 340 } 341 341 bio->bi_opf = REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc); 342 - bio_associate_blkg_from_page(bio, page); 342 + bio_associate_blkcg_from_page(bio, page); 343 343 count_swpout_vm_event(page); 344 344 set_page_writeback(page); 345 345 unlock_page(page);