diff mbox series

[f2fs-dev,v2,2/5] f2fs: expand f2fs_invalidate_compress_page() to f2fs_invalidate_compress_pages_range()

Message ID 20241030103136.2874140-3-yi.sun@unisoc.com (mailing list archive)
State New
Headers show
Series Speed up f2fs truncate | expand

Commit Message

Yi Sun Oct. 30, 2024, 10:31 a.m. UTC
New function f2fs_invalidate_compress_pages_range() adds the @len
parameter. So it can process some consecutive blocks at a time.

Signed-off-by: Yi Sun <yi.sun@unisoc.com>
---
 fs/f2fs/compress.c | 7 ++++---
 fs/f2fs/f2fs.h     | 9 +++++----
 2 files changed, 9 insertions(+), 7 deletions(-)

Comments

Chao Yu Oct. 31, 2024, 7:26 a.m. UTC | #1
On 2024/10/30 18:31, Yi Sun wrote:
> New function f2fs_invalidate_compress_pages_range() adds the @len
> parameter. So it can process some consecutive blocks at a time.
> 
> Signed-off-by: Yi Sun <yi.sun@unisoc.com>
> ---
>   fs/f2fs/compress.c | 7 ++++---
>   fs/f2fs/f2fs.h     | 9 +++++----
>   2 files changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index 7f26440e8595..e607a7885b57 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -1903,11 +1903,12 @@ 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)
> +void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
> +				block_t blkaddr, unsigned int len)
>   {
> -	if (!sbi->compress_inode)
> +	if (!sbi->compress_inode || len == 0)

We can remove len == 0 check condition? Or any caller can pass 0 here?

Thanks,

>   		return;
> -	invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr);
> +	invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr + len - 1);
>   }
>   
>   void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 3c6f3cce5779..d3fe66a93a56 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -4384,7 +4384,8 @@ void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi);
>   int __init f2fs_init_compress_cache(void);
>   void f2fs_destroy_compress_cache(void);
>   struct address_space *COMPRESS_MAPPING(struct f2fs_sb_info *sbi);
> -void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr);
> +void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
> +					block_t blkaddr, unsigned int len);
>   void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
>   						nid_t ino, block_t blkaddr);
>   bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
> @@ -4439,8 +4440,8 @@ static inline int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi) { return
>   static inline void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi) { }
>   static inline int __init f2fs_init_compress_cache(void) { return 0; }
>   static inline void f2fs_destroy_compress_cache(void) { }
> -static inline void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi,
> -				block_t blkaddr) { }
> +static inline void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
> +				block_t blkaddr, unsigned int len) { }
>   static inline void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi,
>   				struct page *page, nid_t ino, block_t blkaddr) { }
>   static inline bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi,
> @@ -4759,7 +4760,7 @@ static inline void f2fs_invalidate_internal_cache(struct f2fs_sb_info *sbi,
>   								block_t blkaddr)
>   {
>   	f2fs_truncate_meta_inode_pages(sbi, blkaddr, 1);
> -	f2fs_invalidate_compress_page(sbi, blkaddr);
> +	f2fs_invalidate_compress_pages_range(sbi, blkaddr, 1);
>   }
>   
>   #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
yi sun Oct. 31, 2024, 9:02 a.m. UTC | #2
On Thu, Oct 31, 2024 at 3:26 PM Chao Yu <chao@kernel.org> wrote:
>
> On 2024/10/30 18:31, Yi Sun wrote:
> > New function f2fs_invalidate_compress_pages_range() adds the @len
> > parameter. So it can process some consecutive blocks at a time.
> >
> > Signed-off-by: Yi Sun <yi.sun@unisoc.com>
> > ---
> >   fs/f2fs/compress.c | 7 ++++---
> >   fs/f2fs/f2fs.h     | 9 +++++----
> >   2 files changed, 9 insertions(+), 7 deletions(-)
> >
> > diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> > index 7f26440e8595..e607a7885b57 100644
> > --- a/fs/f2fs/compress.c
> > +++ b/fs/f2fs/compress.c
> > @@ -1903,11 +1903,12 @@ 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)
> > +void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
> > +                             block_t blkaddr, unsigned int len)
> >   {
> > -     if (!sbi->compress_inode)
> > +     if (!sbi->compress_inode || len == 0)
>
> We can remove len == 0 check condition? Or any caller can pass 0 here?
>
> Thanks,
>

Yes, len==0 can be removed.

> >               return;
> > -     invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr);
> > +     invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr + len - 1);
> >   }
> >
> >   void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index 3c6f3cce5779..d3fe66a93a56 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -4384,7 +4384,8 @@ void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi);
> >   int __init f2fs_init_compress_cache(void);
> >   void f2fs_destroy_compress_cache(void);
> >   struct address_space *COMPRESS_MAPPING(struct f2fs_sb_info *sbi);
> > -void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr);
> > +void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
> > +                                     block_t blkaddr, unsigned int len);
> >   void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
> >                                               nid_t ino, block_t blkaddr);
> >   bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
> > @@ -4439,8 +4440,8 @@ static inline int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi) { return
> >   static inline void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi) { }
> >   static inline int __init f2fs_init_compress_cache(void) { return 0; }
> >   static inline void f2fs_destroy_compress_cache(void) { }
> > -static inline void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi,
> > -                             block_t blkaddr) { }
> > +static inline void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
> > +                             block_t blkaddr, unsigned int len) { }
> >   static inline void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi,
> >                               struct page *page, nid_t ino, block_t blkaddr) { }
> >   static inline bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi,
> > @@ -4759,7 +4760,7 @@ static inline void f2fs_invalidate_internal_cache(struct f2fs_sb_info *sbi,
> >                                                               block_t blkaddr)
> >   {
> >       f2fs_truncate_meta_inode_pages(sbi, blkaddr, 1);
> > -     f2fs_invalidate_compress_page(sbi, blkaddr);
> > +     f2fs_invalidate_compress_pages_range(sbi, blkaddr, 1);
> >   }
> >
> >   #define EFSBADCRC   EBADMSG         /* Bad CRC detected */
>
diff mbox series

