[RHEL7,COMMIT] fs/super: don't destroy super_block in case of leaked inodes

Submitted by Konstantin Khorenko on Aug. 6, 2019, 9:35 a.m.

Details

Message ID 201908060935.x769Zipg004060@finist-ce7.sw.ru
State New
Series "fs/super: don't destroy super_block in case of leaked inodes"
Headers show

Commit Message

Konstantin Khorenko Aug. 6, 2019, 9:35 a.m.
The commit is pushed to "branch-rh7-3.10.0-957.21.3.vz7.106.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.21.3.vz7.106.7
------>
commit 1e96054ee10b18e06155f5402fe7ec5bf4b2c984
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Tue Aug 6 12:35:44 2019 +0300

    fs/super: don't destroy super_block in case of leaked inodes
    
    In case of leaked inode don't destroy superblock to decrease
    possibility of crash.
    
    https://jira.sw.ru/browse/PSBM-95177
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 fs/super.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/super.c b/fs/super.c
index 02c9dc94e555..f131d14587ca 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -339,7 +339,15 @@  void deactivate_locked_super(struct super_block *s)
 		cleancache_invalidate_fs(s);
 		unregister_shrinker(&s->s_shrink);
 		fs->kill_sb(s);
-
+		if (!list_empty(&s->s_inodes)) {
+			pr_err("deactivate_locked_super: busy inodes...\n");
+			spin_lock(&sb_lock);
+			if (!--s->s_count)
+				list_del_init(&s->s_list);
+			spin_unlock(&sb_lock);
+			up_write(&s->s_umount);
+			return;
+		}
 		/*
 		 * Since list_lru_destroy() may sleep, we cannot call it from
 		 * put_super(), where we hold the sb_lock. Therefore we destroy