Skip to content

Commit

Permalink
block: switch bdgrab to use igrab
Browse files Browse the repository at this point in the history
All of the current callers already have a reference, but to prepare for
additional users ensure bdgrab returns NULL if the block device is being
freed.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Dec 1, 2020
1 parent 612c6aa commit 3a4174e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,10 +894,14 @@ static struct block_device *bdget(dev_t dev)
/**
* bdgrab -- Grab a reference to an already referenced block device
* @bdev: Block device to grab a reference to.
*
* Returns the block_device with an additional reference when successful,
* or NULL if the inode is already beeing freed.
*/
struct block_device *bdgrab(struct block_device *bdev)
{
ihold(bdev->bd_inode);
if (!igrab(bdev->bd_inode))
return NULL;
return bdev;
}
EXPORT_SYMBOL(bdgrab);
Expand Down

0 comments on commit 3a4174e

Please sign in to comment.