ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

f2f2 学习笔记 之一

2019-02-04 10:55:07  阅读:419  来源: 互联网

标签:f2f2 f2fs SUM 笔记 summary 学习 file JOURNAL struct


源代码位置

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

/*

  • For segment summary
  • One summary block contains exactly 512 summary entries, which represents
  • exactly 2MB segment by default. Not allow to change the basic units.
  • NOTE: For initializing fields, you must use set_summary
    • If data page, nid represents dnode's nid
    • If node page, nid represents the node page's nid.
  • The ofs_in_node is used by only data page. It represents offset
  • from node's page's beginning to get a data block address.
  • ex) data_blkaddr = (block_t)(nodepage_start_address + ofs_in_node)
    /
    #define ENTRIES_IN_SUM 512
    #define SUMMARY_SIZE (7) /
    sizeof(struct summary) /
    #define SUM_FOOTER_SIZE (5) /
    sizeof(struct summary_footer) /
    #define SUM_ENTRY_SIZE (SUMMARY_SIZE
    ENTRIES_IN_SUM)

/ 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

  • that of nat_journal and sit_journal.
    */
    #define EXTRA_INFO_RESERVED (SUM_JOURNAL_SIZE - 2 - 8)

/*

  • frequently updated NAT/SIT entries can be stored in the spare area in
  • summary blocks
    */
    enum {
    NAT_JOURNAL = 0,
    SIT_JOURNAL
    };

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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有