From: Christian Brauner <brauner@kernel.org>
To: Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@lst.de>
Cc: reiserfs-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH 2/4] reiserfs: centralize freeing of reiserfs info
Date: Mon, 09 Oct 2023 14:33:39 +0200 [thread overview]
Message-ID: <20231009-vfs-fixes-reiserfs-v1-2-723a2f1132ce@kernel.org> (raw)
In-Reply-To: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org>
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@kernel.org>
---
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
next prev parent reply other threads:[~2023-10-09 12:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 12:33 [PATCH 0/4] reiserfs: fixes Christian Brauner
2023-10-09 12:33 ` [PATCH 1/4] reiserfs: user superblock as holder for journal device Christian Brauner
2023-10-09 14:12 ` Jan Kara
2023-10-09 12:33 ` Christian Brauner [this message]
2023-10-09 14:15 ` [PATCH 2/4] reiserfs: centralize freeing of reiserfs info Jan Kara
2023-10-09 12:33 ` [PATCH 3/4] reiserfs: centralize journal device closing Christian Brauner
2023-10-09 14:20 ` Jan Kara
2023-10-09 12:33 ` [PATCH 4/4] reiserfs: fix journal device opening Christian Brauner
2023-10-09 14:25 ` Jan Kara
2023-10-09 16:16 ` Christian Brauner
2023-10-09 16:33 ` Jan Kara
[not found] ` <CAHrFyr6sjz+MM4vAzwHKwasuQi=_dhGM+3JAJkp8A0Hu4gDtbg@mail.gmail.com>
2023-10-10 12:41 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231009-vfs-fixes-reiserfs-v1-2-723a2f1132ce@kernel.org \
--to=brauner@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=reiserfs-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).