From nobody Tue Apr 7 17:16:28 2026 Received: from sender4-op-o15.zoho.com (sender4-op-o15.zoho.com [136.143.188.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABAE42F7478; Thu, 26 Feb 2026 10:18:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772101093; cv=pass; b=FDTPlnGUa4ILZDJLRstTFq9qpUeebFQdjPu/0u43rjS6tUTGT2cJE3fRuvNgLXqALS7KNJhitwy9mnhW1Ivft5Pw7zEdILcJNDAWA2rwDEW7eGhVtHSleqriRX7W7w7bWhkI5WQffVBoIAfLXA5nsSd78OURE7KxLZ94fIXP04A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772101093; c=relaxed/simple; bh=FWFSzWyUz0H+83E5yNlUDk3PdKTV8IEvTJrHvmKb6tE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SUDwIoeMjFvOVktf1a7bjShAnaE7xyycMC6A5j/Jy8+U/SvpXN5R50E4TMEAlXQT9uNJd5N5hQH697sum+cVgWKAtpdlEZUfTyokUC8tgulhetuwnFEvJoydDXw5GdkxYCncbnouFNc1UWw8690DbbYRPf5dwxMN+s1/kHzt0ME= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.beauty; spf=pass smtp.mailfrom=linux.beauty; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b=i5e07uBO; arc=pass smtp.client-ip=136.143.188.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.beauty Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.beauty Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.beauty header.i=me@linux.beauty header.b="i5e07uBO" ARC-Seal: i=1; a=rsa-sha256; t=1772101083; cv=none; d=zohomail.com; s=zohoarc; b=I4bl4u/otnJPzvYLEuWbBWvXchGxqFdv0owTbR9VByh6R3moL2nvWEEWoMFMmcIDC9Y9U5ZErUThg/YXtmTkg61PFxzN//8a8NaIfIhpf2QjOKO34maVltVhENjJWu19BfWOBftPcSgfuAplJaUZqXhqFIwuwHJQy0+NoFr2NA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772101083; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qyse1IS9Q6qz5bThx9u3W/bTyOdCiWCl40LcA4VrhHc=; b=W1hrPjKvmb0lzyTaKF2ew6gMTeMvF8iYr0IPkZJuIpSVNVwLLsvmH+ON2dxtCfJWMiBEpV85yQTfAGB7oiRCAPNxwV6AtP9TjXwAU9u9sihN/QODPOyuUA1enRR6rQ85VPEBj3LvMg1KCHUctyYXFViNp31nk071QxorEQ4LNLE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772101083; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=Qyse1IS9Q6qz5bThx9u3W/bTyOdCiWCl40LcA4VrhHc=; b=i5e07uBODMV23QJ6rg8H2NXdGkCpgOBGdRB6eSAUMqtVzJcyufG0KpYHf4nbaaUE V1MdKCHbOId+GxdoXRycnplpvri2eQAS07wGpQQ9mcM2vHzHx9gxWWO4kfJTIdnIX3P CxTi8heJMnYoqD/uirIyhUiBvzU0jiNbg2LUBTos= Received: by mx.zohomail.com with SMTPS id 177210108066263.684691457057966; Thu, 26 Feb 2026 02:18:00 -0800 (PST) From: Li Chen To: linux-ext4@vger.kernel.org, "Theodore Ts'o" , Andreas Dilger , linux-kernel@vger.kernel.org Cc: Harshad Shirwadkar , Li Chen Subject: [RFC PATCH 2/4] ext4: add dax_fc_bytelog mount option Date: Thu, 26 Feb 2026 18:17:30 +0800 Message-ID: <20260226101736.2271952-3-me@linux.beauty> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260226101736.2271952-1-me@linux.beauty> References: <20260226101736.2271952-1-me@linux.beauty> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" Add dax_fc_bytelog=3D{off,on,force} to control the DAX ByteLog fast commit backend. Initialize the ByteLog ring before fast commit replay and release it on unmount. Signed-off-by: Li Chen --- fs/ext4/super.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 504148b2142b..3645456a61dd 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1368,6 +1368,7 @@ static void ext4_put_super(struct super_block *sb) sbi->s_ea_block_cache =3D NULL; =20 ext4_stop_mmpd(sbi); + ext4_fc_bytelog_release(sb); =20 brelse(sbi->s_sbh); sb->s_fs_info =3D NULL; @@ -1685,6 +1686,8 @@ enum { Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache, Opt_no_prefetch_block_bitmaps, Opt_mb_optimize_scan, Opt_errors, Opt_data, Opt_data_err, Opt_jqfmt, Opt_dax_type, + Opt_dax_fc_bytelog, Opt_dax_fc_bytelog_off, Opt_dax_fc_bytelog_on, + Opt_dax_fc_bytelog_force, #ifdef CONFIG_EXT4_DEBUG Opt_fc_debug_max_replay, Opt_fc_debug_force #endif @@ -1724,6 +1727,13 @@ static const struct constant_table ext4_param_dax[] = =3D { {} }; =20 +static const struct constant_table ext4_param_dax_fc_bytelog[] =3D { + {"off", Opt_dax_fc_bytelog_off}, + {"on", Opt_dax_fc_bytelog_on}, + {"force", Opt_dax_fc_bytelog_force}, + {} +}; + /* * Mount option specification * We don't use fsparam_flag_no because of the way we set the @@ -1780,6 +1790,8 @@ static const struct fs_parameter_spec ext4_param_spec= s[] =3D { fsparam_flag ("i_version", Opt_removed), fsparam_flag ("dax", Opt_dax), fsparam_enum ("dax", Opt_dax_type, ext4_param_dax), + fsparam_enum("dax_fc_bytelog", Opt_dax_fc_bytelog, + ext4_param_dax_fc_bytelog), fsparam_u32 ("stripe", Opt_stripe), fsparam_flag ("delalloc", Opt_delalloc), fsparam_flag ("nodelalloc", Opt_nodelalloc), @@ -1965,6 +1977,7 @@ ext4_sb_read_encoding(const struct ext4_super_block *= es) #define EXT4_SPEC_s_fc_debug_max_replay (1 << 17) #define EXT4_SPEC_s_sb_block (1 << 18) #define EXT4_SPEC_mb_optimize_scan (1 << 19) +#define EXT4_SPEC_s_dax_fc_bytelog BIT(20) =20 struct ext4_fs_context { char *s_qf_names[EXT4_MAXQUOTAS]; @@ -2370,6 +2383,26 @@ static int ext4_parse_param(struct fs_context *fc, s= truct fs_parameter *param) ext4_msg(NULL, KERN_INFO, "dax option not supported"); return -EINVAL; #endif + case Opt_dax_fc_bytelog: + switch (result.uint_32) { + case Opt_dax_fc_bytelog_off: + ctx_clear_mount_opt2(ctx, EXT4_MOUNT2_DAX_FC_BYTELOG); + ctx_clear_mount_opt2(ctx, + EXT4_MOUNT2_DAX_FC_BYTELOG_FORCE); + break; + case Opt_dax_fc_bytelog_on: + ctx_set_mount_opt2(ctx, EXT4_MOUNT2_DAX_FC_BYTELOG); + ctx_clear_mount_opt2(ctx, + EXT4_MOUNT2_DAX_FC_BYTELOG_FORCE); + break; + case Opt_dax_fc_bytelog_force: + ctx_set_mount_opt2(ctx, EXT4_MOUNT2_DAX_FC_BYTELOG); + ctx_set_mount_opt2(ctx, + EXT4_MOUNT2_DAX_FC_BYTELOG_FORCE); + break; + } + ctx->spec |=3D EXT4_SPEC_s_dax_fc_bytelog; + return 0; case Opt_data_err: if (result.uint_32 =3D=3D Opt_data_err_abort) ctx_set_mount_opt(ctx, m->mount_opt); @@ -2819,7 +2852,22 @@ static int ext4_check_opt_consistency(struct fs_cont= ext *fc, !(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_INODE))) { goto fail_dax_change_remount; } - } + + if (ctx->spec & EXT4_SPEC_s_dax_fc_bytelog) { + bool new_on =3D ctx_test_mount_opt2(ctx, + EXT4_MOUNT2_DAX_FC_BYTELOG); + bool new_force =3D ctx_test_mount_opt2(ctx, + EXT4_MOUNT2_DAX_FC_BYTELOG_FORCE); + bool cur_on =3D test_opt2(sb, DAX_FC_BYTELOG); + bool cur_force =3D test_opt2(sb, DAX_FC_BYTELOG_FORCE); + + if (new_on !=3D cur_on || new_force !=3D cur_force) { + ext4_msg(NULL, KERN_ERR, + "can't change dax_fc_bytelog mount option while remounting"); + return -EINVAL; + } + } + } =20 return ext4_check_quota_consistency(fc, sb); } @@ -3038,6 +3086,12 @@ static int _ext4_show_options(struct seq_file *seq, = struct super_block *sb, } else if (test_opt2(sb, DAX_INODE)) { SEQ_OPTS_PUTS("dax=3Dinode"); } + if (test_opt2(sb, DAX_FC_BYTELOG)) { + if (test_opt2(sb, DAX_FC_BYTELOG_FORCE)) + SEQ_OPTS_PUTS("dax_fc_bytelog=3Dforce"); + else + SEQ_OPTS_PUTS("dax_fc_bytelog=3Don"); + } =20 if (sbi->s_groups_count >=3D MB_DEFAULT_LINEAR_SCAN_THRESHOLD && !test_opt2(sb, MB_OPTIMIZE_SCAN)) { @@ -4950,6 +5004,8 @@ static int ext4_load_and_init_journal(struct super_bl= ock *sb, "Failed to set fast commit journal feature"); goto out; } + if (test_opt2(sb, JOURNAL_FAST_COMMIT)) + ext4_fc_bytelog_init(sb, sbi->s_journal); =20 /* We have now updated the journal if required, so we can * validate the data journaling mode. */ @@ -6124,10 +6180,29 @@ static int ext4_load_journal(struct super_block *sb, char *save =3D kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL); __le16 orig_state; bool changed =3D false; + int fc_err; =20 if (save) memcpy(save, ((char *) es) + EXT4_S_ERR_START, EXT4_S_ERR_LEN); + + /* + * Map the ByteLog ring before fast-commit replay so that + * EXT4_FC_TAG_DAX_BYTELOG_ANCHOR records can be processed + * during jbd2_journal_load(). + * + * For filesystems with the INCOMPAT_DAX_FC_BYTELOG feature + * bit set, failing to initialize the ByteLog ring must be + * treated as fatal. + */ + if (test_opt2(sb, JOURNAL_FAST_COMMIT)) { + fc_err =3D ext4_fc_bytelog_init(sb, journal); + if (fc_err && ext4_has_feature_dax_fc_bytelog(sb)) { + kfree(save); + err =3D fc_err; + goto err_out; + } + } err =3D jbd2_journal_load(journal); if (save && memcmp(((char *) es) + EXT4_S_ERR_START, save, EXT4_S_ERR_LEN)) { --=20 2.52.0