Beruflich Dokumente
Kultur Dokumente
Inode_hashtable
sb->clear_inode sb->read_inode
(freeing inos) (iget)
or
sb->delete_inode Fs storage
(iput) Unused inodes
Fs storage
int d_count;
unsigned int d_flags;
struct inode * d_inode; /* Where the name belongs to */
struct dentry * d_parent; /* parent directory */
struct dentry * d_mounts; /* mount information */
struct dentry * d_covers;
struct list_head d_hash; /* lookup hash list */
struct list_head d_lru; /* d_count = 0 LRU list */
struct list_head d_child; /* child of parent list */
struct list_head d_subdirs; /* our children */
…
struct dentry (2/2)
struct list_head d_alias; /* inode alias list */
struct qstr d_name;
unsigned long d_time; /* used by d_revalidate */
struct dentry_operations *d_op;
struct super_block * d_sb; /* The root of the dentry tree */
unsigned long d_reftime; /* last time referenced */
void * d_fsdata; /* fs-specific data */
/* small names */
unsigned char d_iname[DNAME_INLINE_LEN];
};
The Buffer Cache
struct dentry_operations {
int (*d_revalidate)(struct dentry *, int);
int (*d_hash) (struct dentry *, struct qstr *);
int (*d_compare) (struct dentry *, struct qstr *,
Replacement:
dentry_hashtable (hash chains)
Dentry->hash(device #, name) list head level1_cache/level1_head
• LRU list of recently translated
entries. Entries added to the end
may displace older entries if
cache is full.
prune namei level_2_cache/level2_head
Dentry->invalidate inode->lookup • LRU list of recently accessed
dentry->drop dentry->add entries (moved from level 1 on
second access).
Level 2 is safer – only displaced by
repeatedly accessed entry, not
unused dentries (dentry->lru chains) just a new entry.
struct file_system_type {
const char *name;
int fs_flags;
struct super_block * (*read_super)
(struct super_block *, void *, int);
struct file_system_type * next;
};
struct super_block (1/2)
struct super_block {
struct list_head s_list; /* Keep this first */
kdev_t s_dev;
unsigned long s_blocksize;
unsigned char s_lock;
unsigned char s_rd_only;
unsigned char s_dirt;
struct inode *s_ibasket;
short int s_ibasket_count;
struct super_block (2/2)
short int s_ibasket_max;
struct list_head s_dirty; /* dirty inodes */
struct list_head s_files;
…
union {
struct minix_sb_info minix_sb;
struct ext2_sb_info ext2_sb;
struct hpfs_sb_info hpfs_sb;
….
} u;
}
struct super_operations
struct super_operations {
void (*read_inode) (struct inode *);
void (*write_inode) (struct inode *);
void (*put_inode) (struct inode *);
void (*delete_inode) (struct inode *);
int (*notify_change) (struct dentry *, struct iattr *);
void (*put_super) (struct super_block *);
void (*write_super) (struct super_block *);
int (*statfs) (struct super_block *, struct statfs *, int);
int (*remount_fs) (struct super_block *, int *, char *);
void (*clear_inode) (struct inode *);
void (*umount_begin) (struct super_block *);
};
The Buffer Cache
Properties
• Block buffers are either in a free list or in the hash table
• All block buffers are also kept in an LRU list for
replacement
The Buffer Cache
page */
struct buffer_head *b_reqnext; /* request queue */
struct buffer_head (3/3)
struct buffer_head **b_pprev; /* 2x linked list of hash-queue */
char *b_data; /* pointer to data block (1024 bytes) */
void (*b_end_io)(struct buffer_head *bh, int uptodate);
/* I/O completion */
void *b_dev_id;
unsigned long b_rsector; /* Real buffer location on disk */
wait_queue_head_t b_wait;
struct kiobuf * b_kiobuf; /* kiobuf which owns this IO */
};