Re: [f2fs-dev] [PATCH RESEND v2 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-07 Thread Chao Yu

On 2021/1/7 4:22, Jaegeuk Kim wrote:

On 12/09, Jaegeuk Kim wrote:

On 12/10, Chao Yu wrote:

Hi Daeho, Jaegeuk

I found one missing place in this patch which should adapt
"compress vs verity race bugfix"

Could you please check and apply below diff?


Applied.


Hi Chao,

Could you please rebase this patch on top of Eric's cleanup?


Done, :)

Thanks,



Thanks,





 From 61a9812944ac2f6f64fb458d5ef8b662c007bc50 Mon Sep 17 00:00:00 2001
From: Chao Yu 
Date: Thu, 10 Dec 2020 09:52:42 +0800
Subject: [PATCH] fix

Signed-off-by: Chao Yu 
---
  fs/f2fs/data.c | 7 ++-
  1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6787a7a03e86..894c5680db4a 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2271,11 +2271,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, 
struct bio **bio_ret,
f2fs_load_compressed_page(sbi, page, blkaddr);
if (PageUptodate(page)) {
if (!atomic_dec_return(>pending_pages)) {
-   bool verity =
-   f2fs_need_verity(inode, start_idx);
-
-   f2fs_do_decompress_pages(dic, verity);
-   if (verity) {
+   f2fs_do_decompress_pages(dic, for_verity);
+   if (for_verity) {
f2fs_verify_pages(dic->rpages,
dic->cluster_size);
f2fs_free_dic(dic);
--
2.29.2

Thanks,

On 2020/12/9 16:43, Chao Yu wrote:

Support to use address space of inner inode to cache compressed block,
in order to improve cache hit ratio of random read.

Signed-off-by: Chao Yu 
---
   Documentation/filesystems/f2fs.rst |   3 +
   fs/f2fs/compress.c | 198 +++--
   fs/f2fs/data.c |  29 -
   fs/f2fs/debug.c|  13 ++
   fs/f2fs/f2fs.h |  34 -
   fs/f2fs/gc.c   |   1 +
   fs/f2fs/inode.c|  21 ++-
   fs/f2fs/segment.c  |   6 +-
   fs/f2fs/super.c|  19 ++-
   include/linux/f2fs_fs.h|   1 +
   10 files changed, 305 insertions(+), 20 deletions(-)

diff --git a/Documentation/filesystems/f2fs.rst 
b/Documentation/filesystems/f2fs.rst
index dae15c96e659..5fa45fd8e4af 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -268,6 +268,9 @@ compress_mode=%s Control file compression mode. This supports 
"fs" and "user"
 choosing the target file and the timing. The user can 
do manual
 compression/decompression on the compression enabled 
files using
 ioctls.
+compress_cache  Support to use address space of a filesystem managed 
inode to
+cache compressed block, in order to improve cache hit 
ratio of
+random read.
   inlinecrypt   When possible, encrypt/decrypt the contents of 
encrypted
 files using the blk-crypto framework rather than
 filesystem-layer encryption. This allows the use of
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 4bcbacfe3325..446dd41a7bad 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -12,9 +12,11 @@
   #include 
   #include 
   #include 
+#include 
   #include "f2fs.h"
   #include "node.h"
+#include "segment.h"
   #include 
   static struct kmem_cache *cic_entry_slab;
@@ -721,25 +723,14 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
return ret;
   }
-void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)
+void f2fs_do_decompress_pages(struct decompress_io_ctx *dic, bool verity)
   {
-   struct decompress_io_ctx *dic =
-   (struct decompress_io_ctx *)page_private(page);
-   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
struct f2fs_inode_info *fi= F2FS_I(dic->inode);
const struct f2fs_compress_ops *cops =
f2fs_cops[fi->i_compress_algorithm];
int ret;
int i;
-   dec_page_count(sbi, F2FS_RD_DATA);
-
-   if (bio->bi_status || PageError(page))
-   dic->failed = true;
-
-   if (atomic_dec_return(>pending_pages))
-   return;
-
trace_f2fs_decompress_pages_start(dic->inode, dic->cluster_idx,
dic->cluster_size, fi->i_compress_algorithm);
@@ -797,6 +788,7 @@ void f2fs_decompress_pages(struct bio *bio, struct page 
*page, bool verity)
ret = cops->decompress_pages(dic);
if (!ret && (fi->i_compress_flag & 1 << COMPRESS_CHKSUM)) {
+   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
u32 provided = le32_to_cpu(dic->cbuf->chksum);
 

Re: [f2fs-dev] [PATCH RESEND v2 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2021-01-06 Thread Jaegeuk Kim
On 12/09, Jaegeuk Kim wrote:
> On 12/10, Chao Yu wrote:
> > Hi Daeho, Jaegeuk
> > 
> > I found one missing place in this patch which should adapt
> > "compress vs verity race bugfix"
> > 
> > Could you please check and apply below diff?
> 
> Applied.

Hi Chao,

Could you please rebase this patch on top of Eric's cleanup?

Thanks,

> 
> > 
> > From 61a9812944ac2f6f64fb458d5ef8b662c007bc50 Mon Sep 17 00:00:00 2001
> > From: Chao Yu 
> > Date: Thu, 10 Dec 2020 09:52:42 +0800
> > Subject: [PATCH] fix
> > 
> > Signed-off-by: Chao Yu 
> > ---
> >  fs/f2fs/data.c | 7 ++-
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 6787a7a03e86..894c5680db4a 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -2271,11 +2271,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, 
> > struct bio **bio_ret,
> > f2fs_load_compressed_page(sbi, page, blkaddr);
> > if (PageUptodate(page)) {
> > if (!atomic_dec_return(>pending_pages)) {
> > -   bool verity =
> > -   f2fs_need_verity(inode, start_idx);
> > -
> > -   f2fs_do_decompress_pages(dic, verity);
> > -   if (verity) {
> > +   f2fs_do_decompress_pages(dic, for_verity);
> > +   if (for_verity) {
> > f2fs_verify_pages(dic->rpages,
> > dic->cluster_size);
> > f2fs_free_dic(dic);
> > -- 
> > 2.29.2
> > 
> > Thanks,
> > 
> > On 2020/12/9 16:43, Chao Yu wrote:
> > > Support to use address space of inner inode to cache compressed block,
> > > in order to improve cache hit ratio of random read.
> > > 
> > > Signed-off-by: Chao Yu 
> > > ---
> > >   Documentation/filesystems/f2fs.rst |   3 +
> > >   fs/f2fs/compress.c | 198 +++--
> > >   fs/f2fs/data.c |  29 -
> > >   fs/f2fs/debug.c|  13 ++
> > >   fs/f2fs/f2fs.h |  34 -
> > >   fs/f2fs/gc.c   |   1 +
> > >   fs/f2fs/inode.c|  21 ++-
> > >   fs/f2fs/segment.c  |   6 +-
> > >   fs/f2fs/super.c|  19 ++-
> > >   include/linux/f2fs_fs.h|   1 +
> > >   10 files changed, 305 insertions(+), 20 deletions(-)
> > > 
> > > diff --git a/Documentation/filesystems/f2fs.rst 
> > > b/Documentation/filesystems/f2fs.rst
> > > index dae15c96e659..5fa45fd8e4af 100644
> > > --- a/Documentation/filesystems/f2fs.rst
> > > +++ b/Documentation/filesystems/f2fs.rst
> > > @@ -268,6 +268,9 @@ compress_mode=%s   Control file compression mode. 
> > > This supports "fs" and "user"
> > >choosing the target file and the timing. The 
> > > user can do manual
> > >compression/decompression on the compression 
> > > enabled files using
> > >ioctls.
> > > +compress_cacheSupport to use address space of a filesystem 
> > > managed inode to
> > > +  cache compressed block, in order to improve cache hit 
> > > ratio of
> > > +  random read.
> > >   inlinecrypt  When possible, encrypt/decrypt the contents of 
> > > encrypted
> > >files using the blk-crypto framework rather 
> > > than
> > >filesystem-layer encryption. This allows the 
> > > use of
> > > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> > > index 4bcbacfe3325..446dd41a7bad 100644
> > > --- a/fs/f2fs/compress.c
> > > +++ b/fs/f2fs/compress.c
> > > @@ -12,9 +12,11 @@
> > >   #include 
> > >   #include 
> > >   #include 
> > > +#include 
> > >   #include "f2fs.h"
> > >   #include "node.h"
> > > +#include "segment.h"
> > >   #include 
> > >   static struct kmem_cache *cic_entry_slab;
> > > @@ -721,25 +723,14 @@ static int f2fs_compress_pages(struct compress_ctx 
> > > *cc)
> > >   return ret;
> > >   }
> > > -void f2fs_decompress_pages(struct bio *bio, struct page *page, bool 
> > > verity)
> > > +void f2fs_do_decompress_pages(struct decompress_io_ctx *dic, bool verity)
> > >   {
> > > - struct decompress_io_ctx *dic =
> > > - (struct decompress_io_ctx *)page_private(page);
> > > - struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
> > >   struct f2fs_inode_info *fi= F2FS_I(dic->inode);
> > >   const struct f2fs_compress_ops *cops =
> > >   f2fs_cops[fi->i_compress_algorithm];
> > >   int ret;
> > >   int i;
> > > - dec_page_count(sbi, F2FS_RD_DATA);
> > > -
> > > - if (bio->bi_status || PageError(page))
> > > - dic->failed = true;
> > > -
> > > - if (atomic_dec_return(>pending_pages))
> > > - return;
> > > -
> > >   

Re: [PATCH RESEND v2 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2020-12-09 Thread Jaegeuk Kim
On 12/10, Chao Yu wrote:
> Hi Daeho, Jaegeuk
> 
> I found one missing place in this patch which should adapt
> "compress vs verity race bugfix"
> 
> Could you please check and apply below diff?

Applied.

> 
> From 61a9812944ac2f6f64fb458d5ef8b662c007bc50 Mon Sep 17 00:00:00 2001
> From: Chao Yu 
> Date: Thu, 10 Dec 2020 09:52:42 +0800
> Subject: [PATCH] fix
> 
> Signed-off-by: Chao Yu 
> ---
>  fs/f2fs/data.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 6787a7a03e86..894c5680db4a 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -2271,11 +2271,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, 
> struct bio **bio_ret,
>   f2fs_load_compressed_page(sbi, page, blkaddr);
>   if (PageUptodate(page)) {
>   if (!atomic_dec_return(>pending_pages)) {
> - bool verity =
> - f2fs_need_verity(inode, start_idx);
> -
> - f2fs_do_decompress_pages(dic, verity);
> - if (verity) {
> + f2fs_do_decompress_pages(dic, for_verity);
> + if (for_verity) {
>   f2fs_verify_pages(dic->rpages,
>   dic->cluster_size);
>   f2fs_free_dic(dic);
> -- 
> 2.29.2
> 
> Thanks,
> 
> On 2020/12/9 16:43, Chao Yu wrote:
> > Support to use address space of inner inode to cache compressed block,
> > in order to improve cache hit ratio of random read.
> > 
> > Signed-off-by: Chao Yu 
> > ---
> >   Documentation/filesystems/f2fs.rst |   3 +
> >   fs/f2fs/compress.c | 198 +++--
> >   fs/f2fs/data.c |  29 -
> >   fs/f2fs/debug.c|  13 ++
> >   fs/f2fs/f2fs.h |  34 -
> >   fs/f2fs/gc.c   |   1 +
> >   fs/f2fs/inode.c|  21 ++-
> >   fs/f2fs/segment.c  |   6 +-
> >   fs/f2fs/super.c|  19 ++-
> >   include/linux/f2fs_fs.h|   1 +
> >   10 files changed, 305 insertions(+), 20 deletions(-)
> > 
> > diff --git a/Documentation/filesystems/f2fs.rst 
> > b/Documentation/filesystems/f2fs.rst
> > index dae15c96e659..5fa45fd8e4af 100644
> > --- a/Documentation/filesystems/f2fs.rst
> > +++ b/Documentation/filesystems/f2fs.rst
> > @@ -268,6 +268,9 @@ compress_mode=%s Control file compression mode. 
> > This supports "fs" and "user"
> >  choosing the target file and the timing. The user can 
> > do manual
> >  compression/decompression on the compression enabled 
> > files using
> >  ioctls.
> > +compress_cache  Support to use address space of a filesystem 
> > managed inode to
> > +cache compressed block, in order to improve cache hit 
> > ratio of
> > +random read.
> >   inlinecryptWhen possible, encrypt/decrypt the contents of 
> > encrypted
> >  files using the blk-crypto framework rather than
> >  filesystem-layer encryption. This allows the use of
> > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> > index 4bcbacfe3325..446dd41a7bad 100644
> > --- a/fs/f2fs/compress.c
> > +++ b/fs/f2fs/compress.c
> > @@ -12,9 +12,11 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include "f2fs.h"
> >   #include "node.h"
> > +#include "segment.h"
> >   #include 
> >   static struct kmem_cache *cic_entry_slab;
> > @@ -721,25 +723,14 @@ static int f2fs_compress_pages(struct compress_ctx 
> > *cc)
> > return ret;
> >   }
> > -void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)
> > +void f2fs_do_decompress_pages(struct decompress_io_ctx *dic, bool verity)
> >   {
> > -   struct decompress_io_ctx *dic =
> > -   (struct decompress_io_ctx *)page_private(page);
> > -   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
> > struct f2fs_inode_info *fi= F2FS_I(dic->inode);
> > const struct f2fs_compress_ops *cops =
> > f2fs_cops[fi->i_compress_algorithm];
> > int ret;
> > int i;
> > -   dec_page_count(sbi, F2FS_RD_DATA);
> > -
> > -   if (bio->bi_status || PageError(page))
> > -   dic->failed = true;
> > -
> > -   if (atomic_dec_return(>pending_pages))
> > -   return;
> > -
> > trace_f2fs_decompress_pages_start(dic->inode, dic->cluster_idx,
> > dic->cluster_size, fi->i_compress_algorithm);
> > @@ -797,6 +788,7 @@ void f2fs_decompress_pages(struct bio *bio, struct page 
> > *page, bool verity)
> > ret = cops->decompress_pages(dic);
> > if (!ret && (fi->i_compress_flag & 1 << COMPRESS_CHKSUM)) {
> > +   struct f2fs_sb_info *sbi = 

Re: [PATCH RESEND v2 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2020-12-09 Thread Chao Yu

Hi Daeho, Jaegeuk

I found one missing place in this patch which should adapt
"compress vs verity race bugfix"

Could you please check and apply below diff?

From 61a9812944ac2f6f64fb458d5ef8b662c007bc50 Mon Sep 17 00:00:00 2001
From: Chao Yu 
Date: Thu, 10 Dec 2020 09:52:42 +0800
Subject: [PATCH] fix

Signed-off-by: Chao Yu 
---
 fs/f2fs/data.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6787a7a03e86..894c5680db4a 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2271,11 +2271,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, 
struct bio **bio_ret,
f2fs_load_compressed_page(sbi, page, blkaddr);
if (PageUptodate(page)) {
if (!atomic_dec_return(>pending_pages)) {
-   bool verity =
-   f2fs_need_verity(inode, start_idx);
-
-   f2fs_do_decompress_pages(dic, verity);
-   if (verity) {
+   f2fs_do_decompress_pages(dic, for_verity);
+   if (for_verity) {
f2fs_verify_pages(dic->rpages,
dic->cluster_size);
f2fs_free_dic(dic);
--
2.29.2

Thanks,

On 2020/12/9 16:43, Chao Yu wrote:

Support to use address space of inner inode to cache compressed block,
in order to improve cache hit ratio of random read.

Signed-off-by: Chao Yu 
---
  Documentation/filesystems/f2fs.rst |   3 +
  fs/f2fs/compress.c | 198 +++--
  fs/f2fs/data.c |  29 -
  fs/f2fs/debug.c|  13 ++
  fs/f2fs/f2fs.h |  34 -
  fs/f2fs/gc.c   |   1 +
  fs/f2fs/inode.c|  21 ++-
  fs/f2fs/segment.c  |   6 +-
  fs/f2fs/super.c|  19 ++-
  include/linux/f2fs_fs.h|   1 +
  10 files changed, 305 insertions(+), 20 deletions(-)

diff --git a/Documentation/filesystems/f2fs.rst 
b/Documentation/filesystems/f2fs.rst
index dae15c96e659..5fa45fd8e4af 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -268,6 +268,9 @@ compress_mode=%s Control file compression mode. This supports 
"fs" and "user"
 choosing the target file and the timing. The user can 
do manual
 compression/decompression on the compression enabled 
files using
 ioctls.
+compress_cache  Support to use address space of a filesystem managed 
inode to
+cache compressed block, in order to improve cache hit 
ratio of
+random read.
  inlinecryptWhen possible, encrypt/decrypt the contents of 
encrypted
 files using the blk-crypto framework rather than
 filesystem-layer encryption. This allows the use of
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 4bcbacfe3325..446dd41a7bad 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -12,9 +12,11 @@
  #include 
  #include 
  #include 
+#include 
  
  #include "f2fs.h"

  #include "node.h"
+#include "segment.h"
  #include 
  
  static struct kmem_cache *cic_entry_slab;

@@ -721,25 +723,14 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
return ret;
  }
  
-void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)

+void f2fs_do_decompress_pages(struct decompress_io_ctx *dic, bool verity)
  {
-   struct decompress_io_ctx *dic =
-   (struct decompress_io_ctx *)page_private(page);
-   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
struct f2fs_inode_info *fi= F2FS_I(dic->inode);
const struct f2fs_compress_ops *cops =
f2fs_cops[fi->i_compress_algorithm];
int ret;
int i;
  
-	dec_page_count(sbi, F2FS_RD_DATA);

-
-   if (bio->bi_status || PageError(page))
-   dic->failed = true;
-
-   if (atomic_dec_return(>pending_pages))
-   return;
-
trace_f2fs_decompress_pages_start(dic->inode, dic->cluster_idx,
dic->cluster_size, fi->i_compress_algorithm);
  
@@ -797,6 +788,7 @@ void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)

ret = cops->decompress_pages(dic);
  
  	if (!ret && (fi->i_compress_flag & 1 << COMPRESS_CHKSUM)) {

+   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
u32 provided = le32_to_cpu(dic->cbuf->chksum);
u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen);
  
@@ -830,6 +822,30 @@ void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)

f2fs_free_dic(dic);
  }
  
+void 

[PATCH RESEND v2 1/5] f2fs: compress: add compress_inode to cache compressed blocks

2020-12-09 Thread Chao Yu
Support to use address space of inner inode to cache compressed block,
in order to improve cache hit ratio of random read.

Signed-off-by: Chao Yu 
---
 Documentation/filesystems/f2fs.rst |   3 +
 fs/f2fs/compress.c | 198 +++--
 fs/f2fs/data.c |  29 -
 fs/f2fs/debug.c|  13 ++
 fs/f2fs/f2fs.h |  34 -
 fs/f2fs/gc.c   |   1 +
 fs/f2fs/inode.c|  21 ++-
 fs/f2fs/segment.c  |   6 +-
 fs/f2fs/super.c|  19 ++-
 include/linux/f2fs_fs.h|   1 +
 10 files changed, 305 insertions(+), 20 deletions(-)

diff --git a/Documentation/filesystems/f2fs.rst 
b/Documentation/filesystems/f2fs.rst
index dae15c96e659..5fa45fd8e4af 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -268,6 +268,9 @@ compress_mode=%s Control file compression mode. This 
supports "fs" and "user"
 choosing the target file and the timing. The user can 
do manual
 compression/decompression on the compression enabled 
files using
 ioctls.
+compress_cache  Support to use address space of a filesystem managed 
inode to
+cache compressed block, in order to improve cache hit 
ratio of
+random read.
 inlinecrypt When possible, encrypt/decrypt the contents of 
encrypted
 files using the blk-crypto framework rather than
 filesystem-layer encryption. This allows the use of
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 4bcbacfe3325..446dd41a7bad 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -12,9 +12,11 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "f2fs.h"
 #include "node.h"
+#include "segment.h"
 #include 
 
 static struct kmem_cache *cic_entry_slab;
@@ -721,25 +723,14 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
return ret;
 }
 
-void f2fs_decompress_pages(struct bio *bio, struct page *page, bool verity)
+void f2fs_do_decompress_pages(struct decompress_io_ctx *dic, bool verity)
 {
-   struct decompress_io_ctx *dic =
-   (struct decompress_io_ctx *)page_private(page);
-   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
struct f2fs_inode_info *fi= F2FS_I(dic->inode);
const struct f2fs_compress_ops *cops =
f2fs_cops[fi->i_compress_algorithm];
int ret;
int i;
 
-   dec_page_count(sbi, F2FS_RD_DATA);
-
-   if (bio->bi_status || PageError(page))
-   dic->failed = true;
-
-   if (atomic_dec_return(>pending_pages))
-   return;
-
trace_f2fs_decompress_pages_start(dic->inode, dic->cluster_idx,
dic->cluster_size, fi->i_compress_algorithm);
 
@@ -797,6 +788,7 @@ void f2fs_decompress_pages(struct bio *bio, struct page 
*page, bool verity)
ret = cops->decompress_pages(dic);
 
if (!ret && (fi->i_compress_flag & 1 << COMPRESS_CHKSUM)) {
+   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
u32 provided = le32_to_cpu(dic->cbuf->chksum);
u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen);
 
@@ -830,6 +822,30 @@ void f2fs_decompress_pages(struct bio *bio, struct page 
*page, bool verity)
f2fs_free_dic(dic);
 }
 
+void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
+   nid_t ino, block_t blkaddr);
+void f2fs_decompress_pages(struct bio *bio, struct page *page,
+   bool verity, unsigned int ofs)
+{
+   struct decompress_io_ctx *dic =
+   (struct decompress_io_ctx *)page_private(page);
+   struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode);
+   block_t blkaddr;
+
+   dec_page_count(sbi, F2FS_RD_DATA);
+
+   if (bio->bi_status || PageError(page))
+   dic->failed = true;
+
+   blkaddr = SECTOR_TO_BLOCK(bio->bi_iter.bi_sector) + ofs;
+   f2fs_cache_compressed_page(sbi, page, dic->inode->i_ino, blkaddr);
+
+   if (atomic_dec_return(>pending_pages))
+   return;
+
+   f2fs_do_decompress_pages(dic, verity);
+}
+
 static bool is_page_in_cluster(struct compress_ctx *cc, pgoff_t index)
 {
if (cc->cluster_idx == NULL_CLUSTER)
@@ -1600,6 +1616,164 @@ void f2fs_decompress_end_io(struct page **rpages,
}
 }
 
+const struct address_space_operations f2fs_compress_aops = {
+   .releasepage = f2fs_release_page,
+   .invalidatepage = f2fs_invalidate_page,
+};
+
+struct address_space *COMPRESS_MAPPING(struct f2fs_sb_info *sbi)
+{
+   return sbi->compress_inode->i_mapping;
+}
+
+void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr)
+{
+