Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp311115pxa; Wed, 19 Aug 2020 01:49:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqweisRFUijm0NdCnVZT28/EmVwUViIxZE2LNRhL+O+Vb7MiYGGcAwIMDsVQPjl5NOLWDP X-Received: by 2002:a17:906:c1c3:: with SMTP id bw3mr25353069ejb.8.1597826966298; Wed, 19 Aug 2020 01:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597826966; cv=none; d=google.com; s=arc-20160816; b=MheicWakTbpwE21MKIZS8oD0rpQMNWkMN9wmNGgrRigdN4rj3hXOot/oBYtxcA7d8q I6dScORF7ncHy318YRens/duEvXglij+/Ut22z4u5Rc5VhdPdFJ0AhbP0X/huNQJp0t+ 9+vQiQ+6WgXTMTTGx8/Vfzw+nIC+qTSkTMa7NxfzEpV7p0yZ2rpJNjjEEkFyL54efbV8 frJhoVvqeHlpdD7vXg5bOXqsqKCdMF7qeBttxvB+Em97B0wjEEI/fETyC7eF3xePN7/q DAXOFh5UAgH1QaA+MQeJXEWnhy8Lpw5gGqM5lPiLLQIdgrj0wCAOKsnJBh/AFlDjvUjb QKaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=0/SCPCGNkE8/DKe3KlnDzSE6ULXKG3J/25wpF0dXoC8=; b=lkQF9W5DLPd9jZdH9z/f/ICTU4UkLoEinWkdirgNxJXle+SJvsn4AsCYicHFHGncoK ymTckWlcAG1craeVODrrcqMZbQ303JBRRv01PLT9uMZ6W1FuiXalV0GdE7Y5pu33gbhg JgdWHqX52AesREdj4OHCk/c+Z5fDZnXQAkGwrscYsLLRNKfDEvFKO9slON66Zfw05FpX DCO428uNq10kvddaVKZHFqTzIoudHgpP2V7D3b4bz3YllVcRqe0V+3ZzYMs/o2mtOSoN agCf6BVLNsv/3ruORrevVhVxUNmU+Nxh6CQQdCR0g/itdfZUuKkegQWg+MjmlsOBlfuf lpQA== 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 w1si14574565ejc.440.2020.08.19.01.49.02; Wed, 19 Aug 2020 01:49:26 -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 S1726640AbgHSItA (ORCPT + 99 others); Wed, 19 Aug 2020 04:49:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:49844 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726482AbgHSItA (ORCPT ); Wed, 19 Aug 2020 04:49:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 931E8B659; Wed, 19 Aug 2020 08:49:24 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 207521E1312; Wed, 19 Aug 2020 10:48:58 +0200 (CEST) Date: Wed, 19 Aug 2020 10:48:58 +0200 From: Jan Kara To: "Theodore Y. Ts'o" Cc: Jan Kara , Shijie Luo , linux-ext4@vger.kernel.org, linfeilong@huawei.com Subject: Re: [PATCH] jbd2: remove useless variable chksum_seen in do_one_pass Message-ID: <20200819084858.GF1902@quack2.suse.cz> References: <20200811022128.32690-1-luoshijie1@huawei.com> <20200818104826.GA1902@quack2.suse.cz> <20200818191459.GC162457@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200818191459.GC162457@mit.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 18-08-20 15:14:59, Theodore Y. Ts'o wrote: > I wonder if this is even cleaner? What do folks think? > > - Ted Yup, looks good to me. Feel free to add: Reviewed-by: Jan Kara once you add proper changelog and signed-off-by. Honza > > diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c > index 2ed278f0dced..4373abbfd19a 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)) { -- Jan Kara SUSE Labs, CR