Try support forword recovery for compressed files, this is a rough version, need more test to improve it.
Signed-off-by: Fengnan Chang <[email protected]> --- fs/f2fs/node.c | 7 +++++++ fs/f2fs/recovery.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index c280f482c741..1c5335757d7b 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -2803,6 +2803,13 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) dst->i_crtime = src->i_crtime; dst->i_crtime_nsec = src->i_crtime_nsec; } + if (f2fs_sb_has_compression(sbi) && src->i_flags & F2FS_COMPR_FL + && F2FS_FITS_IN_INODE(src, src->i_extra_isize, i_log_cluster_size)) { + dst->i_blocks = src->i_blocks; + dst->i_compress_algorithm = src->i_compress_algorithm; + dst->i_compr_blocks = src->i_compr_blocks; + dst->i_log_cluster_size = src->i_log_cluster_size; + } } new_ni = old_ni; diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index 3cb7f8a43b4d..4198fed4ae6f 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -669,6 +669,11 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, * and then reserve one new block in dnode page. */ if (dest == NEW_ADDR) { + if (f2fs_compressed_file(inode)) { + recovered++; + f2fs_update_data_blkaddr(&dn, dest); + continue; + } f2fs_truncate_data_blocks_range(&dn, 1); f2fs_reserve_new_block(&dn); continue; @@ -702,6 +707,10 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, f2fs_replace_block(sbi, &dn, src, dest, ni.version, false, false); recovered++; + } else if (f2fs_compressed_file(inode) && + (dest == COMPRESS_ADDR)) { + recovered++; + f2fs_update_data_blkaddr(&dn, dest); } } -- 2.32.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
