Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2348616rwo; Thu, 3 Aug 2023 08:11:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlEDXx9zfx6NH/YBK2p/B7SiNm0XvRJ0vg94KH/dy+XyHbfNlum95RZ3w44aBnmtZAr+gKQy X-Received: by 2002:a2e:99c7:0:b0:2b6:fc80:c45f with SMTP id l7-20020a2e99c7000000b002b6fc80c45fmr6600331ljj.13.1691075480068; Thu, 03 Aug 2023 08:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691075480; cv=none; d=google.com; s=arc-20160816; b=aptzSXEWSqArMIHQMJKeTorSjU+IunFK7k+88HbJRo54oq5zAH+sQJagem6QHWG37J qz24FepJLqmQ16kbg32AYzjyffJclJCTyh58+umQBLFdqBQJNtRYwMqwyyx/LbNTctEA 1FYMmwU9kcjqw9sz9NR0fZXokqnqfLYRfWFWVtxl1Of2kxVHE/KxECwM1vR3Fptrkoa9 XjL1XldWo3WMKvyv2FwCG84ZXoc7ud7cQqrjfgsclQwY/exORE6bcvVuRsEvO6HjEjau 1i9IF84WKS8Hv39qKSvTA/vMgHGXeeHc/A1Lo3YLk+vpGI3jI8I2/wfCmDlWCN5FsdJQ pwMw== 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=S1E5dOoVtRyp9fACvc30iT51lC9g+xY5JNgjO6D1dhk=; fh=2Cn0oHhRunYO+MqeElF523wQvgmjxkSAMpH3Se99YF8=; b=eD5SWbc1FAis+c3zujk/D4C8oVtSDl6yvvaa5JpITTeMKlIoT5lVQD23QMiSDudzD6 po7c0uOOzOI6Qm0Oyx9H30pRoHUNrT9e8g+HrTY3mGJuXZZsuxlzbAJBL4hhqq2xDjhB awdKzsxcShW4QEZdYfIDyzP9p92MMNrYprlRNxOLzz2bRPQ4Sy2OpiKVWDAXyOzuvGRR WmlmGkt+ZaPIbbiFyoiM3nF1fTniQov8ezLBQ0o0CQr235UrbCp09OqODCLRigXjCmBF qpTb96l/NSFzFMZj55eU4eRGqcAlkd78IT5m5o0uxRwxk4cABFQaatcBi1f9nAxzwO3s TE7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=BMlYPwsO; 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 kb10-20020a1709070f8a00b00965cb784a27si12657794ejc.699.2023.08.03.08.10.35; Thu, 03 Aug 2023 08:11:20 -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=BMlYPwsO; 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 S236803AbjHCOkZ (ORCPT + 99 others); Thu, 3 Aug 2023 10:40:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236804AbjHCOkM (ORCPT ); Thu, 3 Aug 2023 10:40:12 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A67330C7 for ; Thu, 3 Aug 2023 07:39:03 -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-out2.suse.de (Postfix) with ESMTPS id 922C31F747; Thu, 3 Aug 2023 14:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691073505; 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=S1E5dOoVtRyp9fACvc30iT51lC9g+xY5JNgjO6D1dhk=; b=BMlYPwsOGih5J5hI/O58+eSWhTStOA9D/w5PHiZGUen+9SVbL5Pl9mTyRwAEvJLwm2j7Of ejDVtndt6oqeAN2Yu4Eu1/P0WHDESU7jqXBFFWEbeb3tTqy0V7nCF46JBP559U0MhT2rum 5kpxb5tWdu7kel+zlc6Sg5c8gkmmQVs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691073505; 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=S1E5dOoVtRyp9fACvc30iT51lC9g+xY5JNgjO6D1dhk=; b=Bn3LC6qK/pvgCAkahi2lnr2PU4pD7VudmTP/74utSTdu1+/M+E60MxFCPNkKCENMHMLpqW OQCWsSQhfyaaWHBg== 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 81CFE1333C; Thu, 3 Aug 2023 14:38:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RwKrH+G7y2QXFgAAMHmgww (envelope-from ); Thu, 03 Aug 2023 14:38:25 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 11C36A076B; Thu, 3 Aug 2023 16:38:25 +0200 (CEST) Date: Thu, 3 Aug 2023 16:38:25 +0200 From: Jan Kara To: Zhang Yi Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [PATCH 07/12] jbd2: add fast_commit space check Message-ID: <20230803143825.f364hmpsgqbzvjwo@quack3> References: <20230704134233.110812-1-yi.zhang@huaweicloud.com> <20230704134233.110812-8-yi.zhang@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230704134233.110812-8-yi.zhang@huaweicloud.com> 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,T_SCC_BODY_TEXT_LINE 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 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. 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. Honza > + } > + > if (jbd2_has_feature_csum2(journal) && > jbd2_has_feature_csum3(journal)) { > /* Can't have checksum v2 and v3 at the same time! */ > @@ -1460,7 +1472,6 @@ static int journal_load_superblock(journal_t *journal) > int err; > struct buffer_head *bh; > journal_superblock_t *sb; > - int num_fc_blocks; > > bh = getblk_unmovable(journal->j_dev, journal->j_blk_offset, > journal->j_blocksize); > @@ -1498,9 +1509,8 @@ static int journal_load_superblock(journal_t *journal) > > if (jbd2_has_feature_fast_commit(journal)) { > journal->j_fc_last = be32_to_cpu(sb->s_maxlen); > - num_fc_blocks = jbd2_journal_get_num_fc_blks(sb); > - if (journal->j_last - num_fc_blocks >= JBD2_MIN_JOURNAL_BLOCKS) > - journal->j_last = journal->j_fc_last - num_fc_blocks; > + journal->j_last = journal->j_fc_last - > + be32_to_cpu(sb->s_num_fc_blks); > journal->j_fc_first = journal->j_last + 1; > journal->j_fc_off = 0; > } > -- > 2.39.2 > -- Jan Kara SUSE Labs, CR