其他分享
首页 > 其他分享> > f2f2 学习笔记 之一

f2f2 学习笔记 之一

作者:互联网

源代码位置

include/linux/f2fs_fs.h
fs/f2fs/
Documentation/filesystems/f2fs.txt

inode 是什么?node 是什么?

需要深入理解node/inode:
node block 是索引节点块:包括inode ; direct data block; indirect data block;
inode: data block indices; direct block; indirect block; double indirect block;
根据计算一个inode最多能索引的文件的大小的公式,可以加深理解;

dentry block:
目录相关;
需要先建立起来bucket ; A(2B); 根据name hash值/当前排查层次的bucket 总数,得到一个bucket number,然后据此查对应的bucket;

segment summary

/*

/ a summary entry for a 4KB-sized block in a segment /
struct f2fs_summary {
le32 nid; / parent node id /
union {
u8 reserved[3];
struct {
u8 version; / node version number /
le16 ofs_in_node; / block index in parent node /
} packed;
};
}
packed;

/ summary block type, node or data, is stored to the summary_footer /
#define SUM_TYPE_NODE (1)
#define SUM_TYPE_DATA (0)

struct summary_footer {
unsigned char entry_type; / SUM_TYPE_XXX /
__le32 check_sum; / summary checksum /
} __packed;

#define SUM_JOURNAL_SIZE (F2FS_BLKSIZE - SUM_FOOTER_SIZE -\
SUM_ENTRY_SIZE)
#define NAT_JOURNAL_ENTRIES ((SUM_JOURNAL_SIZE - 2) /\
sizeof(struct nat_journal_entry))
#define NAT_JOURNAL_RESERVED ((SUM_JOURNAL_SIZE - 2) %\
sizeof(struct nat_journal_entry))
#define SIT_JOURNAL_ENTRIES ((SUM_JOURNAL_SIZE - 2) /\
sizeof(struct sit_journal_entry))
#define SIT_JOURNAL_RESERVED ((SUM_JOURNAL_SIZE - 2) %\
sizeof(struct sit_journal_entry))

/* Reserved area should make size of f2fs_extra_info equals to

/*

struct nat_journal_entry {
le32 nid;
struct f2fs_nat_entry ne;
}
packed;

struct nat_journal {
struct nat_journal_entry entries[NAT_JOURNAL_ENTRIES];
__u8 reserved[NAT_JOURNAL_RESERVED];
....
}

file 相关操作

f2fs.h:
file_operations f2fs_file_operations:

fs/f2fs/file.c:

const struct file_operations f2fs_file_operations = {
.llseek = f2fs_llseek,
.read_iter = generic_file_read_iter,
.write_iter = f2fs_file_write_iter,
.open = f2fs_file_open,
.release = f2fs_release_file,
.mmap = f2fs_file_mmap,
.flush = f2fs_file_flush,
.fsync = f2fs_sync_file,
.fallocate = f2fs_fallocate,
.unlocked_ioctl = f2fs_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = f2fs_compat_ioctl,
#endif
.splice_read = generic_file_splice_read,
.splice_write = iter_file_splice_write,
};

open

f2fs_file_open

写流程

读流程

journal

checkpoint

参考链接

http://www.cnblogs.com/tcicy/p/8506898.html

标签:f2f2,f2fs,SUM,笔记,summary,学习,file,JOURNAL,struct
来源: http://blog.51cto.com/xiamachao/2348748