Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp917507rwl; Thu, 10 Aug 2023 03:52:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFO5fSW6/bPcrYjjJsQTrnuzb/BATY3wBprZwRBu5oxlVtPXNFfXrzMWB8EjsoQPkKEgkyU X-Received: by 2002:a19:ca07:0:b0:4fb:cabd:2a66 with SMTP id a7-20020a19ca07000000b004fbcabd2a66mr1205224lfg.21.1691664724302; Thu, 10 Aug 2023 03:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691664724; cv=none; d=google.com; s=arc-20160816; b=T9ktUXcJupFlRF43/9Qlp5GIGPK0UtnGv/qTtkRBOXmvuwpitVIpMcSBYqJtR//Dt7 6FCN+OXofEsHFdWm1M4PaqSa81i5kSZ5PoTm9P4bWxvzpuSNyW8OJGgiR1t2Awf7X3WO elGXjKn9YjP+rN9qV1T64Ao8MpMq18JH/teqofoeOIuX+Vd9UPOa4xiTOppEwQpKryHo Pekf8AYb/6Z0o2sGUmx3yUIgr3VQt7p6CPrkOc9wcGEV+ZZIqW57kPPFCASOjjFXkvV8 BgbGFxg/4O8P3I0J52vzQQZ1n8KP6ufxobAST4Rha+3tL7wMHgVr34Ce+q20D17olfje dk3w== 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=Qpe+PchBwC1KJhD6237VXU0is5AHX+OifwdgLEwO2II=; fh=xEHQz4GTQzhPcHZqf3Waa30h4Fy20awaa+W8Ke6OAoc=; b=0Tmtu/M+kys7LlVvPITGpltOoyDOlEa2lA/t+E2nYT+zjMDT6EOgXHvkdET5sL+YzF oYQzNOTqTgPFhIxPlPH9/rU9+wM8NfYwqxNl/0Vj2t0qNc2y1+20xGU4W1TlPf4EISAz KEs9du1Fyk0aHduZ6eV0OISImw/ujxHvoGgFwr5u9iqOUY+AuvwZ40jfb81OnFLF8+Xf Xnk/GYjn7KEzxLBWwYE4aACV0f3G0QEApZKpn8QhLPqnYempkCkLBkWoFvxcBIAUH4iM 61J1sGFUU8Ozu8rqrtC/5bAlC+iHi2jRWppbd4ClKn39Nnlwxu9pVHnIOkshC7Q9pBmX jEvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=DLDv2WCH; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="2k6OFn/7"; 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 q9-20020a056402040900b005233f273f4dsi1162023edv.495.2023.08.10.03.51.22; Thu, 10 Aug 2023 03:52:04 -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=DLDv2WCH; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="2k6OFn/7"; 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 S234104AbjHJKKU (ORCPT + 99 others); Thu, 10 Aug 2023 06:10:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234175AbjHJKKT (ORCPT ); Thu, 10 Aug 2023 06:10:19 -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 D1B1A83 for ; Thu, 10 Aug 2023 03:10:18 -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 94A1B1F749; Thu, 10 Aug 2023 10:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691662217; 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=Qpe+PchBwC1KJhD6237VXU0is5AHX+OifwdgLEwO2II=; b=DLDv2WCHkENuWKEeisLUDFMfa/2GsTxHxFxQXpaZyQlfqKQrHDYqY4ycRlPqscAU993dO1 KSp8vmdnePbgPCBnlRQ1xuH8ZkZctHQ6ZQwGkxnL1NGVuB0AiFSSBWO3CZDFfm9WKmDBmV d3m+9UPCrxKD64/gU3dUvMuEJE7ErXQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691662217; 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=Qpe+PchBwC1KJhD6237VXU0is5AHX+OifwdgLEwO2II=; b=2k6OFn/7VE9A//a+iGqcIlhHICSXRZEgVmO+L+EKq5/HDZw+rj4T/dmDmgnRCQZDVF1I/g 44SM1kmLL2gY1PCg== 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 82A87138E0; Thu, 10 Aug 2023 10:10:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SnfdH4m31GQUEwAAMHmgww (envelope-from ); Thu, 10 Aug 2023 10:10:17 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 0555FA076F; Thu, 10 Aug 2023 12:10:16 +0200 (CEST) Date: Thu, 10 Aug 2023 12:10:16 +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, yukuai3@huawei.com Subject: Re: [PATCH v2 07/12] jbd2: add fast_commit space check Message-ID: <20230810101016.jed6k7egldi3w5bv@quack3> References: <20230810085417.1501293-1-yi.zhang@huaweicloud.com> <20230810085417.1501293-8-yi.zhang@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230810085417.1501293-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 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 Thu 10-08-23 16:54:12, 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 too large, and the leftover normal journal size should > never less than JBD2_MIN_JOURNAL_BLOCKS. If it happens, the > journal->j_last is likely to be wrong and will probably lead to > incorrect journal recovery. So add a check into the > journal_check_superblock(), and drop the pointless check when > initializing the fastcommit parameters. > > Signed-off-by: Zhang Yi Just one small note below. With that fixed feel free to add: Reviewed-by: Jan Kara > @@ -1389,6 +1390,14 @@ static int journal_check_superblock(journal_t *journal) > return err; > } > > + num_fc_blks = jbd2_has_feature_fast_commit(journal) ? > + jbd2_journal_get_num_fc_blks(sb) : 0; > + if (be32_to_cpu(sb->s_maxlen) < JBD2_MIN_JOURNAL_BLOCKS + num_fc_blks) { To avoid possible overflow of the right hand side, we should probably do the check like: if (be32_to_cpu(sb->s_maxlen) < JBD2_MIN_JOURNAL_BLOCKS || be32_to_cpu(sb->s_maxlen) - JBD2_MIN_JOURNAL_BLOCKS < num_fc_blks) { ... } Honza -- Jan Kara SUSE Labs, CR