很多朋友对于superblock是什么意思、读音和VFS四大对象之一 struct super_block不太懂,今天就由小编来为大家分享,希望可以帮助到大家,下面一起来看看吧!
1、超级块代表了整个文件系统,超级块是文件系统的控制块,有整个文件系统信息,一个文件系统所有的inode都要连接到超级块上,可以说,一个超级块就代表了一个文件系统。
2、structsuper_block{\nstructlist_heads_list;/*Keepthisfirst*/\ndev_ts_dev;/*searchindex;_not_kdev_t*/\nunsignedchars_dirt;\nunsignedchars_blocksize_bits;\nunsignedlongs_blocksize;\nloff_ts_maxbytes;/*Maxfilesize*/\nstructfile_system_type*s_type;\nconststructsuper_operations*s_op;\nconststructdquot_operations*dq_op;\nconststructquotactl_ops*s_qcop;\nconststructexport_operations*s_export_op;\nunsignedlongs_flags;\nunsignedlongs_magic;\nstructdentry*s_root;\nstructrw_semaphores_umount;\nstructmutexs_lock;\nints_count;\natomic_ts_active;\n#ifdefCONFIG_SECURITY\nvoid*s_security;\n#endif\nconststructxattr_handler**s_xattr;\nstructlist_heads_inodes;/*allinodes*/\nstructhlist_bl_heads_anon;/*anonymousdentriesfor(nfs)exporting*/\n#ifdefCONFIG_SMP\nstructlist_head__percpu*s_files;\n#else\nstructlist_heads_files;\n#endif\nstructlist_heads_mounts;/*listofmounts;_not_forfsuse*/\n/*s_dentry_lru,s_nr_dentry_unusedprotectedbydcache.clrulocks*/\nstructlist_heads_dentry_lru;/*unuseddentrylru*/\nints_nr_dentry_unused;/*#ofdentryonlru*/\n/*s_inode_lru_lockprotectss_inode_lruands_nr_inodes_unused*/\nspinlock_ts_inode_lru_lock____cacheline_aligned_in_smp;\nstructlist_heads_inode_lru;/*unusedinodelru*/\nints_nr_inodes_unused;/*#ofinodesonlru*/\nstructblock_device*s_bdev;\nstructbacking_dev_info*s_bdi;\nstructmtd_info*s_mtd;\nstructhlist_nodes_instances;\nstructquota_infos_dquot;/*Diskquotaspecificoptions*/\nints_frozen;\nwait_queue_head_ts_wait_unfrozen;\nchars_id[32];/*Informationalname*/\nu8s_uuid[16];/*UUID*/\nvoid*s_fs_info;/*Filesystemprivateinfo*/\nunsignedints_max_links;\nfmode_ts_mode;\n/*Granularityofc/m/atimeinns.\nCannotbeworsethanasecond*/\nu32s_time_gran;\n/*\n*ThenextfieldisforVFS*only*.Nofilesystemshaveanybusiness\n*evenlookingatit.Youhadbeenwarned.\n*/\nstructmutexs_vfs_rename_mutex;/*Kludge*/\n/*\n*Filesystemsubtype.Ifnon-emptythefilesystemtypefield\n*in/proc/mountswillbe"type.subtype"\n*/\nchar*s_subtype;\n/*\n*Savedmountoptionsforlazyfilesystemsusing\n*generic_show_options()\n*/\nchar__rcu*s_options;\nconststructdentry_operations*s_d_op;/*defaultd_opfordentries*/\n/*\n*Savedpoolidentifierforcleancache(-1meansnone)\n*/\nintcleancache_poolid;\nstructshrinkers_shrink;/*per-sbshrinkerhandle*/\n/*Numberofinodeswithnlink==0butstillreferenced*/\natomic_long_ts_remove_count;\n/*Beingremountedread-only*/\nints_readonly_remount;\n};\n\n
这个数据结构十分庞大,毕竟是聚集了一个文件系统的重要信息,我们关注一些比较重要的信息就行了。
3、structlist_heads_list;\n
s_list这是第一个成员,是一个双向循环链表,把所有的super_block连接起来,一个super_block代表一个在linux上的文件系统,这个list上边的就是所有的在linux上记录的文件系统。
4、dev_ts_dev;\n
s_dev:设备标识符
5、unsignedchars_dirt;\nunsignedchars_blocksize_bits;\nunsignedlongs_blocksize;\nloff_ts_maxbytes;/*Maxfilesize*/\n
s_dev:包含该具体文件系统的块设备标识符。例如,对于/dev/hda1,其设备标识符为0x301
6、s_blocksize:文件系统中数据块大小,以字节单位
7、s_blocksize_bits:上面的size大小占用位数,例如512字节就是9bits
8、s_dirt:脏位,标识是否超级块被修改
9、loff_ts_maxbytes;/*Maxfilesize*/\n
s_maxbytes:允许的最大的文件大小(字节数)
10、structfile_system_type*s_type;\n
structfile_system_type*s_type:文件系统类型(也就是当前这个文件系统属于哪个类型?ext2还是fat32)要区分“文件系统”和“文件系统类型”不一样!一个文件系统类型下可以包括很多文件系统即很多的super_block。
11、conststructsuper_operations*s_op;\nconststructdquot_operations*dq_op;\n
structsuper_operations*s_op:指向某个特定的具体文件系统的用于超级块操作的函数集合。
12、structdquot_operations*dq_op:指向某个特定的具体文件系统用于限额操作的函数集合。
13、conststructexport_operations*s_export_op;\n
structexport_operations*s_export_op:导出方法
14、unsignedlongs_flags;\n
s_flags:安装标识
15、unsignedlongs_magic;\n
s_magic:区别于其他文件系统的标识
16、structdentry*s_root;\n
s_root:指向该具体文件系统安装目录的目录项
17、structrw_semaphores_umount;\n
s_umount:对超级块读写时进行同步
18、structmutexs_lock;\n
s_lock:锁标志位,若置该位,则其它进程不能对该超级块操作
19、ints_count;\n
s_count:对超级块的使用计数
20、atomic_ts_active;\n
s_active:引用计数
21、s_dirty:已修改的索引节点inode形成的链表,一个文件系统中有很多的inode,有些inode节点的内容会被修改,那么会先被记录,然后写回磁盘。
22、s_locked_inodes:要进行同步的索引节点形成的链表
23、s_files:所有的已经打开文件的链表,这个file和实实在在的进程相关的
24、s_bdev:指向文件系统被安装的块设备
25、u:u联合体域包括属于具体文件系统的超级块信息
26、s_instances:具体的意义后来会说的!(同一类型的文件系统通过这个子墩将所有的super_block连接起来)
27、s_dquot:磁盘限额相关选项
END,本文到此结束,如果可以帮助到大家,还望关注本站哦!