All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [RFC PATCH] f2fs: support forword recovery for compressed files
@ 2022-04-24  3:32 Fengnan Chang via Linux-f2fs-devel
  2022-04-24  3:36 ` 常凤楠 via Linux-f2fs-devel
  0 siblings, 1 reply; 2+ messages in thread
From: Fengnan Chang via Linux-f2fs-devel @ 2022-04-24  3:32 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: Fengnan Chang, linux-f2fs-devel

Try support forword recovery for compressed files, this is a rough version,
need more test to improve it.

Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
---
 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
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [RFC PATCH] f2fs: support forword recovery for compressed files
  2022-04-24  3:32 [f2fs-dev] [RFC PATCH] f2fs: support forword recovery for compressed files Fengnan Chang via Linux-f2fs-devel
@ 2022-04-24  3:36 ` 常凤楠 via Linux-f2fs-devel
  0 siblings, 0 replies; 2+ messages in thread
From: 常凤楠 via Linux-f2fs-devel @ 2022-04-24  3:36 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel

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: jaegeuk@kernel.org; chao@kernel.org
> Cc: linux-f2fs-devel@lists.sourceforge.net; 常凤楠
> <changfengnan@vivo.com>
> 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 <changfengnan@vivo.com>
> ---
>  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
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-24  3:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24  3:32 [f2fs-dev] [RFC PATCH] f2fs: support forword recovery for compressed files Fengnan Chang via Linux-f2fs-devel
2022-04-24  3:36 ` 常凤楠 via Linux-f2fs-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.