All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH v2 1/2] f2fs: fix remove page failed in invalidate compress pages
@ 2021-11-26 10:19 Fengnan Chang
  2021-11-26 10:19 ` [f2fs-dev] [PATCH v2 2/2] f2fs: support POSIX_FADV_DONTNEED drop compressed page cache Fengnan Chang
  2021-11-26 15:12 ` [f2fs-dev] [PATCH v2 1/2] f2fs: fix remove page failed in invalidate compress pages Chao Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Fengnan Chang @ 2021-11-26 10:19 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: Fengnan Chang, linux-f2fs-devel

Since compress inode not a regular file, generic_error_remove_page in
f2fs_invalidate_compress_pages will always be failed, set compress
inode as a regular file to fix it.

Fixes: 6ce19aff0b8c ("f2fs: compress: add compress_inode to cache compressed
blocks")
Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
---
 fs/f2fs/inode.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 0f8b2df3e1e0..1db7823d5a13 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -516,6 +516,11 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino)
 	} else if (ino == F2FS_COMPRESS_INO(sbi)) {
 #ifdef CONFIG_F2FS_FS_COMPRESSION
 		inode->i_mapping->a_ops = &f2fs_compress_aops;
+		/*
+		 * generic_error_remove_page only truncates pages of regular
+		 * inode
+		 */
+		inode->i_mode |= S_IFREG;
 #endif
 		mapping_set_gfp_mask(inode->i_mapping,
 			GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE);
-- 
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] 4+ messages in thread

* [f2fs-dev] [PATCH v2 2/2] f2fs: support POSIX_FADV_DONTNEED drop compressed page cache
  2021-11-26 10:19 [f2fs-dev] [PATCH v2 1/2] f2fs: fix remove page failed in invalidate compress pages Fengnan Chang
@ 2021-11-26 10:19 ` Fengnan Chang
  2021-11-26 15:21   ` Chao Yu
  2021-11-26 15:12 ` [f2fs-dev] [PATCH v2 1/2] f2fs: fix remove page failed in invalidate compress pages Chao Yu
  1 sibling, 1 reply; 4+ messages in thread
From: Fengnan Chang @ 2021-11-26 10:19 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: Fengnan Chang, linux-f2fs-devel

Previously, compressed page cache drop when clean page cache, but
POSIX_FADV_DONTNEED can't clean compressed page cache because raw page
don't have private data, and won't call f2fs_invalidate_compress_pages.
This commit call f2fs_invalidate_compress_pages() directly in
f2fs_file_fadvise() for POSIX_FADV_DONTNEED case.

Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
---
 fs/f2fs/file.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 32c0bd545c5c..dafdaad9a9e4 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4677,12 +4677,11 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
 		int advice)
 {
-	struct inode *inode;
 	struct address_space *mapping;
 	struct backing_dev_info *bdi;
+	struct inode *inode = file_inode(filp);
 
 	if (advice == POSIX_FADV_SEQUENTIAL) {
-		inode = file_inode(filp);
 		if (S_ISFIFO(inode->i_mode))
 			return -ESPIPE;
 
@@ -4697,6 +4696,10 @@ static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
 		filp->f_mode &= ~FMODE_RANDOM;
 		spin_unlock(&filp->f_lock);
 		return 0;
+	} else if (advice == POSIX_FADV_DONTNEED) {
+		if (test_opt(F2FS_I_SB(inode), COMPRESS_CACHE) &&
+			f2fs_compressed_file(inode))
+			f2fs_invalidate_compress_pages(F2FS_I_SB(inode), inode->i_ino);
 	}
 
 	return generic_fadvise(filp, offset, len, advice);
-- 
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] 4+ messages in thread

* Re: [f2fs-dev] [PATCH v2 1/2] f2fs: fix remove page failed in invalidate compress pages
  2021-11-26 10:19 [f2fs-dev] [PATCH v2 1/2] f2fs: fix remove page failed in invalidate compress pages Fengnan Chang
  2021-11-26 10:19 ` [f2fs-dev] [PATCH v2 2/2] f2fs: support POSIX_FADV_DONTNEED drop compressed page cache Fengnan Chang
@ 2021-11-26 15:12 ` Chao Yu
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2021-11-26 15:12 UTC (permalink / raw)
  To: Fengnan Chang, jaegeuk; +Cc: linux-f2fs-devel

On 2021/11/26 18:19, Fengnan Chang wrote:
> Since compress inode not a regular file, generic_error_remove_page in
> f2fs_invalidate_compress_pages will always be failed, set compress
> inode as a regular file to fix it.
> 
> Fixes: 6ce19aff0b8c ("f2fs: compress: add compress_inode to cache compressed
> blocks")
> Signed-off-by: Fengnan Chang <changfengnan@vivo.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH v2 2/2] f2fs: support POSIX_FADV_DONTNEED drop compressed page cache
  2021-11-26 10:19 ` [f2fs-dev] [PATCH v2 2/2] f2fs: support POSIX_FADV_DONTNEED drop compressed page cache Fengnan Chang
@ 2021-11-26 15:21   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2021-11-26 15:21 UTC (permalink / raw)
  To: Fengnan Chang, jaegeuk; +Cc: linux-f2fs-devel

On 2021/11/26 18:19, Fengnan Chang wrote:
> Previously, compressed page cache drop when clean page cache, but
> POSIX_FADV_DONTNEED can't clean compressed page cache because raw page
> don't have private data, and won't call f2fs_invalidate_compress_pages.
> This commit call f2fs_invalidate_compress_pages() directly in
> f2fs_file_fadvise() for POSIX_FADV_DONTNEED case.
> 
> Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
> ---
>   fs/f2fs/file.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 32c0bd545c5c..dafdaad9a9e4 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -4677,12 +4677,11 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
>   static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
>   		int advice)
>   {
> -	struct inode *inode;
>   	struct address_space *mapping;
>   	struct backing_dev_info *bdi;
> +	struct inode *inode = file_inode(filp);
>   
>   	if (advice == POSIX_FADV_SEQUENTIAL) {
> -		inode = file_inode(filp);
>   		if (S_ISFIFO(inode->i_mode))
>   			return -ESPIPE;
>   
> @@ -4697,6 +4696,10 @@ static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
>   		filp->f_mode &= ~FMODE_RANDOM;
>   		spin_unlock(&filp->f_lock);
>   		return 0;
> +	} else if (advice == POSIX_FADV_DONTNEED) {
> +		if (test_opt(F2FS_I_SB(inode), COMPRESS_CACHE) &&
> +			f2fs_compressed_file(inode))
> +			f2fs_invalidate_compress_pages(F2FS_I_SB(inode), inode->i_ino);
>   	}

Well, how about invalidating compressed pages after generic_fadvise() in order to
check inode status before dropping caches?

Thanks,

>   
>   	return generic_fadvise(filp, offset, len, advice);
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2021-11-26 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 10:19 [f2fs-dev] [PATCH v2 1/2] f2fs: fix remove page failed in invalidate compress pages Fengnan Chang
2021-11-26 10:19 ` [f2fs-dev] [PATCH v2 2/2] f2fs: support POSIX_FADV_DONTNEED drop compressed page cache Fengnan Chang
2021-11-26 15:21   ` Chao Yu
2021-11-26 15:12 ` [f2fs-dev] [PATCH v2 1/2] f2fs: fix remove page failed in invalidate compress pages Chao Yu

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.