2007-12-19

这个模块提供管理file的一些接口函数.
struct file {
struct list_head f_list; /*组织: annon_list 或者 free_list ( 在使用中|不在使用中)*/
struct dentry *f_dentry;/*组织*/
struct vfsmount *f_vfsmnt;/*组织*/
 struct file_operations *f_op; /*feature*/
atoic_t f_count; /*feature*/
unsigned int f_flags;
mode_t f_mode;
loff_t f_pos;
unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
struct fown_struct f_owner;
unsigned int f_uid, f_gid;
int f_error;

unsigned long f_version;

/* needed for tty driver, and maybe others */
void *private_data;
};

两个链表:
/* Here the new files go */
static LIST_HEAD(anon_list); /*匿名的....为啥叫匿名,看看dentry_open就知道了,正常的file会链接进
inode->i_sb->s_files*/

/* And here the free ones sit */
static LIST_HEAD(free_list);
/* public *and* exported. Not pretty! */
spinlock_t files_lock = SPIN_LOCK_UNLOCKED;


有个分配和释放的几个接口函数:

struct file * get_empty_filp(void)
void fput(struct file * file)
struct file * fget(unsigned int fd)
void put_filp(struct file *file) /*不调用file->f_op->release(inode, file);*/

分配策略:
预留10个(NR_RESERVED_FILES)file结构(即free_list中总有至少10个备用),然后总的数量不超过一个最大值(可配).说他简单是
因为,一旦分配就不再释放了,也不提供shrink操作....嘿嘿,有点像dquota.


void file_move(struct file *file, struct list_head *list)
void file_moveto(struct file *new, struct file *old)
int fs_may_remount_ro(struct super_block *sb) /*如果要吧文件系统重新安装成read only,
就需要看看有没有写操作在执行*/



如果还需要什么分析的话,..... 我晕倒....