Chinaunix首页 | 论坛 | 博客
  • 博客访问: 401831
  • 博文数量: 48
  • 博客积分: 764
  • 博客等级: 上士
  • 技术积分: 1133
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-17 13:29
文章分类

全部博文(48)

文章存档

2014年(5)

2013年(34)

2012年(9)

分类: LINUX

2013-01-06 12:05:11



Reference


Pre-words

It has been 3 months for me after grduated from DLNU. Recently, I came to 帝都Beijing for hunting a KERNEL relating job. Leaking of projects experences makes  me unconfiendt. I made a determine that devote all my energies to submit a kernel patch. I read linux kernel bugzilla all day and nighty. I find an appropriate  one.  Knowing nothing about Btrfs, I begin to collect the infor maion about Btrfs and read the source code of Btrfs.


Getting started

Btrfs at Wikipedia.

新一代 Linux 文件系统 btrfs 简介


Architecture of btrfs

Data Structures

Btree Items

On-disk Format



Timeline of btrfs source code

Initialization

-->init_btrfs_fs()

In this function kernel initlize Btrfs and use register_filesystem to inject  Btrfs into kernel witn a paramater btrfs_fs_type:


static struct file_system_type btrfs_fs_type = {

.owner = THIS_MODULE,

.name = "btrfs",

.mount = btrfs_mount,

.kill_sb = btrfs_kill_super,

.fs_flags = FS_REQUIRES_DEV,

};


The mount member of btrfs_fs_type  btrfs_mount() is a critical function!


Mount

When we use mount command on shell, it directs kernel to call btrfs_mount() function mentioned above. If you  trace the procedures will can find it  happens in mount_fs().

-->btrfs_mount()

                -->sget():find or create a superblock

                -->btrfs_fill_super()

                                  -->btrfs_iget()

                                                     -->btrfs_read_locked_inode()

                                                                               -->inode->i_mapping->a_ops = &btrfs_aops;

                                                                               -->inode->i_fop = &btrfs_file_operations;

                                                                               -->inode->i_op = &btrfs_file_inode_operations;


Here is the defination of btrfs_file_operations is all the operations that a file will use:


const struct file_operations btrfs_file_operations = {

.llseek = btrfs_file_llseek,

.read = do_sync_read,

.write = do_sync_write,

.aio_read       = generic_file_aio_read,

.splice_read = generic_file_splice_read,

.aio_write = btrfs_file_aio_write,

.mmap = btrfs_file_mmap,

.open = generic_file_open,

.release = btrfs_release_file,

.fsync = btrfs_sync_file,

.fallocate = btrfs_fallocate,

.unlocked_ioctl = btrfs_ioctl,

#ifdef CONFIG_COMPAT

.compat_ioctl = btrfs_ioctl,

#endif

};


阅读(1551) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~