From patchwork Mon Oct 9 12:33:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13413670 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F02D6E95A96 for ; Mon, 9 Oct 2023 12:34:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346551AbjJIMej (ORCPT ); Mon, 9 Oct 2023 08:34:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346656AbjJIMeb (ORCPT ); Mon, 9 Oct 2023 08:34:31 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71EAEC6; Mon, 9 Oct 2023 05:33:55 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D37EAC433CA; Mon, 9 Oct 2023 12:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696854835; bh=/Tei9Zub8HjPOpjDb/mLaSHABMBEZFzrwXTdr2GFrfA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pDpEFdgt6V8WNKXYKBcBHNJ7ibPO+Zj1nTTW/0HoXsGwe50ceSTWdqcIowKVHYOcB PDFYObCjUkgdOkySedgg0zctYWrbVLitutiFP1xdtOasSm8ZYY4abDjVU7991i3lQU jENvgs5u/fIQ1lWvE48cpXcwCSZfFXr4s4yuYKDLDRHMezjnu0TdSqUSAVupbsVten qVgLfaH/j4hyafb19iz8ZJ/nQ8082MBvSU13b3Ty4FqFq3HJ5I+ljppeUCeqDUCjU4 5f7piksHlSB0r6NGGaOIZXKpXWa/mRbZcz6CQ4rkqJsIbvEqmV+AgBIpHkILs9BZiD JJTl9lkEVrzlg== From: Christian Brauner Date: Mon, 09 Oct 2023 14:33:38 +0200 Subject: [PATCH 1/4] reiserfs: user superblock as holder for journal device MIME-Version: 1.0 Message-Id: <20231009-vfs-fixes-reiserfs-v1-1-723a2f1132ce@kernel.org> References: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org> In-Reply-To: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org> To: Jan Kara , Christoph Hellwig Cc: reiserfs-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=2116; i=brauner@kernel.org; h=from:subject:message-id; bh=/Tei9Zub8HjPOpjDb/mLaSHABMBEZFzrwXTdr2GFrfA=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQqf9aft708X+xZ0VTfKY+/PWr/f2/+zCVHzHUme6TMbqtc GDR9Q0cpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBEvjcy/C+1ZHj377kv7w2p5oYHCn yHdtyN7nj2zrZG7vvzG8GWJ/4yMpzp8NcwDT+lJJZ/9APvBlnOCZZXjZn4L139P3/7+4h2RVYA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 Reviewed-by: Jan Kara --- 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; From patchwork Mon Oct 9 12:33:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13413671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08058E95A9C for ; Mon, 9 Oct 2023 12:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376350AbjJIMel (ORCPT ); Mon, 9 Oct 2023 08:34:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346619AbjJIMec (ORCPT ); Mon, 9 Oct 2023 08:34:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D2AD9D; Mon, 9 Oct 2023 05:33:57 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7ADF6C433C9; Mon, 9 Oct 2023 12:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696854836; bh=A//yTkylSaachSiYQ/ZpN4wnTcAW8EWJ8nOqinGABEs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nr6oVdxBU2Bwgsdto+Qqpa+niWuHwbhdGLHKNcOtNlGCh6G7Pf2GpSgBjSYBwgt3N PZSmu722SHEOmCintCDq01mlKggSkU2x3UVdYr0t0wrN6lPGhAu82nfY/0KM8N2Xeg iOgFyjzUylyPInj96KHKMmRXnZ2NEz3d1toDyUC1rwd/LKJxYH8Rg2v0FZjtVxQMG6 0fIrqfdPiF35HTDlOlOZzBrYFOa2N1n3MIjnFCYxNWnIfPvaQYky0yoqxeT2+t36Ir vk/KQp69KM4TGWXrNwDHZwU/E5J/mRlQuFA/1o1FqV+v9rUJ7daHEXn83JqU5PJoKJ K08ADa9OHgjIQ== From: Christian Brauner Date: Mon, 09 Oct 2023 14:33:39 +0200 Subject: [PATCH 2/4] reiserfs: centralize freeing of reiserfs info MIME-Version: 1.0 Message-Id: <20231009-vfs-fixes-reiserfs-v1-2-723a2f1132ce@kernel.org> References: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org> In-Reply-To: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org> To: Jan Kara , Christoph Hellwig Cc: reiserfs-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1945; i=brauner@kernel.org; h=from:subject:message-id; bh=A//yTkylSaachSiYQ/ZpN4wnTcAW8EWJ8nOqinGABEs=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQqf9afP7dxiedVvTWzWiL6tJ8+mm+a3T3fpdGi9qRZ68W0 jA7ejlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgInwFDL8r6p9yOdn8djr8J/aZfP0e+ RMJnQHN922ei7av/DNlgCfSYwMNy7f3n/l8ov9kewdVwQ0jd0Tz7U+YnKbzrt88ivD7053eAE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.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 Reviewed-by: Jan Kara --- 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; } From patchwork Mon Oct 9 12:33:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13413672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDBABE95A91 for ; Mon, 9 Oct 2023 12:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376431AbjJIMem (ORCPT ); Mon, 9 Oct 2023 08:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346668AbjJIMec (ORCPT ); Mon, 9 Oct 2023 08:34:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8133F4; Mon, 9 Oct 2023 05:33:58 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C54FC433C7; Mon, 9 Oct 2023 12:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696854838; bh=vL7gXeaL011kYTMUYatRQTiyf0pSn/dtrKj6ZXAphQQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZT8o+VZJcIzri/iCDJzVZTrfdAbhcekGlsGvsz4NMjRg3yVVbdATL8/iIC62Ra692 PDPn8CXxibOemoqXElv+/sZeklaJ0wVnc7jU10uZusFT8IZDjccg7pblkMTf8ue4eD QqPN7sNhhlctwp/hddMudFIGNc+EGPtOwmsF2gvqC0DIkFvSMXxNTa0XTIRZhPEsBe 8JFm1C5pZdaeBBbL5nB47gF71Kwnwcivwxq57X0/ZHGl0u4EL3NSwFlcO3IJorKbF9 jll761Wo1XvWMHA7uZOzNNnl7nKymm3rZ73fIsR27aTFd31podvp5PcyWuebPOwRMW dpEu+1zUcPfFg== From: Christian Brauner Date: Mon, 09 Oct 2023 14:33:40 +0200 Subject: [PATCH 3/4] reiserfs: centralize journal device closing MIME-Version: 1.0 Message-Id: <20231009-vfs-fixes-reiserfs-v1-3-723a2f1132ce@kernel.org> References: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org> In-Reply-To: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org> To: Jan Kara , Christoph Hellwig Cc: reiserfs-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=3506; i=brauner@kernel.org; h=from:subject:message-id; bh=vL7gXeaL011kYTMUYatRQTiyf0pSn/dtrKj6ZXAphQQ=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQqf9YPmTRdk8/MTfGSm/utyNd6cyJuOu8Tqrg9pUzZ2X+D /PzujlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIn8+cjwz2zSti9+Gx/aL9/2XPNO5J X5/fPSvp3+90DNZqWd3Qszy3OMDPP3Nz2dHXR8d3rWrI8cjCHu+xXc1n+OnHZS8byfrdaWBTwA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 Reviewed-by: Jan Kara --- 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; } From patchwork Mon Oct 9 12:33:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13413673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5AF1E95A9D for ; Mon, 9 Oct 2023 12:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376437AbjJIMeo (ORCPT ); Mon, 9 Oct 2023 08:34:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346678AbjJIMec (ORCPT ); Mon, 9 Oct 2023 08:34:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AC9010D; Mon, 9 Oct 2023 05:34:00 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5852C433CB; Mon, 9 Oct 2023 12:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696854840; bh=1XOQKvKpjSd/+56eqGAnKA9SYfbekuL9uuFHtuJE7dg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gPSmAxvYgN+cpMs9bF+LDR60qs+ykUOZZmoZzJQgovcuby88sGcfyw4HSca4wgMNF yNkfqQ4PcYZeFW2wcuf4mMENl6Brz2ryJBOaYF5H3W/RvSZRCGmJN/ATxh/uTbk06x 87BgTkpbNLn9vQcPQpAnWjPxVJP3iXyauinQxU5d0iOWmpizi1KQGXC23SQGNoFjlp yxenpEgxKfOoodxth+5PsyBchIZhlOiIr4fXVZaOMd4UFEIOS65ykKNlwyVRjYXOaJ nx/F+kFJzY4jSXF8bj2u5T+3KeICSDY04djCWCZsT40bN3eIjUtkqE+3OopWsebzKu 1sHrXCZ5g1Ukw== From: Christian Brauner Date: Mon, 09 Oct 2023 14:33:41 +0200 Subject: [PATCH 4/4] reiserfs: fix journal device opening MIME-Version: 1.0 Message-Id: <20231009-vfs-fixes-reiserfs-v1-4-723a2f1132ce@kernel.org> References: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org> In-Reply-To: <20231009-vfs-fixes-reiserfs-v1-0-723a2f1132ce@kernel.org> To: Jan Kara , Christoph Hellwig Cc: reiserfs-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, syzbot+062317ea1d0a6d5e29e7@syzkaller.appspotmail.com, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=2042; i=brauner@kernel.org; h=from:subject:message-id; bh=1XOQKvKpjSd/+56eqGAnKA9SYfbekuL9uuFHtuJE7dg=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQqf9bvb760dda21bEpnqHT3Dv/2R1r7pqTdupqB4/Ix+Xz 3wT1dZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEzk/W9Ghi0qqzdd4W/Xr2E1FsxUDU qZKlhQqLDxgjnPvDgpV+flfIwMXVuclpf8OsjTsE8mMLr/UsV5dxa1NdWtB1hKDpZd85FkAAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org We can't open devices with s_umount held without risking deadlocks. So drop s_umount and reacquire it when opening the journal device. Reported-by: syzbot+062317ea1d0a6d5e29e7@syzkaller.appspotmail.com Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/reiserfs/journal.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index e001a96fc76c..0c680de72d43 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -2714,7 +2714,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name, struct reiserfs_journal_header *jh; struct reiserfs_journal *journal; struct reiserfs_journal_list *jl; - int ret; + int ret = 1; journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal)); if (!journal) { @@ -2727,6 +2727,13 @@ int journal_init(struct super_block *sb, const char *j_dev_name, INIT_LIST_HEAD(&journal->j_working_list); INIT_LIST_HEAD(&journal->j_journal_list); journal->j_persistent_trans = 0; + + /* + * blkdev_put() can't be called under s_umount, see the comment + * in get_tree_bdev() for more details + */ + up_write(&sb->s_umount); + if (reiserfs_allocate_list_bitmaps(sb, journal->j_list_bitmap, reiserfs_bmap_count(sb))) goto free_and_return; @@ -2891,8 +2898,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name, goto free_and_return; } - ret = journal_read(sb); - if (ret < 0) { + if (journal_read(sb) < 0) { reiserfs_warning(sb, "reiserfs-2006", "Replay Failure, unable to mount"); goto free_and_return; @@ -2900,10 +2906,14 @@ int journal_init(struct super_block *sb, const char *j_dev_name, INIT_DELAYED_WORK(&journal->j_work, flush_async_commits); journal->j_work_sb = sb; - return 0; + ret = 0; + free_and_return: - free_journal_ram(sb); - return 1; + if (ret) + free_journal_ram(sb); + + down_write(&sb->s_umount); + return ret; } /*