linux内核super_block结构分析
·
超级块代表了整个文件系统,超级块是文件系统的控制块,有整个文件系统信息,一个文件系统所有的inode都要连接到超级块上,可以说,一个超级块就代表了一个文件系统。
super_block定义在include/linux/fs.h里,我们来看一看这个数据结构的定义
这个数据结构十分庞大,毕竟是聚集了一个文件系统的重要信息,我们关注一些比较重要的信息就行了,如果全都要知道也记不住。
struct list_head s_list;
这是第一个成员,是一个双向循环链表,把所有的super_block连接起来,一个super_block代表一个在linux上的文件系统,这个list上边的就是所有的在linux上记录的文件系统。
dev_t s_dev;
设备标识符
unsigned long s_blocksize;
unsigned char s_blocksize_bits;
unsigned char s_dirt;
unsigned long long s_maxbytes; /* Max file size */
这四个成员变量分别对应这文件系统的块大小,块大小的位数,是否文件系统脏,最大文件大小。
struct file_system_type *s_type;
这个结构体是文件系统类型的结构体,里边是对文件系统的细节描述,每一个文件系统只有一个这个结构体。
const struct super_operations *s_op;
super_block的操作函数集合。
struct dquot_operations *dq_op;
struct quotactl_ops *s_qcop;
struct export_operations *s_export_op;
文件系统的配额操作函数集合,文件系统的配额控制操作函数集合,网络文件系统的导出操作函数集合。
unsigned long s_flags;
文件系统的超级块的状态位。
unsigned long s_magic;
每一个超级块有一个唯一的魔术数标记。
struct dentry *s_root;
超级块内的指向根目录的dentry结构体。
struct rw_semaphore s_umount;
文件系统卸载时候用到的读写信号量。
struct mutex s_lock;
专用的互斥量。
int s_count;
引用计数。
int s_syncing;
文件系统的同步标记位。
int s_need_sync_fs;
需要同步的标记位。
atomic_t s_active;
原子文件系统引用计数。
#ifdef CONFIG_SECURITY
void *s_security;
#endif
如果定义了CONFIG_SECURITY宏,就会定义这个专门的指针,用于安全保护。
struct xattr_handler **s_xattr;
属性操作结构体。
struct list_head s_inodes; /* all inodes */
所有的这个文件系统的inode结构体都在这个队列上。
struct list_head s_dirty; /* dirty inodes */
所有这个文件系统的脏的inode结构体都在这个队列上。
struct list_head s_io; /* parked for writeback */
所有这个文件系统的将要写入的inode都在这个队列上。
struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */
所有的远程网络文件系统匿名目录项的集合。
struct list_head s_files;
所有进程打开的文件集合。
struct block_device *s_bdev;
文件系统的块设备信息,现在的文件一通一般都是磁盘上,所以一般都是磁盘。
struct mtd_info *s_mtd;
类内存设备信息。
char s_id[32];
这个就是文件系统的名字。
void *s_fs_info;
文件系统的私有信息指针。
super_block定义在include/linux/fs.h里,我们来看一看这个数据结构的定义
struct super_block {
struct list_head s_list; /* Keep this first */
dev_t s_dev; /* search index; _not_ kdev_t */
unsigned long s_blocksize;
unsigned char s_blocksize_bits;
unsigned char s_dirt;
unsigned long long s_maxbytes; /* Max file size */
struct file_system_type *s_type;
const struct super_operations *s_op;
struct dquot_operations *dq_op;
struct quotactl_ops *s_qcop;
struct export_operations *s_export_op;
unsigned long s_flags;
unsigned long s_magic;
struct dentry *s_root;
struct rw_semaphore s_umount;
struct mutex s_lock;
int s_count;
int s_syncing;
int s_need_sync_fs;
atomic_t s_active;
#ifdef CONFIG_SECURITY
void *s_security;
#endif
struct xattr_handler **s_xattr;
struct list_head s_inodes; /* all inodes */
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;
struct block_device *s_bdev;
struct mtd_info *s_mtd;
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[32]; /* 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 mutex s_vfs_rename_mutex; /* Kludge */
/* Granularity of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran;
/*
* Filesystem subtype. If non-empty the filesystem type field
* in /proc/mounts will be "type.subtype"
*/
char *s_subtype;
};这个数据结构十分庞大,毕竟是聚集了一个文件系统的重要信息,我们关注一些比较重要的信息就行了,如果全都要知道也记不住。
struct list_head s_list;
这是第一个成员,是一个双向循环链表,把所有的super_block连接起来,一个super_block代表一个在linux上的文件系统,这个list上边的就是所有的在linux上记录的文件系统。
dev_t s_dev;
设备标识符
unsigned long s_blocksize;
unsigned char s_blocksize_bits;
unsigned char s_dirt;
unsigned long long s_maxbytes; /* Max file size */
这四个成员变量分别对应这文件系统的块大小,块大小的位数,是否文件系统脏,最大文件大小。
struct file_system_type *s_type;
这个结构体是文件系统类型的结构体,里边是对文件系统的细节描述,每一个文件系统只有一个这个结构体。
const struct super_operations *s_op;
super_block的操作函数集合。
struct dquot_operations *dq_op;
struct quotactl_ops *s_qcop;
struct export_operations *s_export_op;
文件系统的配额操作函数集合,文件系统的配额控制操作函数集合,网络文件系统的导出操作函数集合。
unsigned long s_flags;
文件系统的超级块的状态位。
unsigned long s_magic;
每一个超级块有一个唯一的魔术数标记。
struct dentry *s_root;
超级块内的指向根目录的dentry结构体。
struct rw_semaphore s_umount;
文件系统卸载时候用到的读写信号量。
struct mutex s_lock;
专用的互斥量。
int s_count;
引用计数。
int s_syncing;
文件系统的同步标记位。
int s_need_sync_fs;
需要同步的标记位。
atomic_t s_active;
原子文件系统引用计数。
#ifdef CONFIG_SECURITY
void *s_security;
#endif
如果定义了CONFIG_SECURITY宏,就会定义这个专门的指针,用于安全保护。
struct xattr_handler **s_xattr;
属性操作结构体。
struct list_head s_inodes; /* all inodes */
所有的这个文件系统的inode结构体都在这个队列上。
struct list_head s_dirty; /* dirty inodes */
所有这个文件系统的脏的inode结构体都在这个队列上。
struct list_head s_io; /* parked for writeback */
所有这个文件系统的将要写入的inode都在这个队列上。
struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */
所有的远程网络文件系统匿名目录项的集合。
struct list_head s_files;
所有进程打开的文件集合。
struct block_device *s_bdev;
文件系统的块设备信息,现在的文件一通一般都是磁盘上,所以一般都是磁盘。
struct mtd_info *s_mtd;
类内存设备信息。
char s_id[32];
这个就是文件系统的名字。
void *s_fs_info;
文件系统的私有信息指针。
更多推荐
所有评论(0)