您的位置:首页 > 编程语言

[文件系统]文件系统学习笔记(十一)——部分代码详解

2014-08-12 15:12 531 查看
1,alloc_vfsmnt()函数

static struct mount *alloc_vfsmnt(const char *name)
{
struct mount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);//在slab高速缓存mnt_cache上分配一个mount结构体,在Namespace.c文件的mnt_int()函数中调用kmem_cache_creat()函数创建名为mnt_cache的缓存
if (mnt) {
int err;
err = mnt_alloc_id(mnt);
if (err)
goto out_free_cache;
if (name) {
mnt->mnt_devname = kstrdup(name, GFP_KERNEL);//将mount->mnt_devname变量赋值为设备名(如/dev/block/mmcblk0p7等)
if (!mnt->mnt_devname)
goto out_free_id;
}
mnt->mnt_pcp = alloc_percpu(struct mnt_pcp);//分配per-cpu变量,每个cpu维护一个变量的副本,每个cpu只会操作到自己cpu对应数组的那个元素
if (!mnt->mnt_pcp)
goto out_free_devname;
this_cpu_add(mnt->mnt_pcp->mnt_count, 1);
INIT_LIST_HEAD(&mnt->mnt_hash);
INIT_LIST_HEAD(&mnt->mnt_child);
INIT_LIST_HEAD(&mnt->mnt_mounts);
INIT_LIST_HEAD(&mnt->mnt_list);
INIT_LIST_HEAD(&mnt->mnt_expire);
INIT_LIST_HEAD(&mnt->mnt_share);
INIT_LIST_HEAD(&mnt->mnt_slave_list);
INIT_LIST_HEAD(&mnt->mnt_slave);
INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks);
}
return mnt;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