免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3237 | 回复: 4
打印 上一主题 下一主题

super_block结构中的s_count是什么? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-14 14:26 |只看该作者 |倒序浏览
小弟这几天看代码
super.c中put_super函数的注释:
/**
*        put_super        -        drop a temporary reference to superblock
*        @sb: superblock in question
*
*        Drops a temporary reference, frees superblock if there's no
*        references left */
super_block结构中的s_count是什么意思?drop a temporary reference to superblock:这里边谁在reference superblock,temptorary又怎么是理解的?谢谢~~

论坛徽章:
0
2 [报告]
发表于 2008-04-14 14:33 |只看该作者
还有deactivate_super这个函数
/**
*        deactivate_super        -        drop an active reference to superblock
*        @s: superblock to deactivate
*
*        Drops an active reference to superblock, acquiring a temprory one if
*        there is no active references left.  In that case we lock superblock,
*        tell fs driver to shut it down and drop the temporary reference we
*        had just acquired.
*/
void deactivate_super(struct super_block *s)
{
        struct file_system_type *fs = s->s_type;
        if (atomic_dec_and_lock(&s->s_active, &sb_lock)) {
                s->s_count -= S_BIAS-1;
                spin_unlock(&sb_lock);
                DQUOT_OFF(s);
                down_write(&s->s_umount);
                fs->kill_sb(s);
                put_filesystem(fs);
                put_super(s);
        }
}
注释中说的drop an active reference to superblock,active reference该怎么理解?

论坛徽章:
0
3 [报告]
发表于 2008-04-15 23:54 |只看该作者
s_active表示这个super_block为活跃中,既s_root有效;
s_count说明super_block有引用,不能释放到SLAB,但不一定为活跃,既s_root不一定有效。

论坛徽章:
0
4 [报告]
发表于 2008-04-17 20:32 |只看该作者
to 楼上的:
《linux内核设计和实现》中说s_active是活动引用数,可以理解为无符号整型,依你s_active表示super_block活动中,那不是只有活跃和不活跃两种情况?
我现在不理解何为对super_block的引用(打开了文件系统中的文件?),另外活跃是什么意思也不知道。谢谢~~

论坛徽章:
0
5 [报告]
发表于 2008-04-18 10:05 |只看该作者
比如说,mm_struct的引用数中有两个,一是mm_count,另一是mm_user。
mm_count是引用数,表示这个mm_struct能否被释放到SLAB;
mm_user表示有多少进程在使用这个mm_struct。不管mm_user值为多少,反映在mm_count中,一律算做一个mm_count。

super block与这个类似,s_count是真正的引用数,s_active表示被mount了多少次。不管s_active值为多少,反映到s_count中,一律算做S_BIAS个s_count
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP