设为首页 加入收藏

TOP

VFS四大对象之一 struct super_block(一)
2017-10-11 15:10:41 】 浏览:10072
Tags:VFS 四大 对象 之一 struct super_block

linux虚拟文件系统四大对象:

1)超级块(super block)

2)索引节点(inode)

3)目录项(dentry)

4)文件对象(file)

现在先介绍第一个

一、super_block的含义:

超级块代表了整个文件系统,超级块是文件系统的控制块,有整个文件系统信息,一个文件系统所有的inode都要连接到超级块上,可以说,一个超级块就代表了一个文件系统。

说到inode是啥?参照下一篇博客;

 1 struct super_block {
 2     struct list_head    s_list;        /* Keep this first */
 3     dev_t            s_dev;        /* search index; _not_ kdev_t */
 4     unsigned char        s_dirt;
 5     unsigned char        s_blocksize_bits;
 6     unsigned long        s_blocksize;
 7     loff_t            s_maxbytes;    /* Max file size */
 8     struct file_system_type    *s_type;
 9     const struct super_operations    *s_op;
10     const struct dquot_operations    *dq_op;
11     const struct quotactl_ops    *s_qcop;
12     const struct export_operations *s_export_op;
13     unsigned long        s_flags;
14     unsigned long        s_magic;
15     struct dentry        *s_root;
16     struct rw_semaphore    s_umount;
17     struct mutex        s_lock;
18     int            s_count;
19     atomic_t        s_active;
20 #ifdef CONFIG_SECURITY
21     void                    *s_security;
22 #endif
23     const struct xattr_handler **s_xattr;
24 
25     struct list_head    s_inodes;    /* all inodes */
26     struct hlist_bl_head    s_anon;        /* anonymous dentries for (nfs) exporting */
27 #ifdef CONFIG_SMP
28     struct list_head __percpu *s_files;
29 #else
30     struct list_head    s_files;
31 #endif
32     struct list_head    s_mounts;    /* list of mounts; _not_ for fs use */
33     /* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */
34     struct list_head    s_dentry_lru;    /* unused dentry lru */
35     int            s_nr_dentry_unused;    /* # of dentry on lru */
36 
37     /* s_inode_lru_lock protects s_inode_lru and s_nr_inodes_unused */
38     spinlock_t        s_inode_lru_lock ____cacheline_aligned_in_smp;
39     struct list_head    s_inode_lru;        /* unused inode lru */
40     int            s_nr_inodes_unused;    /* # of inodes on lru */
41 
42     struct block_device    *s_bdev;
43     struct backing_dev_info *s_bdi;
44     struct mtd_info        *s_mtd;
45     struct hlist_node    s_instances;
46     struct quota_info    s_dquot;    /* Diskquota specific options */
47 
48     int            s_frozen;
49     wait_queue_head_t    s_wait_unfrozen;
50 
51     char s_id[32];                /* Informational name */
52     u8 s_uuid[16];                /* UUID */
53 
54     void             *s_fs_info;    /* Filesystem private info */
55     unsigned int        s_max_links;
56     fmode_t            s_mode;
57 
58     /* Granularity of c/m/atime in ns.
59        Cannot be worse than a second */
60     u32           s_time_gran;
61 
62     /*
63      * The next field is for VFS *only*. No filesystems have any business
64      * even looking at it. You had been warned.
65      */
66     struct mutex s_vfs_rename_mutex;    /* Kludge */
67 
68     /*
69      * Filesystem subtype.  If non-empty the filesystem type field
70      * in /proc/mounts will be "type.subtype"
71      */
72     char *s_subtype;
73 
74     /*
75      * Saved mount options for lazy filesystems using
76      * generic_show_options()
77      */
78     char __rcu *s_options;
79     const struct dentry_operations *s_d_op; /* default d_op for dentries */
80 
81     /*
82      * Saved pool identifier for cleancache (-1 means none)
83      */
84     int cleancache_poolid;
85 
86     struct shrinker s_shrink;    /* per-sb shrinker handle */
87 
88     /* Number of inodes with nlink == 0 but still referenced */
89     atomic_long_t s_remove_count;
90 
91     /* Being remounted read-only */
92     int s_readonly_remount;
93 };

 

这个数据结构十分庞大,毕竟是聚集了一个文件系统的重要信息,我们关注一些比较重要的信息就行了。

 

1 struct list_head    s_list;

s_list 这是第一个成员,是一个双向循环链表,把所有的super_block连接起来,一个super_block代表一个在linux上的文件系统,这个list上边的就是所有的在linux上记录的文件系统。

 

1 dev_t s_dev;

&

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇51单片机 | 1-Wire总线及应用实例 下一篇VFS四大对象之二 struct inode

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目