[Devel] [PATCH RHEL7 COMMIT] ms/fs/super.c: fix WARN on alloc_super() fail path

Konstantin Khorenko khorenko at virtuozzo.com
Tue Mar 15 09:04:11 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.1
------>
commit 55b087bccead386e0e6c893effe6666f6987ae64
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Tue Mar 15 20:04:11 2016 +0400

    ms/fs/super.c: fix WARN on alloc_super() fail path
    
    ms commit b5bd856a0c2a ("fs/super.c: fix WARN on alloc_super() fail path")
    
    On fail path alloc_super() calls destroy_super(), which issues a warning
    if the sb's s_mounts list is not empty, in particular if it has not been
    initialized.  That said s_mounts must be initialized in alloc_super()
    before any possible failure, but currently it is initialized close to
    the end of the function leading to a useless warning dumped to log if
    either percpu_counter_init() or list_lru_init() fails.  Let's fix this.
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    
    Cc: Al Viro <viro at zeniv.linux.org.uk>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    
    Found during investigation of
    https://jira.sw.ru/browse/PSBM-43294
---
 fs/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/super.c b/fs/super.c
index 11de99c..4d6ce6d 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -171,6 +171,8 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
 	if (!s)
 		return NULL;
 
+	INIT_LIST_HEAD(&s->s_mounts);
+
 	if (security_sb_alloc(s))
 		goto fail;
 	for (i = 0; i < SB_FREEZE_LEVELS; i++) {
@@ -193,7 +195,6 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
 	if (list_lru_init_memcg(&s->s_inode_lru))
 		goto err_out_dentry_lru;
 
-	INIT_LIST_HEAD(&s->s_mounts);
 	init_rwsem(&s->s_umount);
 	lockdep_set_class(&s->s_umount, &type->s_umount_key);
 	/*


More information about the Devel mailing list