Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp427126pxa; Wed, 19 Aug 2020 05:32:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkxwoqcA6TwidXvh3fzamuvCpYFuQOZpIBUVID8eVwbf3x8Z8FSnP6Mf+fp0Z0jEZQk16L X-Received: by 2002:a17:906:1986:: with SMTP id g6mr25893074ejd.404.1597840340749; Wed, 19 Aug 2020 05:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597840340; cv=none; d=google.com; s=arc-20160816; b=R9dgbe3ZV4ky9voDnGhb7VXk/yeaBpCz0h0Sbn8A/u2+dviq2eH8cCSPNj1Bnx3hB0 32qoR68+e6hO0mSCtB+d0pWuHs/vCyqKWo123fvJn91SAwOkPvKL41Pbu4Ar3E/r9+SE c3mvmbFuxuBJjbKvheCD8BsuUd4mCa4DXPVqLEf4zW50GI/E97V3x6cqcHY4XX76iTlx WXg5csknE/B4B7PVdOuyZkhDokLY0W9ABA6UHHtAzI4v1261VpmlORfIWFoMMKfbg9fs lQcr4XrMYuDrZNa1a/hFKLDV8X9eaPbSpJkFnl44wdNeEEJXioZ8hwVrMfleeICukwoR SgzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=w0iNp82jLs1vHTLNhNj3MmZuJJ+SVTPNh24zC893KfQ=; b=pPKtLQEh60YGjETBwqvy+Wg963aBs44Z721nx7XMpf3EwE4LvgVfnacn3P0BBxcLLH 3mlYhPMMSSTWrkPYSlQQN0W5OxKU0mgwq6kwq94IiBGLUJ45mjCApnfT3iJMY312BjmW qBqOMdHMZT/Bzr1dUjWNHXpmVjOJlh1g/NBj5SQSrpRV7nDdHPuj0mXhzUOnchJe9mSh fb2bxhOPGxwET/ppjKKaU0oS46B4OAAVN/sTOqStRoGqHWz6R1DKm1mGPj13WhKFVCXB h/xMpoAfJh1SoW6tEImUf65SZ1fMyNKfPL88wKjlMMGa2jHW39npc/k+s4sM8LejyZAD 0TLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z22si16333074ejl.459.2020.08.19.05.31.46; Wed, 19 Aug 2020 05:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726961AbgHSMbl (ORCPT + 99 others); Wed, 19 Aug 2020 08:31:41 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:45536 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726952AbgHSMbk (ORCPT ); Wed, 19 Aug 2020 08:31:40 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id AB49E2E7917A994B3512; Wed, 19 Aug 2020 20:31:36 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Wed, 19 Aug 2020 20:31:26 +0800 From: Shijie Luo To: CC: , , Subject: [PATCH] jbd2: remove unnecessary chksum variables in do_one_pass Date: Wed, 19 Aug 2020 08:29:55 -0400 Message-ID: <20200819122955.33526-1-luoshijie1@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Remove unnecessary chksum variables, and add a chksum_err branch to make it cleaner. Signed-off-by: Shijie Luo Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara --- fs/jbd2/recovery.c | 46 ++++++++++++---------------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index 2ed278f0dced..faa97d748474 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -690,14 +690,11 @@ static int do_one_pass(journal_t *journal, * number. */ if (pass == PASS_SCAN && jbd2_has_feature_checksum(journal)) { - int chksum_err, chksum_seen; struct commit_header *cbh = (struct commit_header *)bh->b_data; unsigned found_chksum = be32_to_cpu(cbh->h_chksum[0]); - chksum_err = chksum_seen = 0; - if (info->end_transaction) { journal->j_failed_commit = info->end_transaction; @@ -705,42 +702,23 @@ static int do_one_pass(journal_t *journal, break; } - if (crc32_sum == found_chksum && - cbh->h_chksum_type == JBD2_CRC32_CHKSUM && - cbh->h_chksum_size == - JBD2_CRC32_CHKSUM_SIZE) - chksum_seen = 1; - else if (!(cbh->h_chksum_type == 0 && - cbh->h_chksum_size == 0 && - found_chksum == 0 && - !chksum_seen)) - /* - * If fs is mounted using an old kernel and then - * kernel with journal_chksum is used then we - * get a situation where the journal flag has - * checksum flag set but checksums are not - * present i.e chksum = 0, in the individual - * commit blocks. - * Hence to avoid checksum failures, in this - * situation, this extra check is added. - */ - chksum_err = 1; - - if (chksum_err) { - info->end_transaction = next_commit_ID; - - if (!jbd2_has_feature_async_commit(journal)) { - journal->j_failed_commit = - next_commit_ID; - brelse(bh); - break; - } - } + /* Neither checksum match nor unused? */ + if (!((crc32_sum == found_chksum && + cbh->h_chksum_type == + JBD2_CRC32_CHKSUM && + cbh->h_chksum_size == + JBD2_CRC32_CHKSUM_SIZE) || + (cbh->h_chksum_type == 0 && + cbh->h_chksum_size == 0 && + found_chksum == 0))) + goto chksum_error; + crc32_sum = ~0; } if (pass == PASS_SCAN && !jbd2_commit_block_csum_verify(journal, bh->b_data)) { + chksum_error: info->end_transaction = next_commit_ID; if (!jbd2_has_feature_async_commit(journal)) { -- 2.19.1