Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3046392rwb; Mon, 7 Aug 2023 07:30:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7vzmvPa4eApgBKLbTiaAQoRYQow2x0ox8EkRhuMPDFdcd4Ng0T1/RzdfRqs9yEJxTk5RZ X-Received: by 2002:a17:90a:d794:b0:268:5d00:3751 with SMTP id z20-20020a17090ad79400b002685d003751mr6798729pju.10.1691418626950; Mon, 07 Aug 2023 07:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691418626; cv=none; d=google.com; s=arc-20160816; b=NrV5VaUy1Z6Glro3PCQNaayQC5I39NEYaOEwvH4ueFCqGYmvwi1aYUFpsgbWVyid4K tLsT+ZKmh64JOFTUodtrCaCRwVTHenMu27YmDAReUfAFdAajrCT82aMehJmFzcTKfqD4 EMdnT5bPQ854fLGA7N89rWfrN5AA7DjpxJBHAuT5lTnsnWyd9neGgJxeUBeVcZfpNSy3 3DX5PbU5iiBmAuOGWtEDIHhk/2+9FpGG90GKB72IcJogXUOor3M86JifJSHTnJOyInKr R73zClbC/varHrI3T/Yd6+mD3l7gnZ84cDQOe1IyABwJE8ypPBC7tjyKrq+4JjSWYOsH aW1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=iuPm8Ny4p7lUvkdkwWjnApG/ArVned/LpHLV9/ddKSg=; fh=EttTcUvRnRmKQgg40QMM0rDNjIsn/u+Zt3tEPPQQV/Y=; b=eNxK8DaQOeSjhRngyQnLGTOuiK5Fz5ugLmdJ4XuHIvciQ5DaarJA8ox52NkniIzOF3 no7Fw10RgHz8nGbpY0pxap49rx0JpntQTB2LJqXm9rXAEXTQKUiXjeOwDDfPY3mPBUGy hk1w27v9K07WLOp/p6nrox6uf4VzKbuYai5e6GDQ/UgaLYC8hTKe/YTtjGmFa4Vi1COD o7iO0lGWTbFYz8aYFAKoTn6P0uz3wnOqggEjIwOUGQhBC0krJVrwqPa6xUsPNysRCAD3 /xhbKav3bQId49o+dJBgqqJ3fGxwFacMYnw48qtJG8utwLWag3ZtSXAo6elIZNoQkOb1 72Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=wLutDvVc; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a17090ab31000b00263bf1c6dc0si8916708pjr.102.2023.08.07.07.30.12; Mon, 07 Aug 2023 07:30:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=wLutDvVc; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233930AbjHGNdl (ORCPT + 99 others); Mon, 7 Aug 2023 09:33:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233952AbjHGNdk (ORCPT ); Mon, 7 Aug 2023 09:33:40 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C41D11BE5 for ; Mon, 7 Aug 2023 06:33:20 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 710A8219E1; Mon, 7 Aug 2023 13:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691415195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iuPm8Ny4p7lUvkdkwWjnApG/ArVned/LpHLV9/ddKSg=; b=wLutDvVcxgPobZwgOuykIAArzBzzd410uaMoplSzu648G3D9eWcmR/MkYAFkBKKQs6yTUB g3D80zqY7/3sxd9ZDbqX5tHHNCc9gFJWTxkcCJGZO2lEjf+p9Fz7NU89wrIT/RZm4TA+ZE csx96WFiatS9Po1xl7SALl7qipIZHsQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691415195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iuPm8Ny4p7lUvkdkwWjnApG/ArVned/LpHLV9/ddKSg=; b=zyktxEBEzwUO3GYOI3Vo9XGwBGLBYRetkUG40E2Iub9aefg6jWA8W2tkQKlyNmwXBTYFd3 Y5NYUg9qjEJNAQDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 62E1113910; Mon, 7 Aug 2023 13:33:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id TNYZGJvy0GTHHgAAMHmgww (envelope-from ); Mon, 07 Aug 2023 13:33:15 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id EA885A076C; Mon, 7 Aug 2023 15:33:14 +0200 (CEST) Date: Mon, 7 Aug 2023 15:33:14 +0200 From: Jan Kara To: Zhang Yi Cc: Jan Kara , linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [PATCH 07/12] jbd2: add fast_commit space check Message-ID: <20230807133314.sjkpdrluvvzgpotx@quack3> References: <20230704134233.110812-1-yi.zhang@huaweicloud.com> <20230704134233.110812-8-yi.zhang@huaweicloud.com> <20230803143825.f364hmpsgqbzvjwo@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL 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-ext4@vger.kernel.org On Mon 07-08-23 18:53:09, Zhang Yi wrote: > On 2023/8/3 22:38, Jan Kara wrote: > > On Tue 04-07-23 21:42:28, Zhang Yi wrote: > >> From: Zhang Yi > >> > >> If JBD2_FEATURE_INCOMPAT_FAST_COMMIT bit is set, it means the journal > >> have fast commit records need to recover, so the fast commit size > >> should not be zero, and also the leftover normal journal size should > >> never less than JBD2_MIN_JOURNAL_BLOCKS. Add a check into the > >> journal_check_superblock() and drop the pointless branch when > >> initializing in-memory fastcommit parameters. > >> > >> Signed-off-by: Zhang Yi > > > > Some comments below. > > > > > >> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c > >> index efdb8db3c06e..210b532a3673 100644 > >> --- a/fs/jbd2/journal.c > >> +++ b/fs/jbd2/journal.c > >> @@ -1392,6 +1392,18 @@ static int journal_check_superblock(journal_t *journal) > >> return err; > >> } > >> > >> + if (jbd2_has_feature_fast_commit(journal)) { > >> + int num_fc_blks = be32_to_cpu(sb->s_num_fc_blks); > >> + > >> + if (!num_fc_blks || > >> + (be32_to_cpu(sb->s_maxlen) - num_fc_blks < > >> + JBD2_MIN_JOURNAL_BLOCKS)) { > >> + printk(KERN_ERR "JBD2: Invalid fast commit size %d\n", > >> + num_fc_blks); > >> + return err; > >> + } > > > > This is wrong sb->s_num_fc_blks == 0 means that the fast-commit area should > > have the default size of 256 blocks. At least that's how it behaves > > currently and we should not change the behavior. > > Thanks for the review and correcting me. I missed the fc_debug_force > mount option, this option enable fast commit feature without init > sb->s_num_fc_blks to disk, so it could left over an unclean image with > fast_commit feature but sb->s_num_fc_blks is still zero. And the mke2fs > could also set sb->s_num_fc_blks to 0. Yes. > > Similarly if the number of fastcommit blocks was too big (i.e. there was > > not enough space left for ordinary journal), we effectively silently > > disable fastcommit and you break this behavior in this patch. > > > > If the fastcommit is too big, jbd2_journal_initialize_fast_commit() > will detect this corruption and refuse to mount. > > [ 1213.810719] JBD2: Cannot enable fast commits. > [ 1213.812282] EXT4-fs (pmem1): Failed to set fast commit journal feature > > It only silently disable fastcommit while recovering the journal, but it > doesn't seem to make much sense, because the journal->j_last is likely to > be wrong (not point to the correct end of normal journal range) and will > probably lead to incorrect recovery. It seems better to report the error > and exit as early as possible. So I suppose we could keep this "too big" > check in journal_check_superblock(). How does that sound ? Ah, you are right. So let's keep the "space for journal too small" check as you suggest. Honza -- Jan Kara SUSE Labs, CR