f2fs: enhance scalibility of {d,id,did,x}node disk layout
PATCH 1/2 f2fs: enhance scalibility of {d,id,did,x}node disk layout
Scalibility of non-inode disk layout is very bad, it's hard to add or reuse any fields in current structure, so, for new feature like node checksum which wants to add 4 bytes field in node structure, the bad scaliblity becomes a obstacle for its implementation.
In order to enhance scalibility, we introduce a new filesystem feature 'extended_node' which can be enabled via mkfs.f2fs, once this feature is set, we will add and configure f2fs_super_block::extra_nsize to indicate extended space used for storing new attribution, accordingly, it needs to recalculate space of original .addr/.nid/xattr space in node block.
dnode, idnode, didnode, xnode disk layout:
+----------------------+ | .addr or .nid, .xatt | +----------------------+<----+ | ...... | | | .epoch | | | .transaction_id | +------ f2fs_super_block::extra_nsize | .node_checksum | | +----------------------+<----+ | node_footer | | (nid, ino, offset) | +----------------------+
--- fs/f2fs/f2fs.h | 23 +++++++++++++++++++++++ fs/f2fs/file.c | 7 ++++--- fs/f2fs/gc.c | 9 +++++---- fs/f2fs/node.c | 46 +++++++++++++++++++++++++--------------------- fs/f2fs/node.h | 13 ++++++++----- fs/f2fs/super.c | 16 +++++++++++----- fs/f2fs/sysfs.c | 7 +++++++ fs/f2fs/xattr.c | 10 ++++++---- fs/f2fs/xattr.h | 6 ++++-- include/linux/f2fs_fs.h | 18 ++++++++++-------- 10 files changed, 103 insertions(+), 52 deletions(-)
fs/f2fs/f2fs.h +23 -0
@@ -127,6 +127,7 @@ struct f2fs_mount_info {#define F2FS_FEATURE_FLEXIBLE_INLINE_XATTR 0x0040#define F2FS_FEATURE_QUOTA_INO 0x0080#define F2FS_FEATURE_INODE_CRTIME 0x0100 +#define F2FS_FEATURE_EXTENDED_NODE 0x0200#define F2FS_HAS_FEATURE (sb, mask) \ ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
@@ -416,6 +417,7 @@ struct f2fs_flush_device {#define DEF_INLINE_RESERVED_SIZE 1#define DEF_MIN_INLINE_SIZE 1static inline int get_extra_isize (struct inode *inode); +static inline int get_extra_nsize (struct super_block *sb);static inline int get_inline_xattr_addrs (struct inode *inode);#define MAX_INLINE_DATA (inode) (sizeof(__le32) * \ (CUR_ADDRS_PER_INODE(inode) - \
@@ -1123,6 +1125,7 @@ struct f2fs_sb_info {int inline_xattr_size;/* inline xattr size */ unsigned int trigger_ssr_threshold;/* threshold to trigger ssr */ int readdir_ra;/* readahead inode in readdir */ +unsigned int extra_nsize;/* extra attr size in {d,id,did,x}node */ block_t user_block_count;/* # of user blocks */ block_t total_valid_block_count;/* # of valid blocks */
@@ -2344,6 +2347,16 @@ static inline unsigned int addrs_per_inode(struct inode *inode)return CUR_ADDRS_PER_INODE (inode) -get_inline_xattr_addrs (inode); } +static inline unsigned int addrs_per_dnode (struct inode *inode) +{ +return DEF_ADDRS_PER_BLOCK -get_extra_nsize (inode->i_sb); +} + +static inline unsigned int nids_per_idnode (struct inode *inode) +{ +return DEF_NIDS_PER_BLOCK -get_extra_nsize (inode->i_sb); +} +static inline void *inline_xattr_addr (struct inode *inode,struct page *page) {struct f2fs_inode *ri =F2FS_INODE (page);
@@ -2533,6 +2546,11 @@ static inline int get_extra_isize(struct inode *inode)return F2FS_I (inode)->i_extra_isize /sizeof (__le32); } +static inline int get_extra_nsize (struct super_block *sb) +{ +return F2FS_SB (sb)->extra_nsize /sizeof (__le32); +} +static inline int get_inline_xattr_addrs (struct inode *inode) {return F2FS_I (inode)->i_inline_xattr_size;
@@ -3229,6 +3247,11 @@ static inline int f2fs_sb_has_inode_crtime(struct super_block *sb)return F2FS_HAS_FEATURE (sb,F2FS_FEATURE_INODE_CRTIME ); } +static inline int f2fs_sb_has_extended_node (struct super_block *sb) +{ +return F2FS_HAS_FEATURE (sb,F2FS_FEATURE_EXTENDED_NODE ); +} +#ifdef CONFIG_BLK_DEV_ZONED static inline int get_blkz_type (struct f2fs_sb_info *sbi,struct block_device *bdev,block_t blkaddr)
fs/f2fs/file.c +4 -3
@@ -540,7 +540,7 @@ void truncate_data_blocks_range(struct dnode_of_data *dn, int count)void truncate_data_blocks (struct dnode_of_data *dn) { -truncate_data_blocks_range (dn,ADDRS_PER_BLOCK ); +truncate_data_blocks_range (dn,ADDRS_PER_BLOCK (dn->inode)); } static int truncate_partial_data_page(struct inode *inode, u64 from,
@@ -978,7 +978,8 @@ static int __read_out_blkaddrs(struct inode *inode, block_t *blkaddr, }else if (ret == -ENOENT ) {if (dn.max_level ==0 )return -ENOENT ; - done =min ((pgoff_t )ADDRS_PER_BLOCK - dn.ofs_in_node, len); + done =min ((pgoff_t )ADDRS_PER_BLOCK (inode) - dn.ofs_in_node, + len); blkaddr += done; do_replace += done; goto next;
@@ -1122,7 +1123,7 @@ static int __exchange_data_block(struct inode *src_inode,int ret;while (len) { - olen =min ((pgoff_t )4 *ADDRS_PER_BLOCK , len); + olen =min ((pgoff_t )4 *ADDRS_PER_BLOCK (src_inode), len); src_blkaddr =f2fs_kvzalloc (F2FS_I_SB (src_inode),sizeof (block_t) * olen,GFP_KERNEL );
fs/f2fs/gc.c +5 -4
@@ -538,7 +538,7 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,*/ block_t start_bidx_of_node (unsigned int node_ofs,struct inode *inode) { -unsigned int indirect_blks =2 *NIDS_PER_BLOCK +4 ; +unsigned int indirect_blks =2 *NIDS_PER_BLOCK (inode) +4 ;unsigned int bidx;if (node_ofs ==0 )
@@ -547,13 +547,14 @@ block_t start_bidx_of_node(unsigned int node_ofs, struct inode *inode)if (node_ofs <=2 ) { bidx = node_ofs -1 ; }else if (node_ofs <= indirect_blks) { -int dec = (node_ofs -4 ) / (NIDS_PER_BLOCK +1 ); +int dec = (node_ofs -4 ) / (NIDS_PER_BLOCK (inode) +1 ); bidx = node_ofs -2 - dec; }else { -int dec = (node_ofs - indirect_blks -3 ) / (NIDS_PER_BLOCK +1 ); +int dec = (node_ofs - indirect_blks -3 ) / + (NIDS_PER_BLOCK (inode) +1 ); bidx = node_ofs -5 - dec; } -return bidx *ADDRS_PER_BLOCK +ADDRS_PER_INODE (inode); +return bidx *ADDRS_PER_BLOCK (inode) +ADDRS_PER_INODE (inode); } static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
fs/f2fs/node.c +25 -21
119 lines not on this page · raw message
fs/f2fs/node.h +8 -5
@@ -338,17 +338,20 @@ static inline bool is_recoverable_dnode(struct page *page)*/ static inline bool IS_DNODE (struct page *node_page) { +struct f2fs_sb_info *sbi =F2FS_P_SB (node_page);unsigned int ofs =ofs_of_node (node_page); +unsigned int nids_per_block =DEF_NIDS_PER_BLOCK - +get_extra_nsize (sbi->sb);if (f2fs_has_xattr_block (ofs))return true; -if (ofs ==3 || ofs ==4 +NIDS_PER_BLOCK || - ofs ==5 +2 *NIDS_PER_BLOCK ) +if (ofs ==3 || ofs ==4 + nids_per_block || + ofs ==5 +2 * nids_per_block)return false; -if (ofs >=6 +2 *NIDS_PER_BLOCK ) { - ofs -=6 +2 *NIDS_PER_BLOCK ; -if (!((long int )ofs % (NIDS_PER_BLOCK +1 ))) +if (ofs >=6 +2 * nids_per_block) { + ofs -=6 +2 * nids_per_block; +if (!((long int )ofs % (nids_per_block +1 )))return false; }return true;
fs/f2fs/super.c +11 -5
@@ -1901,10 +1901,12 @@ static const struct export_operations f2fs_export_ops = { .get_parent = f2fs_get_parent, }; -static loff_t max_file_blocks (void ) +static loff_t max_file_blocks (struct super_block *sb) { +unsigned int nids_per_block =DEF_NIDS_PER_BLOCK - +get_extra_nsize (sb); +loff_t leaf_count =DEF_ADDRS_PER_BLOCK -get_extra_nsize (sb);loff_t result =0 ; -loff_t leaf_count =ADDRS_PER_BLOCK ;/* * note: previously, result is equal to (DEF_ADDRS_PER_INODE -
@@ -1917,11 +1919,11 @@ static loff_t max_file_blocks(void) result += (leaf_count *2 );/* two indirect node blocks */ - leaf_count *=NIDS_PER_BLOCK ; + leaf_count *= nids_per_block; result += (leaf_count *2 );/* one double indirect node block */ - leaf_count *=NIDS_PER_BLOCK ; + leaf_count *= nids_per_block; result += leaf_count;return result;
@@ -2554,6 +2556,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) goto free_sb_buf; }#endif + +if (f2fs_sb_has_extended_node (sb)) + sbi->extra_nsize =le16_to_cpu (raw_super->extra_nsize); +default_options (sbi);/* parse mount options */ options =kstrdup ((const char *)data,GFP_KERNEL );
@@ -2566,7 +2572,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)if (err) goto free_options; - sbi->max_file_blocks =max_file_blocks (); + sbi->max_file_blocks =max_file_blocks (sb); sb->s_maxbytes = sbi->max_file_blocks <<le32_to_cpu (raw_super->log_blocksize); sb->s_max_links =F2FS_LINK_MAX ;
fs/f2fs/sysfs.c +7 -0
@@ -116,6 +116,9 @@ static ssize_t features_show(struct f2fs_attr *a,if (f2fs_sb_has_inode_crtime (sb)) len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , len ?", " :"" ,"inode_crtime" ); +if (f2fs_sb_has_extended_node (sb)) + len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len ?", " :"" ,"extended_node" ); len +=snprintf (buf + len,PAGE_SIZE - len,"\n" );return len; }
@@ -236,6 +239,7 @@ enum feat_id {FEAT_FLEXIBLE_INLINE_XATTR ,FEAT_QUOTA_INO ,FEAT_INODE_CRTIME , + FEAT_EXTENDED_NODE, }; static ssize_t f2fs_feature_show(struct f2fs_attr *a,
@@ -251,6 +255,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,case FEAT_FLEXIBLE_INLINE_XATTR :case FEAT_QUOTA_INO :case FEAT_INODE_CRTIME : +case FEAT_EXTENDED_NODE :return snprintf (buf,PAGE_SIZE ,"supported\n" ); }return 0 ;
@@ -329,6 +334,7 @@ F2FS_FEATURE_RO_ATTR(inode_checksum, FEAT_INODE_CHECKSUM);F2FS_FEATURE_RO_ATTR (flexible_inline_xattr,FEAT_FLEXIBLE_INLINE_XATTR );F2FS_FEATURE_RO_ATTR (quota_ino,FEAT_QUOTA_INO );F2FS_FEATURE_RO_ATTR (inode_crtime,FEAT_INODE_CRTIME ); +F2FS_FEATURE_RO_ATTR (extended_node,FEAT_EXTENDED_NODE );#define ATTR_LIST (name) (&f2fs_attr_##name.attr)static struct attribute *f2fs_attrs[] = {
@@ -383,6 +389,7 @@ static struct attribute *f2fs_feat_attrs[] = {ATTR_LIST (flexible_inline_xattr),ATTR_LIST (quota_ino),ATTR_LIST (inode_crtime), +ATTR_LIST (extended_node), NULL, };
fs/f2fs/xattr.c +6 -4
@@ -278,7 +278,8 @@ static int read_xattr_block(struct inode *inode, void *txattr_addr)return PTR_ERR (xpage); xattr_addr =page_address (xpage); -memcpy (txattr_addr + inline_size, xattr_addr,VALID_XATTR_BLOCK_SIZE ); +memcpy (txattr_addr + inline_size, xattr_addr, +VALID_XATTR_BLOCK_SIZE (inode));f2fs_put_page (xpage,1 );return 0 ;
@@ -291,7 +292,7 @@ static int lookup_all_xattrs(struct inode *inode, struct page *ipage, {void *cur_addr, *txattr_addr, *last_addr =NULL ;nid_t xnid =F2FS_I (inode)->i_xattr_nid; -unsigned int size = xnid ?VALID_XATTR_BLOCK_SIZE :0 ; +unsigned int size = xnid ?VALID_XATTR_BLOCK_SIZE (inode) :0 ;unsigned int inline_size =inline_xattr_size (inode);int err =0 ;
@@ -346,7 +347,7 @@ static int read_all_xattrs(struct inode *inode, struct page *ipage, {struct f2fs_xattr_header *header;nid_t xnid =F2FS_I (inode)->i_xattr_nid; -unsigned int size =VALID_XATTR_BLOCK_SIZE ; +unsigned int size =VALID_XATTR_BLOCK_SIZE (inode);unsigned int inline_size =inline_xattr_size (inode);void *txattr_addr;int err;
@@ -454,7 +455,8 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,if (inline_size)memcpy (inline_addr, txattr_addr, inline_size); -memcpy (xattr_addr, txattr_addr + inline_size,VALID_XATTR_BLOCK_SIZE ); +memcpy (xattr_addr, txattr_addr + inline_size, +VALID_XATTR_BLOCK_SIZE (inode));if (inline_size)set_page_dirty (ipage ? ipage : in_page);
fs/f2fs/xattr.h +4 -2
@@ -72,10 +72,12 @@ struct f2fs_xattr_entry {for (entry =XATTR_FIRST_ENTRY (addr);\ !IS_XATTR_LAST_ENTRY (entry);\ entry = XATTR_NEXT_ENTRY(entry)) -#define VALID_XATTR_BLOCK_SIZE (PAGE_SIZE - sizeof(struct node_footer)) +#define VALID_XATTR_BLOCK_SIZE (i) (PAGE_SIZE - \ + sizeof(struct node_footer) - \ + F2FS_I_SB(i)->extra_nsize)#define XATTR_PADDING_SIZE (sizeof(__u32))#define MIN_OFFSET (i) XATTR_ALIGN(inline_xattr_size(i) + \ - VALID_XATTR_BLOCK_SIZE) + VALID_XATTR_BLOCK_SIZE(i))#define MAX_VALUE_LEN (i) (MIN_OFFSET(i) - \ sizeof(struct f2fs_xattr_header) - \
include/linux/f2fs_fs.h +10 -8
@@ -111,7 +111,8 @@ struct f2fs_super_block {__u8 encrypt_pw_salt[16 ];/* Salt used for string2key algorithm */ struct f2fs_device devs[MAX_DEVICES ];/* device list */ __le32 qf_ino[F2FS_MAX_QUOTAS ];/* quota inode numbers */ -__u8 reserved[315 ];/* valid reserved region */ +__le16 extra_nsize;/* extra node size */ +__u8 reserved[313 ];/* valid reserved region */ } __packed;/*
@@ -192,15 +193,16 @@ struct f2fs_extent {/* 200 bytes for inline xattrs by default */ #define DEFAULT_INLINE_XATTR_ADDRS 50#define DEF_ADDRS_PER_INODE 923/* Address Pointers in an Inode */ +#define DEF_ADDRS_PER_BLOCK 1018/* Address Pointers in a Direct Block */ +#define DEF_NIDS_PER_BLOCK 1018/* Node IDs in an Indirect Block */ +#define DEF_NIDS_PER_INODE 5/* Node IDs in an Inode */ #define CUR_ADDRS_PER_INODE (inode) (DEF_ADDRS_PER_INODE - \ get_extra_isize(inode)) -#define DEF_NIDS_PER_INODE 5/* Node IDs in an Inode */ #define ADDRS_PER_INODE (inode) addrs_per_inode(inode) -#define ADDRS_PER_BLOCK 1018/* Address Pointers in a Direct Block */ -#define NIDS_PER_BLOCK 1018/* Node IDs in an Indirect Block */ - +#define ADDRS_PER_BLOCK (inode) addrs_per_dnode(inode) +#define NIDS_PER_BLOCK (inode) nids_per_idnode(inode)#define ADDRS_PER_PAGE (page, inode) \ - (IS_INODE(page) ? ADDRS_PER_INODE(inode) : ADDRS_PER_BLOCK) + (IS_INODE(page) ? ADDRS_PER_INODE(inode) : ADDRS_PER_BLOCK(inode))#define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1)#define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2)
@@ -265,11 +267,11 @@ struct f2fs_inode { } __packed;struct direct_node { -__le32 addr[ADDRS_PER_BLOCK ];/* array of data block address */ +__le32 addr[DEF_ADDRS_PER_BLOCK ];/* array of data block address */ } __packed;struct indirect_node { -__le32 nid[NIDS_PER_BLOCK ];/* array of data block address */ +__le32 nid[DEF_NIDS_PER_BLOCK ];/* array of data block address */ } __packed;enum {
Signature · 6 lines
2.15.0.55.gc2ece9dc4de6 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
PATCH 2/2 f2fs: support {d,id,did,x}node checksum
This patch adds to support {d,id,did,x}node checksum in kernel side.
--- fs/f2fs/f2fs.h | 15 +++++++- fs/f2fs/inode.c | 98 +++++++++++++++++++++++++++++++------------------ fs/f2fs/node.c | 2 +- fs/f2fs/segment.c | 2 +- fs/f2fs/sysfs.c | 7 ++++ include/linux/f2fs_fs.h | 10 ++++- 6 files changed, 93 insertions(+), 41 deletions(-)
fs/f2fs/f2fs.h +13 -2
@@ -128,6 +128,7 @@ struct f2fs_mount_info {#define F2FS_FEATURE_QUOTA_INO 0x0080#define F2FS_FEATURE_INODE_CRTIME 0x0100#define F2FS_FEATURE_EXTENDED_NODE 0x0200 +#define F2FS_FEATURE_NODE_CHECKSUM 0x0400#define F2FS_HAS_FEATURE (sb, mask) \ ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
@@ -2570,6 +2571,11 @@ static inline int get_inline_xattr_addrs(struct inode *inode) sizeof((f2fs_inode)->field)) \ <= (F2FS_OLD_ATTRIBUTE_SIZE + extra_isize)) \ +#define F2FS_FITS_IN_NODE (extra_nsize, field) \ + ((offsetof(struct f2fs_node, footer) - \ + offsetof(struct f2fs_node, field)) \ + <= (extra_nsize)) \ +static inline void f2fs_reset_iostat (struct f2fs_sb_info *sbi) {int i;
@@ -2616,8 +2622,8 @@ int f2fs_pin_file_control(struct inode *inode, bool inc);* inode.c */ void f2fs_set_inode_flags (struct inode *inode); -bool f2fs_inode_chksum_verify (struct f2fs_sb_info *sbi,struct page *page); -void f2fs_inode_chksum_set (struct f2fs_sb_info *sbi,struct page *page); +bool f2fs_node_chksum_verify (struct f2fs_sb_info *sbi,struct page *page); +void f2fs_node_chksum_set (struct f2fs_sb_info *sbi,struct page *page);struct inode *f2fs_iget (struct super_block *sb,unsigned long ino);struct inode *f2fs_iget_retry (struct super_block *sb,unsigned long ino);int try_to_free_nats (struct f2fs_sb_info *sbi,int nr_shrink);
@@ -3252,6 +3258,11 @@ static inline int f2fs_sb_has_extended_node(struct super_block *sb)return F2FS_HAS_FEATURE (sb,F2FS_FEATURE_EXTENDED_NODE ); } +static inline int f2fs_sb_has_node_checksum (struct super_block *sb) +{ +return F2FS_HAS_FEATURE (sb,F2FS_FEATURE_NODE_CHECKSUM ); +} +#ifdef CONFIG_BLK_DEV_ZONED static inline int get_blkz_type (struct f2fs_sb_info *sbi,struct block_device *bdev,block_t blkaddr)
fs/f2fs/inode.c +63 -35
138 lines not on this page · raw message
fs/f2fs/node.c +1 -1
@@ -1194,7 +1194,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid, goto out_err; } -if (!f2fs_inode_chksum_verify (sbi, page)) { +if (!f2fs_node_chksum_verify (sbi, page)) { err = -EBADMSG ; goto out_err; }
fs/f2fs/segment.c +1 -1
@@ -2678,7 +2678,7 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,if (page &&IS_NODESEG (type)) {fill_node_footer_blkaddr (page,NEXT_FREE_BLKADDR (sbi, curseg)); -f2fs_inode_chksum_set (sbi, page); +f2fs_node_chksum_set (sbi, page); }if (add_list) {
fs/f2fs/sysfs.c +7 -0
@@ -119,6 +119,9 @@ static ssize_t features_show(struct f2fs_attr *a,if (f2fs_sb_has_extended_node (sb)) len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , len ?", " :"" ,"extended_node" ); +if (f2fs_sb_has_node_checksum (sb)) + len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len ?", " :"" ,"node_checksum" ); len +=snprintf (buf + len,PAGE_SIZE - len,"\n" );return len; }
@@ -240,6 +243,7 @@ enum feat_id {FEAT_QUOTA_INO ,FEAT_INODE_CRTIME ,FEAT_EXTENDED_NODE , + FEAT_NODE_CHECKSUM, }; static ssize_t f2fs_feature_show(struct f2fs_attr *a,
@@ -256,6 +260,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,case FEAT_QUOTA_INO :case FEAT_INODE_CRTIME :case FEAT_EXTENDED_NODE : +case FEAT_NODE_CHECKSUM :return snprintf (buf,PAGE_SIZE ,"supported\n" ); }return 0 ;
@@ -335,6 +340,7 @@ F2FS_FEATURE_RO_ATTR(flexible_inline_xattr, FEAT_FLEXIBLE_INLINE_XATTR);F2FS_FEATURE_RO_ATTR (quota_ino,FEAT_QUOTA_INO );F2FS_FEATURE_RO_ATTR (inode_crtime,FEAT_INODE_CRTIME );F2FS_FEATURE_RO_ATTR (extended_node,FEAT_EXTENDED_NODE ); +F2FS_FEATURE_RO_ATTR (node_checksum,FEAT_NODE_CHECKSUM );#define ATTR_LIST (name) (&f2fs_attr_##name.attr)static struct attribute *f2fs_attrs[] = {
@@ -390,6 +396,7 @@ static struct attribute *f2fs_feat_attrs[] = {ATTR_LIST (quota_ino),ATTR_LIST (inode_crtime),ATTR_LIST (extended_node), +ATTR_LIST (node_checksum), NULL, };
include/linux/f2fs_fs.h +8 -2
@@ -295,8 +295,14 @@ struct f2fs_node {/* can be one of three types: inode, direct, and indirect types */ union {struct f2fs_inode i; -struct direct_node dn; -struct indirect_node in; +union { +struct { +__le32 data[1017 ]; +__le32 node_checksum; + }; +struct direct_node dn; +struct indirect_node in; + }; };struct node_footer footer; } __packed;
Signature · 1 line
2.15.0.55.gc2ece9dc4de6
Jaegeuk Kim
maintainerRe: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 84 lines · Chao Yu
This patch adds to support {d,id,did,x}node checksum in kernel side.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/f2fs.h | 15 +++++++- fs/f2fs/inode.c | 98 +++++++++++++++++++++++++++++++------------------ fs/f2fs/node.c | 2 +- fs/f2fs/segment.c | 2 +- fs/f2fs/sysfs.c | 7 ++++ include/linux/f2fs_fs.h | 10 ++++- 6 files changed, 93 insertions(+), 41 deletions(-)fs/f2fs/f2fs.h +13
-2@@ -128,6 +128,7 @@ struct f2fs_mount_info {#define F2FS_FEATURE_QUOTA_INO 0x0080#define F2FS_FEATURE_INODE_CRTIME 0x0100#define F2FS_FEATURE_EXTENDED_NODE 0x0200 +#define F2FS_FEATURE_NODE_CHECKSUM 0x0400#define F2FS_HAS_FEATURE (sb, mask) \ ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)@@ -2570,6 +2571,11 @@ static inline int get_inline_xattr_addrs(struct inode *inode) sizeof((f2fs_inode)->field)) \ <= (F2FS_OLD_ATTRIBUTE_SIZE + extra_isize)) \ +#define F2FS_FITS_IN_NODE (extra_nsize, field) \ + ((offsetof(struct f2fs_node, footer) - \ + offsetof(struct f2fs_node, field)) \ + <= (extra_nsize)) \ +static inline void f2fs_reset_iostat (struct f2fs_sb_info *sbi) {int i;@@ -2616,8 +2622,8 @@ int f2fs_pin_file_control(struct inode *inode, bool inc);* inode.c */ void f2fs_set_inode_flags (struct inode *inode); -bool f2fs_inode_chksum_verify (struct f2fs_sb_info *sbi,struct page *page); -void f2fs_inode_chksum_set (struct f2fs_sb_info *sbi,struct page *page); +bool f2fs_node_chksum_verify (struct f2fs_sb_info *sbi,struct page *page); +void f2fs_node_chksum_set (struct f2fs_sb_info *sbi,struct page *page);struct inode *f2fs_iget (struct super_block *sb,unsigned long ino);struct inode *f2fs_iget_retry (struct super_block *sb,unsigned long ino);int try_to_free_nats (struct f2fs_sb_info *sbi,int nr_shrink);@@ -3252,6 +3258,11 @@ static inline int f2fs_sb_has_extended_node(struct super_block *sb)return F2FS_HAS_FEATURE (sb,F2FS_FEATURE_EXTENDED_NODE ); } +static inline int f2fs_sb_has_node_checksum (struct super_block *sb) +{ +return F2FS_HAS_FEATURE (sb,F2FS_FEATURE_NODE_CHECKSUM ); +} +#ifdef CONFIG_BLK_DEV_ZONED static inline int get_blkz_type (struct f2fs_sb_info *sbi,struct block_device *bdev,block_t blkaddr)fs/f2fs/inode.c +4
-12@@ -111,75 +111,103 @@ static void __recover_inline_status(struct inode *inode, struct page *ipage)return ; } -static bool f2fs_enable_inode_chksum (struct f2fs_sb_info *sbi,struct page *page) +static bool f2fs_enable_node_chksum (struct f2fs_sb_info *sbi,struct page *page) { -struct f2fs_inode *ri = &F2FS_NODE (page)->i; -int extra_isize =le32_to_cpu (ri->i_extra_isize); - -if (!f2fs_sb_has_inode_chksum (sbi->sb)) -return false; - -if (!RAW_IS_INODE (F2FS_NODE (page)) || !(ri->i_inline &F2FS_EXTRA_ATTR )) -return false; - -if (!F2FS_FITS_IN_INODE (ri, extra_isize, i_inode_checksum)) -return false; +if (IS_INODE (page)) { +struct f2fs_inode *ri = &F2FS_NODE (page)->i; +int extra_isize =le32_to_cpu (ri->i_extra_isize);
fs/f2fs/inode.c static void __recover_inline_status(struct inode *inode, struct page *ipage) · line 128
Quoted 10 lines
fs/f2fs/inode.c +10
-0+ +if (!(ri->i_inline &F2FS_EXTRA_ATTR )) +return false; +if (!f2fs_sb_has_inode_chksum (sbi->sb)) +return false; +if (!F2FS_FITS_IN_INODE (ri, extra_isize, i_inode_checksum)) +return false; + }else { +if (!f2fs_sb_has_extended_node (sbi->sb)) +return false;
What if we want to add more entries in addition to node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value instead of extra_nsize? For example, layout #1 means node_checksum with extra_nsize=X?
Quoted 73 lines
fs/f2fs/inode.c +30
-18+if (!f2fs_sb_has_node_checksum (sbi->sb)) +return false; +if (!F2FS_FITS_IN_NODE (sbi->extra_nsize, node_checksum)) +return false; + }return true; } -static __u32 f2fs_inode_chksum (struct f2fs_sb_info *sbi,struct page *page) +static __u32 f2fs_node_chksum (struct f2fs_sb_info *sbi,struct page *page) {struct f2fs_node *node =F2FS_NODE (page); -struct f2fs_inode *ri = &node->i; -__le32 ino = node->footer.ino; -__le32 gen = ri->i_generation; -__u32 chksum, chksum_seed; -__u32 dummy_cs =0 ; -unsigned int offset = offsetof(struct f2fs_inode , i_inode_checksum); -unsigned int cs_size =sizeof (dummy_cs); +__le32 append, ino = node->footer.ino; +__u32 chksum, chksum_seed, dummy_cs =0 ; +unsigned int offset, cs_size =sizeof (dummy_cs); +bool is_inode =RAW_IS_INODE (node); + +if (is_inode) { + append = node->i.i_generation; + offset = offsetof(struct f2fs_inode , i_inode_checksum); + }else { + append = node->footer.nid; + offset = offsetof(struct f2fs_node , node_checksum); + } chksum =f2fs_chksum (sbi, sbi->s_chksum_seed, (__u8 *)&ino,sizeof (ino)); - chksum_seed =f2fs_chksum (sbi, chksum, (__u8 *)&gen,sizeof (gen)); + chksum_seed =f2fs_chksum (sbi, chksum, (__u8 *)&append,sizeof (append)); - chksum =f2fs_chksum (sbi, chksum_seed, (__u8 *)ri, offset); + chksum =f2fs_chksum (sbi, chksum_seed, (__u8 *)node, offset); chksum =f2fs_chksum (sbi, chksum, (__u8 *)&dummy_cs, cs_size); offset += cs_size; - chksum =f2fs_chksum (sbi, chksum, (__u8 *)ri + offset, + chksum =f2fs_chksum (sbi, chksum, (__u8 *)node + offset,F2FS_BLKSIZE - offset);return chksum; } -bool f2fs_inode_chksum_verify (struct f2fs_sb_info *sbi,struct page *page) +bool f2fs_node_chksum_verify (struct f2fs_sb_info *sbi,struct page *page) { -struct f2fs_inode *ri; +struct f2fs_node *rn;__u32 provided, calculated; -if (!f2fs_enable_inode_chksum (sbi, page) || +if (!f2fs_enable_node_chksum (sbi, page) ||PageDirty (page) ||PageWriteback (page))return true; - ri = &F2FS_NODE (page)->i; - provided =le32_to_cpu (ri->i_inode_checksum); - calculated =f2fs_inode_chksum (sbi, page); + rn =F2FS_NODE (page); +if (RAW_IS_INODE (rn)) + provided =le32_to_cpu (rn->i.i_inode_checksum); +else + provided =le32_to_cpu (rn->node_checksum); + calculated =f2fs_node_chksum (sbi, page);if (provided != calculated) f2fs_msg(sbi->sb, KERN_WARNING, - "checksum invalid, ino = %x, %x vs. %x",
fs/f2fs/inode.c static void __recover_inline_status(struct inode *inode, struct page *ipage) · line 192
Quoted 10 lines
fs/f2fs/inode.c +9
-1- ino_of_node(page), provided, calculated); +"checksum invalid, ino = %u, nid = %u, %x vs. %x" , +ino_of_node (page),nid_of_node (page), + provided, calculated); + + else + f2fs_msg(sbi->sb, KERN_WARNING, +"checksum is valid, ino = %u, nid = %u, %x vs. %x" , +ino_of_node (page),nid_of_node (page), + provided, calculated);
Need to clean up.
Quoted 102 lines
fs/f2fs/inode.c +10
-4return provided == calculated; } -void f2fs_inode_chksum_set (struct f2fs_sb_info *sbi,struct page *page) +void f2fs_node_chksum_set (struct f2fs_sb_info *sbi,struct page *page) { -struct f2fs_inode *ri = &F2FS_NODE (page)->i; +struct f2fs_node *rn =F2FS_NODE (page); +__le32 chksum; -if (!f2fs_enable_inode_chksum (sbi, page)) +if (!f2fs_enable_node_chksum (sbi, page))return ; - ri->i_inode_checksum =cpu_to_le32 (f2fs_inode_chksum (sbi, page)); + chksum =cpu_to_le32 (f2fs_node_chksum (sbi, page)); + +if (RAW_IS_INODE (rn)) + rn->i.i_inode_checksum = chksum; +else + rn->node_checksum = chksum; }static int do_read_inode (struct inode *inode)fs/f2fs/node.c +1
-1@@ -1194,7 +1194,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid, goto out_err; } -if (!f2fs_inode_chksum_verify (sbi, page)) { +if (!f2fs_node_chksum_verify (sbi, page)) { err = -EBADMSG ; goto out_err; }fs/f2fs/segment.c +1
-1@@ -2678,7 +2678,7 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,if (page &&IS_NODESEG (type)) {fill_node_footer_blkaddr (page,NEXT_FREE_BLKADDR (sbi, curseg)); -f2fs_inode_chksum_set (sbi, page); +f2fs_node_chksum_set (sbi, page); }if (add_list) {fs/f2fs/sysfs.c +7
-0@@ -119,6 +119,9 @@ static ssize_t features_show(struct f2fs_attr *a,if (f2fs_sb_has_extended_node (sb)) len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , len ?", " :"" ,"extended_node" ); +if (f2fs_sb_has_node_checksum (sb)) + len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len ?", " :"" ,"node_checksum" ); len +=snprintf (buf + len,PAGE_SIZE - len,"\n" );return len; }@@ -240,6 +243,7 @@ enum feat_id {FEAT_QUOTA_INO ,FEAT_INODE_CRTIME ,FEAT_EXTENDED_NODE , + FEAT_NODE_CHECKSUM, }; static ssize_t f2fs_feature_show(struct f2fs_attr *a,@@ -256,6 +260,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,case FEAT_QUOTA_INO :case FEAT_INODE_CRTIME :case FEAT_EXTENDED_NODE : +case FEAT_NODE_CHECKSUM :return snprintf (buf,PAGE_SIZE ,"supported\n" ); }return 0 ;@@ -335,6 +340,7 @@ F2FS_FEATURE_RO_ATTR(flexible_inline_xattr, FEAT_FLEXIBLE_INLINE_XATTR);F2FS_FEATURE_RO_ATTR (quota_ino,FEAT_QUOTA_INO );F2FS_FEATURE_RO_ATTR (inode_crtime,FEAT_INODE_CRTIME );F2FS_FEATURE_RO_ATTR (extended_node,FEAT_EXTENDED_NODE ); +F2FS_FEATURE_RO_ATTR (node_checksum,FEAT_NODE_CHECKSUM );#define ATTR_LIST (name) (&f2fs_attr_##name.attr)static struct attribute *f2fs_attrs[] = {@@ -390,6 +396,7 @@ static struct attribute *f2fs_feat_attrs[] = {ATTR_LIST (quota_ino),ATTR_LIST (inode_crtime),ATTR_LIST (extended_node), +ATTR_LIST (node_checksum), NULL, };include/linux/f2fs_fs.h +0
-0
include/linux/f2fs_fs.h struct f2fs_node { · line 301
Quoted 9 lines
include/linux/f2fs_fs.h +4
-2@@ -295,8 +295,14 @@ struct f2fs_node {/* can be one of three types: inode, direct, and indirect types */ union { struct f2fs_inode i; -struct direct_node dn; -struct indirect_node in; + union { + struct { + __le32 data[1017]; + __le32 node_checksum;
What does 1017 mean? We need to make this structure more flexibly for new entries. Like this?
union {
struct node_v1;
struct node_v2;
struct node_v3;
...
struct direct_node dn;
struct indirect_node in;
};
};
struct node_v1 {
__le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1];
__le32 node_checksum;
}
struct node_v2 {
__le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];
__le32 comp[V2_NSIZE];
}
...Quoted 9 lines
include/linux/f2fs_fs.h +4
-0+ }; +struct direct_node dn; +struct indirect_node in; + }; };struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6
Re: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value instead
Hmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/ extra_nsize only, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.
One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };
Quoted 7 lines
struct node_v1 {
__le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1];
__le32 node_checksum;
}
struct node_v2 {
__le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct node_v2, but V2_NSIZE is defined as fixed 500, there must be 492 bytes wasted.
Or we can define V2_NSIZE as 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.
One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by f2fs_inode:
struct f2fs_node {
union {
struct f2fs_inode i;
union {
struct {
__le32 node_checksum;
__le32 feature_field_1;
__le32 feature_field_2;
....
__le32 addr[];
};
struct direct_node dn;
struct indirect_node in;
};
};
struct node_footer footer;
} __packed;Moving all extended fields to the head of f2fs_node, so we don't have to use macro to indicate actual size of addr.
Thanks,
Quoted 16 lines
__le32 comp[V2_NSIZE]; } ...Quoted 9 lines
include/linux/f2fs_fs.h +4
-0+ }; +struct direct_node dn; +struct indirect_node in; + }; };struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Jaegeuk Kim
maintainerRe: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.
Thinking what'd be the best way. My concern is, once getting more entries, we can't set each of features individually. Like the second entry should have enabled node_checksum, which we may not want to do.
Quoted 19 lines
Thanks,
Quoted 16 lines
__le32 comp[V2_NSIZE]; } ...Quoted 9 lines
include/linux/f2fs_fs.h +4
-0+ }; +struct direct_node dn; +struct indirect_node in; + }; };struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Chao Yu
maintainerRe: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;
Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g. f2fs_inode::i_flags2 to indicate which new field in f2fs_node is valid, for example:
#define F2FS_NODE_CHECKSUM 0x0001
#define F2FS_NODE_FIELD1 0x0002
#define F2FS_NODE_FIELD2 0x0004
union {
struct {
__le32 node_checksum;
__le32 field_1;
__le32 field_2;
....
__le32 addr[];
};
struct direct_node dn;
struct indirect_node in;
};f2fs_inode::i_flags2 = F2FS_NODE_CHECKSUM | F2FS_NODE_FIELD1 indicates that f2fs_node::node_checksum and f2fs_node::field_1 are valid;
f2fs_inode::i_flags2 = F2FS_NODE_FIELD1 | F2FS_NODE_FIELD2 indicates that f2fs_node::field_1 and f2fs_node::field_2 are valid.
Any thoughts?
Thanks,
Quoted 21 lines
enabled
node_checksum, which we may not want to do.Quoted 19 lines
Thanks,
Quoted 16 lines
__le32 comp[V2_NSIZE]; } ...Quoted 9 lines
include/linux/f2fs_fs.h +4
-0+ }; +struct direct_node dn; +struct indirect_node in; + }; };struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Jaegeuk Kim
maintainerRe: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.
So, that's why I thought we may need a sort of each formats.
Quoted 26 lines
Any thoughts?
Thanks,
Quoted 21 lines
enabled
node_checksum, which we may not want to do.Quoted 19 lines
Thanks,
Quoted 16 lines
__le32 comp[V2_NSIZE]; } ...Quoted 9 lines
include/linux/f2fs_fs.h +4
-0+ }; +struct direct_node dn; +struct indirect_node in; + }; };struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Chao Yu
maintainerRe: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 105 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };
Quoted 7 lines
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.So, that's why I thought we may need a sort of each formats.
Hmm.. if we have two new added fields, there are (2 << 2) combinations of all formats, as:
struct original {
__le32 data[DEF_ADDRS_PER_BLOCK];
}struct node_v1 {
__le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1];
__le32 field_1;
}struct node_v2 {
__le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1];
__le32 field_2;
}struct node_v2 {
__le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2];
__le32 field_1;
__le32 field_2;
}If we add more new fields, the node version will increase sharply due to there is (n << 2) combination with n fields. Right? Any thoughts to reduce maintaining overhead on those node versions structures?
Thanks,
Quoted 27 lines
Quoted 27 lines
Any thoughts?
Thanks,
Quoted 21 lines
enabled
node_checksum, which we may not want to do.Quoted 19 lines
Thanks,
Quoted 16 lines
__le32 comp[V2_NSIZE]; } ...Quoted 9 lines
include/linux/f2fs_fs.h +4
-0+ }; +struct direct_node dn; +struct indirect_node in; + }; };struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Re: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Hi Jaegeuk,
Quoted 137 lines · Chao Yu
Quoted 105 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };Quoted 7 lines
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.So, that's why I thought we may need a sort of each formats.
Hmm.. if we have two new added fields, there are (2 << 2) combinations of all formats, as:
struct original { __le32 data[DEF_ADDRS_PER_BLOCK]; }struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 field_1; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1]; __le32 field_2; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2]; __le32 field_1; __le32 field_2; }
Quoted 3 lines
If we add more new fields, the node version will increase sharply due to there is (n << 2) combination with n fields. Right? Any thoughts to reduce maintaining overhead on those node versions structures?
Do you have time to explain more about the design of multiple version structure for node block, I'm still be confused about two things:
1. what will we do if we want to add one new field in node structure.
2. how can we recognize which fields are valid and which ones are invalid.
Thanks,
Quoted 33 lines
Thanks,
Quoted 15 lines
Quoted 15 lines
Any thoughts?
Thanks,
Quoted 9 lines
enabled
node_checksum, which we may not want to do.Quoted 7 lines
Thanks,
Quoted 4 lines
__le32 comp[V2_NSIZE]; } ...Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4
-0+ }; + struct direct_node dn; + struct indirect_node in; + };Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
(quoted diff) +0
-0}; struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
Chao Yu
maintainerRe: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Ping,
Quoted 185 lines · Chao Yu
Hi Jaegeuk,
Quoted 137 lines · Chao Yu
Quoted 105 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };Quoted 7 lines
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.So, that's why I thought we may need a sort of each formats.
Hmm.. if we have two new added fields, there are (2 << 2) combinations of all formats, as:
struct original { __le32 data[DEF_ADDRS_PER_BLOCK]; }struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 field_1; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1]; __le32 field_2; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2]; __le32 field_1; __le32 field_2; }Quoted 3 lines
If we add more new fields, the node version will increase sharply due to there is (n << 2) combination with n fields. Right? Any thoughts to reduce maintaining overhead on those node versions structures?
Do you have time to explain more about the design of multiple version structure for node block, I'm still be confused about two things:
1. what will we do if we want to add one new field in node structure.
2. how can we recognize which fields are valid and which ones are invalid.Thanks,
Quoted 33 lines
Thanks,
Quoted 15 lines
Quoted 15 lines
Any thoughts?
Thanks,
Quoted 9 lines
enabled
node_checksum, which we may not want to do.Quoted 7 lines
Thanks,
Quoted 4 lines
__le32 comp[V2_NSIZE]; } ...Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4
-0+ }; + struct direct_node dn; + struct indirect_node in; + };Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
(quoted diff) +0
-0}; struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
Jaegeuk Kim
maintainerRe: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 151 lines · Chao Yu
Ping,
Quoted 148 lines · Chao Yu
Hi Jaegeuk,
Quoted 137 lines · Chao Yu
Quoted 105 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };Quoted 7 lines
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.So, that's why I thought we may need a sort of each formats.
Hmm.. if we have two new added fields, there are (2 << 2) combinations of all formats, as:
struct original { __le32 data[DEF_ADDRS_PER_BLOCK]; }struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 field_1; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1]; __le32 field_2; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2]; __le32 field_1; __le32 field_2; }Quoted 3 lines
If we add more new fields, the node version will increase sharply due to there is (n << 2) combination with n fields. Right? Any thoughts to reduce maintaining overhead on those node versions structures?
Do you have time to explain more about the design of multiple version structure for node block, I'm still be confused about two things:
1. what will we do if we want to add one new field in node structure.
2. how can we recognize which fields are valid and which ones are invalid.
Can we discuss this in LSF/MM, if we get an invitation letter? :P
Quoted 37 lines
Quoted 37 lines
Thanks,
Quoted 33 lines
Thanks,
Quoted 15 lines
Quoted 15 lines
Any thoughts?
Thanks,
Quoted 9 lines
enabled
node_checksum, which we may not want to do.Quoted 7 lines
Thanks,
Quoted 4 lines
__le32 comp[V2_NSIZE]; } ...Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4
-0+ }; + struct direct_node dn; + struct indirect_node in; + };Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
(quoted diff) +0
-0}; struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
Re: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 148 lines · Jaegeuk Kim
Quoted 147 lines · Chao Yu
Ping,
Quoted 144 lines · Chao Yu
Hi Jaegeuk,
Quoted 140 lines · Chao Yu
Quoted 105 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };Quoted 7 lines
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.So, that's why I thought we may need a sort of each formats.
Hmm.. if we have two new added fields, there are (2 << 2) combinations of all formats, as:
struct original { __le32 data[DEF_ADDRS_PER_BLOCK]; }struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 field_1; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1]; __le32 field_2; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2]; __le32 field_1; __le32 field_2; }If we add more new fields, the node version will increase sharply due to there is (n << 2) combination with n fields. Right? Any thoughts to reduce maintaining overhead on those node versions structures?
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Do you have time to explain more about the design of multiple version structure for node block, I'm still be confused about two things:
1. what will we do if we want to add one new field in node structure.
2. how can we recognize which fields are valid and which ones are invalid.Can we discuss this in LSF/MM, if we get an invitation letter? :P
I'm OK, I hope we can get the invitation and reach an agreement about node extension format, so I can add checksum for node block as soon as possible, since during development our guys suffer node block inconsistence occasionally, I hope checksum can relief us from hard debug work on fs. ;)
Thanks,
Quoted 41 lines
Quoted 35 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Thanks,
Quoted 27 lines
Quoted 27 lines
Any thoughts?
Thanks,
Quoted 21 lines
enabled
node_checksum, which we may not want to do.Quoted 19 lines
Thanks,
Quoted 16 lines
__le32 comp[V2_NSIZE]; } ...Quoted 9 lines
(quoted diff) +4
-0+ }; + struct direct_node dn; + struct indirect_node in; + }; }; struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
.
.
Re: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
In reply to Chao YuPing again..
Do you have time to discuss this?
Quoted 191 lines · Chao Yu
Ping,
Quoted 144 lines · Chao Yu
Hi Jaegeuk,
Quoted 137 lines · Chao Yu
Quoted 105 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };Quoted 7 lines
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.So, that's why I thought we may need a sort of each formats.
Hmm.. if we have two new added fields, there are (2 << 2) combinations of all formats, as:
struct original { __le32 data[DEF_ADDRS_PER_BLOCK]; }struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 field_1; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1]; __le32 field_2; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2]; __le32 field_1; __le32 field_2; }Quoted 3 lines
If we add more new fields, the node version will increase sharply due to there is (n << 2) combination with n fields. Right? Any thoughts to reduce maintaining overhead on those node versions structures?
Quoted 41 lines
Do you have time to explain more about the design of multiple version structure for node block, I'm still be confused about two things:
1. what will we do if we want to add one new field in node structure.
2. how can we recognize which fields are valid and which ones are invalid.Thanks,
Quoted 33 lines
Thanks,
Quoted 15 lines
Quoted 15 lines
Any thoughts?
Thanks,
Quoted 9 lines
enabled
node_checksum, which we may not want to do.Quoted 7 lines
Thanks,
Quoted 4 lines
__le32 comp[V2_NSIZE]; } ...Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4
-0+ }; + struct direct_node dn; + struct indirect_node in; + };Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
(quoted diff) +0
-0}; struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
.
Jaegeuk Kim
maintainerRe: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 3 lines · Chao Yu
Ping again..
Do you have time to discuss this?
We may need a time to have a chat in person. Do you have any chance to visit US?
Quoted 193 lines · Chao Yu
Quoted 191 lines
Ping,
Quoted 144 lines · Chao Yu
Hi Jaegeuk,
Quoted 137 lines · Chao Yu
Quoted 105 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };Quoted 7 lines
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.So, that's why I thought we may need a sort of each formats.
Hmm.. if we have two new added fields, there are (2 << 2) combinations of all formats, as:
struct original { __le32 data[DEF_ADDRS_PER_BLOCK]; }struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 field_1; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1]; __le32 field_2; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2]; __le32 field_1; __le32 field_2; }Quoted 3 lines
If we add more new fields, the node version will increase sharply due to there is (n << 2) combination with n fields. Right? Any thoughts to reduce maintaining overhead on those node versions structures?
Quoted 41 lines
Do you have time to explain more about the design of multiple version structure for node block, I'm still be confused about two things:
1. what will we do if we want to add one new field in node structure.
2. how can we recognize which fields are valid and which ones are invalid.Thanks,
Quoted 33 lines
Thanks,
Quoted 15 lines
Quoted 15 lines
Any thoughts?
Thanks,
Quoted 9 lines
enabled
node_checksum, which we may not want to do.Quoted 7 lines
Thanks,
Quoted 4 lines
__le32 comp[V2_NSIZE]; } ...Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +4
-0+ }; + struct direct_node dn; + struct indirect_node in; + };Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
(quoted diff) +0
-0}; struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
.
Re: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
Quoted 7 lines · Jaegeuk Kim
Quoted 3 lines · Chao Yu
Ping again..
Do you have time to discuss this?
We may need a time to have a chat in person. Do you have any chance to visit US?
I prefer to, just count on LSF, but...
I think I need to find a conference which is opened in US first.
Just checked events.linuxfoundation.org, and didn't find any suitable conference I could attend recently in US.
Location: US
Apr 18-20 Boston, Could Foundry Summit
Apr 23-25 Park City, LSF
Sep 24-26 Nashville, API strategy & practice
Oct 10-11 New York, Open FinTech Forum
Dec 11-13 Seattle, KubeCon & CloudNativeCon
Any other conferences?
Thanks,
Quoted 197 lines
Quoted 188 lines · Chao Yu
Quoted 185 lines
Ping,
Quoted 182 lines · Chao Yu
Hi Jaegeuk,
Quoted 137 lines · Chao Yu
Quoted 105 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 72 lines · Jaegeuk Kim
Quoted 71 lines · Chao Yu
Quoted 2 lines · Jaegeuk Kim
What if we want to add more entries in addition to
node_checksum? Do we have to add a new feature flag at every time? How about adding a layout value insteadHmm.. for previous implementation, IMO, we'd better add a new feature flag at every time, otherwise, w/
extra_nsizeonly, in current image, we can know a valid range of extended area in node block, but we don't know which fields/features are valid/enabled or not.One more thing is that if we can add one feature flag for each field, we got one more chance to disable it dynamically.
Quoted 4 lines
of
extra_nsize? For example, layout #1 meansnode_checksumwith extra_nsize=X?What does 1017 mean? We need to make this structure more flexibly for new
Yes, using raw 1017 is not appropriate here.
Quoted 11 lines
entries. Like this?
union { struct node_v1; struct node_v2; struct node_v3; ... struct direct_node dn; struct indirect_node in; }; };Quoted 7 lines
struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 node_checksum; } struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=500];Hmm.. If we only need to add one more 4 bytes field in struct
node_v2, butV2_NSIZEis defined as fixed 500, there must be 492 bytes wasted.Or we can define
V2_NSIZEas 8, but if there comes more and more extended fields, node version count can be a large number, it results in complicated version recognization and handling.One more question is how can we control which fields are valid or not in comp[Vx_NSIZE]?
Anyway, what I'm thinking is maybe we can restructure layout of node block like the one used by
f2fs_inode:struct f2fs_node { union { struct f2fs_inode i; union { struct { __le32 node_checksum; __le32 feature_field_1; __le32 feature_field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; }; }; struct node_footer footer; } __packed;Quoted 4 lines
Quoted 2 lines
Moving all extended fields to the head of
f2fs_node, so we don't have to use macro to indicate actual size of addr.Thinking what'd be the best way. My concern is, once getting more entries, we
OK, I think we need more discussion.. ;)
Quoted 1 line
can't set each of features individually. Like the second entry should have
Oh, that will be hard. If we have to avoid that, we have to tag in somewhere e.g.
f2fs_inode::i_flags2to indicate which new field inf2fs_nodeis valid, for example:#define
F2FS_NODE_CHECKSUM0x0001
#defineF2FS_NODE_FIELD10x0002
#defineF2FS_NODE_FIELD20x0004union { struct { __le32 node_checksum; __le32 field_1; __le32 field_2; .... __le32 addr[]; }; struct direct_node dn; struct indirect_node in; };Quoted 7 lines
Quoted 5 lines
f2fs_inode::i_flags2=F2FS_NODE_CHECKSUM|F2FS_NODE_FIELD1indicates thatf2fs_node::node_checksumandf2fs_node::field_1are valid;
f2fs_inode::i_flags2=F2FS_NODE_FIELD1|F2FS_NODE_FIELD2indicates thatf2fs_node::field_1andf2fs_node::field_2are valid.So, that's why I thought we may need a sort of each formats.
Hmm.. if we have two new added fields, there are (2 << 2) combinations of all formats, as:
struct original { __le32 data[DEF_ADDRS_PER_BLOCK]; }struct node_v1 { __le32 data[DEF_ADDRS_PER_BLOCK - V1_NSIZE=1]; __le32 field_1; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V2_NSIZE=1]; __le32 field_2; }struct node_v2 { __le32 data[DEF_ADDRS_PER_BLOCK - V3_NSIZE=2]; __le32 field_1; __le32 field_2; }Quoted 3 lines
If we add more new fields, the node version will increase sharply due to there is (n << 2) combination with n fields. Right? Any thoughts to reduce maintaining overhead on those node versions structures?
Do you have time to explain more about the design of multiple version structure for node block, I'm still be confused about two things:
1. what will we do if we want to add one new field in node structure.
2. how can we recognize which fields are valid and which ones are invalid.Thanks,
Quoted 31 lines
Thanks,
Quoted 27 lines
Quoted 27 lines
Any thoughts?
Thanks,
Quoted 21 lines
enabled
node_checksum, which we may not want to do.Quoted 19 lines
Thanks,
Quoted 16 lines
__le32 comp[V2_NSIZE]; } ...Quoted 9 lines
(quoted diff) +4
-0+ }; + struct direct_node dn; + struct indirect_node in; + }; }; struct node_footer footer; } __packed;Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
.
.
.
Re: [PATCH 2/2] f2fs: support {d,id,did,x}node checksum
In reply to Chao YuHi Jaegeuk,
Is it time to consider this metadata chksum feature? Maybe for 5.7 version.
Thanks,
Quoted 296 lines · Chao Yu
This patch adds to support {d,id,did,x}node checksum in kernel side.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/f2fs.h | 15 +++++++- fs/f2fs/inode.c | 98 +++++++++++++++++++++++++++++++------------------ fs/f2fs/node.c | 2 +- fs/f2fs/segment.c | 2 +- fs/f2fs/sysfs.c | 7 ++++ include/linux/f2fs_fs.h | 10 ++++- 6 files changed, 93 insertions(+), 41 deletions(-)fs/f2fs/f2fs.h +13
-2@@ -128,6 +128,7 @@ struct f2fs_mount_info {#define F2FS_FEATURE_QUOTA_INO 0x0080#define F2FS_FEATURE_INODE_CRTIME 0x0100#define F2FS_FEATURE_EXTENDED_NODE 0x0200 +#define F2FS_FEATURE_NODE_CHECKSUM 0x0400#define F2FS_HAS_FEATURE (sb, mask) \ ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)@@ -2570,6 +2571,11 @@ static inline int get_inline_xattr_addrs(struct inode *inode) sizeof((f2fs_inode)->field)) \ <= (F2FS_OLD_ATTRIBUTE_SIZE + extra_isize)) \ +#define F2FS_FITS_IN_NODE (extra_nsize, field) \ + ((offsetof(struct f2fs_node, footer) - \ + offsetof(struct f2fs_node, field)) \ + <= (extra_nsize)) \ +static inline void f2fs_reset_iostat (struct f2fs_sb_info *sbi) {int i;@@ -2616,8 +2622,8 @@ int f2fs_pin_file_control(struct inode *inode, bool inc);* inode.c */ void f2fs_set_inode_flags (struct inode *inode); -bool f2fs_inode_chksum_verify (struct f2fs_sb_info *sbi,struct page *page); -void f2fs_inode_chksum_set (struct f2fs_sb_info *sbi,struct page *page); +bool f2fs_node_chksum_verify (struct f2fs_sb_info *sbi,struct page *page); +void f2fs_node_chksum_set (struct f2fs_sb_info *sbi,struct page *page);struct inode *f2fs_iget (struct super_block *sb,unsigned long ino);struct inode *f2fs_iget_retry (struct super_block *sb,unsigned long ino);int try_to_free_nats (struct f2fs_sb_info *sbi,int nr_shrink);@@ -3252,6 +3258,11 @@ static inline int f2fs_sb_has_extended_node(struct super_block *sb)return F2FS_HAS_FEATURE (sb,F2FS_FEATURE_EXTENDED_NODE ); } +static inline int f2fs_sb_has_node_checksum (struct super_block *sb) +{ +return F2FS_HAS_FEATURE (sb,F2FS_FEATURE_NODE_CHECKSUM ); +} +#ifdef CONFIG_BLK_DEV_ZONED static inline int get_blkz_type (struct f2fs_sb_info *sbi,struct block_device *bdev,block_t blkaddr)fs/f2fs/inode.c +63
-35@@ -111,75 +111,103 @@ static void __recover_inline_status(struct inode *inode, struct page *ipage)return ; } -static bool f2fs_enable_inode_chksum (struct f2fs_sb_info *sbi,struct page *page) +static bool f2fs_enable_node_chksum (struct f2fs_sb_info *sbi,struct page *page) { -struct f2fs_inode *ri = &F2FS_NODE (page)->i; -int extra_isize =le32_to_cpu (ri->i_extra_isize); - -if (!f2fs_sb_has_inode_chksum (sbi->sb)) -return false; - -if (!RAW_IS_INODE (F2FS_NODE (page)) || !(ri->i_inline &F2FS_EXTRA_ATTR )) -return false; - -if (!F2FS_FITS_IN_INODE (ri, extra_isize, i_inode_checksum)) -return false; +if (IS_INODE (page)) { +struct f2fs_inode *ri = &F2FS_NODE (page)->i; +int extra_isize =le32_to_cpu (ri->i_extra_isize); + +if (!(ri->i_inline &F2FS_EXTRA_ATTR )) +return false; +if (!f2fs_sb_has_inode_chksum (sbi->sb)) +return false; +if (!F2FS_FITS_IN_INODE (ri, extra_isize, i_inode_checksum)) +return false; + }else { +if (!f2fs_sb_has_extended_node (sbi->sb)) +return false; +if (!f2fs_sb_has_node_checksum (sbi->sb)) +return false; +if (!F2FS_FITS_IN_NODE (sbi->extra_nsize, node_checksum)) +return false; + }return true; } -static __u32 f2fs_inode_chksum (struct f2fs_sb_info *sbi,struct page *page) +static __u32 f2fs_node_chksum (struct f2fs_sb_info *sbi,struct page *page) {struct f2fs_node *node =F2FS_NODE (page); -struct f2fs_inode *ri = &node->i; -__le32 ino = node->footer.ino; -__le32 gen = ri->i_generation; -__u32 chksum, chksum_seed; -__u32 dummy_cs =0 ; -unsigned int offset = offsetof(struct f2fs_inode , i_inode_checksum); -unsigned int cs_size =sizeof (dummy_cs); +__le32 append, ino = node->footer.ino; +__u32 chksum, chksum_seed, dummy_cs =0 ; +unsigned int offset, cs_size =sizeof (dummy_cs); +bool is_inode =RAW_IS_INODE (node); + +if (is_inode) { + append = node->i.i_generation; + offset = offsetof(struct f2fs_inode , i_inode_checksum); + }else { + append = node->footer.nid; + offset = offsetof(struct f2fs_node , node_checksum); + } chksum =f2fs_chksum (sbi, sbi->s_chksum_seed, (__u8 *)&ino,sizeof (ino)); - chksum_seed =f2fs_chksum (sbi, chksum, (__u8 *)&gen,sizeof (gen)); + chksum_seed =f2fs_chksum (sbi, chksum, (__u8 *)&append,sizeof (append)); - chksum =f2fs_chksum (sbi, chksum_seed, (__u8 *)ri, offset); + chksum =f2fs_chksum (sbi, chksum_seed, (__u8 *)node, offset); chksum =f2fs_chksum (sbi, chksum, (__u8 *)&dummy_cs, cs_size); offset += cs_size; - chksum =f2fs_chksum (sbi, chksum, (__u8 *)ri + offset, + chksum =f2fs_chksum (sbi, chksum, (__u8 *)node + offset,F2FS_BLKSIZE - offset);return chksum; } -bool f2fs_inode_chksum_verify (struct f2fs_sb_info *sbi,struct page *page) +bool f2fs_node_chksum_verify (struct f2fs_sb_info *sbi,struct page *page) { -struct f2fs_inode *ri; +struct f2fs_node *rn;__u32 provided, calculated; -if (!f2fs_enable_inode_chksum (sbi, page) || +if (!f2fs_enable_node_chksum (sbi, page) ||PageDirty (page) ||PageWriteback (page))return true; - ri = &F2FS_NODE (page)->i; - provided =le32_to_cpu (ri->i_inode_checksum); - calculated =f2fs_inode_chksum (sbi, page); + rn =F2FS_NODE (page); +if (RAW_IS_INODE (rn)) + provided =le32_to_cpu (rn->i.i_inode_checksum); +else + provided =le32_to_cpu (rn->node_checksum); + calculated =f2fs_node_chksum (sbi, page);if (provided != calculated)f2fs_msg (sbi->sb,KERN_WARNING , -"checksum invalid, ino = %x, %x vs. %x" , -ino_of_node (page), provided, calculated); +"checksum invalid, ino = %u, nid = %u, %x vs. %x" , +ino_of_node (page),nid_of_node (page), + provided, calculated); + +else +f2fs_msg (sbi->sb,KERN_WARNING , +"checksum is valid, ino = %u, nid = %u, %x vs. %x" , +ino_of_node (page),nid_of_node (page), + provided, calculated);return provided == calculated; } -void f2fs_inode_chksum_set (struct f2fs_sb_info *sbi,struct page *page) +void f2fs_node_chksum_set (struct f2fs_sb_info *sbi,struct page *page) { -struct f2fs_inode *ri = &F2FS_NODE (page)->i; +struct f2fs_node *rn =F2FS_NODE (page); +__le32 chksum; -if (!f2fs_enable_inode_chksum (sbi, page)) +if (!f2fs_enable_node_chksum (sbi, page))return ; - ri->i_inode_checksum =cpu_to_le32 (f2fs_inode_chksum (sbi, page)); + chksum =cpu_to_le32 (f2fs_node_chksum (sbi, page)); + +if (RAW_IS_INODE (rn)) + rn->i.i_inode_checksum = chksum; +else + rn->node_checksum = chksum; }static int do_read_inode (struct inode *inode)fs/f2fs/node.c +1
-1@@ -1194,7 +1194,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid, goto out_err; } -if (!f2fs_inode_chksum_verify (sbi, page)) { +if (!f2fs_node_chksum_verify (sbi, page)) { err = -EBADMSG ; goto out_err; }fs/f2fs/segment.c +1
-1@@ -2678,7 +2678,7 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,if (page &&IS_NODESEG (type)) {fill_node_footer_blkaddr (page,NEXT_FREE_BLKADDR (sbi, curseg)); -f2fs_inode_chksum_set (sbi, page); +f2fs_node_chksum_set (sbi, page); }if (add_list) {fs/f2fs/sysfs.c +7
-0@@ -119,6 +119,9 @@ static ssize_t features_show(struct f2fs_attr *a,if (f2fs_sb_has_extended_node (sb)) len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , len ?", " :"" ,"extended_node" ); +if (f2fs_sb_has_node_checksum (sb)) + len +=snprintf (buf + len,PAGE_SIZE - len,"%s%s" , + len ?", " :"" ,"node_checksum" ); len +=snprintf (buf + len,PAGE_SIZE - len,"\n" );return len; }@@ -240,6 +243,7 @@ enum feat_id {FEAT_QUOTA_INO ,FEAT_INODE_CRTIME ,FEAT_EXTENDED_NODE , + FEAT_NODE_CHECKSUM, }; static ssize_t f2fs_feature_show(struct f2fs_attr *a,@@ -256,6 +260,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,case FEAT_QUOTA_INO :case FEAT_INODE_CRTIME :case FEAT_EXTENDED_NODE : +case FEAT_NODE_CHECKSUM :return snprintf (buf,PAGE_SIZE ,"supported\n" ); }return 0 ;@@ -335,6 +340,7 @@ F2FS_FEATURE_RO_ATTR(flexible_inline_xattr, FEAT_FLEXIBLE_INLINE_XATTR);F2FS_FEATURE_RO_ATTR (quota_ino,FEAT_QUOTA_INO );F2FS_FEATURE_RO_ATTR (inode_crtime,FEAT_INODE_CRTIME );F2FS_FEATURE_RO_ATTR (extended_node,FEAT_EXTENDED_NODE ); +F2FS_FEATURE_RO_ATTR (node_checksum,FEAT_NODE_CHECKSUM );#define ATTR_LIST (name) (&f2fs_attr_##name.attr)static struct attribute *f2fs_attrs[] = {@@ -390,6 +396,7 @@ static struct attribute *f2fs_feat_attrs[] = {ATTR_LIST (quota_ino),ATTR_LIST (inode_crtime),ATTR_LIST (extended_node), +ATTR_LIST (node_checksum), NULL, };include/linux/f2fs_fs.h +8
-2@@ -295,8 +295,14 @@ struct f2fs_node {/* can be one of three types: inode, direct, and indirect types */ union {struct f2fs_inode i; -struct direct_node dn; -struct indirect_node in; +union { +struct { +__le32 data[1017 ]; +__le32 node_checksum; + }; +struct direct_node dn; +struct indirect_node in; + }; };struct node_footer footer; } __packed;