Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\block_dev.c Create Date:2022-07-28 20:14:49
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:d_mutex locking:* mutex_lock(part->bd_mutex)* mutex_lock_nested(whole->bd_mutex, 1)

Proto:static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)

Type:int

Parameter:

TypeParameterName
struct block_device *bdev
fmode_tmode
intfor_part
1562  perm = 0
1563  bool first_open = false
1565  If mode & le is open for reading Then perm |= MAY_READ
1567  If mode & le is open for writing Then perm |= MAY_WRITE
1572  If Not for_part Then
1573  ret = devcgroup_inode_permission( will die , perm)
1574  If ret != 0 Then
1575  bdput(bdev)
1576  Return ret
1580  restart :
1582  ret = -ENXIO
1583  disk = bdev_get_gendisk(bdev, & partno)
1584  If Not disk Then Go to out
1587  disk_block_events(disk)
1588  mutex_lock_nested( & open/close mutex , for_part)
1589  If Not bd_openers Then
1590  first_open = true
1591  bd_disk = disk
1592  bd_queue = queue
1593  bd_contains = bdev
1594  bd_partno = partno
1596  If Not partno Then
1597  ret = -ENXIO
1599  If Not bd_part Then Go to out_clear
1602  ret = 0
1603  If open Then
1621  If Not ret Then
1632  If bd_invalidated && ( Not ret || ret == -ENOMEDIUM ) Then bdev_disk_changed(bdev, ret == - ENOMEDIUM)
1636  If ret Then Go to out_clear
1638  Else
1641  ret = -ENOMEM
1642  If Not whole Then Go to out_clear
1644  BUG_ON(for_part)
1646  If ret Then Go to out_clear
1648  bd_contains = whole
1650  If Not (flags & GENHD_FL_UP) || Not bd_part || Not nr_sects Then
1652  ret = -ENXIO
1653  Go to out_clear
1655  bd_set_size(bdev, (loff_t)nr_sects << 9)
1659  If bd_bdi == noop_backing_dev_info Then bd_bdi = bdi_get(backing_dev_info)
1661  Else
1662  If bd_contains == bdev Then
1663  ret = 0
1664  If open Then ret = open(bdev, mode)
1667  If bd_invalidated && ( Not ret || ret == -ENOMEDIUM ) Then bdev_disk_changed(bdev, ret == - ENOMEDIUM)
1670  If ret Then Go to out_unlock_bdev
1674  bd_openers++
1675  If for_part Then number of times partitions within this device have been opened. ++
1677  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
1678  disk_unblock_events(disk)
1680  If Not first_open Then put_disk_and_module(disk)
1682  Return 0
1684  out_clear :
1685  disk_put_part(bd_part)
1686  bd_disk = NULL
1687  bd_part = NULL
1688  bd_queue = NULL
1689  If bdev != bd_contains Then __blkdev_put(bd_contains, mode, 1)
1691  bd_contains = NULL
1692  out_unlock_bdev :
1693  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
1694  disk_unblock_events(disk)
1695  put_disk_and_module(disk)
1696  out :
1697  bdput(bdev)
1699  Return ret
Caller
NameDescribe
__blkdev_getd_mutex locking:* mutex_lock(part->bd_mutex)* mutex_lock_nested(whole->bd_mutex, 1)
blkdev_getlkdev_get - open a block device*@bdev: block_device to open*@mode: FMODE_* mask*@holder: exclusive holder identifier* Open @bdev with @mode. If @mode includes %FMODE_EXCL, @bdev is* open with exclusive access. Specifying %FMODE_EXCL with %NULL