From patchwork Mon Sep 30 18:56:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11167321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 529151599 for ; Mon, 30 Sep 2019 19:07:55 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B45B224EF for ; Mon, 30 Sep 2019 19:07:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B45B224EF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6EC7D5E4F9F; Mon, 30 Sep 2019 12:01:32 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id A6ADC5C3CA7 for ; Mon, 30 Sep 2019 11:57:41 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id D5C961005F9F; Mon, 30 Sep 2019 14:56:57 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id D36A9BB; Mon, 30 Sep 2019 14:56:57 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 30 Sep 2019 14:56:33 -0400 Message-Id: <1569869810-23848-135-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569869810-23848-1-git-send-email-jsimmons@infradead.org> References: <1569869810-23848-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 134/151] lustre: llite: fix mount error handing X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Saveliev , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Vladimir Saveliev lustre_fill_super() allocates lsi and assumes that on failures lsi will be freed by server_fill_super() or ll_fill_super(). - server_fill_super() does not free lsi when lsi_prepare() fails. - ll_fill_super() does not free lsi when OBD_ALLOC_PTR(cfg) or ll_init_sbi() fail. WC-bug-id: https://jira.whamcloud.com/browse/LU-5991 Cray-bug-id: MRP-2229 Lustre-commit: acabfb9594c9 ("LU-5991 llite: fix mount error handing") Signed-off-by: Vladimir Saveliev Reviewed-on: https://review.whamcloud.com/12959 Reviewed-by: Sergey Cheremencev Reviewed-by: Andriy Skulysh Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/llite_lib.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index 758f856..c94bc65 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -939,7 +939,7 @@ int ll_fill_super(struct super_block *sb) { struct lustre_profile *lprof = NULL; struct lustre_sb_info *lsi = s2lsi(sb); - struct ll_sb_info *sbi; + struct ll_sb_info *sbi = NULL; char *dt = NULL, *md = NULL; char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; @@ -950,21 +950,20 @@ int ll_fill_super(struct super_block *sb) CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); + try_module_get(THIS_MODULE); + cfg = kzalloc(sizeof(*cfg), GFP_NOFS); if (!cfg) { - ll_common_put_super(sb); - return -ENOMEM; + err = -ENOMEM; + goto out_free; } - try_module_get(THIS_MODULE); /* client additional sb info */ sbi = ll_init_sbi(); lsi->lsi_llsbi = sbi; if (!sbi) { - module_put(THIS_MODULE); - kfree(cfg); - ll_common_put_super(sb); - return -ENOMEM; + err = -ENOMEM; + goto out_free; } err = ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags); @@ -1048,12 +1047,12 @@ int ll_fill_super(struct super_block *sb) kfree(dt); if (lprof) class_put_profile(lprof); + kfree(cfg); if (err) ll_put_super(sb); else if (sbi->ll_flags & LL_SBI_VERBOSE) LCONSOLE_WARN("Mounted %s\n", profilenm); - kfree(cfg); return err; } /* ll_fill_super */ @@ -1073,6 +1072,9 @@ void ll_put_super(struct super_block *sb) int next, force = 1, rc = 0; long ccc_count; + if (!sbi) + goto out_no_sbi; + CDEBUG(D_VFSTRACE, "VFS Op: sb %p - %s\n", sb, profilenm); cfg.cfg_instance = sb; @@ -1125,6 +1127,7 @@ void ll_put_super(struct super_block *sb) ll_free_sbi(sb); lsi->lsi_llsbi = NULL; +out_no_sbi: ll_common_put_super(sb); cl_env_cache_purge(~0);