-
Notifications
You must be signed in to change notification settings - Fork 0
blk-mq: fix possible deadlocks #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
blktests-ci
wants to merge
13
commits into
linus-master_base
Choose a base branch
from
series/1028951=>linus-master
base: linus-master_base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To move implementation details inside blk-wbt.c, prepare to fix possible deadlock to call wbt_init() while queue is frozen in the next patch. Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
…_counter If wbt is disabled by default and user configures wbt by sysfs, queue will be frozen first and then pcpu_alloc_mutex will be held in blk_stat_alloc_callback(). Fix this problem by allocating memory first before queue frozen. Signed-off-by: Yu Kuai <yukuai@fnnas.com>
There is already a helper blk_mq_debugfs_register_rqos() to register one rqos, however this helper is called synchronously when the rqos is created with queue frozen. Prepare to fix possible deadlock to create blk-mq debugfs entries while queue is still frozen. Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Currently rq-qos debugfs entries are created from rq_qos_add(), while rq_qos_add() can be called while queue is still frozen. This can deadlock because creating new entries can trigger fs reclaim. Fix this problem by delaying creating rq-qos debugfs entries after queue is unfrozen. - For wbt, 1) it can be initialized by default, fix it by calling new helper after wbt_init() from wbt_init_enable_default(); 2) it can be initialized by sysfs, fix it by calling new helper after queue is unfrozen from wbt_set_lat(). - For iocost and iolatency, they can only be initialized by blkcg configuration, however, they don't have debugfs entries for now, hence they are not handled yet. Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Because it's only used inside blk-mq-debugfs.c now. Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Because this helper is only used by iocost and iolatency, while they don't have debugfs entries. Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Creating new debugfs entries can trigger fs reclaim, hence we can't do this with queue frozen, meanwhile, other locks that can be held while queue is frozen should not be held as well. Signed-off-by: Yu Kuai <yukuai@fnnas.com>
blk_throtl_init() can be called with rq_qos_mutex held from blkcg configuration, and fs reclaim can be triggered because GFP_KERNEL is used to allocate memory. This can deadlock because rq_qos_mutex can be held with queue frozen. Fix the problem by using blkg_conf_open_bdev_frozen(), also remove useless queue frozen from blk_throtl_init(). Signed-off-by: Yu Kuai <yukuai@fnnas.com>
queue should not be frozen under rq_qos_mutex, see example from commit 9730763 ("block: correct locking order for protecting blk-wbt parameters"), which means current implementation of rq_qos_add() is problematic. Add a new helper and prepare to fix this problem in following patches. Signed-off-by: Yu Kuai <yukuai@fnnas.com>
wbt_init() can be called from sysfs attribute and wbt_init_enable_default(), however queue_wb_lat_store() can freeze queue first, and then wbt_init() will hold rq_qos_mutex. Fix this problem by converting to use new helper rq_qos_add_frozen() in wbt_init(), and freeze queue before calling wbt_init() from wbt_init_enable_default(). Fixes: a13bd91 ("block/rq_qos: protect rq_qos apis with a new lock") Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Like wbt, rq_qos_add() can be called from two path and the lock order are inversely: - From ioc_qos_write(), queue is already frozen before rq_qos_add(); - From ioc_cost_model_write(), rq_qos_add() is called directly; Fix this problem by converting to use blkg_conf_open_bdev_frozen() from ioc_cost_model_write(), then since all rq_qos_add() callers already freeze queue, convert to use rq_qos_add_frozen(). Signed-off-by: Yu Kuai <yukuai@fnnas.com>
…ueue Currently blk-iolatency will hold rq_qos_mutex first and then call rq_qos_add() to freeze queue. Fix this problem by converting to use blkg_conf_open_bdev_frozen() from iolatency_set_limit(), and convert to use rq_qos_add_frozen(). Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Now that there is no caller of rq_qos_add(), remove it, and also rename rq_qos_add_frozen() back to rq_qos_add(). Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Author
|
Upstream branch: d26143b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: blk-mq: fix possible deadlocks
version: 6
url: https://patchwork.kernel.org/project/linux-block/list/?series=1036552