For now, write compressed file with fsync, we need do CP, it's a heavy
behavior. This patch try to support forward recovery for compressed file.
This is a rough version, need more test to improve it.
Anyway, looking forward some suggestions.
When test this patch, you should disable CP when fsync, like this:
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f08e6208e183..aedda8ae58af 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -196,8 +196,8 @@ static inline enum cp_reason_type need_do_checkpoint(struct
inode *inode)
if (!S_ISREG(inode->i_mode))
cp_reason = CP_NON_REGULAR;
- else if (f2fs_compressed_file(inode))
- cp_reason = CP_COMPRESSED;
+ //else if (f2fs_compressed_file(inode))
+ // cp_reason = CP_COMPRESSED;
else if (inode->i_nlink != 1)
cp_reason = CP_HARDLINK;
else if (is_sbi_flag_set(sbi, SBI_NEED_CP))
> -----Original Message-----
> From: 常凤楠
> Sent: Sunday, April 24, 2022 11:32 AM
> To: [email protected]; [email protected]
> Cc: [email protected]; 常凤楠
> <[email protected]>
> Subject: [RFC PATCH] f2fs: support forword recovery for compressed files
>
> 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