[RFC,54/62] ext4: make use of ->free_inode()
diff mbox series

Message ID 20190416175340.21068-54-viro@ZenIV.linux.org.uk
State New
Headers show
Series
  • [RFC,01/62] securityfs: fix use-after-free on symlink traversal
Related show

Commit Message

Al Viro April 16, 2019, 5:53 p.m. UTC
From: Al Viro <viro@zeniv.linux.org.uk>

the rest of this ->destroy_inode() instance could probably be folded
into ext4_evict_inode()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/ext4/super.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Jan Kara April 18, 2019, 12:10 p.m. UTC | #1
On Tue 16-04-19 18:53:32, Al Viro wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
> 
> the rest of this ->destroy_inode() instance could probably be folded
> into ext4_evict_inode()
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Looks good to me. You can add:

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

You're right about the possibility of moving the check to
ext4_evict_inode() (probably ext4_clear_inode() would be the best). But we
can leave that for later.

								Honza

> ---
>  fs/ext4/super.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 6ed4eb81e674..981f702848e7 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1107,9 +1107,8 @@ static int ext4_drop_inode(struct inode *inode)
>  	return drop;
>  }
>  
> -static void ext4_i_callback(struct rcu_head *head)
> +static void ext4_free_in_core_inode(struct inode *inode)
>  {
> -	struct inode *inode = container_of(head, struct inode, i_rcu);
>  	kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
>  }
>  
> @@ -1124,7 +1123,6 @@ static void ext4_destroy_inode(struct inode *inode)
>  				true);
>  		dump_stack();
>  	}
> -	call_rcu(&inode->i_rcu, ext4_i_callback);
>  }
>  
>  static void init_once(void *foo)
> @@ -1402,6 +1400,7 @@ static const struct quotactl_ops ext4_qctl_operations = {
>  
>  static const struct super_operations ext4_sops = {
>  	.alloc_inode	= ext4_alloc_inode,
> +	.free_inode	= ext4_free_in_core_inode,
>  	.destroy_inode	= ext4_destroy_inode,
>  	.write_inode	= ext4_write_inode,
>  	.dirty_inode	= ext4_dirty_inode,
> -- 
> 2.11.0
>

Patch
diff mbox series

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6ed4eb81e674..981f702848e7 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1107,9 +1107,8 @@  static int ext4_drop_inode(struct inode *inode)
 	return drop;
 }
 
-static void ext4_i_callback(struct rcu_head *head)
+static void ext4_free_in_core_inode(struct inode *inode)
 {
-	struct inode *inode = container_of(head, struct inode, i_rcu);
 	kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
 }
 
@@ -1124,7 +1123,6 @@  static void ext4_destroy_inode(struct inode *inode)
 				true);
 		dump_stack();
 	}
-	call_rcu(&inode->i_rcu, ext4_i_callback);
 }
 
 static void init_once(void *foo)
@@ -1402,6 +1400,7 @@  static const struct quotactl_ops ext4_qctl_operations = {
 
 static const struct super_operations ext4_sops = {
 	.alloc_inode	= ext4_alloc_inode,
+	.free_inode	= ext4_free_in_core_inode,
 	.destroy_inode	= ext4_destroy_inode,
 	.write_inode	= ext4_write_inode,
 	.dirty_inode	= ext4_dirty_inode,