Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3018452pxa; Tue, 18 Aug 2020 04:35:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2MRko4O5+4raGcaAxA0k9s602zSS+O+lCJxvpm4JKfEO9cwnTAd8nYuoo1iQ7bHNNR8NF X-Received: by 2002:a05:6402:6d9:: with SMTP id n25mr18825299edy.304.1597750555599; Tue, 18 Aug 2020 04:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597750555; cv=none; d=google.com; s=arc-20160816; b=rk7jMxXZ+L9Vvs0Iv1vsbcPA2ItXX1oVVpJgbi1f7bvw9XMBBqPGqzM+YrgOCK5BtZ 8eaqWFtTwX3qtPiwzGMkzLtdz1giiRH+qJy/Pk6U57DN9xgdcxbVPy9CA3sIhgtoqCGB Dh6B5KSTkOMW7D1PepnYMAK9A2xu5X6YY8WH+5WmB3OAAi+P+yzylq7xq0oDEEJxJal4 QAI5XUQ2HvNNIDAMua/Xwf2sEApIMOEi4nDmdqXSqJWOvSe0WkJ9hHVvSwTGNxbSGie0 jaF2rrPYcm2lRcyBBVM0e9mAviHFeokARSDx6HoT3jG84mCJeX/faSxvqgxZenM0Dmry r2pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=7PQBtpnJ7sBpmKmWvmiAF0Y0JwQEgNU76J44hlZhM4k=; b=JhhUo8jPGOYb5p3YZIJpMoDNyeazjwWKkHNVAnpYZVMr8Qs1Kj5wcOFiW77Z3Dgtj8 uBLYIsk+/fdPY/AHVi4PYANoTtOhFQmhyQD9Rivd/tneDPAXCytppJ3a46mTYJA3WRG7 6Y0HpLGyDupGSECFi2OBuLZxumQTceDv7aeh1dvT3T2p0Oi5Sz9rcqPOOjCddU5jT28a CmUIDC6jNznJom+PhhPE5OPJwnYuusRKbgNK6onvTVIeKD/BC3SFCXnivrQKyB2UpAms /uIy4kDQjvXkX8Gk/Yq8DoHTE6PkGuW/mE7Px1ye9tiHLfWpOMgcSa3vmw70t6UrNPHD YUBA== 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 dp16si18902170ejc.17.2020.08.18.04.35.24; Tue, 18 Aug 2020 04:35:55 -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 S1726357AbgHRLeV (ORCPT + 99 others); Tue, 18 Aug 2020 07:34:21 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9759 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726273AbgHRLdw (ORCPT ); Tue, 18 Aug 2020 07:33:52 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 323F07CB18BC536593F5; Tue, 18 Aug 2020 19:33:40 +0800 (CST) Received: from [127.0.0.1] (10.174.179.226) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Tue, 18 Aug 2020 19:33:31 +0800 Subject: Re: [PATCH] jbd2: remove useless variable chksum_seen in do_one_pass To: Jan Kara CC: , , References: <20200811022128.32690-1-luoshijie1@huawei.com> <20200818104826.GA1902@quack2.suse.cz> From: Shijie Luo Message-ID: Date: Tue, 18 Aug 2020 19:33:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20200818104826.GA1902@quack2.suse.cz> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.174.179.226] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 2020/8/18 18:48, Jan Kara wrote: > On Mon 10-08-20 22:21:28, Shijie Luo wrote: >> This variable only indicates that we do checksum success, while >> chksum_err can also do. Moreover, condition "!chksum_seen" in else >> if bracket is pointless. >> >> Signed-off-by: Shijie Luo > Thanks for the patch! Some comments below. > >> @@ -709,11 +707,10 @@ static int do_one_pass(journal_t *journal, >> cbh->h_chksum_type == JBD2_CRC32_CHKSUM && >> cbh->h_chksum_size == >> JBD2_CRC32_CHKSUM_SIZE) >> - chksum_seen = 1; >> + chksum_err = 0; >> else if (!(cbh->h_chksum_type == 0 && >> cbh->h_chksum_size == 0 && >> - found_chksum == 0 && >> - !chksum_seen)) >> + found_chksum == 0)) >> /* >> * If fs is mounted using an old kernel and then >> * kernel with journal_chksum is used then we > I agree the use of chksum_err & chksum_seen looks rather arbitrary. In fact > the code seems to be equivalent to: > > /* 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)) { > info->end_transaction = next_commit_ID; > if (jbd2_has_feature_async_commit(journal)) { > ... > } > } > crc32_sum = ~0; > > which would be even simpler... > > Honza Thanks for your review,it 's definitely true to use these code as a substitute, but I think these are a little bit hard to read.  By the way, I found a indentation error on "chksum_err = 1". Do you think which one is better? I will take your opinion into account and send a v2 patch.