函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\block_dev.c Create Date:2022-07-29 10:46:07
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:d_mutex locking:* mutex_lock(part->bd_mutex)* mutex_lock_nested(whole->bd_mutex, 1)

函数原型:static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)

返回类型:int

参数:

类型参数名称
struct block_device *bdev
fmode_tmode
intfor_part
1562  perm等于0
1563  bool first_open = false
1565  如果mode按位与le is open for reading perm或等于MAY_READ
1567  如果mode按位与le is open for writing perm或等于MAY_WRITE
1572  如果非for_part
1573  ret等于devcgroup_inode_permission( will die , perm)
1574  如果ret不等于0则
1575  bdput(bdev)
1576  返回:ret
1580  restart :
1582  ret等于负ENXIO
1583  disk等于bdev_get_gendisk(bdev, & partno)
1584  如果非disk则转到:out
1587  disk_block_events(disk)
1588  mutex_lock_nested( & open/close mutex , for_part)
1589  如果非bd_openers
1590  first_open = true
1591  bd_disk等于disk
1592  bd_queue等于queue
1593  bd_contains等于bdev
1594  bd_partno等于partno
1596  如果非partno
1597  ret等于负ENXIO
1599  如果非bd_part则转到:out_clear
1602  ret等于0
1603  如果open
1621  如果非ret
1632  如果bd_invalidated且非retret恒等于负ENOMEDIUM的值则bdev_disk_changed(bdev, ret == - ENOMEDIUM)
1636  如果ret则转到:out_clear
1638  否则
1641  ret等于负ENOMEM
1642  如果非whole则转到:out_clear
1644  BUG_ON(for_part)
1646  如果ret则转到:out_clear
1648  bd_contains等于whole
1650  如果非flags按位与GENHD_FL_UP的值或非bd_part或非nr_sects
1652  ret等于负ENXIO
1653  转到:out_clear
1655  bd_set_size(bdev, (loff_t)nr_sects << 9)
1659  如果bd_bdi恒等于noop_backing_dev_infobd_bdi等于bdi_get(backing_dev_info)
1661  否则
1662  如果bd_contains恒等于bdev
1663  ret等于0
1664  如果openret等于open(bdev, mode)
1667  如果bd_invalidated且非retret恒等于负ENOMEDIUM的值则bdev_disk_changed(bdev, ret == - ENOMEDIUM)
1670  如果ret则转到:out_unlock_bdev
1674  bd_openers自加
1675  如果for_part 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  如果非first_openput_disk_and_module(disk)
1682  返回:0
1684  out_clear :
1685  disk_put_part(bd_part)
1686  bd_disk = NULL
1687  bd_part = NULL
1688  bd_queue = NULL
1689  如果bdev不等于bd_contains__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  返回:ret
调用者
名称描述
__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