super block这个数据结构,乃至super block在磁盘上的位置,是哪里的规定?

没规定,1k偏移只是ext文件系统.但是像fat,它们第0扇区后就是保留扇区,但linux一样要识别它们.

知道这个现象就能搞清楚了:双系统的ntf分区,在linux下一样是可以识别并正常操作的,但那些文件系统可能连superblock的概念都没有.

vfs层不干预"文件系统格式",所以super block自然也不能干涉.

再说内存里的super block,它跟inode, dentry, file并列vfs的四大数据结构.(看到网上有谁这么一说)

super block总是觉得不知道它是干嘛的,抽象出来这么一个东西.

其实大概3个作用:

1,文件系统总览,这个文件系统的大致信息.像block size等等.

2,作为一个文件系统的root数据结构,像dentry里是直接存着到sb的指针的.它上面还有一些字段,估计vfs层做统一处理时,用得着.要维护某些状态.

3,文件系统提供的一大批函数操作是由这个结构里的指针指向的,叫做super_operation.

结构:

    struct super_block
{
struct list_head s_list;/* Keep this first */// 连接super_block的链表
dev_t s_dev;/* search index; _not_ kdev_t */
unsignedlong s_blocksize;
unsignedlong s_old_blocksize;
unsignedchar s_blocksize_bits;
unsignedchar s_dirt;
unsignedlonglong s_maxbytes;/* Max file size */
struct file_system_type *s_type;// 所表示的文件系统的类型
struct super_operations *s_op;// 文件相关操作函数集合表
struct dquot_operations *dq_op;//
struct quotactl_ops *s_qcop;//
struct export_operations *s_export_op;//
unsignedlong s_flags;//
unsignedlong s_magic;//
struct dentry *s_root;// Linux文件系统中某个索引节点(inode)的链接
struct rw_semaphore s_umount;//
struct semaphore s_lock;//
int s_count;//
int s_syncing;//
int s_need_sync_fs;//
atomic_t s_active;//
void*s_security;//
struct xattr_handler **s_xattr;//
struct list_head s_inodes;/* all inodes */// 链接文件系统的inode
struct list_head s_dirty;/* dirty inodes */
struct list_head s_io;/* parked for writeback */
struct hlist_head s_anon;/* anonymous dentries for (nfs) exporting */
struct list_head s_files;// 对于每一个打开的文件,由file对象来表示。链接文件系统中file
struct block_device *s_bdev;//
struct list_head s_instances;//
struct quota_info s_dquot;/* Diskquota specific options */
int s_frozen;//
wait_queue_head_t s_wait_unfrozen;//
char s_id[];/* Informational name */
void*s_fs_info;/* Filesystem private info */
/**
* The next field is for VFS *only*. No filesystems have any business
* even looking at it. You had been warned.
*/
struct semaphore s_vfs_rename_sem;/* Kludge */
/* Granuality of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran;
};

ext2,3的blocksize可以是1,2,4,8kb.

ext4的blocksize可以是1~64kb.

blocksize的大小会影响:

1,最大文件体积.

2,文件系统最大体积.(Maxiumn File System Size,应该是容量)

3,性能

VFS,super_block,inode,dentry—结构体图解  (这篇写的不错)

linux vfs四大对象之一 superblock

vfs的super block的更多相关文章

  1. block(data block,directory block)、inode、块位图、inode位图和super block概念详解【转】

    本文转载自:https://blog.csdn.net/jhndiuowehu/article/details/50788287 一.基本概念:      1.block:文件系统中存储数据的最小单元 ...

  2. VFS

    VFS的作用:为文件系统提供通用的接口. 通用文件模型:common file model.特殊文件系统需要将它的物理结构转换成通用文件模型. common file model包括以下几个重要对象: ...

  3. VFS对象总结

    关键术语: 超级快(super block)对象: 一个超级块对应一个具体的文件系统(已经安装的文件系统类型如 ext2,此处是实际的文件系统,不是 VFS). iNode 对象: inode是内核文 ...

  4. Ext2文件系统布局,文件数据块寻址,VFS虚拟文件系统

    注:本分类下文章大多整理自<深入分析linux内核源代码>一书,另有参考其他一些资料如<linux内核完全剖析>.<linux c 编程一站式学习>等,只是为了更好 ...

  5. VFS四大对象之一 struct super_block

    linux虚拟文件系统四大对象: 1)超级块(super block) 2)索引节点(inode) 3)目录项(dentry) 4)文件对象(file) 现在先介绍第一个 一.super_block的 ...

  6. 解析Linux中的VFS文件系统之文件系统的注册(二)

    继上一篇文章:http://www.cnblogs.com/linhaostudy/p/7397024.html 3. 文件系统的注册 这里的文件系统是指可能会被挂载到目录树中的各个实际文件系统,所谓 ...

  7. 解析Linux中的VFS文件系统机制

    转载:原文地址https://www.ibm.com/developerworks/cn/linux/l-vfs/ 1. 摘要 本文阐述 Linux 中的文件系统部分,源代码来自基于 IA32 的 2 ...

  8. VFS文件系统结构分析

    VFS是Linux非常核心的一个概念,linux下的大部分操作都要用到VFS的相关功能.这里从使用者的角度,对VFS进行了简单说明.使用者不但需要知道Linux下有哪些文件操作的函数,还需要对VFS的 ...

  9. VFS,super_block,inode,dentry—结构体图解

    总结: VFS只存在于内存中,它在系统启动时被创建,系统关闭时注销. VFS的作用就是屏蔽各类文件系统的差异,给用户.应用程序.甚至Linux其他管理模块提供统一的接口集合. 管理VFS数据结构的组成 ...

随机推荐

  1. 【面经分享】前端小白半年准备,成功进入bat

    先介绍下背景 非211,985本科毕业.一年半PHP经验,一年半前端经验,前端一直在做React开发. 半年之前,我是一个前端小小小白.多么小白呢? css调样式全靠试. 盒模型,好像知道是啥?好像又 ...

  2. ThreadPoolExecutor实现异步多线程

    import time from concurrent.futures import ThreadPoolExecutor executor = ThreadPoolExecutor(max_work ...

  3. react-native 异常处理 Execution failed for task ':app:mergeDebugResources'.

    1.react-native run-android 失败 * What went wrong:Execution failed for task ':app:mergeDebugResources' ...

  4. storm集群搭建和java应用

    1. vim /etc/hosts ssh免密登录192.168.132.154 c0192.168.132.156 c1192.168.132.155 c2 storm集群:192.168.132. ...

  5. Linux实用技巧--隧道

    平时开发过程中,可能会遇到一些网络问题,比如npm install 一些依赖包.本地电脑是可以,没有问题.但是测试环境服务器,由于公司内部网络安全限制,不可以随意访问外部网络.因此下载一个依赖包就变得 ...

  6. Activation Functions and Their Derivatives

    1. Sigmoid Function: when z=0,g'(z)=0.25 2. tanh Function: when x=0,tanh'(x)=1 3. Relu

  7. vuejs基础-style样式

    在Vue中使用样式 使用class样式 数组 <h1 :class="['red', 'thin']">这是一个邪恶的H1</h1> 数组中使用三元表达式 ...

  8. call,apply,bind的用法和细节差异

    call,apply,bind的用法 call,apply和bind都用来改变js中this对象的指向 var dog = { name:'dog', speak: function(value){ ...

  9. Linux Interactive Exploit Development with GDB and PEDA

    Exploit Development Process● Occupy EIP● Find the offset(s)● Determine the attack vector● Build the ...

  10. Codeforces - 1194E - Count The Rectangles - 扫描线

    https://codeforc.es/contest/1194/problem/E 给5000条正常的(同方向不会重叠,也不会退化成点的)线段,他们都是平行坐标轴方向的,求能组成多少个矩形. 先进行 ...