mkfs.f2fs: avoid wrong discard of dnode
PATCH 1/1 mkfs.f2fs: avoid wrong discard of dnode
This can drop root inode, which can be caused by previous stale data.
Signed-off-by Jaegeuk Kim <[email protected]>
--- mkfs/f2fs_format.c | 7 +++++++ 1 file changed, 7 insertions(+)
mkfs/f2fs_format.c +7 -0
@@ -847,6 +847,10 @@ static int f2fs_write_super_block(void)static int discard_obsolete_dnode (struct f2fs_node *raw_node,u_int64_t offset) {u_int64_t next_blkaddr =0 ; +u_int64_t root_inode_pos =get_sb (main_blkaddr); + +/* only root inode was written before truncating dnodes */ + root_inode_pos += c.cur_seg[CURSEG_HOT_NODE ] * c.blks_per_seg;if (c.zoned_mode)return 0 ;
@@ -869,6 +873,9 @@ static int discard_obsolete_dnode(struct f2fs_node *raw_node, u_int64_t offset)return -1 ; } offset = next_blkaddr; +/* should avoid recursive chain due to stale data */ +if (offset == root_inode_pos) +break ; }while (1 );return 0 ;
Signature · 6 lines
2.13.0.rc1.294.g07d810a77f-goog ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot