LINUX VFS精华版PPT

上传人:c****d 文档编号:243150572 上传时间:2024-09-16 格式:PPT 页数:67 大小:311KB
返回 下载 相关 举报
LINUX VFS精华版PPT_第1页
第1页 / 共67页
LINUX VFS精华版PPT_第2页
第2页 / 共67页
LINUX VFS精华版PPT_第3页
第3页 / 共67页
点击查看更多>>
资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,LINUX VFS,2009春,1,LINUX VFS(虚拟文件系统Virtual ),1. VFS之What 是什么(概念,定义,功能),2. VFS之Why为什么(目的,作用),3. VFS之HowVFS如何工作,4. VFS之3W总结,2,1. VFS之What 是什么(概念,定义,功能),VFS:Virtual 虚拟文件系统,,或Virtual 虚拟文件转换/开关,VFS是Linux和UNIX文件系统中采用的一种技术机制,旨在一个操作系统中,支持多个不同类型的文件系统,。VFS是操作系统内核中这样一组数据结构与子程序的集合,它位于操作系统系统调用界面与具体类型文件系统之间,负责,记录操作系统中可以支持和已经安装有哪些文件系统类型,,将相关系统调用转换为对具体类型文件系统的调用,,负责不同类型文件系统间的协同工作(例如跨FS复制),,实现对不同类型文件系统的动态装卸和可扩充性等。,3,续1. VFS之What 是什么(概念,定义,功能),通过以上功能,VFS,向用户、应用程序、和操作系统其他部件提供了一个,通用的、统一的、标准的、抽象的、虚拟的,系统调用接口界面(所以称,Virtual,),对以上应用程序等,掩盖,不同类型文件系统的差异和细节,为以上应用程序等提供了对具体文件系统类型的,程序独立性和透明性,。,例如,当用户程序AP1在两次运行中分别读EXT2、NTFS文件,都使用同样的read()系统调用函数,程序AP1不必改变,VFS是从OS系统调用界面到各具体类型文件系统之间的中介、,分支,机构、,转换,机构(所以称,switch,)、函数转换表,其作用类似于设备开关表、系统调用分支表、总线、主板插槽等。,4,5,LINUX VFS支持哪些文件系统,目前至少50多种,可从fs.h中的union u或fs/*.c或/proc/看到,本地文件系统:EXT2,EXT3,EXT4,FAT,NTFS,minix,UFS,HFS,ISOFS,HPFS,AFFS(FFS),SYSV(S5FS),EFS,UDF等,网络文件系统:NFS,coda,SAMBA,等,虚拟文件系统:PROC,等,6,Union u,7,2. VFS之Why为什么/目的/作用,前已概述,稍微深入一点的思考:“在一个操作系统中支持多种不同类型文件系统”存在或需要解决哪些问题?(相对于一个操作系统只支持单类型文件系统而言),卷格式不同,卷管理信息内容与格式不同,目录项内容与格式不同,文件描述信息内容与格式不同,相应操作子程序也就不同(打开文件,读写文件等),所以同样的读文件系统调用read(),对不同类型的文件系统(例如EXT或NTFS),需调用相应不同的操作子程序。,VFS最关键的作用,就在于提供了对上述不同操作子程序的分支跳转支持机制。,8,3. VFS之HowVFS如何工作,关键数据结构:文件操作表,文件系统安装登记表,关键流程步骤:根据文件操作表从标准系统调用跳转至相应具体类型文件系统的操作子程序。,把“/d1/f1”这整个路径名,一次性地转交给具体类型文件系统去处理?,如此简单吗?NO.,VFS内部实现机制包括种数据结构、行源代码,为何有这些更多的工作要做?有哪些工作?,9,文件操作表struct 完整说明(fs.h中,共34行),struct ,struct module *owner;,loff_t (*llseek) (struct file *, loff_t, int);,ssize_t (*read) (struct file *, char _user *, size_t, loff_t *);,ssize_t (*write) (struct file *, const char _user *, size_t, loff_t *);,ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);,ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);,int (*readdir) (struct file *, void *, filldir_t);,unsigned int (*poll) (struct file *, struct poll_table_struct *);,int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);,long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);,long (*compat_ioctl) (struct file *, unsigned int, unsigned long);,int (*mmap) (struct file *, struct vm_area_struct *);,int (*open) (struct inode *, struct file *);,int (*flush) (struct file *, fl_owner_t id);,int (*release) (struct inode *, struct file *);,int (*fsync) (struct file *, struct dentry *, int datasync);,int (*aio_fsync) (struct kiocb *, int datasync);,int (*fasync) (int, struct file *, int);,int (*lock) (struct file *, int, struct *);,ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *);,ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);,unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);,int (*check_flags)(int);,int (*dir_notify)(struct file *filp, unsigned long arg);,int (*flock) (struct file *, int, struct *);,ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);,ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);,;,10,文件操作表struct 重点标释,struct ,loff_t (*,llseek,) (struct file *, loff_t, int);,ssize_t (*,read,) (struct file *, char _user *, size_t, loff_t *);,ssize_t (*,write,) (struct file *, const char _user *, size_t, loff_t *);,int (*,mmap,) (struct file *, struct vm_area_struct *);,int (*,open,) (struct inode *, struct file *);,;,11,关键流程步骤,应用程序中open(“/d1/f1”),通过系统调用进入内核,VFS判断/d1/f1所属文件系统类型,根据文件操作表跳转至相应具体类型文件系统(例如EXT2)的open操作子程序,12,为何不是1次转换那么简单?更多工作有哪些?,安装点和链接,/d1/f1路径上可能存在两个不同类型的文件系统,结论:需逐个分量逐次调用具体类型文件系统,而不能一次性的整个路径名转交,因此,与具体类型文件系统的交互(即调用次数)增多了,因此,内存,缓冲,数据结构进入VFS,内存活动I结点,目录项,超级块,等,为了统一管理和减少代码重复,文件系统,类型无关,的操作(即大部分内存操作)进入VFS,文件系统,类型相关,的操作(即所有外存操作,及少量内存操作)留在具体类型文件系统中,以上这三个因素导致的VFS实际结构和过程,13,3.VFS之HowVFS如何工作,3.1 VFS数据结构:单多类型对比,3.2 VFS工作过程:单多类型对比,文件系统登记与安装,打开文件,读文件,3.3 VFS相关源码和.h文件简介,理解要点:与单类型FS对比,3.0 几个概念的区分,14,3.0 几个概念的区分,一个,已发布,的linuxOS,版本,,支持几种FS类型?,一个,已安装,的linuxOS,实例,,支持几种FS类型?,一个FS,类型,的,注册,(register)FS代码,一个FS,实例,的产生和建立(,格式化,)FS数据(外存盘卷),一个FS,实例,的,安装,(mount)FS数据从外存进入内存,VFS只有代码和内存数据,,在外存不存在,开机时产生,关机后不再存在,。,单类型FS和具体类型FS既可能指代码,也可能指外存数据(盘卷实体)。具体类型FS既可能对单类型FS而言,也可能指多类型FS而言。,FS的含义可能指以上所有内容中一个或全体,依上下文而定。,15,相关词汇,版本version 发布distribute,类型type 登记注册register,实例instance 安装mount,FS建立(格式化,初始化):mkfs,formatted,initialize,16,相关概念和过程之间关系,注册FS类型(此处是指代码),安装具体类型FS(此处是指实例,数据),打开文件,读写文件,关闭文件,卸载具体类型FS,注销具体类型FS,17,3.1 VFS数据结构,分两级看:,数据结构总图级:与单类型对比,Struct级:.h文件,需结合工作过程图看,18,VFS数据结构总图,文件系统安装表,Vfsmount(无op),超级块对象,Super_block,FS类型注册表,(无op),进程表,进程打开文件表,File对象,系统打开文件表,Dentry对象,活动I结点表,Inode对象,文件操作表,Inode对象操作表,inode_operations,目录项操作表,dentry_operations,超级块对象操作表,super_operations,外存目录文件中的目录项,外存INODE,外存超级块,外存,具体类型FS,19,VFS数据结构总图要点分析,与单类型FS数据结构总图对比:,VFS多了文件系统类型注册表,VFS多了几张对具体类型FS的操作分支表,VFS的与外存对应的内存暂存数据结构内容与格式是通用的、面向多种类型FS的。,VFS的OO(面向对象思想):,系统打开文件表:目录项对象(dentry对象),内存活动I结点表:inode对象,进程打开文件表:文件对象(file对象),内存超级块表:超级块对象,Vfs关于FS级的数据结构为何一分为三,20,文件描述信息的三个数据结构,21,单类型FS数据结构总图,22,单类型FS数据结构要点简单回顾,外存数据结构:超级块,I结点,目录项等,内存数据结构包括两种,与外存对应暂存信息,当前使用信息(与外存没有对应),为提高效率,凡是正使用或已打开的外存数据,都在内存留存,以便再次使用时不必重复读写外存。,关于卷的内存数据结构:,内存超级块外存超级块,关于文件的内存数据结构:,内存活动I结点表外存I结点,系统打开文件表外存目录项,进程打开文件表在外存没有对应,为何关于文件的内存数据结构是一分为三的?,链接,导致系统打开文件表与活动I结点分离,多进程同时打开一个文件,,导致系统,打开文件表与进程打开文件表的分离,因为单类型,所以没有文件系统类型登记表,23,进程表中的相关内容,Struct task_struct,.,/* information */,struct fs_struct *fs,;/* open */,struct *files,;,24,struct fs_struct,struct fs_struct atomic_t count;rwlock_t lock;int umask;struct dentry * root, * pwd, * altroot;struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;,25,进程打开文件表Struct 完整说明与重点标释,Struct ,atomic_t count;,rwlock_t ;,int max_fds;,int max_fdset;,int next_fd;,struct file *fd,;/*current fd array*/,fd_set *close_on_exec;,fd_set *open_fds;,fd_set close_on_exec_init;,fd_set open_fds_init;,struct file * fd_arrayNR_OREN_DEFAULT;,26,进程打开文件表(struct file)的内容,重点信息:,文件操作表,指向系统打开文件表的指针,文件当前读写位置指针,其他信息:,打开方式,文件主信息,,指向FS安装表的指针,指向文件缓冲区的指针,,链表信息,关于权限、安全、互斥的信息,相关struct:,Struct file,Struct,struct file * fd_arrayNR_OREN_DEFAULT;,27,进程打开文件表struct file完整说明(fs.h中,共35行),struct file ,/*,* fu_list becomes invalid after is called and queued via,* fu_rcuhead for RCU freeing,*/,union ,struct list_headfu_list;,struct rcu_head fu_rcuhead;, f_u;,struct pathf_path;,#define f_dentryf_path.dentry,#define f_vfsmntf_path.mnt,const struct *f_op;,atomic_tf_count;,unsigned int f_flags;,mode_tf_mode;,loff_tf_pos;,struct fown_structf_owner;,unsigned intf_uid, f_gid;,struct f_ra;,unsigned longf_version;,#ifdef CONFIG_SECURITY,void*f_security;,#endif,/* needed for tty driver, and maybe others */,void*private_data;,#ifdef CONFIG_EPOLL,/* Used by fs/eventpoll.c to link all the hooks to this file */,struct list_headf_ep_links;,spinlock_tf_ep_lock;,#endif /* #ifdef CONFIG_EPOLL */,struct address_space*f_mapping;,;,28,进程打开文件表struct file重点标释,struct file ,struct pathf_path;,const,struct *f_op,;,atomic_tf_count;,unsigned int f_flags;,mode_tf_mode;,loff_t,f_pos,;,struct fown_structf_owner;,unsigned intf_uid, f_gid;,struct f_ra;,unsigned longf_version;,void*private_data;,struct address_space*f_mapping;,.;,29,系统打开文件表(struct dentry)内容,重点信息:,文件名,指向活动I结点表的指针,目录项对象操作表,其他信息:,指向超级块的指针,链表信息,文件系统类型相关信息,引用计数,关于互斥、保护信息等,相关struct:,Struct dentry,30,系统打开文件表struct dentry完整说明(dcache.h文件中,共34行),struct dentry atomic_t d_count;unsigned int d_flags;/* protected by d_lock */spinlock_t d_lock;/* per dentry lock */struct inode *d_inode;/* Where the name belongs to - NULL is * negative */* * The next three fields are touched by _d_lookup. Place them here * so they all fit in a cache line. */struct hlist_node d_hash;/* lookup hash list */struct dentry *d_parent;/* parent directory */struct qstr d_name;struct list_head d_lru;/* LRU list */* * d_child and d_rcu can share memory */union struct list_head d_child;/* child of parent list */ struct rcu_head d_rcu; d_u;struct list_head d_subdirs;/* our children */struct list_head d_alias;/* inode alias list */unsigned long d_time;/* used by d_revalidate */struct dentry_operations *d_op;struct super_block *d_sb;/* The root of the dentry tree */void *d_fsdata;/* fs-specific data */#ifdef CONFIG_PROFILINGstruct dcookie_struct *d_cookie; /* cookie, if any */#endifint d_mounted;unsigned char d_inameDNAME_INLINE_LEN_MIN;/* small names */;,31,系统打开文件表struct dentry重点标释,struct dentry atomic_t d_count;unsigned int d_flags;/* protected by d_lock */spinlock_t d_lock;/* per dentry lock */,struct inode *d_inode;,/* Where the name belongs to - struct dentry *d_parent;/* parent directory */struct qstr d_name;,struct dentry_operations *d_op,;struct super_block *d_sb;/* The root of the dentry tree */void *d_fsdata;/* fs-specific data */int d_mounted;,unsigned char d_inameDNAME_INLINE_LEN_MIN;/* small names */,;,32,struct dentry_operations,struct dentry_operations int (*d_revalidate)(struct dentry *, struct nameidata *);int (*d_hash) (struct dentry *, struct qstr *);int (*d_compare) (struct dentry *, struct qstr *, struct qstr *);int (*d_delete)(struct dentry *);void (*d_release)(struct dentry *);void (*d_iput)(struct dentry *, struct inode *);char *(*d_dname)(struct dentry *, char *, int);,33,活动I结点表的内容,重点内容:,外存I结点号,I结点对象操作表指针,文件对象操作表指针,,其他内容:,文件长度、类型、权限,文件主各种信息,各种时间信息,设备号,链接数,此I结点的所有链接的链头,指向文件缓冲区的指针,内存超级块指针,,各种链表信息,队列指针,状态信息,限额信息,计数信息,关于锁、互斥的信息,指向文件系统类型相关信息的指针,等,相关struct: struct inode,34,活动I结点表struct inode完整说明(fs.h中,共66行),struct inode ,struct hlist_nodei_hash;,struct list_headi_list;,struct list_headi_sb_list;,struct list_headi_dentry;,unsigned longi_ino;,atomic_ti_count;,unsigned inti_nlink;,uid_ti_uid;,gid_ti_gid;,dev_ti_rdev;,unsigned longi_version;,loff_ti_size;,#ifdef _NEED_I_SIZE_ORDERED,seqcount_ti_size_seqcount;,#endif,struct timespeci_atime;,struct timespeci_mtime;,struct timespeci_ctime;,unsigned inti_blkbits;,blkcnt_ti_blocks;,unsigned short i_bytes;,umode_ti_mode;,spinlock_ti_lock;/* i_blocks, i_bytes, maybe i_size */,struct mutexi_mutex;,struct rw_semaphorei_alloc_sem;,const struct inode_operations*i_op;,const struct *i_fop;/* former -i_op-default_ */,struct super_block*i_sb;,struct *i_flock;,struct address_space*i_mapping;,struct address_spacei_data;,#ifdef CONFIG_QUOTA,struct dquot*i_dquotMAXQUOTAS;,#endif,struct list_headi_devices;,union ,struct pipe_inode_info*i_pipe;,struct block_device*i_bdev;,struct cdev*i_cdev;,;,inti_cindex;,_u32i_generation;,#ifdef CONFIG_DNOTIFY,unsigned longi_dnotify_mask; /* Directory notify events */,struct dnotify_struct*i_dnotify; /* for directory notifications */,#endif,#ifdef CONFIG_INOTIFY,struct list_headinotify_watches; /* watches on this inode */,struct mutexinotify_mutex;/* protects the watches list */,#endif,unsigned longi_state;,unsigned longdirtied_when;/* jiffies of first dirtying */,unsigned inti_flags;,atomic_ti_writecount;,#ifdef CONFIG_SECURITY,void*i_security;,#endif,void*i_private; /* fs or device private pointer */,;,35,活动I结点表struct inode重点标释,struct inode ,struct list_headi_dentry;,unsigned long,i_ino,;,atomic_ti_count;,unsigned inti_nlink;,dev_ti_rdev;,unsigned longi_version;,loff_ti_size;,const,struct inode_operations*i_op,;,const,struct *i_fop,;/* former -i_op-default_ */,struct super_block*i_sb;,struct address_space*i_mapping;,struct address_spacei_data;,inti_cindex;,_u32i_generation;,void*i_private; /* fs or device private pointer */,;,36,struct inode_operations,struct inode_operations int (*create) (struct inode *,struct dentry *,int, struct nameidata *);struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);int (*link) (struct dentry *,struct inode *,struct dentry *);int (*unlink) (struct inode *,struct dentry *);int (*symlink) (struct inode *,struct dentry *,const char *);int (*mkdir) (struct inode *,struct dentry *,int);int (*rmdir) (struct inode *,struct dentry *);int (*mknod) (struct inode *,struct dentry *,int,dev_t);int (*rename) (struct inode *, struct dentry *,struct inode *, struct dentry *);int (*readlink) (struct dentry *, char _user *,int);void * (*follow_link) (struct dentry *, struct nameidata *);void (*put_link) (struct dentry *, struct nameidata *, void *);void (*truncate) (struct inode *);int (*permission) (struct inode *, int, struct nameidata *);int (*setattr) (struct dentry *, struct iattr *);int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);ssize_t (*listxattr) (struct dentry *, char *, size_t);int (*removexattr) (struct dentry *, const char *);void (*truncate_range)(struct inode *, loff_t, loff_t);,37,3.2 VFS工作过程,重点分析以下过程:,3.2.1 文件系统类型登记注册(register),3.2.2 文件系统安装(mount),3.2.3 文件打开(open),3.2.4 读文件(read),每个过程都与单类型FS对比,38,3.2.1 VFS文件系统注册工作原理,VFS文件系统类型注册,主要数据结构:文件系统类型注册链表,VFS文件系统类型注册时机和相关用户界面,VFS文件系统注册内部实现工作过程,单类型FS没有文件系统类型注册问题与需要,39,VFS文件系统类型注册链表,该表概述:,每个已安装的OS实例,有一张该链表,每个FS类型在表中有一“行”,该OS实例,支持多少种FS类型,该表就有多少行,链头,该链表在开机(OS启动)时自动生成,并可在OS运行过程中由用户补充注册新的FS类型,每行主要内容(struct ),文件系统类型名,读超级块的函数指针,链表指针,等,40,struct 完整说明(fs.h中,共12行)和重点标释,struct ,const char *,name,;,/*文件系统类型名*/,int fs_flags;,int (*,get_sb,) (struct *, int,const char *, void *, struct vfsmount *);,void (*kill_sb) (struct super_block *);,/*读超块*/,struct module *owner;,struct * next;,struct list_head fs_supers;,struct lock_class_key s_lock_key;,struct lock_class_key s_umount_key;,;,41,VFS文件系统类型注册时机/用户界面,向OS内核注册FS类型,有两种途径:,一种是在编译内核时确定,并在OS初始化时通过内嵌的函数调用向FS类型注册表登记。,另一种是通过linux模块(module)机制,把某个FS当作一个模块,装入该模块时(通过kerneld或insmod/modprob命令)向FS类型注册表登记其类型,卸载该模块时则从FS类型注册表注销。,FS类型注册和注销函数:,Int register_(struct *fs),Int unregister_(struct *fs),42,文件系统注册的内部工作过程,(注意调用参数为struct 指针),根据FS类型名在链表中检查是否已注册(重名),将struct 链入链表,OK,43,3.2.2 VFS下的文件系统安装,VFS下的FS安装时机和相关用户界面:,OS初启时自动安装:,根FS(由全程变量ROOT_DEV指示),根据/etc/fstab的指定,逐个安装文件系统,OS运行过程中可随时安装其他FS实例:,命令mount 设备名 安装点目录名,系统调用和函数mount(设备名,安装点目录名),例如,mount /dev/sda1 /home/usr1/d1,将C:安装到d1下,主要数据结构:文件系统安装表,内存超级块,VFS“文件系统安装”内部工作过程,简忆与对比:FS基础知识及单类型FS安装,Vfs关于FS的数据结构为何一分为三,44,简忆与对比:FS基础知识/单类型FS安装,比较linux/unix安装点机制与windows驱符机制,关于文件系统实例的概念:闭体,卷,分区,盘,设备,格式化与FS类型,安装,安装点,单类型文件系统的文件系统安装用户界面同前,但格式化时和内部实现时不用考虑FS类型,45,文件系统安装表,表概述:,每个已安装的OS实例,有一张该链表,每个已安装的FS实例,在表中有一“行”,该OS实例,已安装多少个FS实例,该表就有多少行,链头,该链表在OS启动时自动生成第一行根,在OS运行过程中用户每安装/卸载一个FS时,增/减一行,该表有时又称FS注册表,注意区分于FS类型注册表,每行主要内容struct vfsmount,主要内容:超级块指针,设备名,安装点,根目录项,其他内容:链表信息,父fs信息,,46,struct vfsmount完整说明(mount.h中,共27行),struct vfsmount struct list_head mnt_hash;struct vfsmount *mnt_parent;/* fs we are mounted on */struct dentry *mnt_mountpoint;/* dentry of mountpoint */struct dentry *mnt_root;/* root of the mounted tree */struct super_block *mnt_sb;/* pointer to superblock */struct list_head mnt_mounts;/* list of children, anchored here */struct list_head mnt_child;/* and going through their mnt_child */int mnt_flags;/* 4 bytes hole on 64bits arches */char *mnt_devname;/* Name of device e.g. /dev/dsk/hda1 */struct list_head mnt_list;struct list_head mnt_expire;/* link in fs-specific expiry list */struct list_head mnt_share;/* circular list of shared mounts */struct list_head mnt_slave_list;/* list of slave mounts */struct list_head mnt_slave;/* slave list entry */struct vfsmount *mnt_master;/* slave is on master-mnt_slave_list */struct mnt_namespace *mnt_ns;/* containing namespace */* * We put mnt_count ,47,struct vfsmount重点标释,struct vfsmount ,struct dentry *mnt_mountpoint;,/*,指向安装点dentry的指针,*/,struct dentry *mnt_root,;/*,指向该FS根目录dentry的指针,*/,struct super_block *mnt_sb,;/*,指向该FS的超级块,*/,char *mnt_devname,;/*,该FS设备名,*/.;,48,VFS“文件系统安装”内部工作过程,过程图中红色部分为与单类型FS不同处。黑体部分原来由具体类型FS完成,现由VFS完成,但过程与具体类型FS类似。(类型相关无关),注意:因为一个FS可安装在多个安装点,因此一个超级块可对应多个struct vfsmount。,相关函数:,Sys_mount,do_mount,Static struct vfsmount *add_vfsmnt(struct nameidata *nd,struct dentry *root,const char *dev_name),Static void move_vfsmnt(struct vfsmount *mnt,struct dentry *mountpoint,struct vfsmount *parent,const char *dev_name),Static void remove_vfsmnt(struct vfsmount *mnt),49,VFS下”文件系统安装”内部工作过程图,应用程序通过mount系统调用进入内核,参数:,FS类型,/设备名/安装点/等,根据设备名查VFS内存超级块对象链表,判断该FS超级块已在内存否?否则,通过FS类型注册表,读该设备超级块,建立该设备的内存超级块对象和根目录项对象,申请新struct vfsmount并填写其各项内容:,超级块指针,设备名,安装点,根目录项指针等。,OK,50,struct super_block完整说明(在fs.h中,共60行),struct super_block ,struct list_heads_list;/* Keep this first */,dev_ts_dev;/* search index; _not_ kdev_t */,unsigned longs_blocksize;,unsigned chars_blocksize_bits;,unsigned chars_dirt;,unsigned long longs_maxbytes;/* Max */,struct *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 longs_flags;,unsigned longs_magic;,struct dentry*s_root;,struct rw_semaphores_umount;,struct mutexs_lock;,ints_count;,ints_syncing;,ints_need_sync_fs;,atomic_ts_active;,#ifdef CONFIG_SECURITY,void *s_security;,#endif,struct xattr_handler*s_xattr;,struct list_heads_inodes;/* all inodes */,struct list_heads_dirty;/* dirty inodes */,struct list_heads_io;/* parked for writeback */,struct hlist_heads_anon;/* anonymous dentries for (nfs) exporting */,struct list_heads_files;,struct block_device*s_bdev;,struct mtd_info*s_mtd;,struct list_heads_instances;,struct quota_infos_dquot;/* Diskquota specific options */,ints_frozen;,wait_queue_head_ts_wait_unfrozen;,char s_id32;/* Informational name */,void *s_fs_info;/* private info */,/*,* The next field is for VFS *only*. No 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;,/*,* subtype. If non-empty the type field,* in /proc/mounts will be type.subtype,*/,char *s_subtype;,;,51,struct super_block重点标释,struct super_block ,dev_ts_dev;/* search index; _not_ kdev_t */,unsigned longs_blocksize;,unsigned chars_blocksize_bits;,unsigned chars_dirt;,unsigned long longs_maxbytes;/* Max */,struct *s_type,;/*,指向该FS的struct */,const struct super_operations*s_op,;,/*指向一组对该FS进行操作的函数*/,struct dentry*s_root,;,/*,指向该FS根目录dentry对象,*/,struct block_device*s_bdev;,struct list_heads_instances;,;,52,内存超级块对象struct super_block,注意超级块与vfsmount可能是一对多的关系。,内容两类:一种来自外存超级块,一种在外存无对应,主要内容:,超级块对象操作表,指向该FS根目录dentry对象的指针,指向该FS的struct 的指针,指向该超级块的vfsmount结构队列的指针(一FS可装在多处,故一个超级块可对应多个vfsmount),其他内容:,各种链表信息、标志和状态信息,从外存超级块复制来的信息,FS类型相关信息,,53,struct super_operations,struct super_operations struct inode *(*alloc_inode)(struct super_block *sb);void (*destroy_inode)(struct inode *);void (*read_inode) (struct inode *); void (*dirty_inode) (struct inode *);int (*write_inode) (struct inode *, int);void (*put_inode) (struct inode *);void (*drop_inode) (struct inode *);void (*delete_inode) (struct inode *);void (*put_super) (struct super_block *);void (*write_super) (struct super_block *)
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!