育才二中学区图:最近看vfs部分,写了个笔记,大家看看
来源:百度文库 编辑:九乡新闻网 时间:2024/04/28 20:41:05
采用主要以图表的方式表达,这样感觉很直观.
super block
相关的数据结构为:
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 long s_old_blocksize;
unsigned char s_blocksize_bits;
unsigned char s_dirt;
unsigned long long 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;
unsigned long s_flags;
unsigned long s_magic;
struct dentry *s_root;
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 */
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 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 semaphore s_vfs_rename_sem; /* Kludge */
/* Granuality of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran;
};
super_block存在于两个链表中,一个是系统所有super_block的链表, 一个是对于特定的文件系统的super_block链表.
所有的super_block都存在于 super-blocks 链表中:
下载 (4.76 KB)
图1
2008-05-23 16:30
对于特定的文件系统, 该文件系统的所有的super block 都存在于file_sytem_type中的fs_supers链表中.
而所有的文件系统,都存在于file_systems链表中.这是通过调用register_filesystem接口来注册文件系统的.
int register_filesystem(struct file_system_type * fs)
下载 (9.67 KB)
图2
2008-05-23 16:30
[ 本帖最后由 xpl 于 2009-3-19 15:58 编辑 ] __________________________________
http://blog.sina.com.cn/bytex
诚邀您共建CU技术主题索引贴| ChinaUnix板块调整意见征集 | Redhat授权RHCE超低价考试| InnoDB存储引擎有奖讨论 xpl
相关的数据结构为:
struct inode {
struct hlist_node i_hash;
struct list_head i_list;
struct list_head i_sb_list;
struct list_head i_dentry;
unsigned long i_ino;
atomic_t i_count;
umode_t i_mode;
unsigned int i_nlink;
uid_t i_uid;
gid_t i_gid;
dev_t i_rdev;
loff_t i_size;
struct timespec i_atime;
struct timespec i_mtime;
struct timespec i_ctime;
unsigned int i_blkbits;
unsigned long i_blksize;
unsigned long i_version;
unsigned long i_blocks;
unsigned short i_bytes;
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
struct semaphore i_sem;
struct rw_semaphore i_alloc_sem;
struct inode_operations *i_op;
struct file_operations *i_fop; /* former ->i_op->default_file_ops */
struct super_block *i_sb;
struct file_lock *i_flock;
struct address_space *i_mapping;
struct address_space i_data;
#ifdef CONFIG_QUOTA
struct dquot *i_dquot[MAXQUOTAS];
#endif
/* These three should probably be a union */
struct list_head i_devices;
struct pipe_inode_info *i_pipe;
struct block_device *i_bdev;
struct cdev *i_cdev;
int i_cindex;
__u32 i_generation;
#ifdef CONFIG_DNOTIFY
unsigned long i_dnotify_mask; /* Directory notify events */
struct dnotify_struct *i_dnotify; /* for directory notifications */
#endif
unsigned long i_state;
unsigned long dirtied_when; /* jiffies of first dirtying */
unsigned int i_flags;
atomic_t i_writecount;
void *i_security;
union {
void *generic_ip;
} u;
#ifdef __NEED_I_SIZE_ORDERED
seqcount_t i_size_seqcount;
#endif
};
inode存在于两个双向链表中:
一个是inode所在文件系统的super block的 s_inodes 链表中
一个是根据inode的使用状态存在于以下三个链表中的某个链表中:
1. 未用的: inode_unused 链表
2. 正在使用的: inode_in_use 链表
3. 脏的: super block中的s_dirty 链表
另外,还有一个重要的链表: inode_hashtable(这个暂不介绍).
下载 (10.8 KB)
2008-05-23 16:32 __________________________________
http://blog.sina.com.cn/bytex
诚邀您共建CU技术主题索引贴| ChinaUnix板块调整意见征集 | Redhat授权RHCE超低价考试| InnoDB存储引擎有奖讨论 xpl
相关的数据结构为:
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 16-byte range, with 16-byte alignment.
*/
struct dentry *d_parent; /* parent directory */
struct qstr d_name;
struct list_head d_lru; /* LRU list */
struct list_head d_child; /* child of parent list */
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 */
struct rcu_head d_rcu;
struct dcookie_struct *d_cookie; /* cookie, if any */
struct hlist_node d_hash; /* lookup hash list */
int d_mounted;
unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */
};
dentry对象存在于三个双向链表中:
所有未用的目录项: dentry_unused 链表
正在使用的目录项: 对应inode的 i_dentry 链表
表示父子目录结构的链表
另外,还有一个重要的链表: inode_hashtable(这个暂不介绍).
下载 (9.67 KB)
2008-05-23 16:33 __________________________________
http://blog.sina.com.cn/bytex
诚邀您共建CU技术主题索引贴| ChinaUnix板块调整意见征集 | Redhat授权RHCE超低价考试| InnoDB存储引擎有奖讨论 xpl
和进程相关的信息, 涉及到四个重要的数据结构:
file, fs_struct, files_struct 和 namespace
相关的数据结构为:
struct file {
struct list_head f_list;
struct dentry *f_dentry;
struct vfsmount *f_vfsmnt;
struct file_operations *f_op;
atomic_t f_count;
unsigned int f_flags;
mode_t f_mode;
int f_error;
loff_t f_pos;
struct fown_struct f_owner;
unsigned int f_uid, f_gid;
struct file_ra_state f_ra;
size_t f_maxcount;
unsigned long f_version;
void *f_security;
/* 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_head f_ep_links;
spinlock_t f_ep_lock;
#endif /* #ifdef CONFIG_EPOLL */
struct address_space *f_mapping;
};
-------------------------------------------------------------------------------
struct fs_struct {
atomic_t count;
rwlock_t lock;
int umask;
struct dentry * root, * pwd, * altroot;
struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;
};
-------------------------------------------------------------------------------
struct files_struct {
atomic_t count;
spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
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_array[NR_OPEN_DEFAULT];
};
-------------------------------------------------------------------------------
struct namespace {
atomic_t count;
struct vfsmount * root;
struct list_head list;
struct rw_semaphore sem;
};
每个进程都有自己的namespace.
fs_struct用于表示进程与文件系统之间的结构关系,比如当前的工作目录,进程的根目录等等.
files_struct 用于表示当前进程打开的文件.
而对于每一个打开的文件,由file对象来表示.
下载 (5.66 KB)
2008-05-23 16:35
Linux中,常常用文件描述符(file descriptor)来表示一个打开的文件,这个描述符的值往往是一个大于或等于0的整数.
而这个整数,其实就是在files_struct中file数组fd的下标.
对于所有打开的文件, 这些文件描述符会存储在open_fds的位图中.
super block
相关的数据结构为:
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 long s_old_blocksize;
unsigned char s_blocksize_bits;
unsigned char s_dirt;
unsigned long long 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;
unsigned long s_flags;
unsigned long s_magic;
struct dentry *s_root;
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 */
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 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 semaphore s_vfs_rename_sem; /* Kludge */
/* Granuality of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran;
};
super_block存在于两个链表中,一个是系统所有super_block的链表, 一个是对于特定的文件系统的super_block链表.
所有的super_block都存在于 super-blocks 链表中:
下载 (4.76 KB)
图1
2008-05-23 16:30
对于特定的文件系统, 该文件系统的所有的super block 都存在于file_sytem_type中的fs_supers链表中.
而所有的文件系统,都存在于file_systems链表中.这是通过调用register_filesystem接口来注册文件系统的.
int register_filesystem(struct file_system_type * fs)
下载 (9.67 KB)
图2
2008-05-23 16:30
[ 本帖最后由 xpl 于 2009-3-19 15:58 编辑 ] __________________________________
http://blog.sina.com.cn/bytex
诚邀您共建CU技术主题索引贴| ChinaUnix板块调整意见征集 | Redhat授权RHCE超低价考试| InnoDB存储引擎有奖讨论 xpl
- 发短消息
- 加为好友
xpl 当前离线
- UID
- 61059
- 帖子
- 330
- 精华
- 4
- 积分
- 536
- 可用积分
- 536
- 信誉积分
- 100
- 专家积分
- 43
- 空间积分
- 0
- 阅读权限
- 20
- 在线时间
- 71 小时
- 注册时间
- 2006-04-05
- 最后登录
- 2010-10-29
精灵王
- 帖子
- 330
- 主题
- 18
- 精华
- 4
- 可用积分
- 536
- 专家积分
- 43
- 在线时间
- 71 小时
- 注册时间
- 2006-04-05
- 最后登录
- 2010-10-29
状态:...当前离线...
[微博] [博客] [短信]
2楼 发表于 2008-05-23 16:32 | 只看该作者
回复 #1 xpl 的帖子
2. inode相关的数据结构为:
struct inode {
struct hlist_node i_hash;
struct list_head i_list;
struct list_head i_sb_list;
struct list_head i_dentry;
unsigned long i_ino;
atomic_t i_count;
umode_t i_mode;
unsigned int i_nlink;
uid_t i_uid;
gid_t i_gid;
dev_t i_rdev;
loff_t i_size;
struct timespec i_atime;
struct timespec i_mtime;
struct timespec i_ctime;
unsigned int i_blkbits;
unsigned long i_blksize;
unsigned long i_version;
unsigned long i_blocks;
unsigned short i_bytes;
spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
struct semaphore i_sem;
struct rw_semaphore i_alloc_sem;
struct inode_operations *i_op;
struct file_operations *i_fop; /* former ->i_op->default_file_ops */
struct super_block *i_sb;
struct file_lock *i_flock;
struct address_space *i_mapping;
struct address_space i_data;
#ifdef CONFIG_QUOTA
struct dquot *i_dquot[MAXQUOTAS];
#endif
/* These three should probably be a union */
struct list_head i_devices;
struct pipe_inode_info *i_pipe;
struct block_device *i_bdev;
struct cdev *i_cdev;
int i_cindex;
__u32 i_generation;
#ifdef CONFIG_DNOTIFY
unsigned long i_dnotify_mask; /* Directory notify events */
struct dnotify_struct *i_dnotify; /* for directory notifications */
#endif
unsigned long i_state;
unsigned long dirtied_when; /* jiffies of first dirtying */
unsigned int i_flags;
atomic_t i_writecount;
void *i_security;
union {
void *generic_ip;
} u;
#ifdef __NEED_I_SIZE_ORDERED
seqcount_t i_size_seqcount;
#endif
};
inode存在于两个双向链表中:
一个是inode所在文件系统的super block的 s_inodes 链表中
一个是根据inode的使用状态存在于以下三个链表中的某个链表中:
1. 未用的: inode_unused 链表
2. 正在使用的: inode_in_use 链表
3. 脏的: super block中的s_dirty 链表
另外,还有一个重要的链表: inode_hashtable(这个暂不介绍).
下载 (10.8 KB)
2008-05-23 16:32 __________________________________
http://blog.sina.com.cn/bytex
诚邀您共建CU技术主题索引贴| ChinaUnix板块调整意见征集 | Redhat授权RHCE超低价考试| InnoDB存储引擎有奖讨论 xpl
- 发短消息
- 加为好友
xpl 当前离线
- UID
- 61059
- 帖子
- 330
- 精华
- 4
- 积分
- 536
- 可用积分
- 536
- 信誉积分
- 100
- 专家积分
- 43
- 空间积分
- 0
- 阅读权限
- 20
- 在线时间
- 71 小时
- 注册时间
- 2006-04-05
- 最后登录
- 2010-10-29
精灵王
- 帖子
- 330
- 主题
- 18
- 精华
- 4
- 可用积分
- 536
- 专家积分
- 43
- 在线时间
- 71 小时
- 注册时间
- 2006-04-05
- 最后登录
- 2010-10-29
状态:...当前离线...
[微博] [博客] [短信]
3楼 发表于 2008-05-23 16:33 | 只看该作者3. 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 - NULL is
* negative */
/*
* The next three fields are touched by __d_lookup. Place them here
* so they all fit in a 16-byte range, with 16-byte alignment.
*/
struct dentry *d_parent; /* parent directory */
struct qstr d_name;
struct list_head d_lru; /* LRU list */
struct list_head d_child; /* child of parent list */
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 */
struct rcu_head d_rcu;
struct dcookie_struct *d_cookie; /* cookie, if any */
struct hlist_node d_hash; /* lookup hash list */
int d_mounted;
unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */
};
dentry对象存在于三个双向链表中:
所有未用的目录项: dentry_unused 链表
正在使用的目录项: 对应inode的 i_dentry 链表
表示父子目录结构的链表
另外,还有一个重要的链表: inode_hashtable(这个暂不介绍).
下载 (9.67 KB)
2008-05-23 16:33 __________________________________
http://blog.sina.com.cn/bytex
诚邀您共建CU技术主题索引贴| ChinaUnix板块调整意见征集 | Redhat授权RHCE超低价考试| InnoDB存储引擎有奖讨论 xpl
- 发短消息
- 加为好友
xpl 当前离线
- UID
- 61059
- 帖子
- 330
- 精华
- 4
- 积分
- 536
- 可用积分
- 536
- 信誉积分
- 100
- 专家积分
- 43
- 空间积分
- 0
- 阅读权限
- 20
- 在线时间
- 71 小时
- 注册时间
- 2006-04-05
- 最后登录
- 2010-10-29
精灵王
- 帖子
- 330
- 主题
- 18
- 精华
- 4
- 可用积分
- 536
- 专家积分
- 43
- 在线时间
- 71 小时
- 注册时间
- 2006-04-05
- 最后登录
- 2010-10-29
状态:...当前离线...
[微博] [博客] [短信]
4楼 发表于 2008-05-23 16:35 | 只看该作者4. 进程相关的信息
和进程相关的信息, 涉及到四个重要的数据结构:
file, fs_struct, files_struct 和 namespace
相关的数据结构为:
struct file {
struct list_head f_list;
struct dentry *f_dentry;
struct vfsmount *f_vfsmnt;
struct file_operations *f_op;
atomic_t f_count;
unsigned int f_flags;
mode_t f_mode;
int f_error;
loff_t f_pos;
struct fown_struct f_owner;
unsigned int f_uid, f_gid;
struct file_ra_state f_ra;
size_t f_maxcount;
unsigned long f_version;
void *f_security;
/* 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_head f_ep_links;
spinlock_t f_ep_lock;
#endif /* #ifdef CONFIG_EPOLL */
struct address_space *f_mapping;
};
-------------------------------------------------------------------------------
struct fs_struct {
atomic_t count;
rwlock_t lock;
int umask;
struct dentry * root, * pwd, * altroot;
struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;
};
-------------------------------------------------------------------------------
struct files_struct {
atomic_t count;
spinlock_t file_lock; /* Protects all the below members. Nests inside tsk->alloc_lock */
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_array[NR_OPEN_DEFAULT];
};
-------------------------------------------------------------------------------
struct namespace {
atomic_t count;
struct vfsmount * root;
struct list_head list;
struct rw_semaphore sem;
};
每个进程都有自己的namespace.
fs_struct用于表示进程与文件系统之间的结构关系,比如当前的工作目录,进程的根目录等等.
files_struct 用于表示当前进程打开的文件.
而对于每一个打开的文件,由file对象来表示.
下载 (5.66 KB)
2008-05-23 16:35
Linux中,常常用文件描述符(file descriptor)来表示一个打开的文件,这个描述符的值往往是一个大于或等于0的整数.
而这个整数,其实就是在files_struct中file数组fd的下标.
对于所有打开的文件, 这些文件描述符会存储在open_fds的位图中.
最近看vfs部分,写了个笔记,大家看看
最近看vfs部分,写了个笔记,更新了mount 文件系统部分...
最近办群了,也没时间来写了,对不起大家!
最近看了篇贪官语录,把它摘录下来,供大家欣赏:
检察官最近写了两本书 当干部的"童鞋"不妨来看看
我最近看的文字,想推荐给大家
即将失恋了...写个东西给她看吧!
最近最喜欢的25个网站,大家赶紧入手吧
最近最喜欢的25个网站,大家赶紧入手吧!
看了很受启发.给大家看看人体酸碱度
人体酸碱度 看了很受启发.给大家看看...
人体酸碱度 看了很受启发.给大家看看1
人体酸碱度 看了很受启发.给大家看看0
人体酸碱度 看了很受启发. 给大家看看
人体酸碱度 看了很受启发.给大家看看.
人体酸碱度 看了很受启发.给大家看看
人体酸碱度 看了很受启发.给大家看看(1)
把我看哭了好几次的一个帖子,整理出来大家看看
把我看哭了好几次的一个帖子,整理出来大家看看 嗳的很难
人体酸碱度 看了很受启发.给大家看看aa
人体酸碱度 看了很受启发.给大家看看
写个故事给他家看看
中国人整死中国人的道道(看了很难过,大家也看看吧!还能吃什么?)
看了此文 大家会睡觉了!