Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3428296pxu; Mon, 30 Nov 2020 03:01:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxM/EU1m+QonbnGZKTzKZte5DbvjA2AKlPetR+3HygY+pQVe8GlT+0rCib10/NqgdUAbwfs X-Received: by 2002:a17:906:179a:: with SMTP id t26mr20626112eje.49.1606734114951; Mon, 30 Nov 2020 03:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606734114; cv=none; d=google.com; s=arc-20160816; b=DwfsiPd0DF1MfsVCfWShG5ofJg6nLIelBKn/Dcfojuy+8VeT6TGI/kprQyt/ojl7lS //EmXTvO5qkIO8DAEgAU2ld+ZwP3sOpBfy2Wafa+Mq3ePLXMQnzKX9Xnq5DUU27twMCm QU3UYCSpqdMMKcAs5TFu2UyTYu265ddnqKduwIplFS8YudtBHZLdWbV++IMzIGyoa2Xs Xru0c4L6CdWVGR8Q0DV6BfHo6jJ+V2bYz9K/c/M3sYYC9GdpwA65NK/KzLE+SrSHaPAY bsVC+G33kSo/2liS7lB97afeuWcEeaFc5FZlDuTuoxdF9DMyewk7qMchZn+ZCSDarbSz K9aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=sKQ9zspGq1ReWz+fFOiGldn3TD1baqoQ+l5jd6a7fhQ=; b=QgMOggRBNxeF27pNz3+5HWc+sa4Zg9GTSXqHk+NbcqbQfUtWaxPTG3H7JonvQ9b5zb OnHF8k2BDWNkPD6HOxZqYPxfJJcHUgesRfj2xnEafuUbj/iGQ1EqK9Y9f2kMaQmaaKK1 FNm2jm5x3p024W8JjQUv6e4BCFuU0KElI/vDH0/z3mk60hLVFchndIB6YLF2cZ2vmS26 Me4uZRJkL6kFRATqh1Pwk49t2ek1cG8P2YqyisyfUcCqJjwoO94p3RSOM1BliN1hay5+ o8Njsa9//PbLXCFTDYpI8eC4gw4NfXVzSSQmArwCAQpKhKhbfDCX02M9t9VKCjTBIcsI 4ygQ== 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 l14si12431491edv.255.2020.11.30.03.01.16; Mon, 30 Nov 2020 03:01:54 -0800 (PST) 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 S1728632AbgK3LAZ (ORCPT + 99 others); Mon, 30 Nov 2020 06:00:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:55318 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727656AbgK3LAZ (ORCPT ); Mon, 30 Nov 2020 06:00:25 -0500 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 89353AD20; Mon, 30 Nov 2020 10:59:43 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 2DA981E131B; Mon, 30 Nov 2020 11:59:43 +0100 (CET) Date: Mon, 30 Nov 2020 11:59:43 +0100 From: Jan Kara To: Andreas Dilger Cc: Jan Kara , Eric Biggers , Ted Tso , linux-ext4@vger.kernel.org Subject: Re: [PATCH 02/12] ext4: Remove redundant sb checksum recomputation Message-ID: <20201130105943.GI11250@quack2.suse.cz> References: <20201127113405.26867-1-jack@suse.cz> <20201127113405.26867-3-jack@suse.cz> <301139FC-B346-4199-B26E-1FF0CB970746@dilger.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <301139FC-B346-4199-B26E-1FF0CB970746@dilger.ca> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sun 29-11-20 15:11:05, Andreas Dilger wrote: > On Nov 27, 2020, at 4:33 AM, Jan Kara wrote: > > > > Superblock is written out either through ext4_commit_super() or through > > ext4_handle_dirty_super(). In both cases we recompute the checksum so it > > is not necessary to recompute it after updating superblock free inodes & > > blocks counters. > > I searched through the code to see where s_sbh is being used, and it > looks like there is one case that doesn't update the checksum using > ext4_handle_dirty_super(), namely: > > ext4_file_ioctl(cmd=FS_IOC_GET_ENCRYPTION_PWSALT) > { > err = ext4_journal_get_write_access(handle, sbi->s_sbh); > if (err) > goto pwsalt_err_journal; > generate_random_uuid(sbi->s_es->s_encrypt_pw_salt); > err = ext4_handle_dirty_metadata(handle, NULL, > sbi->s_sbh); > > I don't think that is a problem with this patch, per se, but looks like > a bug that could be hit in rare cases with fscrypt + metadata_csum. It > would only happen once per filesystem, and would normally be hidden by > later superblock updates, but should probably be fixed anyway. Yeah, good spotting. I'll write a fix for this. > Reviewed-by: Andreas Dilger Thanks for review! Honza > > > Signed-off-by: Jan Kara > > --- > > fs/ext4/super.c | 2 -- > > 1 file changed, 2 deletions(-) > > > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > > index 2b08b162075c..61e6e5f156f3 100644 > > --- a/fs/ext4/super.c > > +++ b/fs/ext4/super.c > > @@ -5004,13 +5004,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) > > block = ext4_count_free_clusters(sb); > > ext4_free_blocks_count_set(sbi->s_es, > > EXT4_C2B(sbi, block)); > > - ext4_superblock_csum_set(sb); > > err = percpu_counter_init(&sbi->s_freeclusters_counter, block, > > GFP_KERNEL); > > if (!err) { > > unsigned long freei = ext4_count_free_inodes(sb); > > sbi->s_es->s_free_inodes_count = cpu_to_le32(freei); > > - ext4_superblock_csum_set(sb); > > err = percpu_counter_init(&sbi->s_freeinodes_counter, freei, > > GFP_KERNEL); > > } > > -- > > 2.16.4 > > > > > Cheers, Andreas > > > > > -- Jan Kara SUSE Labs, CR