Patch

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 7f26440e8595..e607a7885b57 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1903,11 +1903,12 @@  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)
+void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
+				block_t blkaddr, unsigned int len)
 {
-	if (!sbi->compress_inode)
+	if (!sbi->compress_inode || len == 0)
 		return;
-	invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr);
+	invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr + len - 1);
 }
 
 void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 3c6f3cce5779..d3fe66a93a56 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -4384,7 +4384,8 @@  void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi);
 int __init f2fs_init_compress_cache(void);
 void f2fs_destroy_compress_cache(void);
 struct address_space *COMPRESS_MAPPING(struct f2fs_sb_info *sbi);
-void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr);
+void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
+					block_t blkaddr, unsigned int len);
 void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
 						nid_t ino, block_t blkaddr);
 bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
@@ -4439,8 +4440,8 @@  static inline int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi) { return
 static inline void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi) { }
 static inline int __init f2fs_init_compress_cache(void) { return 0; }
 static inline void f2fs_destroy_compress_cache(void) { }
-static inline void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi,
-				block_t blkaddr) { }
+static inline void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
+				block_t blkaddr, unsigned int len) { }
 static inline void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi,
 				struct page *page, nid_t ino, block_t blkaddr) { }
 static inline bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi,
@@ -4759,7 +4760,7 @@  static inline void f2fs_invalidate_internal_cache(struct f2fs_sb_info *sbi,
 								block_t blkaddr)
 {
 	f2fs_truncate_meta_inode_pages(sbi, blkaddr, 1);
-	f2fs_invalidate_compress_page(sbi, blkaddr);
+	f2fs_invalidate_compress_pages_range(sbi, blkaddr, 1);
 }
 
 #define EFSBADCRC	EBADMSG		/* Bad CRC detected */