Skip to content

Commit

Permalink
block: clarify context for refcount increment helpers
Browse files Browse the repository at this point in the history
Let us clarify the context under which the helpers to increment the
refcount for the gendisk and request_queue can be called under. We
make this explicit on the places where we may sleep with might_sleep().

We don't address the decrement context yet, as that needs some extra
work and fixes, but will be addressed in the next patch.

Signed-off-by: Luis Chamberlain <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Bart Van Assche <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
mcgrof authored and axboe committed Jun 24, 2020
1 parent b5bd357 commit 763b589
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ EXPORT_SYMBOL(blk_alloc_queue);
* @q: the request_queue structure to increment the refcount for
*
* Increment the refcount of the request_queue kobject.
*
* Context: Any context.
*/
bool blk_get_queue(struct request_queue *q)
{
Expand Down
6 changes: 6 additions & 0 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,11 +985,15 @@ static ssize_t disk_badblocks_store(struct device *dev,
*
* This function gets the structure containing partitioning
* information for the given device @devt.
*
* Context: can sleep
*/
struct gendisk *get_gendisk(dev_t devt, int *partno)
{
struct gendisk *disk = NULL;

might_sleep();

if (MAJOR(devt) != BLOCK_EXT_MAJOR) {
struct kobject *kobj;

Expand Down Expand Up @@ -1764,6 +1768,8 @@ EXPORT_SYMBOL(__alloc_disk_node);
*
* This increments the refcount for the struct gendisk, and the gendisk's
* fops module owner.
*
* Context: Any context.
*/
struct kobject *get_disk_and_module(struct gendisk *disk)
{
Expand Down

0 comments on commit 763b589

Please sign in to comment.