Skip to content

fix blkcg offlining and destruction

Dennis Zhou cgroups linux-block lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Revert "blk-throttle: fix race between blkcg_bio_issue_check() and cgroup_rmdir()"block/blk-cgroup.c include/linux/blk-cgroup.h+16 -630 replies
2/3blkcg: delay blkg destruction until after writeback has finishedblock/blk-cgroup.c include/linux/blk-cgroup.h mm/backing-dev.c+94 -80 replies
3/3blkcg: use tryget logic when associating a blkg with a bioblock/bio.c block/blk-throttle.c+5 -30 replies

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchTejun Heo
SeriesA-b
1/3
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] fix blkcg offlining and destruction

Hi everyone,

This is a split of an earlier series I sent out [1] containing the first 3 patches with fixes from feedback. This series tackles the first problem where blkcgs were not being destroyed.

There is a regression in blkcg destruction where references weren't properly put causing blkcgs to never be destroyed. Previously, blkgs were destroyed during offlining of the blkcg. This puts back the blkcg reference a blkg holds allowing blkcg ref to reach zero. Then, blkcg_css_free() is called as part of the final cleanup.

To address the problem, 0001 reverts the broken commit, 0002 delays blkg destruction until writeback has finished, and 0003 closes the window on a race condition between a css migration and dying, and blkg association. This should fix the issue where blkg_get() was getting called when a blkcg had already begun exiting. If a bio finds itself here, it will just fall back to root. Oddly enough at one point, blk-throttle was using policy data from and associating with potentially different blkgs, thus how this was exposed.

[1] https://lore.kernel.org/lkml/[email protected]/T

This patchset contains the following 3 patches:
0001-Revert-blk-throttle-fix-race-between-blkcg_bio_issue.patch 0002-blkcg-delay-blkg-destruction-until-after-writeback-h.patch 0003-blkcg-use-tryget-logic-when-associating-a-blkg-with-.patch

0001 reverts the broken commit.
0002 delays blkg destruction until after writeback. 0003 fixes a race condition for ongoing IO and blkcg destruction.

This patchset is on top of axboe#for-4.19/block b86d865cb1ca.

diffstats below:

Dennis Zhou (Facebook) (3):
Revert "blk-throttle: fix race between blkcg_bio_issue_check() and

    cgroup_rmdir()"

blkcg: delay blkg destruction until after writeback has finished
blkcg: use tryget logic when associating a blkg with a bio

 block/bio.c                |   3 +-
 block/blk-cgroup.c         | 105 +++++++++++++++++--------------------
 block/blk-throttle.c       |   5 +-
 include/linux/blk-cgroup.h |  45 +++++++++++++++-
 mm/backing-dev.c           |   5 ++
 5 files changed, 102 insertions(+), 61 deletions(-)

Thanks,
Dennis