mkfs.f2fs: cleanup w/ alloc_next_free_block()
PATCH v3 3/4 mkfs.f2fs: cleanup w/ alloc_next_free_block()
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_offset field in f2fs_configuration to record last blkaddr in each log.
---
v3:
- rebase the code
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
PATCH v3 4/4 mkfs.f2fs: refactor format flow for cleanup
During 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.
---
v3:
- remove trailing whitespace
include/f2fs_fs.h | 235 ++++++++++++------------ mkfs/f2fs_format.c | 447 ++++++++++++++++++++++----------------------- 2 files changed, 336 insertions(+), 346 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[NR_CURSEG_TYPE ]; +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[NR_CURSEG_TYPE ]; +struct f2fs_journal sit_jnl; +struct f2fs_journal nat_jnl; +struct f2fs_summary sum[NR_CURSEG_TYPE ][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 +215 -232
630 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
mkfs/f2fs_format.c static int f2fs_write_qf_inode(int qtype, int offset)
Quoted 107 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]>---
v3:
- rebase the codeinclude/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 +26
-22@@ -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)
I removed "int offset" which os obsolete. Please check dev-test branch.
Quoted 96 lines
mkfs/f2fs_format.c +17
-36raw_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
Quoted 107 lines · Jaegeuk Kim
Quoted 106 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]>---
v3:
- rebase the codeinclude/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 +26
-22@@ -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;
Quoted 3 lines
mkfs/f2fs_format.c static int f2fs_write_qf_inode(int qtype, int offset)
Quoted 1 line
mkfs/f2fs_format.c +0
-0@@ -1366,14 +1370,10 @@ static int f2fs_write_qf_inode(int qtype, int offset)I removed "int offset" which os obsolete. Please check dev-test branch.
Thanks, it looks good to me.
Thanks,
Quoted 84 lines
Quoted 84 lines
mkfs/f2fs_format.c +14
-31raw_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