Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp586810imw; Fri, 15 Jul 2022 09:02:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vgKQBlcog7MuqFWDHNCWbj5OSd3+1lD4svCb+RyCTgB1eT672ywywikL+2MSOpoHnq83gm X-Received: by 2002:a63:2cd5:0:b0:411:3eca:da41 with SMTP id s204-20020a632cd5000000b004113ecada41mr12420790pgs.502.1657900966955; Fri, 15 Jul 2022 09:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657900966; cv=none; d=google.com; s=arc-20160816; b=CU2olrfClFqaw2J+P9L8OyTStV69RtSc3S/wKDYqZpi5OpP95yu3bFksit+wB0Do1U 6676iE/POoZF9hOk6EIT4EjPcVKyEd5ctRgSRuLcKje+RzlghEQn2//K7c/O+r2BgAeD aYF1Wn7C98c7OBvd61pYYAHPl7GOc1il/L9RxA0SwVyM+e6DYovvoDKUUkTCT5NS+FgK ofwOLHknzs63hL9ZGX6pjGDus2P/32ZNmIRANcASv2flzEn3RyuDzFwieIT2wgTMxMsP 0i+gu9U1GHUuu4i61fU481OZ+5iELJg+07EqpqnXjcI5S3C5oZDe8lDEBOi/h5x61t0q Mylw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uSx+XOZ+NNQnlFQDc/qFzZAoZQ5fOeiks1a2TAFwlCs=; b=HRdkpJ+EwCFKvqF/Un/tt9RhWQsG8+XW6pbjePHojWpNl1s2x5oK0gYu6+QK7/1Vtn gh/WyKbMc50jZx8gFEaZziTJeQEaA0mWuGgQ7+yRPgiO2pnjuiod/qwayE2smwjzXQSO dDKpouCPKT4UCdWP0hCsxT+VcgI2MEFX8qTqUvQWoM2xeUTPmwbcM+y1ucXgNQdEcrgD dJ1wNucvx1UwE7gGdnYOCyIktvzjzD24jb3TXb3WRiLhG+5HSf+oUuCASesDF1G76uEK IY1JVTxXWpZZczKpLsMSqSQSLnGy6K4/FA5hcfHP2raHFSuJa7JzEFCXKjoTjuL5zADr 24qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a63d947000000b0040c921bb46asi5737548pgj.424.2022.07.15.09.02.31; Fri, 15 Jul 2022 09:02:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235564AbiGOPmr (ORCPT + 99 others); Fri, 15 Jul 2022 11:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233608AbiGOPmZ (ORCPT ); Fri, 15 Jul 2022 11:42:25 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EE605508B for ; Fri, 15 Jul 2022 08:42:24 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R691e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VJPnC2I_1657899733; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VJPnC2I_1657899733) by smtp.aliyun-inc.com; Fri, 15 Jul 2022 23:42:14 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu Cc: LKML , Gao Xiang , Yue Hu Subject: [PATCH v2 02/16] erofs: clean up z_erofs_collector_begin() Date: Fri, 15 Jul 2022 23:41:49 +0800 Message-Id: <20220715154203.48093-3-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 In-Reply-To: <20220715154203.48093-1-hsiangkao@linux.alibaba.com> References: <20220715154203.48093-1-hsiangkao@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rearrange the code and get rid of all gotos. Reviewed-by: Yue Hu Signed-off-by: Gao Xiang --- fs/erofs/zdata.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 1b6816dd235f..c7be447ac64d 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -521,7 +521,7 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe) static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe) { struct erofs_map_blocks *map = &fe->map; - struct erofs_workgroup *grp; + struct erofs_workgroup *grp = NULL; int ret; DBG_BUGON(fe->pcl); @@ -530,33 +530,31 @@ static int z_erofs_collector_begin(struct z_erofs_decompress_frontend *fe) DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_NIL); DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED); - if (map->m_flags & EROFS_MAP_META) { - if ((map->m_pa & ~PAGE_MASK) + map->m_plen > PAGE_SIZE) { - DBG_BUGON(1); - return -EFSCORRUPTED; - } - goto tailpacking; + if (!(map->m_flags & EROFS_MAP_META)) { + grp = erofs_find_workgroup(fe->inode->i_sb, + map->m_pa >> PAGE_SHIFT); + } else if ((map->m_pa & ~PAGE_MASK) + map->m_plen > PAGE_SIZE) { + DBG_BUGON(1); + return -EFSCORRUPTED; } - grp = erofs_find_workgroup(fe->inode->i_sb, map->m_pa >> PAGE_SHIFT); if (grp) { fe->pcl = container_of(grp, struct z_erofs_pcluster, obj); + ret = -EEXIST; } else { -tailpacking: ret = z_erofs_register_pcluster(fe); - if (!ret) - goto out; - if (ret != -EEXIST) - return ret; } - ret = z_erofs_lookup_pcluster(fe); - if (ret) { - erofs_workgroup_put(&fe->pcl->obj); + if (ret == -EEXIST) { + ret = z_erofs_lookup_pcluster(fe); + if (ret) { + erofs_workgroup_put(&fe->pcl->obj); + return ret; + } + } else if (ret) { return ret; } -out: z_erofs_pagevec_ctor_init(&fe->vector, Z_EROFS_NR_INLINE_PAGEVECS, fe->pcl->pagevec, fe->pcl->vcnt); /* since file-backed online pages are traversed in reverse order */ -- 2.24.4