Re: [PATCH 3/4] reiserfs: centralize journal device closing

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

 



On Mon 09-10-23 14:33:40, Christian Brauner wrote:
> Currently the journal device is closed 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 kill the journal device in
> reiserfs_kill_b().
> 
> Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								Honza

> ---
>  fs/reiserfs/journal.c  | 18 ++++++++----------
>  fs/reiserfs/reiserfs.h |  2 ++
>  fs/reiserfs/super.c    |  4 ++++
>  3 files changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
> index b9d9bf26d108..e001a96fc76c 100644
> --- a/fs/reiserfs/journal.c
> +++ b/fs/reiserfs/journal.c
> @@ -90,8 +90,6 @@ static int flush_commit_list(struct super_block *s,
>  static int can_dirty(struct reiserfs_journal_cnode *cn);
>  static int journal_join(struct reiserfs_transaction_handle *th,
>  			struct super_block *sb);
> -static void release_journal_dev(struct super_block *super,
> -			       struct reiserfs_journal *journal);
>  static void dirty_one_transaction(struct super_block *s,
>  				 struct reiserfs_journal_list *jl);
>  static void flush_async_commits(struct work_struct *work);
> @@ -1889,12 +1887,6 @@ static void free_journal_ram(struct super_block *sb)
>  	if (journal->j_header_bh) {
>  		brelse(journal->j_header_bh);
>  	}
> -	/*
> -	 * j_header_bh is on the journal dev, make sure
> -	 * not to release the journal dev until we brelse j_header_bh
> -	 */
> -	release_journal_dev(sb, journal);
> -	vfree(journal);
>  }
>  
>  /*
> @@ -2587,13 +2579,19 @@ static void journal_list_init(struct super_block *sb)
>  	SB_JOURNAL(sb)->j_current_jl = alloc_journal_list(sb);
>  }
>  
> -static void release_journal_dev(struct super_block *super,
> -			       struct reiserfs_journal *journal)
> +void reiserfs_release_journal_dev(struct super_block *super,
> +				  struct reiserfs_journal *journal)
>  {
>  	if (journal->j_dev_bd != NULL) {
>  		blkdev_put(journal->j_dev_bd, super);
>  		journal->j_dev_bd = NULL;
>  	}
> +
> +	/*
> +	 * j_header_bh is on the journal dev, make sure not to release
> +	 * the journal dev until we brelse j_header_bh
> +	 */
> +	vfree(journal);
>  }
>  
>  static int journal_init_dev(struct super_block *super,
> diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
> index 7d12b8c5b2fa..dd5d69c25e32 100644
> --- a/fs/reiserfs/reiserfs.h
> +++ b/fs/reiserfs/reiserfs.h
> @@ -3414,3 +3414,5 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
>  long reiserfs_compat_ioctl(struct file *filp,
>  		   unsigned int cmd, unsigned long arg);
>  int reiserfs_unpack(struct inode *inode);
> +void reiserfs_release_journal_dev(struct super_block *super,
> +				  struct reiserfs_journal *journal);
> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
> index 6db8ed10a78d..c04d9a4427e5 100644
> --- a/fs/reiserfs/super.c
> +++ b/fs/reiserfs/super.c
> @@ -550,6 +550,7 @@ int remove_save_link(struct inode *inode, int truncate)
>  static void reiserfs_kill_sb(struct super_block *s)
>  {
>  	struct reiserfs_sb_info *sbi = REISERFS_SB(s);
> +	struct reiserfs_journal *journal = NULL;
>  
>  	if (sbi) {
>  		reiserfs_proc_info_done(s);
> @@ -567,10 +568,13 @@ static void reiserfs_kill_sb(struct super_block *s)
>  		sbi->xattr_root = NULL;
>  		dput(sbi->priv_root);
>  		sbi->priv_root = NULL;
> +		journal = SB_JOURNAL(s);
>  	}
>  
>  	kill_block_super(s);
>  
> +	if (journal)
> +		reiserfs_release_journal_dev(s, journal);
>  	kfree(sbi);
>  	s->s_fs_info = NULL;
>  }
> 
> -- 
> 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