EXT3 file Read and write process overview
EXT3 file system in the read and write operation, the first need to open the appropriate file, and then read and write operations. When the open operation is made, the Linux kernel creates a file object that describes it. The file object is contacted with the dentry of the file and the Inode object, and the Ext3 files action method, the mapping processing method (address spaces) is registered to the file object.
The Ext3 file read and write process involves the page cache of the VFS layer, and the usual read and write operations use this layer of page cache to improve the IO performance of the disk. In Linux, the background runs the data between the writeback thread timing synchronization Pagecache and the device. The way Page cache can improve IO performance, but it also has a potential impact on the security of the data.
The purpose of this paper is to analyze the key functions in the reading and writing process of ext3 file system, and to analyze the page cache principle and the writeback mechanism in the subsequent articles.
Key Data Structures
The file data structure is a key data structure used by Linux to describe a file that is created when a file is opened by a process. When a file is closed, the files object is destroyed immediately. The file data structure is not persisted to the device as metadata information. The data structure is defined as follows:
struct File {/* * Fu_list becomes invalid after file_free are called and queued via * Fu_rcuhead for
RCU Freeing * * Union {struct List_head fu_list;
struct Rcu_head fu_rcuhead;
} F_u; struct path F_path; /* file path, containing file dentry directory entries and vfsmount information */#define F_DENTRY f_path.dentry #define F_VFSMNT f_path.mnt const struct File_operations *f_op;
/* File operation function set///* protects F_ep_links, f_flags, F_pos vs I_size in Lseek seek_cur.
* Must not is taken from IRQ context.
* * spinlock_t F_lock;
#ifdef CONFIG_SMP int f_sb_list_cpu;
#endif atomic_long_t F_count;
unsigned int f_flags; fmode_t F_mode;
/* File operation mode * * loff_t f_pos;
struct Fown_struct f_owner;
const struct CRED *f_cred;
struct File_ra_state F_ra;
U64 f_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 hooks to this file */struct List_head F_ep_lin
ks
struct List_head f_tfile_llink; #endif/* #ifdef config_epoll * * struct address_space *f_mapping;
/* address space mapping information, pointing to the inode in the i_mapping * * * #ifdef config_debug_writecount unsigned long f_mnt_write_state; #endif};