mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
block: switch bdgrab to use igrab
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 <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
612c6aa781
commit
3a4174e686
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user