struct bdev_inode {
struct block_device bdev;
struct inode vfs_inode;
};
struct block_device *bdget(dev_t dev)
{
struct block_device *bdev;}
给定dev_t dev,可通过该函数查找或创建请求的块设备。
struct inode *iget5_locked(struct super_block *sb, unsigned long hashval,
int (*test)(struct inode *, void *),
int (*set)(struct inode *, void *), void *data)
{
struct hlist_head *head = inode_hashtable + hash(sb, hashval);
struct inode *inode;
inode = ifind(sb, head, test, data, 1);
if (inode)
return inode;
/*
* get_new_inode() will do the right thing, re-trying the search
* in case it had to block at any point.
*/
return get_new_inode(sb, head, test, set, data);
}
iget5_locked(...)使用ifind()函数查找由hashval和data指定的inode或创建新的inode.
该inode经过container_of获取bdev_inode类型指针
然后由获得的bdev_inode指针对 struct block_device bdev进行操作。如果是新创建的,则初始化;否则直接返回以创建的bdev.