Re: [PATCH 2/4] reiserfs: centralize freeing of reiserfs info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon 09-10-23 14:33:39, Christian Brauner wrote:
> Currently the reiserfs info is free in multiple locations:
> 
> * in reiserfs_fill_super() if reiserfs_fill_super() fails
> * in reiserfs_put_super() when reiserfs is shut down and
>   reiserfs_fill_super() had succeeded
> 
> Stop duplicating this logic and always free reiserfs info in
> reiserfs_kill_sb().
> 
> Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								Honza

> ---
>  fs/reiserfs/super.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
> index 7eaf36b3de12..6db8ed10a78d 100644
> --- a/fs/reiserfs/super.c
> +++ b/fs/reiserfs/super.c
> @@ -549,7 +549,9 @@ int remove_save_link(struct inode *inode, int truncate)
>  
>  static void reiserfs_kill_sb(struct super_block *s)
>  {
> -	if (REISERFS_SB(s)) {
> +	struct reiserfs_sb_info *sbi = REISERFS_SB(s);
> +
> +	if (sbi) {
>  		reiserfs_proc_info_done(s);
>  		/*
>  		 * Force any pending inode evictions to occur now. Any
> @@ -561,13 +563,16 @@ static void reiserfs_kill_sb(struct super_block *s)
>  		 */
>  		shrink_dcache_sb(s);
>  
> -		dput(REISERFS_SB(s)->xattr_root);
> -		REISERFS_SB(s)->xattr_root = NULL;
> -		dput(REISERFS_SB(s)->priv_root);
> -		REISERFS_SB(s)->priv_root = NULL;
> +		dput(sbi->xattr_root);
> +		sbi->xattr_root = NULL;
> +		dput(sbi->priv_root);
> +		sbi->priv_root = NULL;
>  	}
>  
>  	kill_block_super(s);
> +
> +	kfree(sbi);
> +	s->s_fs_info = NULL;
>  }
>  
>  #ifdef CONFIG_QUOTA
> @@ -630,8 +635,6 @@ static void reiserfs_put_super(struct super_block *s)
>  	mutex_destroy(&REISERFS_SB(s)->lock);
>  	destroy_workqueue(REISERFS_SB(s)->commit_wq);
>  	kfree(REISERFS_SB(s)->s_jdev);
> -	kfree(s->s_fs_info);
> -	s->s_fs_info = NULL;
>  }
>  
>  static struct kmem_cache *reiserfs_inode_cachep;
> @@ -2240,9 +2243,6 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
>  	}
>  #endif
>  	kfree(sbi->s_jdev);
> -	kfree(sbi);
> -
> -	s->s_fs_info = NULL;
>  	return errval;
>  }
>  
> 
> -- 
> 2.34.1
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Linux File System Development]     [Linux BTRFS]     [Linux NFS]     [Linux Filesystems]     [Ext4 Filesystem]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Resources]

  Powered by Linux