From patchwork Tue May 29 14:45:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 87A6960327 for ; Tue, 29 May 2018 14:57:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B00C286AA for ; Tue, 29 May 2018 14:57:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79D6D28744; Tue, 29 May 2018 14:57:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E9B3286AA for ; Tue, 29 May 2018 14:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936569AbeE2Oxg (ORCPT ); Tue, 29 May 2018 10:53:36 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35643 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935715AbeE2OqZ (ORCPT ); Tue, 29 May 2018 10:46:25 -0400 Received: by mail-wm0-f68.google.com with SMTP id o78-v6so41496078wmg.0 for ; Tue, 29 May 2018 07:46:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nWxkccE8L1lYGi2L8/UZ4EXxmAziAUGJt9+JzY0lSmo=; b=qkdnYjj+fYgaaaBRJaUkOqHCwQ1TAOPp3UVYCPxOD36zpPYzkEomv/6ns+mddovbs7 1Fo4Wg93bqRLettBzXIwN1LowXx2Dg4E5vAM3MTd34VFjlgic4PiKB3ksHoPbbc774Gy 7fYN+Eb+okfbfW5H72hc67/OLUgWKVvHwNsWDNSw7GaHT4+dNb2CAk0z4sPb+X2mKSZr 9HpBzfnWoRvMPqTYUnpzMzAlVJqFYF2dB6xc0+w2A8GcqV3MHPmBIgdi8oGu6T08VnpY U9JdH0O+78kaF45DFcyg+AP2W3QwEH5uJJWX8MreBW3IoDPcMvx2TjSpInfveRtgESll TBmg== X-Gm-Message-State: ALKqPwdJhyum5gFV1rxjl7mWlCJPcDNwQpbGbUzL+w+625pt5+XDQjUl Yre9KWBJ/wUkyEDfo+buvfhTPg== X-Google-Smtp-Source: ADUXVKLK6D4TRalg5VQXMQh/uS7I2HQDdIGTVH4kkD1Spk/r1S2yy86WONcc6vbFrlzU8pfp42SQbQ== X-Received: by 2002:a1c:3282:: with SMTP id y124-v6mr12682961wmy.33.1527605184412; Tue, 29 May 2018 07:46:24 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id n71-v6sm20942227wmi.14.2018.05.29.07.46.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:23 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/28] ovl: Use out_err instead of out_nomem Date: Tue, 29 May 2018 16:45:52 +0200 Message-Id: <20180529144612.16675-9-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144612.16675-1-mszeredi@redhat.com> References: <20180529144612.16675-1-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vivek Goyal Right now we use goto out_nomem which assumes error code is -ENOMEM. But there are other errors returned like -ESTALE as well. So instead of out_nomem, use out_err which will do ERR_PTR(err). That way one can put error code in err and jump to out_err. This just code reorganization and no change of functionality. I am about to add more code and this organization helps laying more code and error paths on top of it. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/inode.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 60c88a09a3f3..0d5615b80422 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -782,6 +782,7 @@ struct inode *ovl_get_inode(struct super_block *sb, int fsid = bylower ? oip->lowerpath->layer->fsid : 0; bool is_dir; unsigned long ino = 0; + int err = -ENOMEM; if (!realinode) realinode = d_inode(lowerdentry); @@ -798,7 +799,7 @@ struct inode *ovl_get_inode(struct super_block *sb, inode = ovl_iget5(sb, oip->newinode, key); if (!inode) - goto out_nomem; + goto out_err; if (!(inode->i_state & I_NEW)) { /* * Verify that the underlying files stored in the inode @@ -807,8 +808,8 @@ struct inode *ovl_get_inode(struct super_block *sb, if (!ovl_verify_inode(inode, lowerdentry, upperdentry, true)) { iput(inode); - inode = ERR_PTR(-ESTALE); - goto out; + err = -ESTALE; + goto out_err; } dput(upperdentry); @@ -824,8 +825,10 @@ struct inode *ovl_get_inode(struct super_block *sb, } else { /* Lower hardlink that will be broken on copy up */ inode = new_inode(sb); - if (!inode) - goto out_nomem; + if (!inode) { + err = -ENOMEM; + goto out_err; + } } ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev, ino, fsid); ovl_inode_init(inode, upperdentry, lowerdentry); @@ -851,7 +854,7 @@ struct inode *ovl_get_inode(struct super_block *sb, out: return inode; -out_nomem: - inode = ERR_PTR(-ENOMEM); +out_err: + inode = ERR_PTR(err); goto out; }