Pull block fixes from Jens Axboe: "Small collection of fixes that should go into this release. This contains: - Small series that fixes a race between blkcg teardown and writeback (Dennis Zhou) - Fix disallowing invalid block size settings from the nbd ioctl (me) - BFQ fix for a use-after-free on last release of a bfqg (Konstantin Khlebnikov) - Fix for the "don't warn for flush" fix (Mikulas)" * tag 'for-linus-20180906' of git://git.kernel.dk/linux-block: block: bfq: swap puts in bfqg_and_blkg_put block: don't warn when doing fsync on read-only devices nbd: don't allow invalid blocksize settings blkcg: use tryget logic when associating a blkg with a bio blkcg: delay blkg destruction until after writeback has finished Revert "blk-throttle: fix race between blkcg_bio_issue_check() and cgroup_rmdir()"
Showing the changes to include/linux (1 of 8 files). Show all
Unified · Split
| @@ -56,6 +56,7 @@ struct blkcg { · 55 unmodified lines | ||
| 56 | 56 | struct list_head all_blkcgs_node; |
| 57 | 57 | #ifdef CONFIG_CGROUP_WRITEBACK |
| 58 | 58 | struct list_head cgwb_list; |
| 59 | + refcount_t cgwb_refcnt; | |
| 59 | 60 | #endif |
| 60 | 61 | }; |
| 61 | 62 | |
| @@ -89,7 +90,6 @@ struct blkg_policy_data { · 27 unmodified lines | ||
| 89 | 90 | /* the blkg and policy id this per-policy data belongs to */ |
| 90 | 91 | struct blkcg_gq *blkg; |
| 91 | 92 | int plid; |
| 92 | − bool offline; | |
| 93 | 93 | }; |
| 94 | 94 | |
| 95 | 95 | /* |
| @@ -387,6 +387,49 @@ static inline struct blkcg *cpd_to_blkcg(struct blkcg_policy_data *cpd) · 291 unmodified lines | ||
| 387 | 387 | return cpd ? cpd->blkcg : NULL; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | +extern void blkcg_destroy_blkgs(struct blkcg *blkcg); | |
| 391 | + | |
| 392 | +#ifdef CONFIG_CGROUP_WRITEBACK | |
| 393 | + | |
| 394 | +/** | |
| 395 | + * blkcg_cgwb_get - get a reference for blkcg->cgwb_list | |
| 396 | + * @blkcg: blkcg of interest | |
| 397 | + * | |
| 398 | + * This is used to track the number of active wb's related to a blkcg. | |
| 399 | + */ | |
| 400 | +static inline void blkcg_cgwb_get(struct blkcg *blkcg) | |
| 401 | +{ | |
| 402 | + refcount_inc(&blkcg->cgwb_refcnt); | |
| 403 | +} | |
| 404 | + | |
| 405 | +/** | |
| 406 | + * blkcg_cgwb_put - put a reference for @blkcg->cgwb_list | |
| 407 | + * @blkcg: blkcg of interest | |
| 408 | + * | |
| 409 | + * This is used to track the number of active wb's related to a blkcg. | |
| 410 | + * When this count goes to zero, all active wb has finished so the | |
| 411 | + * blkcg can continue destruction by calling blkcg_destroy_blkgs(). | |
| 412 | + * This work may occur in cgwb_release_workfn() on the cgwb_release | |
| 413 | + * workqueue. | |
| 414 | + */ | |
| 415 | +static inline void blkcg_cgwb_put(struct blkcg *blkcg) | |
| 416 | +{ | |
| 417 | + if (refcount_dec_and_test(&blkcg->cgwb_refcnt)) | |
| 418 | + blkcg_destroy_blkgs(blkcg); | |
| 419 | +} | |
| 420 | + | |
| 421 | +#else | |
| 422 | + | |
| 423 | +static inline void blkcg_cgwb_get(struct blkcg *blkcg) { } | |
| 424 | + | |
| 425 | +static inline void blkcg_cgwb_put(struct blkcg *blkcg) | |
| 426 | +{ | |
| 427 | + /* wb isn't being accounted, so trigger destruction right away */ | |
| 428 | + blkcg_destroy_blkgs(blkcg); | |
| 429 | +} | |
| 430 | + | |
| 431 | +#endif | |
| 432 | + | |
| 390 | 433 | /** |
| 391 | 434 | * blkg_path - format cgroup path of blkg |
| 392 | 435 | * @blkg: blkg of interest |