diff mbox series

[1/4] reiserfs: user superblock as holder for journal device

Message ID 20231009-vfs-fixes-reiserfs-v1-1-723a2f1132ce@kernel.org (mailing list archive)
State New, archived
Headers show
Series reiserfs: fixes | expand

Commit Message

Christian Brauner Oct. 9, 2023, 12:33 p.m. UTC
I see no reason to use the journal as the holder of the block device.
The superblock should be used. In the case were the journal and main
device are the same we can easily reclaim because the same holder is
used.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/reiserfs/journal.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

Comments

Jan Kara Oct. 9, 2023, 2:12 p.m. UTC | #1
On Mon 09-10-23 14:33:38, Christian Brauner wrote:
> I see no reason to use the journal as the holder of the block device.
> The superblock should be used. In the case were the journal and main
> device are the same we can easily reclaim because the same holder is
> used.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Looks sane. Feel free to add:

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

								Honza

> ---
>  fs/reiserfs/journal.c | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
> index 015bfe4e4524..b9d9bf26d108 100644
> --- a/fs/reiserfs/journal.c
> +++ b/fs/reiserfs/journal.c
> @@ -2591,12 +2591,7 @@ static void release_journal_dev(struct super_block *super,
>  			       struct reiserfs_journal *journal)
>  {
>  	if (journal->j_dev_bd != NULL) {
> -		void *holder = NULL;
> -
> -		if (journal->j_dev_bd->bd_dev != super->s_dev)
> -			holder = journal;
> -
> -		blkdev_put(journal->j_dev_bd, holder);
> +		blkdev_put(journal->j_dev_bd, super);
>  		journal->j_dev_bd = NULL;
>  	}
>  }
> @@ -2606,7 +2601,6 @@ static int journal_init_dev(struct super_block *super,
>  			    const char *jdev_name)
>  {
>  	blk_mode_t blkdev_mode = BLK_OPEN_READ;
> -	void *holder = journal;
>  	int result;
>  	dev_t jdev;
>  
> @@ -2621,10 +2615,8 @@ static int journal_init_dev(struct super_block *super,
>  
>  	/* there is no "jdev" option and journal is on separate device */
>  	if ((!jdev_name || !jdev_name[0])) {
> -		if (jdev == super->s_dev)
> -			holder = NULL;
> -		journal->j_dev_bd = blkdev_get_by_dev(jdev, blkdev_mode, holder,
> -						      NULL);
> +		journal->j_dev_bd = blkdev_get_by_dev(jdev, blkdev_mode, super,
> +						      &fs_holder_ops);
>  		if (IS_ERR(journal->j_dev_bd)) {
>  			result = PTR_ERR(journal->j_dev_bd);
>  			journal->j_dev_bd = NULL;
> @@ -2638,8 +2630,8 @@ static int journal_init_dev(struct super_block *super,
>  		return 0;
>  	}
>  
> -	journal->j_dev_bd = blkdev_get_by_path(jdev_name, blkdev_mode, holder,
> -					       NULL);
> +	journal->j_dev_bd = blkdev_get_by_path(jdev_name, blkdev_mode, super,
> +					       &fs_holder_ops);
>  	if (IS_ERR(journal->j_dev_bd)) {
>  		result = PTR_ERR(journal->j_dev_bd);
>  		journal->j_dev_bd = NULL;
> 
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 015bfe4e4524..b9d9bf26d108 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -2591,12 +2591,7 @@  static void release_journal_dev(struct super_block *super,
 			       struct reiserfs_journal *journal)
 {
 	if (journal->j_dev_bd != NULL) {
-		void *holder = NULL;
-
-		if (journal->j_dev_bd->bd_dev != super->s_dev)
-			holder = journal;
-
-		blkdev_put(journal->j_dev_bd, holder);
+		blkdev_put(journal->j_dev_bd, super);
 		journal->j_dev_bd = NULL;
 	}
 }
@@ -2606,7 +2601,6 @@  static int journal_init_dev(struct super_block *super,
 			    const char *jdev_name)
 {
 	blk_mode_t blkdev_mode = BLK_OPEN_READ;
-	void *holder = journal;
 	int result;
 	dev_t jdev;
 
@@ -2621,10 +2615,8 @@  static int journal_init_dev(struct super_block *super,
 
 	/* there is no "jdev" option and journal is on separate device */
 	if ((!jdev_name || !jdev_name[0])) {
-		if (jdev == super->s_dev)
-			holder = NULL;
-		journal->j_dev_bd = blkdev_get_by_dev(jdev, blkdev_mode, holder,
-						      NULL);
+		journal->j_dev_bd = blkdev_get_by_dev(jdev, blkdev_mode, super,
+						      &fs_holder_ops);
 		if (IS_ERR(journal->j_dev_bd)) {
 			result = PTR_ERR(journal->j_dev_bd);
 			journal->j_dev_bd = NULL;
@@ -2638,8 +2630,8 @@  static int journal_init_dev(struct super_block *super,
 		return 0;
 	}
 
-	journal->j_dev_bd = blkdev_get_by_path(jdev_name, blkdev_mode, holder,
-					       NULL);
+	journal->j_dev_bd = blkdev_get_by_path(jdev_name, blkdev_mode, super,
+					       &fs_holder_ops);
 	if (IS_ERR(journal->j_dev_bd)) {
 		result = PTR_ERR(journal->j_dev_bd);
 		journal->j_dev_bd = NULL;