diff mbox series

[RFC,v3,7/8] ext4: remove bdev_try_to_free_page() callback

Message ID 20210527135641.420514-8-yi.zhang@huawei.com
State Superseded
Headers show
Series ext4, jbd2: fix 3 issues about bdev_try_to_free_page() | expand

Commit Message

Zhang Yi May 27, 2021, 1:56 p.m. UTC
After we introduce a jbd2 shrinker to release checkpointed buffer's
journal head, we could free buffer without bdev_try_to_free_page()
under memory pressure. So this patch remove the whole
bdev_try_to_free_page() callback directly. It also remove many
use-after-free issues relate to it together.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
---
 fs/ext4/super.c | 21 ---------------------
 1 file changed, 21 deletions(-)

Comments

Jan Kara June 7, 2021, 3:50 p.m. UTC | #1
On Thu 27-05-21 21:56:40, Zhang Yi wrote:
> After we introduce a jbd2 shrinker to release checkpointed buffer's
> journal head, we could free buffer without bdev_try_to_free_page()
> under memory pressure. So this patch remove the whole
> bdev_try_to_free_page() callback directly. It also remove many
> use-after-free issues relate to it together.
> 
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/super.c | 21 ---------------------
>  1 file changed, 21 deletions(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index bf6d0085e1b7..b778236d06e6 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1442,26 +1442,6 @@ static int ext4_nfs_commit_metadata(struct inode *inode)
>  	return ext4_write_inode(inode, &wbc);
>  }
>  
> -/*
> - * Try to release metadata pages (indirect blocks, directories) which are
> - * mapped via the block device.  Since these pages could have journal heads
> - * which would prevent try_to_free_buffers() from freeing them, we must use
> - * jbd2 layer's try_to_free_buffers() function to release them.
> - */
> -static int bdev_try_to_free_page(struct super_block *sb, struct page *page,
> -				 gfp_t wait)
> -{
> -	journal_t *journal = EXT4_SB(sb)->s_journal;
> -
> -	WARN_ON(PageChecked(page));
> -	if (!page_has_buffers(page))
> -		return 0;
> -	if (journal)
> -		return jbd2_journal_try_to_free_buffers(journal, page);
> -
> -	return try_to_free_buffers(page);
> -}
> -
>  #ifdef CONFIG_FS_ENCRYPTION
>  static int ext4_get_context(struct inode *inode, void *ctx, size_t len)
>  {
> @@ -1656,7 +1636,6 @@ static const struct super_operations ext4_sops = {
>  	.quota_write	= ext4_quota_write,
>  	.get_dquots	= ext4_get_dquots,
>  #endif
> -	.bdev_try_to_free_page = bdev_try_to_free_page,
>  };
>  
>  static const struct export_operations ext4_export_ops = {
> -- 
> 2.25.4
>
diff mbox series

Patch

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index bf6d0085e1b7..b778236d06e6 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1442,26 +1442,6 @@  static int ext4_nfs_commit_metadata(struct inode *inode)
 	return ext4_write_inode(inode, &wbc);
 }
 
-/*
- * Try to release metadata pages (indirect blocks, directories) which are
- * mapped via the block device.  Since these pages could have journal heads
- * which would prevent try_to_free_buffers() from freeing them, we must use
- * jbd2 layer's try_to_free_buffers() function to release them.
- */
-static int bdev_try_to_free_page(struct super_block *sb, struct page *page,
-				 gfp_t wait)
-{
-	journal_t *journal = EXT4_SB(sb)->s_journal;
-
-	WARN_ON(PageChecked(page));
-	if (!page_has_buffers(page))
-		return 0;
-	if (journal)
-		return jbd2_journal_try_to_free_buffers(journal, page);
-
-	return try_to_free_buffers(page);
-}
-
 #ifdef CONFIG_FS_ENCRYPTION
 static int ext4_get_context(struct inode *inode, void *ctx, size_t len)
 {
@@ -1656,7 +1636,6 @@  static const struct super_operations ext4_sops = {
 	.quota_write	= ext4_quota_write,
 	.get_dquots	= ext4_get_dquots,
 #endif
-	.bdev_try_to_free_page = bdev_try_to_free_page,
 };
 
 static const struct export_operations ext4_export_ops = {