From patchwork Wed Mar 15 01:31:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 69921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2082095wrd; Tue, 14 Mar 2023 18:39:55 -0700 (PDT) X-Google-Smtp-Source: AK7set91EE6oVy95Tbdxfh3+2WpL9iPu6pTvCStBkj+P+EacejDUbkLHG52TUsZAZc69OVEYUANH X-Received: by 2002:a05:6a20:160a:b0:cc:88af:12ab with SMTP id l10-20020a056a20160a00b000cc88af12abmr45992047pzj.28.1678844395238; Tue, 14 Mar 2023 18:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678844395; cv=none; d=google.com; s=arc-20160816; b=BA9vBoRsUYmZYSFZIjrycrZQU9qa1j3QoAT2ueVvmGClAr1J2IkWMLi06zngPUzikF R3ORIg659c//TsuMvumpczwKDvW4NXFnsS8KIu+qwWjIzHt/6pjmDQQ709fpqqB+lhl9 usZ/C+l9e/vfwu1nKXswGg4mz1cFO37AX64dkDvx/T3HLM+ATtorUHB2WnlsZsagRFJk b7PvWe/k8U9T39PQFwaWslbl+bUinvcAImuRBixbISK+9eZ4HCyjjtQ76aebhXTKtQdc b0jcdP4KxHzKe1QaGQ27khfdy+QD40Kc5NLijydb4kLw54/qVSrSO1m3HZKzgKupO40v kXfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=J/3UrJcbJN5j/KZ56LekiGh/HhuddfA/NVRwbqSwQzo=; b=jH+W87up6QhX5B9PDblrkyU4EymwzpgxtdRPNR07NBoyDagrx9GTsJ4Idh66DqThEh a3knN0BiXlITM7TRKUjUtuacl7RT1wbRLDv8+kG4htGLnoGekH10BOXps4kRExrSmmna uTpeN4whjVZSvKHQ/TIcTg3iRSmBvCQGEm+2wSZeb4T3gEIzExP1R11NLRxaTWchxKc0 4e30sb50vHgS3902B1Z7jE8anmEJJ5bRrx+FWetepQknb4LzLTabCqKLWkEGTD85GIlv G4VXyWCfTOYUrkhT1nNYjbtT+nRLi+t4Guxaf1LdtSzGS7HoufCCs45U3edbwvFQxiQB ztXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y5-20020aa78f25000000b00623cc95e511si3592867pfr.117.2023.03.14.18.39.42; Tue, 14 Mar 2023 18:39:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbjCOBc6 (ORCPT + 99 others); Tue, 14 Mar 2023 21:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbjCOBcv (ORCPT ); Tue, 14 Mar 2023 21:32:51 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A70583669E; Tue, 14 Mar 2023 18:32:18 -0700 (PDT) Received: from kwepemm600013.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Pbt8t6cqnznXQ4; Wed, 15 Mar 2023 09:29:18 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 09:32:15 +0800 From: Zhihao Cheng To: , , , CC: , , , Subject: [PATCH v3 1/6] ext4: Fix reusing stale buffer heads from last failed mounting Date: Wed, 15 Mar 2023 09:31:23 +0800 Message-ID: <20230315013128.3911115-2-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315013128.3911115-1-chengzhihao1@huawei.com> References: <20230315013128.3911115-1-chengzhihao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760395940515473276?= X-GMAIL-MSGID: =?utf-8?q?1760395940515473276?= Following process makes ext4 load stale buffer heads from last failed mounting in a new mounting operation: mount_bdev ext4_fill_super | ext4_load_and_init_journal | ext4_load_journal | jbd2_journal_load | load_superblock | journal_get_superblock | set_buffer_verified(bh) // buffer head is verified | jbd2_journal_recover // failed caused by EIO | goto failed_mount3a // skip 'sb->s_root' initialization deactivate_locked_super kill_block_super generic_shutdown_super if (sb->s_root) // false, skip ext4_put_super->invalidate_bdev-> // invalidate_mapping_pages->mapping_evict_folio-> // filemap_release_folio->try_to_free_buffers, which // cannot drop buffer head. blkdev_put blkdev_put_whole if (atomic_dec_and_test(&bdev->bd_openers)) // false, systemd-udev happens to open the device. Then // blkdev_flush_mapping->kill_bdev->truncate_inode_pages-> // truncate_inode_folio->truncate_cleanup_folio-> // folio_invalidate->block_invalidate_folio-> // filemap_release_folio->try_to_free_buffers will be skipped, // dropping buffer head is missed again. Second mount: ext4_fill_super ext4_load_and_init_journal ext4_load_journal ext4_get_journal jbd2_journal_init_inode journal_init_common bh = getblk_unmovable bh = __find_get_block // Found stale bh in last failed mounting journal->j_sb_buffer = bh jbd2_journal_load load_superblock journal_get_superblock if (buffer_verified(bh)) // true, skip journal->j_format_version = 2, value is 0 jbd2_journal_recover do_one_pass next_log_block += count_tags(journal, bh) // According to journal_tag_bytes(), 'tag_bytes' calculating is // affected by jbd2_has_feature_csum3(), jbd2_has_feature_csum3() // returns false because 'j->j_format_version >= 2' is not true, // then we get wrong next_log_block. The do_one_pass may exit // early whenoccuring non JBD2_MAGIC_NUMBER in 'next_log_block'. The filesystem is corrupted here, journal is partially replayed, and new journal sequence number actually is already used by last mounting. The invalidate_bdev() can drop all buffer heads even racing with bare reading block device(eg. systemd-udev), so we can fix it by invalidating bdev in error handling path in __ext4_fill_super(). Fetch a reproducer in [Link]. Link: https://bugzilla.kernel.org/show_bug.cgi?id=217171 Fixes: 25ed6e8a54df ("jbd2: enable journal clients to enable v2 checksumming") Cc: stable@vger.kernel.org # v3.5 Signed-off-by: Zhihao Cheng Reviewed-by: Jan Kara --- fs/ext4/super.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index f43e526112ae..61511b7ba017 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1126,6 +1126,12 @@ static void ext4_blkdev_remove(struct ext4_sb_info *sbi) struct block_device *bdev; bdev = sbi->s_journal_bdev; if (bdev) { + /* + * Invalidate the journal device's buffers. We don't want them + * floating about in memory - the physical journal device may + * hotswapped, and it breaks the `ro-after' testing code. + */ + invalidate_bdev(bdev); ext4_blkdev_put(bdev); sbi->s_journal_bdev = NULL; } @@ -1272,13 +1278,7 @@ static void ext4_put_super(struct super_block *sb) sync_blockdev(sb->s_bdev); invalidate_bdev(sb->s_bdev); if (sbi->s_journal_bdev && sbi->s_journal_bdev != sb->s_bdev) { - /* - * Invalidate the journal device's buffers. We don't want them - * floating about in memory - the physical journal device may - * hotswapped, and it breaks the `ro-after' testing code. - */ sync_blockdev(sbi->s_journal_bdev); - invalidate_bdev(sbi->s_journal_bdev); ext4_blkdev_remove(sbi); } @@ -5610,6 +5610,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) brelse(sbi->s_sbh); ext4_blkdev_remove(sbi); out_fail: + invalidate_bdev(sb->s_bdev); sb->s_fs_info = NULL; return err ? err : ret; } From patchwork Wed Mar 15 01:31:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 69927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2091965wrd; Tue, 14 Mar 2023 19:08:23 -0700 (PDT) X-Google-Smtp-Source: AK7set9WXiLswhPUbiQgg/0UJojztUKlShRpIOMYCpaOwQZ76JjreJi1kwbxVV2Iruxh9rJWL9xT X-Received: by 2002:a17:903:22cf:b0:1a0:5b98:f965 with SMTP id y15-20020a17090322cf00b001a05b98f965mr1196441plg.62.1678846103071; Tue, 14 Mar 2023 19:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678846103; cv=none; d=google.com; s=arc-20160816; b=nD7vZ6tUaXjcPIuNy9/wtp5AnTNfOVRUDRg0u2aINkzLtxA8/ISBbdlzNfnDPFHysy FCDhUR7g2ZYkOvtutnst/n/f+GdQ5VTlQ8qcSRt1+A732li2raThW/5A+4kwRzXPPurF seCecFEN1pXK+VxjP1vimtB10z4jUT1FPm1VSM6O7EDxd0rWBG1ymkf//sgSAGhtf1Xb zI/ozjtw8HLj3PmiCZU196q5AQO+FDhbVLvjDznPKnLyz2GTE1iBRjWat6fo5Qyz34jY gFBRjazOJxAAe9CYfHkoTOo2BY/goWOYhRxxapcL+kQ0lsVby1mP2i3sOB2X82VQagXM LAoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UFq21MYuT/DA/HIrWCb94fQwILW/40p5KGZKDUyJXeM=; b=xWaZCMR8u4XCm3u6fJpCl/XN51ugs3rUXCTv3CPvcPnVUbYw3+H4/tqukurga9PX0z 9pqeZKS1UYKawG9hrxvT784Zg3B/IAUeJQ4rWI1/QsPTHyO3+sRwSjIZhBGyciBe15CP JOcaP//jqrxGHQDWHv/wQOMYlEHavgxCBAR6TKND8WwZHKL4nZThjR05CXLCQvzPLENk 3YGUk1XrxkbtwLTnxBMEc8A5YKmLRBBDAJZ00kIdFz1qV60c0A0/gdYpaF5/SKTT6Lvk dj/u914EzQWlyemiZWGE+xdlL9mL7/18Vb6V+PVv9LsP5+ZB+kNx3w2Rf74QNLr5FwGa tYPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id io16-20020a17090312d000b0019ce74dd5c8si3739405plb.529.2023.03.14.19.08.04; Tue, 14 Mar 2023 19:08:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbjCOBdC (ORCPT + 99 others); Tue, 14 Mar 2023 21:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230133AbjCOBcw (ORCPT ); Tue, 14 Mar 2023 21:32:52 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CD293865D; Tue, 14 Mar 2023 18:32:19 -0700 (PDT) Received: from kwepemm600013.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4PbtD2607KzKmrn; Wed, 15 Mar 2023 09:32:02 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 09:32:16 +0800 From: Zhihao Cheng To: , , , CC: , , , Subject: [PATCH v3 2/6] ext4: ext4_put_super: Remove redundant checking for 'sbi->s_journal_bdev' Date: Wed, 15 Mar 2023 09:31:24 +0800 Message-ID: <20230315013128.3911115-3-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315013128.3911115-1-chengzhihao1@huawei.com> References: <20230315013128.3911115-1-chengzhihao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760397731861938926?= X-GMAIL-MSGID: =?utf-8?q?1760397731861938926?= As discussed in [1], 'sbi->s_journal_bdev != sb->s_bdev' will always become true if sbi->s_journal_bdev exists. Filesystem block device and journal block device are both opened with 'FMODE_EXCL' mode, so these two devices can't be same one. Then we can remove the redundant checking 'sbi->s_journal_bdev != sb->s_bdev' if 'sbi->s_journal_bdev' exists. [1] https://lore.kernel.org/lkml/f86584f6-3877-ff18-47a1-2efaa12d18b2@huawei.com/ Signed-off-by: Zhihao Cheng Reviewed-by: Jan Kara --- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 61511b7ba017..a22417d113ca 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1277,7 +1277,7 @@ static void ext4_put_super(struct super_block *sb) sync_blockdev(sb->s_bdev); invalidate_bdev(sb->s_bdev); - if (sbi->s_journal_bdev && sbi->s_journal_bdev != sb->s_bdev) { + if (sbi->s_journal_bdev) { sync_blockdev(sbi->s_journal_bdev); ext4_blkdev_remove(sbi); } From patchwork Wed Mar 15 01:31:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 69922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2084070wrd; Tue, 14 Mar 2023 18:46:11 -0700 (PDT) X-Google-Smtp-Source: AK7set8S1DxFqX2PImvXVDjsXvnfP2lAjocnwB2HKz8cLlTi0B1JCLauwk+VXQ/O6Gm2+bJfjSn+ X-Received: by 2002:a17:902:f1d4:b0:19a:bbd0:c5ca with SMTP id e20-20020a170902f1d400b0019abbd0c5camr845362plc.48.1678844771320; Tue, 14 Mar 2023 18:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678844771; cv=none; d=google.com; s=arc-20160816; b=Q0grlHxAxGNeHD6n6QjyPiOdhxu14IOAwD6i0rN5wmCvGiRgBO/0Gty+H+WbpafR/T jXnN5pD/yPdlgj9dn9gW1BtKSVrS+F/NMJpyB2P4g1JOrnWaewtdNLld7FjxXcKM61bM RkFB7sx49uBvnmnwkJKCzNQAjfoBLo9kvqwEjZO8GWqL9hqZBps6XsugF+U31CVuInJq QD6IFAYSkPQLiZqKOYCp4FoQpgBjen+5YzLNauiB96nrSs9WL5QucCckN8T/HM23HK71 C95tRZ2WdmmXsmUI2qTgaDpTpe+fD2QtJ3eoi7bTY1Xt5MdhLCI7Go5rIWKraTs5tORF il6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=91tmhh+RHm+CKNx7w9s22+1tlj1VzWDYjEbLoB9fBlA=; b=i1L2OcsUkEu4q3/zc3bsu9ENmwEi8V/vh1Xr5FQdTsESBGOdubXIPPN7zZpmKKDm5B L3AitVTprWXgJOBXlmjmgm0klzOl819izc6OUxH3jLNLmYGW0vw+38wP0MVL2cnMJP39 M9mK9dcDUcBrrPcaY6rNwd6yv4NeeKrNE2eIJUWRf2/X+On3UoLanwPUPOLBWORxHyeY aeot6QCfO7J4utDqeHFgBbqNPhMWb9aRiGn6nuNAwP8yazYhv1kl8/9qb0ZLiX5gPw3P dmWEjp4YssrOepdHWTsfEy+Lbn8tMaSQ/efLCdk8iPZe1MghUYACY1DhcHHh/LQf+B6t hVxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a170902dace00b00194a5108613si4144627plx.177.2023.03.14.18.45.55; Tue, 14 Mar 2023 18:46:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbjCOBdH (ORCPT + 99 others); Tue, 14 Mar 2023 21:33:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbjCOBcv (ORCPT ); Tue, 14 Mar 2023 21:32:51 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA8BB1F920; Tue, 14 Mar 2023 18:32:19 -0700 (PDT) Received: from kwepemm600013.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Pbt9p5srhzHwwT; Wed, 15 Mar 2023 09:30:06 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 09:32:17 +0800 From: Zhihao Cheng To: , , , CC: , , , Subject: [PATCH v3 3/6] jbd2: remove unused feature macros Date: Wed, 15 Mar 2023 09:31:25 +0800 Message-ID: <20230315013128.3911115-4-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315013128.3911115-1-chengzhihao1@huawei.com> References: <20230315013128.3911115-1-chengzhihao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760396334886069968?= X-GMAIL-MSGID: =?utf-8?q?1760396334886069968?= From: Zhang Yi JBD2_HAS_[IN|RO_]COMPAT_FEATURE macros are no longer used, just remove them. Signed-off-by: Zhang Yi Signed-off-by: Zhihao Cheng Reviewed-by: Jan Kara --- include/linux/jbd2.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index f619bae1dcc5..a91cf9c7a94b 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -274,17 +274,6 @@ typedef struct journal_superblock_s /* 0x0400 */ } journal_superblock_t; -/* Use the jbd2_{has,set,clear}_feature_* helpers; these will be removed */ -#define JBD2_HAS_COMPAT_FEATURE(j,mask) \ - ((j)->j_format_version >= 2 && \ - ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask)))) -#define JBD2_HAS_RO_COMPAT_FEATURE(j,mask) \ - ((j)->j_format_version >= 2 && \ - ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask)))) -#define JBD2_HAS_INCOMPAT_FEATURE(j,mask) \ - ((j)->j_format_version >= 2 && \ - ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask)))) - #define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001 #define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001 From patchwork Wed Mar 15 01:31:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 69924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2084624wrd; Tue, 14 Mar 2023 18:47:58 -0700 (PDT) X-Google-Smtp-Source: AK7set/S9TIEg9s+/pZF1Nb04gKHZVnS59yVXJGkWAnUAyP1q5ZVxHC8P99NyfaC2VTH/fUE7EfV X-Received: by 2002:a05:6a21:78aa:b0:b8:723f:e21b with SMTP id bf42-20020a056a2178aa00b000b8723fe21bmr47282221pzc.3.1678844878585; Tue, 14 Mar 2023 18:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678844878; cv=none; d=google.com; s=arc-20160816; b=ZyG5VzWEY2b3WFkHzO9LM0Zo52ctKiLH0QvBQkBP2GqSEDGgLlHqWWJqcWWKc2Yg2t WqAj3OdiMUFFzJKRSqAts1RMz3eFUKOXCiDUGAODQmA1vERi6Nx2jlapInSSdSXSTuLS 2Fpny94pdFxZNITkHe11BOZjPthslKkYt/harWulTQdhGdwixngTOe8KHf1qUm7Edjl0 HUjzxCRSWebH9RtLcvTPl4+CREIXZy6IJharHneYiSoxXRvd7jov4E1exkyWGyxGKh8w NMN/b6T4PH7slcu+JEfeWBs5PqnW7DyjrtWWEb39omA1Yen730OqDDFic1Xy1ZmwJrcl V5LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ojSaZqeXuWwV8D/Wj2w/l5Q8pmQToDYiEaZgcS961po=; b=jQlyglLJ0cd46Brv9gI5vVbyBBFeGzR9bD2ypj0YTOfoE5V60dn4jBcJlr3gcFfhJG /DrHFf+TigPA++Q+SDnMRbTnsyfipm5GVNNan1heK/tjn9x9uWn4SMWiBsfUICsxG1zc 1ZjvPB5T/JB4X+kL/hun9MyWSZNQm1wzYJg77hEHNqAfIlPG79JU3heygMm/QIv/kLVZ 6i9pQ6gs6WrEZsN1cuB1luedp8sCQWEw70FLUR+hJK2UT+a3xr4jZF2BFVnT0Di3Fbd+ NYpCJFA7BrpAn/bSDQQJ/OxKwFqRhqK73QzCui9FT+sKmffq4TFXX6fGngU5kABAgtNX yyWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p25-20020a634f59000000b004fc2dfedcd6si3592117pgl.213.2023.03.14.18.47.43; Tue, 14 Mar 2023 18:47:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjCOBdL (ORCPT + 99 others); Tue, 14 Mar 2023 21:33:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbjCOBcx (ORCPT ); Tue, 14 Mar 2023 21:32:53 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C74C26CD6; Tue, 14 Mar 2023 18:32:23 -0700 (PDT) Received: from kwepemm600013.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PbtCJ728YzrSmT; Wed, 15 Mar 2023 09:31:24 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 09:32:17 +0800 From: Zhihao Cheng To: , , , CC: , , , Subject: [PATCH v3 4/6] jbd2: switch to check format version in superblock directly Date: Wed, 15 Mar 2023 09:31:26 +0800 Message-ID: <20230315013128.3911115-5-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315013128.3911115-1-chengzhihao1@huawei.com> References: <20230315013128.3911115-1-chengzhihao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760396447586772497?= X-GMAIL-MSGID: =?utf-8?q?1760396447586772497?= From: Zhang Yi We should only check and set extented features if journal format version is 2, and now we check the in memory copy of the superblock 'journal->j_format_version', which relys on the parameter initialization sequence, switch to use the h_blocktype in superblock cloud be more clear. Signed-off-by: Zhang Yi Signed-off-by: Zhihao Cheng Reviewed-by: Jan Kara --- fs/jbd2/journal.c | 16 +++++++--------- include/linux/jbd2.h | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 8ae419152ff6..8d5fe6738cc4 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2062,10 +2062,12 @@ int jbd2_journal_load(journal_t *journal) return err; sb = journal->j_superblock; - /* If this is a V2 superblock, then we have to check the - * features flags on it. */ - if (journal->j_format_version >= 2) { + /* + * If this is a V2 superblock, then we have to check the + * features flags on it. + */ + if (jbd2_format_support_feature(journal)) { if ((sb->s_feature_ro_compat & ~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) || (sb->s_feature_incompat & @@ -2227,7 +2229,7 @@ int jbd2_journal_check_used_features(journal_t *journal, unsigned long compat, if (journal->j_format_version == 0 && journal_get_superblock(journal) != 0) return 0; - if (journal->j_format_version == 1) + if (!jbd2_format_support_feature(journal)) return 0; sb = journal->j_superblock; @@ -2257,11 +2259,7 @@ int jbd2_journal_check_available_features(journal_t *journal, unsigned long comp if (!compat && !ro && !incompat) return 1; - /* We can support any known requested features iff the - * superblock is in version 2. Otherwise we fail to support any - * extended sb features. */ - - if (journal->j_format_version != 2) + if (!jbd2_format_support_feature(journal)) return 0; if ((compat & JBD2_KNOWN_COMPAT_FEATURES) == compat && diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index a91cf9c7a94b..1ffcea5c024e 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1313,11 +1313,22 @@ struct journal_s rwsem_release(&j->j_trans_commit_map, _THIS_IP_); \ } while (0) +/* + * We can support any known requested features iff the + * superblock is not in version 1. Otherwise we fail to support any + * extended sb features. + */ +static inline bool jbd2_format_support_feature(journal_t *j) +{ + return j->j_superblock->s_header.h_blocktype != + cpu_to_be32(JBD2_SUPERBLOCK_V1); +} + /* journal feature predicate functions */ #define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \ static inline bool jbd2_has_feature_##name(journal_t *j) \ { \ - return ((j)->j_format_version >= 2 && \ + return (jbd2_format_support_feature(j) && \ ((j)->j_superblock->s_feature_compat & \ cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname)) != 0); \ } \ @@ -1335,7 +1346,7 @@ static inline void jbd2_clear_feature_##name(journal_t *j) \ #define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \ static inline bool jbd2_has_feature_##name(journal_t *j) \ { \ - return ((j)->j_format_version >= 2 && \ + return (jbd2_format_support_feature(j) && \ ((j)->j_superblock->s_feature_ro_compat & \ cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname)) != 0); \ } \ @@ -1353,7 +1364,7 @@ static inline void jbd2_clear_feature_##name(journal_t *j) \ #define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \ static inline bool jbd2_has_feature_##name(journal_t *j) \ { \ - return ((j)->j_format_version >= 2 && \ + return (jbd2_format_support_feature(j) && \ ((j)->j_superblock->s_feature_incompat & \ cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname)) != 0); \ } \ From patchwork Wed Mar 15 01:31:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 69923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2084232wrd; Tue, 14 Mar 2023 18:46:47 -0700 (PDT) X-Google-Smtp-Source: AK7set/Hd7ADOwutaErgojr5WdLMrEtz/JAgpW9jZ3Wvhqo1kzVg4ZCDceHfHNqbTLQAbYSR2UsT X-Received: by 2002:a17:902:d412:b0:19d:137c:2ad2 with SMTP id b18-20020a170902d41200b0019d137c2ad2mr736408ple.52.1678844807086; Tue, 14 Mar 2023 18:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678844807; cv=none; d=google.com; s=arc-20160816; b=eVMg4m6DZtIj2spSeEiK8ejwK7I4f+Wo/HGTUrN9SkuhQPKtwN4abSO/b2NuRyLmb1 /zQGAuu4+wSeVFfUR9NBaKMb2JpjIc5cRbgK0EVbPSWqzwgRRyNJ0lvQGTbZ1u2ORsyp 27sy2M1X5y5m5e56usxs5M6R92sp5mv0uZ+WtBO0e721wTiVg0cVPXs//GeRNFg+ztZ+ Ma+H9E46lIZL9HSOoLCxdfN4M49c2uOvQ8BwYw5Kx95f3Hr/HKvU2NOrEZAz1HBfkPc+ vujw1xVhg7mY90TTzMB5AnOhyOVsyGHl8vZ80dlJ+471F5scKQAf9EiQ4UeNzvxaiksW pFtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tewZE47RkXZocLp2iuDzKMSdtt+Ith+uO1bbcTRvcxc=; b=0+qDvbXE1p1Ov3PBIyy7LvtVPgbKu8+h5uJW5fSqtHLkQt9lZ2DFhm/hH4knjBIjtU oRT2XaJXoHbpaaSUA3VudjIZtTTs+nCKw0P3AZ/nv1A9oke+qyp5+Bk32RJ9u0tiX0wi bmKx06HRJhvwTllJc2Q/IGcM1nEtXLLohyMf1F7kZKvzcbGpj49KgoAIBeUyArpyAw+Y W0mCAQctQg2+5bZO8Fr2/RmKJkVrqScde/l3Ar7XkME6wzCnZiHFfVC4vFLYzwlEZFc7 0iRuqb56B5KDNDfTDOPqzN0Q4hkGc7bvjLi4assihrqrVlGOrL3+2RRnOSravSGfbMrH plTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d13-20020a170902cecd00b001a10b5e2a28si635031plg.111.2023.03.14.18.46.32; Tue, 14 Mar 2023 18:46:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230342AbjCOBdO (ORCPT + 99 others); Tue, 14 Mar 2023 21:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbjCOBc5 (ORCPT ); Tue, 14 Mar 2023 21:32:57 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C67BE32CD3; Tue, 14 Mar 2023 18:32:30 -0700 (PDT) Received: from kwepemm600013.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Pbt9r16cVzHwwk; Wed, 15 Mar 2023 09:30:08 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 09:32:18 +0800 From: Zhihao Cheng To: , , , CC: , , , Subject: [PATCH v3 5/6] jbd2: factor out journal initialization from journal_get_superblock() Date: Wed, 15 Mar 2023 09:31:27 +0800 Message-ID: <20230315013128.3911115-6-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315013128.3911115-1-chengzhihao1@huawei.com> References: <20230315013128.3911115-1-chengzhihao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760396372462847540?= X-GMAIL-MSGID: =?utf-8?q?1760396372462847540?= From: Zhang Yi Current journal_get_superblock() couple journal superblock checking and partial journal initialization, factor out initialization part from it to make things clear. Signed-off-by: Zhang Yi Signed-off-by: Zhihao Cheng Reviewed-by: Jan Kara --- fs/jbd2/journal.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 8d5fe6738cc4..ee678f9e40c4 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1925,21 +1925,13 @@ static int journal_get_superblock(journal_t *journal) goto out; } - switch(be32_to_cpu(sb->s_header.h_blocktype)) { - case JBD2_SUPERBLOCK_V1: - journal->j_format_version = 1; - break; - case JBD2_SUPERBLOCK_V2: - journal->j_format_version = 2; - break; - default: + if (be32_to_cpu(sb->s_header.h_blocktype) != JBD2_SUPERBLOCK_V1 && + be32_to_cpu(sb->s_header.h_blocktype) != JBD2_SUPERBLOCK_V2) { printk(KERN_WARNING "JBD2: unrecognised superblock format ID\n"); goto out; } - if (be32_to_cpu(sb->s_maxlen) < journal->j_total_len) - journal->j_total_len = be32_to_cpu(sb->s_maxlen); - else if (be32_to_cpu(sb->s_maxlen) > journal->j_total_len) { + if (be32_to_cpu(sb->s_maxlen) > journal->j_total_len) { printk(KERN_WARNING "JBD2: journal file too short\n"); goto out; } @@ -1982,25 +1974,14 @@ static int journal_get_superblock(journal_t *journal) journal->j_chksum_driver = NULL; goto out; } - } - - if (jbd2_journal_has_csum_v2or3(journal)) { /* Check superblock checksum */ if (sb->s_checksum != jbd2_superblock_csum(journal, sb)) { printk(KERN_ERR "JBD2: journal checksum error\n"); err = -EFSBADCRC; goto out; } - - /* Precompute checksum seed for all metadata */ - journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, - sizeof(sb->s_uuid)); } - - journal->j_revoke_records_per_block = - journal_revoke_records_per_block(journal); set_buffer_verified(bh); - return 0; out: @@ -2025,12 +2006,30 @@ static int load_superblock(journal_t *journal) sb = journal->j_superblock; + switch (be32_to_cpu(sb->s_header.h_blocktype)) { + case JBD2_SUPERBLOCK_V1: + journal->j_format_version = 1; + break; + case JBD2_SUPERBLOCK_V2: + journal->j_format_version = 2; + break; + } + journal->j_tail_sequence = be32_to_cpu(sb->s_sequence); journal->j_tail = be32_to_cpu(sb->s_start); journal->j_first = be32_to_cpu(sb->s_first); journal->j_errno = be32_to_cpu(sb->s_errno); journal->j_last = be32_to_cpu(sb->s_maxlen); + if (be32_to_cpu(sb->s_maxlen) < journal->j_total_len) + journal->j_total_len = be32_to_cpu(sb->s_maxlen); + /* Precompute checksum seed for all metadata */ + if (jbd2_journal_has_csum_v2or3(journal)) + journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, + sizeof(sb->s_uuid)); + journal->j_revoke_records_per_block = + journal_revoke_records_per_block(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); @@ -2226,8 +2225,7 @@ int jbd2_journal_check_used_features(journal_t *journal, unsigned long compat, if (!compat && !ro && !incompat) return 1; /* Load journal superblock if it is not loaded yet. */ - if (journal->j_format_version == 0 && - journal_get_superblock(journal) != 0) + if (journal_get_superblock(journal)) return 0; if (!jbd2_format_support_feature(journal)) return 0; From patchwork Wed Mar 15 01:31:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 69926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2085358wrd; Tue, 14 Mar 2023 18:49:57 -0700 (PDT) X-Google-Smtp-Source: AK7set9PuHX6E8kHvZ9DQfuGtIvu6cOZMy0+Z/+iqxY72+O7EqLv3V8gxdh31V7D4RUedW5idFBK X-Received: by 2002:aa7:9f96:0:b0:625:5e9e:17d5 with SMTP id z22-20020aa79f96000000b006255e9e17d5mr3349712pfr.9.1678844997174; Tue, 14 Mar 2023 18:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678844997; cv=none; d=google.com; s=arc-20160816; b=EGIMJhKtQw/te4UsTaYJknd0/Ma/O/3cjt6tWAqoyLkMKVA9Yivo5DfmGMh0uPW30g 8SiogWuS/ifawsbvE/WX92poYnGQncpQxhmm9gjOulQWA5OPb3AnJeVUmhcXdZbxf/bo 3o2QwKmJyPKmFkSfm+LZNiXLLKxpH/CW9BkE/2yj+kbCOnN/OZrEB7YPfow04QE4iNS+ G4belV2/6VLwnBY04BiRObQvN80NbMpgT6D8uRI6/wO8shFzxppdmc/xNznLHY4Z9aXP EJn0phLakzyEpL6afUjjGz1NrI2kgK/z5yEb2rNcfor73Ocoh/kd7kk3msf63qthl74S Qh5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Qb6pESAc8W350yQcNMZ4RCy6UvU+MMAe8NR/s/eKCTE=; b=rsxkmsJhe1cTc9llzYnTzE3m5/8fvfxmiSB+QT73v+zg2YUVhaKOBFNA1+pPiVrGkB enwsooTqUNlNaI7GBmeB1t772nRYBuupP7SVBeCMVj7igQlLenQhHDrFtYjOXk9MtWE/ v07ZTNFYcOqt58k3QDZRVL8JDe6M2yYvOfre3w199ZiZIq2hFhOJSVXyyvnm15YEhuSC b9prmlUA+UMCz0/HV4p85EUsxp+dvOx51A5VmrtPAi+XGIoPUtH28OX/qr3jdDkmKqKB 3MEnMGNTk8OaQYYRxlWMNKsKC0wsFAIHpaYpfIkqAfMKz/cF5oQmynVrA1CYRybtRuTo bGqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a056a00178c00b006257ed5354bsi2045005pfg.195.2023.03.14.18.49.44; Tue, 14 Mar 2023 18:49:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbjCOBdT (ORCPT + 99 others); Tue, 14 Mar 2023 21:33:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjCOBdD (ORCPT ); Tue, 14 Mar 2023 21:33:03 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7805C32513; Tue, 14 Mar 2023 18:32:34 -0700 (PDT) Received: from kwepemm600013.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Pbt8y1ks7znX4T; Wed, 15 Mar 2023 09:29:22 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Mar 2023 09:32:19 +0800 From: Zhihao Cheng To: , , , CC: , , , Subject: [PATCH v3 6/6] jbd2: remove j_format_version Date: Wed, 15 Mar 2023 09:31:28 +0800 Message-ID: <20230315013128.3911115-7-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230315013128.3911115-1-chengzhihao1@huawei.com> References: <20230315013128.3911115-1-chengzhihao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760396571913175003?= X-GMAIL-MSGID: =?utf-8?q?1760396571913175003?= From: Zhang Yi journal->j_format_version is no longer used, remove it. Signed-off-by: Zhang Yi Signed-off-by: Zhihao Cheng Reviewed-by: Jan Kara --- fs/jbd2/journal.c | 9 --------- include/linux/jbd2.h | 5 ----- 2 files changed, 14 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index ee678f9e40c4..837a9a85e585 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2006,15 +2006,6 @@ static int load_superblock(journal_t *journal) sb = journal->j_superblock; - switch (be32_to_cpu(sb->s_header.h_blocktype)) { - case JBD2_SUPERBLOCK_V1: - journal->j_format_version = 1; - break; - case JBD2_SUPERBLOCK_V2: - journal->j_format_version = 2; - break; - } - journal->j_tail_sequence = be32_to_cpu(sb->s_sequence); journal->j_tail = be32_to_cpu(sb->s_start); journal->j_first = be32_to_cpu(sb->s_first); diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 1ffcea5c024e..6990fc891612 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -792,11 +792,6 @@ struct journal_s */ journal_superblock_t *j_superblock; - /** - * @j_format_version: Version of the superblock format. - */ - int j_format_version; - /** * @j_state_lock: Protect the various scalars in the journal. */