[rh7] ms/ext4: remove extent status procfs files if journal load fails

Submitted by Andrey Ryabinin on April 23, 2018, 12:46 p.m.

Details

Message ID 20180423124604.14003-1-aryabinin@virtuozzo.com
State New
Series "ms/ext4: remove extent status procfs files if journal load fails"
Headers show

Commit Message

Andrey Ryabinin April 23, 2018, 12:46 p.m.
From: "Darrick J. Wong" <darrick.wong@oracle.com>

commit 50460fe8c6d1d95b16427936e351f277a1c72d43 upstream.

If we can't load the journal, remove the procfs files for the extent
status information file to avoid leaking resources.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org

[aryabinin: This bug causes the WARN bellow, eventually leading
  to crash in shrink_slab()]

EXT4-fs (loop0): INFO: recovery required on readonly filesystem
EXT4-fs (loop0): write access unavailable, cannot proceed
------------[ cut here ]------------
WARNING: CPU: 55 PID: 469689 at fs/proc/generic.c:641 remove_proc_entry+0x151/0x1a0
remove_proc_entry: removing non-empty directory 'ext4/loop0', leaking at least 'es_shrinker_info'

Call Trace:
 [<ffffffff816d5d81>] dump_stack+0x19/0x1b
 [<ffffffff8108a8d8>] __warn+0xd8/0x100
 [<ffffffff8108a95f>] warn_slowpath_fmt+0x5f/0x80
 [<ffffffff81298c11>] remove_proc_entry+0x151/0x1a0
 [<ffffffffc03985e7>] ext4_fill_super+0x267/0x2cc0 [ext4]
 [<ffffffff81222c92>] mount_bdev+0x1f2/0x240
 [<ffffffffc0392ef4>] ext4_mount+0x44/0x60 [ext4]
 [<ffffffff81223849>] mount_fs+0x39/0x1b0
 [<ffffffff81240e87>] vfs_kern_mount+0x67/0x110
 [<ffffffff8124372c>] do_mount+0x24c/0xb30
 [<ffffffff81244356>] SyS_mount+0x96/0xf0
 [<ffffffff816e8a7d>] system_call_fastpath+0x16/0x1b
---[ end trace 8b5c76e01d611a1e ]---

https://jira.sw.ru/browse/PSBM-83691
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 fs/ext4/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index a8aae06a9336..f644bf01587a 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4399,7 +4399,7 @@  static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) &&
 	    !(sb->s_flags & MS_RDONLY))
 		if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
-			goto failed_mount3;
+			goto failed_mount3a;
 
 	/*
 	 * The first inode we look at is the journal inode.  Don't try
@@ -4409,7 +4409,7 @@  static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	    EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
 		err = ext4_load_journal(sb, es, journal_devnum);
 		if (err)
-			goto failed_mount3;
+			goto failed_mount3a;
 	} else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) &&
 	      EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) {
 		ext4_msg(sb, KERN_ERR, "required journal recovery "
@@ -4694,6 +4694,7 @@  failed_mount_wq:
 		jbd2_journal_destroy(sbi->s_journal);
 		sbi->s_journal = NULL;
 	}
+failed_mount3a:
 	ext4_es_unregister_shrinker(sbi);
 failed_mount3:
 	del_timer_sync(&sbi->s_err_report);