Skip to content

Commit 763b589

Browse files
mcgrofaxboe
authored andcommitted
block: clarify context for refcount increment helpers
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 <mcgrof@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b5bd357 commit 763b589

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

block/blk-core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ EXPORT_SYMBOL(blk_alloc_queue);
610610
* @q: the request_queue structure to increment the refcount for
611611
*
612612
* Increment the refcount of the request_queue kobject.
613+
*
614+
* Context: Any context.
613615
*/
614616
bool blk_get_queue(struct request_queue *q)
615617
{

block/genhd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,11 +985,15 @@ static ssize_t disk_badblocks_store(struct device *dev,
985985
*
986986
* This function gets the structure containing partitioning
987987
* information for the given device @devt.
988+
*
989+
* Context: can sleep
988990
*/
989991
struct gendisk *get_gendisk(dev_t devt, int *partno)
990992
{
991993
struct gendisk *disk = NULL;
992994

995+
might_sleep();
996+
993997
if (MAJOR(devt) != BLOCK_EXT_MAJOR) {
994998
struct kobject *kobj;
995999

@@ -1764,6 +1768,8 @@ EXPORT_SYMBOL(__alloc_disk_node);
17641768
*
17651769
* This increments the refcount for the struct gendisk, and the gendisk's
17661770
* fops module owner.
1771+
*
1772+
* Context: Any context.
17671773
*/
17681774
struct kobject *get_disk_and_module(struct gendisk *disk)
17691775
{

0 commit comments

Comments
 (0)