f2fs-tools: add noatime for quota file
PATCH 1/4 f2fs-tools: add noatime for quota file
Disk quota file is controlled by filesystem quota subsystem, access time of quota file is almost random, and should be meanless to user, so let's add noatime to quota file.
Meanwhile, set quota file w/ F2FS_IMMUTABLE_FL instead of FS_IMMUTABLE_FL, since F2FS_IMMUTABLE_FL is on-disk flag, however FS_IMMUTABLE_FL is in-memory one.
--- fsck/node.c | 2 +- include/f2fs_fs.h | 7 ++++++- mkfs/f2fs_format.c | 2 +- tools/f2fs_io/f2fs_io.h | 4 ++++ 4 files changed, 12 insertions(+), 3 deletions(-)
fsck/node.c +1 -1
@@ -62,7 +62,7 @@ int f2fs_rebuild_qf_inode(struct f2fs_sb_info *sbi, int qtype) raw_node->i.i_size =cpu_to_le64 (1024 *6 ); raw_node->i.i_blocks =cpu_to_le64 (1 ); - raw_node->i.i_flags =FS_IMMUTABLE_FL ; + raw_node->i.i_flags =F2FS_NOATIME_FL |F2FS_IMMUTABLE_FL ;if (is_set_ckpt_flags (ckpt,CP_CRC_RECOVERY_FLAG )) cp_ver |= (cur_cp_crc (ckpt) <<32 );
include/f2fs_fs.h +6 -1
@@ -750,7 +750,12 @@ enum {#define QUOTA_DATA (i) (2)#define QUOTA_INO (sb,t) (le32_to_cpu((sb)->qf_ino[t])) -#define FS_IMMUTABLE_FL 0x00000010/* Immutable file */ +/* +* On-disk inode flags (f2fs_inode::i_flags) +*/ +#define F2FS_IMMUTABLE_FL 0x00000010/* Immutable file */ +#define F2FS_NOATIME_FL 0x00000080/* do not update atime */ +#define F2FS_ENC_UTF8_12_1 1#define F2FS_ENC_STRICT_MODE_FL (1 << 0)
mkfs/f2fs_format.c +1 -1
@@ -1364,7 +1364,7 @@ static int f2fs_write_qf_inode(int qtype, int offset) raw_node->i.i_size =cpu_to_le64 (1024 *6 ); raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); - raw_node->i.i_flags =FS_IMMUTABLE_FL ; + raw_node->i.i_flags =F2FS_NOATIME_FL |F2FS_IMMUTABLE_FL ; raw_node->footer.next_blkaddr = cpu_to_le32( get_sb(main_blkaddr) +
tools/f2fs_io/f2fs_io.h +4 -0
@@ -167,6 +167,10 @@ struct fscrypt_get_policy_ex_arg {#define F2FS_IOC_FSGETXATTR FS_IOC_FSGETXATTR#define F2FS_IOC_FSSETXATTR FS_IOC_FSSETXATTR +#ifndef FS_IMMUTABLE_FL +#define FS_IMMUTABLE_FL 0x00000010/* Immutable file */ +#endif +#ifndef FS_ENCRYPT_FL #define FS_ENCRYPT_FL 0x00000800/* Encrypted file */ #endif
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 2/4 mkfs.f2fs: remove unneeded nat initialization in f2fs_update_nat_root()
- remove unneeded nat initialization for root/quota inode due to it has been initialized in nat journal.
- name f2fs_update_nat_root() to f2fs_update_nat_default().
--- mkfs/f2fs_format.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
mkfs/f2fs_format.c +2 -22
@@ -1413,12 +1413,10 @@ static int f2fs_write_qf_inode(int qtype, int offset)return 0 ; } -static int f2fs_update_nat_root (void ) +static int f2fs_update_nat_default (void ) {struct f2fs_nat_block *nat_blk =NULL ;uint64_t nat_seg_blk_offset =0 ; -enum quota_type qtype; -int i; nat_blk =calloc (F2FS_BLKSIZE ,1 );if (nat_blk ==NULL ) {
@@ -1426,24 +1424,6 @@ static int f2fs_update_nat_root(void)return -1 ; } -/* update quota */ -for (qtype = i =0 ; qtype <F2FS_MAX_QUOTAS ; qtype++) { -if (!((1 << qtype) & c.quota_bits)) -continue ; - nat_blk->entries[sb->qf_ino[qtype]].block_addr = -cpu_to_le32 (get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + i +1 ); - nat_blk->entries[sb->qf_ino[qtype]].ino = sb->qf_ino[qtype]; - i++; - } - -/* update root */ - nat_blk->entries[get_sb (root_ino)].block_addr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * c.blks_per_seg); - nat_blk->entries[get_sb (root_ino)].ino = sb->root_ino; -/* update node nat */ nat_blk->entries[get_sb (node_ino)].block_addr =cpu_to_le32 (1 ); nat_blk->entries[get_sb (node_ino)].ino = sb->node_ino;
@@ -1660,7 +1640,7 @@ static int f2fs_create_root_dir(void) }#endif - err =f2fs_update_nat_root (); + err =f2fs_update_nat_default ();if (err <0 ) {MSG (1 ,"\tError: Failed to update NAT for root!!!\n" ); goto exit;
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 3/4 mkfs.f2fs: cleanup w/ alloc_next_free_block()
In reply to Chao YuIntroduce alloc_next_free_block() to wrap below openned codes:
blkaddr = get_sb(main_blkaddr) +
c.cur_seg[curseg_type] * c.blks_per_seg + c.curseg_offset[curseg_type];
Meanwhile add curseg_offset field in f2fs_configuration to record last blkaddr in each log.
--- include/f2fs_fs.h | 2 + mkfs/f2fs_format.c | 101 +++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 58 deletions(-)
include/f2fs_fs.h +2 -0
@@ -603,6 +603,8 @@ struct f2fs_configuration {/* compression support for sload.f2fs */ compress_config_t compress; + +block_t curseg_offset[6 ]; };#ifdef CONFIG_64BIT
mkfs/f2fs_format.c +43 -58
160 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/4] mkfs.f2fs: cleanup w/ alloc_next_free_block()
Quoted 20 lines · Chao Yu
Introduce
alloc_next_free_block()to wrap below openned codes:blkaddr =
get_sb(main_blkaddr)+
c.cur_seg[curseg_type] * c.blks_per_seg + c.curseg_offset[curseg_type];Meanwhile add
curseg_offsetfield inf2fs_configurationto record last blkaddr in each log.Signed-off-by Chao Yu <[email protected]>--- include/f2fs_fs.h | 2 + mkfs/f2fs_format.c | 101 +++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 58 deletions(-)include/f2fs_fs.h +0
-0
include/f2fs_fs.h struct f2fs_configuration { · line 607
Quoted 5 lines
include/f2fs_fs.h +2
-0@@ -603,6 +603,8 @@ struct f2fs_configuration {/* compression support for sload.f2fs */ compress_config_t compress; + +block_t curseg_offset[6 ];
NR_CURSEG_TYPE?
Quoted 176 lines
include/f2fs_fs.h +0
-0};#ifdef CONFIG_64BIT mkfs/f2fs_format.c +43
-58@@ -1230,11 +1230,24 @@ static int f2fs_discard_obsolete_dnode(void) }#endif +static block_t alloc_next_free_block (int curseg_type,int blkcnt) +{ +block_t blkaddr; + + blkaddr =get_sb (main_blkaddr) + + c.cur_seg[curseg_type] * c.blks_per_seg + + c.curseg_offset[curseg_type]; + + c.curseg_offset[curseg_type] += blkcnt; + +return blkaddr; +} +static int f2fs_write_root_inode (void ) {struct f2fs_node *raw_node =NULL ; -uint64_t data_blk_nor; -uint64_t main_area_node_seg_blk_offset =0 ; +block_t data_blkaddr; +block_t node_blkaddr; raw_node =calloc (F2FS_BLKSIZE ,1 );if (raw_node ==NULL ) {@@ -1248,24 +1261,15 @@ static int f2fs_write_root_inode(void)if (c.lpf_ino) raw_node->i.i_links =cpu_to_le32 (3 ); - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg +1 ); - - data_blk_nor =get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA ] * c.blks_per_seg; - raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blk_nor); - - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg; - -DBG (1 ,"\tWriting root inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { + data_blkaddr =alloc_next_free_block (CURSEG_HOT_DATA ,1 ); + raw_node->i.i_addr[get_extra_isize (raw_node)] = +cpu_to_le32 (data_blkaddr); + + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); + +DBG (1 ,"\tWriting root inode (hot node), offset 0x%x\n" , node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);return -1 ;@@ -1349,8 +1353,8 @@ static int f2fs_write_default_quota(int qtype, unsigned int blkaddr,static int f2fs_write_qf_inode (int qtype,int offset) {struct f2fs_node *raw_node =NULL ; -uint64_t data_blk_nor; -uint64_t main_area_node_seg_blk_offset =0 ; +block_t data_blkaddr; +block_t node_blkaddr;__le32 raw_id;int i;@@ -1366,14 +1370,10 @@ static int f2fs_write_qf_inode(int qtype, int offset) raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); raw_node->i.i_flags =F2FS_NOATIME_FL |F2FS_IMMUTABLE_FL ; - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg +1 + qtype +1 ); + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); - data_blk_nor =get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA ] * c.blks_per_seg +1 - + offset *QUOTA_DATA (i); + data_blkaddr =alloc_next_free_block (CURSEG_HOT_DATA ,QUOTA_DATA (i));if (qtype ==0 ) raw_id = raw_node->i.i_uid;@@ -1385,24 +1385,17 @@ static int f2fs_write_qf_inode(int qtype, int offset)ASSERT (0 );/* write two blocks */ -if (f2fs_write_default_quota (qtype, data_blk_nor, raw_id)) { +if (f2fs_write_default_quota (qtype, data_blkaddr, raw_id)) {free (raw_node);return -1 ; }for (i =0 ; i <QUOTA_DATA (qtype); i++) raw_node->i.i_addr[get_extra_isize (raw_node) + i] = -cpu_to_le32 (data_blk_nor + i); +cpu_to_le32 (data_blkaddr + i); - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + offset +1 ; - -DBG (1 ,"\tWriting quota inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { +DBG (1 ,"\tWriting quota inode (hot node), offset 0x%x\n" , node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);return -1 ;@@ -1492,8 +1485,8 @@ static block_t f2fs_add_default_dentry_lpf(void)static int f2fs_write_lpf_inode (void ) {struct f2fs_node *raw_node; -uint64_t main_area_node_seg_blk_offset; -block_t data_blk_nor; +block_t data_blkaddr; +block_t node_blkaddr;int err =0 ;ASSERT (c.lpf_ino);@@ -1510,28 +1503,20 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_namelen =le32_to_cpu (strlen (LPF ));memcpy (raw_node->i.i_name,LPF ,strlen (LPF )); - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * c.blks_per_seg + -1 + c.quota_inum +1 ); + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); - data_blk_nor =f2fs_add_default_dentry_lpf (); -if (data_blk_nor ==0 ) { + data_blkaddr =f2fs_add_default_dentry_lpf (); +if (data_blkaddr ==0 ) {MSG (1 ,"\tError: Failed to add default dentries for lost+found!!!\n" ); err =-1 ; goto exit; } - raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blk_nor); - - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + c.quota_inum +1 ; + raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blkaddr); -DBG (1 ,"\tWriting lost+found inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { +DBG (1 ,"\tWriting lost+found inode (hot node), offset 0x%x\n" , + node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" ); err =-1 ; goto exit;Signature · 1 line
2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/4] mkfs.f2fs: cleanup w/ alloc_next_free_block()
Quoted 22 lines · Jaegeuk Kim
Quoted 21 lines · Chao Yu
Introduce
alloc_next_free_block()to wrap below openned codes:blkaddr =
get_sb(main_blkaddr)+
c.cur_seg[curseg_type] * c.blks_per_seg + c.curseg_offset[curseg_type];Meanwhile add
curseg_offsetfield inf2fs_configurationto record last blkaddr in each log.Signed-off-by Chao Yu <[email protected]>--- include/f2fs_fs.h | 2 + mkfs/f2fs_format.c | 101 +++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 58 deletions(-)include/f2fs_fs.h +0
-0@@ -603,6 +603,8 @@ struct f2fs_configuration {
Quoted 6 lines
include/f2fs_fs.h struct f2fs_configuration { · line 607
Quoted 4 lines
include/f2fs_fs.h +2
-0/* compression support for sload.f2fs */ compress_config_t compress; + +block_t curseg_offset[6 ];
NR_CURSEG_TYPE?
The macro is defined after struct f2fs_configuration...
How about updating all value w/ macro in below patch, as the patch relocates struct f2fs_configuration?
[PATCH 4/4]mkfs.f2fs: refactor format flow for cleanup
Thanks,
Quoted 164 lines
Quoted 164 lines
include/f2fs_fs.h +0
-0};#ifdef CONFIG_64BIT mkfs/f2fs_format.c +40
-53@@ -1230,11 +1230,24 @@ static int f2fs_discard_obsolete_dnode(void) }#endif +static block_t alloc_next_free_block (int curseg_type,int blkcnt) +{ +block_t blkaddr; + + blkaddr =get_sb (main_blkaddr) + + c.cur_seg[curseg_type] * c.blks_per_seg + + c.curseg_offset[curseg_type]; + + c.curseg_offset[curseg_type] += blkcnt; + +return blkaddr; +} +static int f2fs_write_root_inode (void ) {struct f2fs_node *raw_node =NULL ; -uint64_t data_blk_nor; -uint64_t main_area_node_seg_blk_offset =0 ; +block_t data_blkaddr; +block_t node_blkaddr; raw_node =calloc (F2FS_BLKSIZE ,1 );if (raw_node ==NULL ) {@@ -1248,24 +1261,15 @@ static int f2fs_write_root_inode(void)if (c.lpf_ino) raw_node->i.i_links =cpu_to_le32 (3 ); - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg +1 ); - - data_blk_nor =get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA ] * c.blks_per_seg; - raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blk_nor); - - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg; - -DBG (1 ,"\tWriting root inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { + data_blkaddr =alloc_next_free_block (CURSEG_HOT_DATA ,1 ); + raw_node->i.i_addr[get_extra_isize (raw_node)] = +cpu_to_le32 (data_blkaddr); + + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); + +DBG (1 ,"\tWriting root inode (hot node), offset 0x%x\n" , node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);return -1 ;@@ -1349,8 +1353,8 @@ static int f2fs_write_default_quota(int qtype, unsigned int blkaddr,static int f2fs_write_qf_inode (int qtype,int offset) {struct f2fs_node *raw_node =NULL ; -uint64_t data_blk_nor; -uint64_t main_area_node_seg_blk_offset =0 ; +block_t data_blkaddr; +block_t node_blkaddr;__le32 raw_id;int i;@@ -1366,14 +1370,10 @@ static int f2fs_write_qf_inode(int qtype, int offset) raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); raw_node->i.i_flags =F2FS_NOATIME_FL |F2FS_IMMUTABLE_FL ; - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg +1 + qtype +1 ); + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); - data_blk_nor =get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA ] * c.blks_per_seg +1 - + offset *QUOTA_DATA (i); + data_blkaddr =alloc_next_free_block (CURSEG_HOT_DATA ,QUOTA_DATA (i));if (qtype ==0 ) raw_id = raw_node->i.i_uid;@@ -1385,24 +1385,17 @@ static int f2fs_write_qf_inode(int qtype, int offset)ASSERT (0 );/* write two blocks */ -if (f2fs_write_default_quota (qtype, data_blk_nor, raw_id)) { +if (f2fs_write_default_quota (qtype, data_blkaddr, raw_id)) {free (raw_node);return -1 ; }for (i =0 ; i <QUOTA_DATA (qtype); i++) raw_node->i.i_addr[get_extra_isize (raw_node) + i] = -cpu_to_le32 (data_blk_nor + i); +cpu_to_le32 (data_blkaddr + i); - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + offset +1 ; - -DBG (1 ,"\tWriting quota inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { +DBG (1 ,"\tWriting quota inode (hot node), offset 0x%x\n" , node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);return -1 ;@@ -1492,8 +1485,8 @@ static block_t f2fs_add_default_dentry_lpf(void)static int f2fs_write_lpf_inode (void ) {struct f2fs_node *raw_node; -uint64_t main_area_node_seg_blk_offset; -block_t data_blk_nor; +block_t data_blkaddr; +block_t node_blkaddr;int err =0 ;ASSERT (c.lpf_ino);@@ -1510,28 +1503,20 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_namelen =le32_to_cpu (strlen (LPF ));memcpy (raw_node->i.i_name,LPF ,strlen (LPF )); - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * c.blks_per_seg + -1 + c.quota_inum +1 ); + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); - data_blk_nor =f2fs_add_default_dentry_lpf (); -if (data_blk_nor ==0 ) { + data_blkaddr =f2fs_add_default_dentry_lpf (); +if (data_blkaddr ==0 ) {MSG (1 ,"\tError: Failed to add default dentries for lost+found!!!\n" ); err =-1 ; goto exit; } - raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blk_nor); - - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + c.quota_inum +1 ; + raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blkaddr);
Quoted 13 lines
Quoted 13 lines
mkfs/f2fs_format.c +3
-5-DBG (1 ,"\tWriting lost+found inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { +DBG (1 ,"\tWriting lost+found inode (hot node), offset 0x%x\n" , + node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" ); err =-1 ; goto exit;Signature · 1 line
2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/4] mkfs.f2fs: cleanup w/ alloc_next_free_block()
Quoted 29 lines · Chao Yu
Quoted 16 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Introduce
alloc_next_free_block()to wrap below openned codes:blkaddr =
get_sb(main_blkaddr)+
c.cur_seg[curseg_type] * c.blks_per_seg + c.curseg_offset[curseg_type];Meanwhile add
curseg_offsetfield inf2fs_configurationto record last blkaddr in each log.Signed-off-by Chao Yu <[email protected]>--- include/f2fs_fs.h | 2 + mkfs/f2fs_format.c | 101 +++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 58 deletions(-)Quoted 11 lines
include/f2fs_fs.h struct f2fs_configuration { · line 606
Quoted 9 lines
include/f2fs_fs.h +2
-0@@ -603,6 +603,8 @@ struct f2fs_configuration {/* compression support for sload.f2fs */ compress_config_t compress; + +block_t curseg_offset[6 ];
NR_CURSEG_TYPE?
Quoted 4 lines
The macro is defined after struct
f2fs_configuration...How about updating all value w/ macro in below patch, as the patch relocates struct
f2fs_configuration?
Could you please post patches?
Quoted 159 lines
[PATCH 4/4]mkfs.f2fs: refactor format flow for cleanup
Thanks,
Quoted 154 lines
Quoted 154 lines
include/f2fs_fs.h +0
-0};#ifdef CONFIG_64BIT mkfs/f2fs_format.c +40
-58@@ -1230,11 +1230,24 @@ static int f2fs_discard_obsolete_dnode(void) }#endif +static block_t alloc_next_free_block (int curseg_type,int blkcnt) +{ +block_t blkaddr; + + blkaddr =get_sb (main_blkaddr) + + c.cur_seg[curseg_type] * c.blks_per_seg + + c.curseg_offset[curseg_type]; + + c.curseg_offset[curseg_type] += blkcnt; + +return blkaddr; +} +static int f2fs_write_root_inode (void ) {struct f2fs_node *raw_node =NULL ; -uint64_t data_blk_nor; -uint64_t main_area_node_seg_blk_offset =0 ; +block_t data_blkaddr; +block_t node_blkaddr; raw_node =calloc (F2FS_BLKSIZE ,1 );if (raw_node ==NULL ) {@@ -1248,24 +1261,15 @@ static int f2fs_write_root_inode(void)if (c.lpf_ino) raw_node->i.i_links =cpu_to_le32 (3 ); - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg +1 ); - - data_blk_nor =get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA ] * c.blks_per_seg; - raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blk_nor); - - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg; - -DBG (1 ,"\tWriting root inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { + data_blkaddr =alloc_next_free_block (CURSEG_HOT_DATA ,1 ); + raw_node->i.i_addr[get_extra_isize (raw_node)] = +cpu_to_le32 (data_blkaddr); + + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); + +DBG (1 ,"\tWriting root inode (hot node), offset 0x%x\n" , node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);return -1 ;@@ -1349,8 +1353,8 @@ static int f2fs_write_default_quota(int qtype, unsigned int blkaddr,static int f2fs_write_qf_inode (int qtype,int offset) {struct f2fs_node *raw_node =NULL ; -uint64_t data_blk_nor; -uint64_t main_area_node_seg_blk_offset =0 ; +block_t data_blkaddr; +block_t node_blkaddr;__le32 raw_id;int i;@@ -1366,14 +1370,10 @@ static int f2fs_write_qf_inode(int qtype, int offset) raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); raw_node->i.i_flags =F2FS_NOATIME_FL |F2FS_IMMUTABLE_FL ; - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg +1 + qtype +1 ); + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); - data_blk_nor =get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA ] * c.blks_per_seg +1 - + offset *QUOTA_DATA (i); + data_blkaddr =alloc_next_free_block (CURSEG_HOT_DATA ,QUOTA_DATA (i));if (qtype ==0 ) raw_id = raw_node->i.i_uid;@@ -1385,24 +1385,17 @@ static int f2fs_write_qf_inode(int qtype, int offset)ASSERT (0 );/* write two blocks */ -if (f2fs_write_default_quota (qtype, data_blk_nor, raw_id)) { +if (f2fs_write_default_quota (qtype, data_blkaddr, raw_id)) {free (raw_node);return -1 ; }for (i =0 ; i <QUOTA_DATA (qtype); i++) raw_node->i.i_addr[get_extra_isize (raw_node) + i] = -cpu_to_le32 (data_blk_nor + i); +cpu_to_le32 (data_blkaddr + i); - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + offset +1 ; - -DBG (1 ,"\tWriting quota inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { +DBG (1 ,"\tWriting quota inode (hot node), offset 0x%x\n" , node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);return -1 ;@@ -1492,8 +1485,8 @@ static block_t f2fs_add_default_dentry_lpf(void)static int f2fs_write_lpf_inode (void ) {struct f2fs_node *raw_node; -uint64_t main_area_node_seg_blk_offset; -block_t data_blk_nor; +block_t data_blkaddr; +block_t node_blkaddr;int err =0 ;ASSERT (c.lpf_ino);@@ -1510,28 +1503,20 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_namelen =le32_to_cpu (strlen (LPF ));memcpy (raw_node->i.i_name,LPF ,strlen (LPF )); - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * c.blks_per_seg + -1 + c.quota_inum +1 ); + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); - data_blk_nor =f2fs_add_default_dentry_lpf (); -if (data_blk_nor ==0 ) { + data_blkaddr =f2fs_add_default_dentry_lpf (); +if (data_blkaddr ==0 ) {MSG (1 ,"\tError: Failed to add default dentries for lost+found!!!\n" ); err =-1 ; goto exit; } - raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blk_nor); - - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + c.quota_inum +1 ; + raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blkaddr); -DBG (1 ,"\tWriting lost+found inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) {
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +3
-0+DBG (1 ,"\tWriting lost+found inode (hot node), offset 0x%x\n" , + node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" ); err =-1 ; goto exit;Signature · 1 line
2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/4] mkfs.f2fs: cleanup w/ alloc_next_free_block()
Quoted 30 lines · Jaegeuk Kim
Quoted 29 lines · Chao Yu
Quoted 27 lines · Jaegeuk Kim
Quoted 20 lines · Chao Yu
Introduce
alloc_next_free_block()to wrap below openned codes:blkaddr =
get_sb(main_blkaddr)+
c.cur_seg[curseg_type] * c.blks_per_seg + c.curseg_offset[curseg_type];Meanwhile add
curseg_offsetfield inf2fs_configurationto record last blkaddr in each log.Signed-off-by Chao Yu <[email protected]>--- include/f2fs_fs.h | 2 + mkfs/f2fs_format.c | 101 +++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 58 deletions(-)include/f2fs_fs.h +0
-0include/f2fs_fs.h struct f2fs_configuration { · line 606
Quoted 4 lines
include/f2fs_fs.h +2
-0@@ -603,6 +603,8 @@ struct f2fs_configuration {/* compression support for sload.f2fs */ compress_config_t compress; + +block_t curseg_offset[6 ];
NR_CURSEG_TYPE?
Quoted 6 lines
Quoted 4 lines
The macro is defined after struct
f2fs_configuration...How about updating all value w/ macro in below patch, as the patch relocates struct
f2fs_configuration?Could you please post patches?
Sure, let revise in v2. :)
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/4] mkfs.f2fs: cleanup w/ alloc_next_free_block()
In reply to Jaegeuk KimQuoted 30 lines · Jaegeuk Kim
Quoted 29 lines · Chao Yu
Quoted 27 lines · Jaegeuk Kim
Quoted 20 lines · Chao Yu
Introduce
alloc_next_free_block()to wrap below openned codes:blkaddr =
get_sb(main_blkaddr)+
c.cur_seg[curseg_type] * c.blks_per_seg + c.curseg_offset[curseg_type];Meanwhile add
curseg_offsetfield inf2fs_configurationto record last blkaddr in each log.Signed-off-by Chao Yu <[email protected]>--- include/f2fs_fs.h | 2 + mkfs/f2fs_format.c | 101 +++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 58 deletions(-)include/f2fs_fs.h +0
-0include/f2fs_fs.h struct f2fs_configuration { · line 606
Quoted 4 lines
include/f2fs_fs.h +2
-0@@ -603,6 +603,8 @@ struct f2fs_configuration {/* compression support for sload.f2fs */ compress_config_t compress; + +block_t curseg_offset[6 ];
NR_CURSEG_TYPE?
Quoted 6 lines
Quoted 4 lines
The macro is defined after struct
f2fs_configuration...How about updating all value w/ macro in below patch, as the patch relocates struct
f2fs_configuration?Could you please post patches?
Could you please check below patch?
[PATCH v2 4/4] mkfs.f2fs: refactor format flow for cleanup
Thanks,
Quoted 160 lines
Quoted 160 lines
[PATCH 4/4]mkfs.f2fs: refactor format flow for cleanup
Thanks,
Quoted 154 lines
Quoted 154 lines
include/f2fs_fs.h +0
-0};#ifdef CONFIG_64BIT mkfs/f2fs_format.c +40
-58@@ -1230,11 +1230,24 @@ static int f2fs_discard_obsolete_dnode(void) }#endif +static block_t alloc_next_free_block (int curseg_type,int blkcnt) +{ +block_t blkaddr; + + blkaddr =get_sb (main_blkaddr) + + c.cur_seg[curseg_type] * c.blks_per_seg + + c.curseg_offset[curseg_type]; + + c.curseg_offset[curseg_type] += blkcnt; + +return blkaddr; +} +static int f2fs_write_root_inode (void ) {struct f2fs_node *raw_node =NULL ; -uint64_t data_blk_nor; -uint64_t main_area_node_seg_blk_offset =0 ; +block_t data_blkaddr; +block_t node_blkaddr; raw_node =calloc (F2FS_BLKSIZE ,1 );if (raw_node ==NULL ) {@@ -1248,24 +1261,15 @@ static int f2fs_write_root_inode(void)if (c.lpf_ino) raw_node->i.i_links =cpu_to_le32 (3 ); - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg +1 ); - - data_blk_nor =get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA ] * c.blks_per_seg; - raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blk_nor); - - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg; - -DBG (1 ,"\tWriting root inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { + data_blkaddr =alloc_next_free_block (CURSEG_HOT_DATA ,1 ); + raw_node->i.i_addr[get_extra_isize (raw_node)] = +cpu_to_le32 (data_blkaddr); + + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); + +DBG (1 ,"\tWriting root inode (hot node), offset 0x%x\n" , node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);return -1 ;@@ -1349,8 +1353,8 @@ static int f2fs_write_default_quota(int qtype, unsigned int blkaddr,static int f2fs_write_qf_inode (int qtype,int offset) {struct f2fs_node *raw_node =NULL ; -uint64_t data_blk_nor; -uint64_t main_area_node_seg_blk_offset =0 ; +block_t data_blkaddr; +block_t node_blkaddr;__le32 raw_id;int i;@@ -1366,14 +1370,10 @@ static int f2fs_write_qf_inode(int qtype, int offset) raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); raw_node->i.i_flags =F2FS_NOATIME_FL |F2FS_IMMUTABLE_FL ; - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg +1 + qtype +1 ); + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); - data_blk_nor =get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA ] * c.blks_per_seg +1 - + offset *QUOTA_DATA (i); + data_blkaddr =alloc_next_free_block (CURSEG_HOT_DATA ,QUOTA_DATA (i));if (qtype ==0 ) raw_id = raw_node->i.i_uid;@@ -1385,24 +1385,17 @@ static int f2fs_write_qf_inode(int qtype, int offset)ASSERT (0 );/* write two blocks */ -if (f2fs_write_default_quota (qtype, data_blk_nor, raw_id)) { +if (f2fs_write_default_quota (qtype, data_blkaddr, raw_id)) {free (raw_node);return -1 ; }for (i =0 ; i <QUOTA_DATA (qtype); i++) raw_node->i.i_addr[get_extra_isize (raw_node) + i] = -cpu_to_le32 (data_blk_nor + i); +cpu_to_le32 (data_blkaddr + i); - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + offset +1 ; - -DBG (1 ,"\tWriting quota inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) { +DBG (1 ,"\tWriting quota inode (hot node), offset 0x%x\n" , node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" );free (raw_node);return -1 ;@@ -1492,8 +1485,8 @@ static block_t f2fs_add_default_dentry_lpf(void)static int f2fs_write_lpf_inode (void ) {struct f2fs_node *raw_node; -uint64_t main_area_node_seg_blk_offset; -block_t data_blk_nor; +block_t data_blkaddr; +block_t node_blkaddr;int err =0 ;ASSERT (c.lpf_ino);@@ -1510,28 +1503,20 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_namelen =le32_to_cpu (strlen (LPF ));memcpy (raw_node->i.i_name,LPF ,strlen (LPF )); - raw_node->footer.next_blkaddr =cpu_to_le32 ( -get_sb (main_blkaddr) + - c.cur_seg[CURSEG_HOT_NODE ] * c.blks_per_seg + -1 + c.quota_inum +1 ); + node_blkaddr =alloc_next_free_block (CURSEG_HOT_NODE ,1 ); + raw_node->footer.next_blkaddr =cpu_to_le32 (node_blkaddr +1 ); - data_blk_nor =f2fs_add_default_dentry_lpf (); -if (data_blk_nor ==0 ) { + data_blkaddr =f2fs_add_default_dentry_lpf (); +if (data_blkaddr ==0 ) {MSG (1 ,"\tError: Failed to add default dentries for lost+found!!!\n" ); err =-1 ; goto exit; } - raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blk_nor); - - main_area_node_seg_blk_offset =get_sb (main_blkaddr); - main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE ] * - c.blks_per_seg + c.quota_inum +1 ; + raw_node->i.i_addr[get_extra_isize (raw_node)] =cpu_to_le32 (data_blkaddr); -DBG (1 ,"\tWriting lost+found inode (hot node), %x %x %x at offset 0x%08" PRIu64"\n" , -get_sb (main_blkaddr), - c.cur_seg[CURSEG_HOT_NODE ], - c.blks_per_seg, main_area_node_seg_blk_offset); -if (write_inode (raw_node, main_area_node_seg_blk_offset) <0 ) {
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mkfs/f2fs_format.c +3
-0+DBG (1 ,"\tWriting lost+found inode (hot node), offset 0x%x\n" , + node_blkaddr); +if (write_inode (raw_node, node_blkaddr) <0 ) {MSG (1 ,"\tError: While writing the raw_node to disk!!!\n" ); err =-1 ; goto exit;Signature · 1 line
2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 4/4 mkfs.f2fs: refactor format flow for cleanup
In reply to Chao YuDuring formatting device, node/data block and filesystem metatdata related to same inode were updated in separated functions, e.g. for root inode:
- f2fs_write_root_inode() updates root inode's block
- f2fs_write_check_point_pack updates its nat/sit journal, summary block
Result in:
- there are some redundant codes in between f2fs_write_check_point_pack() and functions in f2fs_create_root_dir().
- readability is bad due to filesystem meta and data/node updates in separated places.
- bad scalability if we want to add more default inode.
So that, this patch introduces below functions:
- update_sit_journal
- update_nat_jounral
- update_summary_entry
Then use them to update inode related metadata into cache in below functions:
- f2fs_write_root_inode
- f2fs_add_default_dentry_root
- f2fs_write_qf_inode
- f2fs_write_default_quota
- f2fs_write_lpf_inode
- f2fs_write_lpf_inode
Finally, f2fs_write_check_point_pack() can write back cached metadata into CP area directly.
--- include/f2fs_fs.h | 235 ++++++++++++------------ mkfs/f2fs_format.c | 449 ++++++++++++++++++++++----------------------- 2 files changed, 337 insertions(+), 347 deletions(-)
include/f2fs_fs.h +121 -114
@@ -494,119 +494,6 @@ typedef struct {#define ALIGN_DOWN (addrs, size) (((addrs) / (size)) * (size))#define ALIGN_UP (addrs, size) ALIGN_DOWN(((addrs) + (size) - 1), (size)) -struct f2fs_configuration { -uint32_t conf_reserved_sections; -uint32_t reserved_segments; -uint32_t new_reserved_segments; -int sparse_mode; -int zoned_mode; -int zoned_model; -size_t zone_blocks; -double overprovision; -double new_overprovision; -uint32_t cur_seg[6 ]; -uint32_t segs_per_sec; -uint32_t secs_per_zone; -uint32_t segs_per_zone; -uint32_t start_sector; -uint32_t total_segments; -uint32_t sector_size; -uint64_t device_size; -uint64_t total_sectors; -uint64_t wanted_total_sectors; -uint64_t wanted_sector_size; -uint64_t target_sectors; -uint32_t sectors_per_blk; -uint32_t blks_per_seg; -__u8 init_version[VERSION_LEN +1 ]; -__u8 sb_version[VERSION_LEN +1 ]; -__u8 version[VERSION_LEN +1 ]; -char *vol_label; -char *vol_uuid; -uint16_t s_encoding; -uint16_t s_encoding_flags; -int heap; -int32_t kd; -int32_t dump_fd; -struct device_info devices[MAX_DEVICES ]; -int ndevs; -char *extension_list[2 ]; -const char *rootdev_name; -int dbg_lv; -int show_dentry; -int trim; -int trimmed; -int func; -void *private; -int dry_run; -int no_kernel_check; -int fix_on; -int force; -int defset; -int bug_on; -int force_stop; -int abnormal_stop; -int fs_errors; -int bug_nat_bits; -bool quota_fixed; -int alloc_failed; -int auto_fix; -int layout; -int show_file_map; -u64 show_file_map_max_offset; -int quota_fix; -int preen_mode; -int ro; -int preserve_limits;/* preserve quota limits */ -int large_nat_bitmap; -int fix_chksum;/* fix old cp.chksum position */ -__le32 feature;/* defined features */ -unsigned int quota_bits;/* quota bits */ -time_t fixed_time; - -/* mkfs parameters */ -int fake_seed; -uint32_t next_free_nid; -uint32_t quota_inum; -uint32_t quota_dnum; -uint32_t lpf_inum; -uint32_t lpf_dnum; -uint32_t lpf_ino; -uint32_t root_uid; -uint32_t root_gid; - -/* defragmentation parameters */ -int defrag_shrink; -uint64_t defrag_start; -uint64_t defrag_len; -uint64_t defrag_target; - -/* sload parameters */ -char *from_dir; -char *mount_point; -char *target_out_dir; -char *fs_config_file; -#ifdef HAVE_LIBSELINUX -struct selinux_opt seopt_file[8 ]; -int nr_opt; -#endif -int preserve_perms; - -/* resize parameters */ -int safe_resize; - -/* precomputed fs UUID checksum for seeding other checksums */ -uint32_t chksum_seed; - -/* cache parameters */ -dev_cache_config_t cache_config; - -/* compression support for sload.f2fs */ -compress_config_t compress; - -block_t curseg_offset[6 ]; -}; -#ifdef CONFIG_64BIT #define BITS_PER_LONG 64#else
@@ -721,6 +608,12 @@ enum { NO_CHECK_TYPE }; +enum { +CURSEG_RO_HOT_DATA , +CURSEG_RO_HOT_NODE , +NR_RO_CURSEG_TYPE , +}; +#define F2FS_MIN_SEGMENTS 9/* SB + 2 (CP + SIT + NAT) + SSA + MAIN */ /*
@@ -749,7 +642,7 @@ enum {#define F2FS_META_INO (sbi) (sbi->meta_ino_num)#define F2FS_MAX_QUOTAS 3 -#define QUOTA_DATA (i) (2) +#define QUOTA_DATA 2#define QUOTA_INO (sb,t) (le32_to_cpu((sb)->qf_ino[t]))/*
@@ -1471,6 +1364,120 @@ enum { SSR }; +#define MAX_CACHE_SUMS 8 + +struct f2fs_configuration { +uint32_t conf_reserved_sections; +uint32_t reserved_segments; +uint32_t new_reserved_segments; +int sparse_mode; +int zoned_mode; +int zoned_model; +size_t zone_blocks; +double overprovision; +double new_overprovision; +uint32_t cur_seg[6 ]; +uint32_t segs_per_sec; +uint32_t secs_per_zone; +uint32_t segs_per_zone; +uint32_t start_sector; +uint32_t total_segments; +uint32_t sector_size; +uint64_t device_size; +uint64_t total_sectors; +uint64_t wanted_total_sectors; +uint64_t wanted_sector_size; +uint64_t target_sectors; +uint32_t sectors_per_blk; +uint32_t blks_per_seg; +__u8 init_version[VERSION_LEN +1 ]; +__u8 sb_version[VERSION_LEN +1 ]; +__u8 version[VERSION_LEN +1 ]; +char *vol_label; +char *vol_uuid; +uint16_t s_encoding; +uint16_t s_encoding_flags; +int heap; +int32_t kd; +int32_t dump_fd; +struct device_info devices[MAX_DEVICES ]; +int ndevs; +char *extension_list[2 ]; +const char *rootdev_name; +int dbg_lv; +int show_dentry; +int trim; +int trimmed; +int func; +void *private; +int dry_run; +int no_kernel_check; +int fix_on; +int force; +int defset; +int bug_on; +int force_stop; +int abnormal_stop; +int fs_errors; +int bug_nat_bits; +bool quota_fixed; +int alloc_failed; +int auto_fix; +int layout; +int show_file_map; +u64 show_file_map_max_offset; +int quota_fix; +int preen_mode; +int ro; +int preserve_limits;/* preserve quota limits */ +int large_nat_bitmap; +int fix_chksum;/* fix old cp.chksum position */ +__le32 feature;/* defined features */ +unsigned int quota_bits;/* quota bits */ +time_t fixed_time; + +/* mkfs parameters */ +int fake_seed; +uint32_t next_free_nid; +uint32_t lpf_ino; +uint32_t root_uid; +uint32_t root_gid; + +/* defragmentation parameters */ +int defrag_shrink; +uint64_t defrag_start; +uint64_t defrag_len; +uint64_t defrag_target; + +/* sload parameters */ +char *from_dir; +char *mount_point; +char *target_out_dir; +char *fs_config_file; +#ifdef HAVE_LIBSELINUX +struct selinux_opt seopt_file[8 ]; +int nr_opt; +#endif +int preserve_perms; + +/* resize parameters */ +int safe_resize; + +/* precomputed fs UUID checksum for seeding other checksums */ +uint32_t chksum_seed; + +/* cache parameters */ +dev_cache_config_t cache_config; + +/* compression support for sload.f2fs */ +compress_config_t compress; + +block_t curseg_offset[6 ]; +struct f2fs_journal sit_jnl; +struct f2fs_journal nat_jnl; +struct f2fs_summary sum[6 ][MAX_CACHE_SUMS ]; +}; +extern int utf8_to_utf16 (char *,const char *,size_t ,size_t );extern int utf16_to_utf8 (char *,const char *,size_t ,size_t );extern int log_base_2 (uint32_t );
mkfs/f2fs_format.c +216 -233
636 lines not on this page · raw message
Signature · 8 lines
2.40.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel