summaryrefslogtreecommitdiffstats
path: root/block/bfq-iosched.h
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2023-01-03 09:47:55 +0100
committerJens Axboe <axboe@kernel.dk>2023-01-16 04:53:27 +0100
commit216f764716f34fe68cedc7296ae2043a7727e640 (patch)
tree2e5261483bfdff8833f016b56ea997a1b48294d7 /block/bfq-iosched.h
parentMerge branch 'md-fixes' of https://git.kernel.org/pub/scm/linux/kernel/git/so... (diff)
downloadlinux-216f764716f34fe68cedc7296ae2043a7727e640.tar.xz
linux-216f764716f34fe68cedc7296ae2043a7727e640.zip
block, bfq: switch 'bfqg->ref' to use atomic refcount apis
The updating of 'bfqg->ref' should be protected by 'bfqd->lock', however, during code review, we found that bfq_pd_free() update 'bfqg->ref' without holding the lock, which is problematic: 1) bfq_pd_free() triggered by removing cgroup is called asynchronously; 2) bfqq will grab bfqg reference, and exit bfqq will drop the reference, which can concurrent with 1). Unfortunately, 'bfqd->lock' can't be held here because 'bfqd' might already be freed in bfq_pd_free(). Fix the problem by using atomic refcount apis. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230103084755.1256479-1-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bfq-iosched.h')
-rw-r--r--block/bfq-iosched.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 41aa151ccc22..466e4865ace6 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -928,7 +928,7 @@ struct bfq_group {
char blkg_path[128];
/* reference counter (see comments in bfq_bic_update_cgroup) */
- int ref;
+ refcount_t ref;
/* Is bfq_group still online? */
bool online;