2023-01-19 05:09:27

by Zhang Yi

[permalink] [raw]
Subject: [RFC PATCH 2/2] ext4: add journal cycled recording support

From: Zhang Yi <[email protected]>

Introduce a new mount option names 'journal_cycle_record' to let jbd2
continue record journal log from the recovered head transaction block
or checkpointed/cleaned transactions on the previous mount.

Signed-off-by: Zhang Yi <[email protected]>
---
fs/ext4/ext4.h | 2 ++
fs/ext4/super.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 140e1eb300d1..b62e7886fc2c 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1267,6 +1267,8 @@ struct ext4_inode_info {
#define EXT4_MOUNT2_MB_OPTIMIZE_SCAN 0x00000080 /* Optimize group
* scanning in mballoc
*/
+#define EXT4_MOUNT2_JOURNAL_CYCLE_RECORD 0x00000100 /* Journal cycled record
+ * log on empty logging area */

#define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \
~EXT4_MOUNT_##opt
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 260c1b3e3ef2..8260019830dc 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1591,6 +1591,7 @@ 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_journal_cycle_record,
#ifdef CONFIG_EXT4_DEBUG
Opt_fc_debug_max_replay, Opt_fc_debug_force
#endif
@@ -1670,6 +1671,7 @@ static const struct fs_parameter_spec ext4_param_specs[] = {
fsparam_flag ("journal_checksum", Opt_journal_checksum),
fsparam_flag ("nojournal_checksum", Opt_nojournal_checksum),
fsparam_flag ("journal_async_commit",Opt_journal_async_commit),
+ fsparam_flag ("journal_cycle_record",Opt_journal_cycle_record),
fsparam_flag ("abort", Opt_abort),
fsparam_enum ("data", Opt_data, ext4_param_data),
fsparam_enum ("data_err", Opt_data_err,
@@ -1826,6 +1828,8 @@ static const struct mount_opts {
{Opt_nombcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET},
{Opt_no_prefetch_block_bitmaps, EXT4_MOUNT_NO_PREFETCH_BLOCK_BITMAPS,
MOPT_SET},
+ {Opt_journal_cycle_record, EXT4_MOUNT2_JOURNAL_CYCLE_RECORD,
+ MOPT_SET | MOPT_2 | MOPT_NO_EXT2},
#ifdef CONFIG_EXT4_DEBUG
{Opt_fc_debug_force, EXT4_MOUNT2_JOURNAL_FAST_COMMIT,
MOPT_SET | MOPT_2 | MOPT_EXT4_ONLY},
@@ -2772,6 +2776,12 @@ static int ext4_check_opt_consistency(struct fs_context *fc,
!(sbi->s_mount_opt2 & EXT4_MOUNT2_DAX_INODE))) {
goto fail_dax_change_remount;
}
+
+ if (ctx_test_mount_opt2(ctx, EXT4_MOUNT2_JOURNAL_CYCLE_RECORD)) {
+ ext4_msg(NULL, KERN_ERR,
+ "can't change journal_cycle_record on remount");
+ return -EINVAL;
+ }
}

return ext4_check_quota_consistency(fc, sb);
@@ -5293,6 +5303,11 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
goto failed_mount3a;
}

+ if (test_opt2(sb, JOURNAL_CYCLE_RECORD)) {
+ ext4_msg(sb, KERN_ERR, "can't mount with "
+ "journal_cycle_record, fs mounted w/o journal");
+ goto failed_mount3a;
+ }
if (test_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM)) {
ext4_msg(sb, KERN_ERR, "can't mount with "
"journal_checksum, fs mounted w/o journal");
@@ -5698,6 +5713,8 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)
journal->j_flags |= JBD2_ABORT_ON_SYNCDATA_ERR;
else
journal->j_flags &= ~JBD2_ABORT_ON_SYNCDATA_ERR;
+ if (test_opt2(sb, JOURNAL_CYCLE_RECORD))
+ journal->j_flags |= JBD2_CYCLE_RECORD;
write_unlock(&journal->j_state_lock);
}

--
2.31.1


2023-01-30 09:22:25

by Yujie Liu

[permalink] [raw]
Subject: Re: [RFC PATCH 2/2] ext4: add journal cycled recording support

Greeting,

FYI, we noticed xfstests.ext4.053.fail due to commit (built with gcc-11):

commit: 8ed4c906ef9a43941026aad0360d84a9338e1c4c ("[RFC PATCH 2/2] ext4: add journal cycled recording support")
url: https://github.com/intel-lab-lkp/linux/commits/Zhang-Yi/jbd2-cycled-record-log-on-clean-journal-logging-area/20230119-131055
base: https://git.kernel.org/cgit/linux/kernel/git/tytso/ext4.git dev
patch link: https://lore.kernel.org/all/[email protected]/
patch subject: [RFC PATCH 2/2] ext4: add journal cycled recording support

in testcase: xfstests
version: xfstests-x86_64-fb6575e-1_20230116
with following parameters:

disk: 4HDD
fs: ext2
test: ext4-group-02

test-description: xfstests is a regression test suite for xfs and other files ystems.
test-url: git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git

on test machine: 4 threads Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (Skylake) with 32G memory

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):


QA output created by 053
Silence is golden.
mounting ext3 "noload" checking "norecovery" (going to remount options noload) (failed remount) FAILED
mounting ext3 "noload" checking "noload" (going to remount options noload) (failed remount) FAILED
mounting ext3 "data=journal" (failed mount) FAILED
mounting ext3 "data=journal" (failed mount) FAILED
mounting ext3 "data=ordered" (failed mount) FAILED
mounting ext3 "data=ordered" (failed mount) FAILED
mounting ext3 "data=writeback" (failed mount) FAILED
mounting ext3 "data=writeback" (failed mount) FAILED
mkfs failed - /usr/sbin/mkfs.ext4 -Fq -J device=/dev/loop0 /dev/sda4 1048576k /dev/sda4


If you fix the issue, kindly add following tag
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-lkp/[email protected]


To reproduce:

git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
sudo bin/lkp install job.yaml # job file is attached in this email
bin/lkp split-job --compatible job.yaml # generate the yaml file for lkp run
sudo bin/lkp run generated-yaml-file

# if come across any failure that blocks the test,
# please remove ~/.lkp and /lkp dir to run from a clean state.


--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Attachments:
(No filename) (2.32 kB)
config-6.1.0-rc4-00062-g8ed4c906ef9a (167.13 kB)
job-script (5.65 kB)
dmesg.xz (45.20 kB)
xfstests (2.88 kB)
job.yaml (4.59 kB)
reproduce (852.00 B)
Download all attachments

2023-02-01 09:29:54

by Zhang Yi

[permalink] [raw]
Subject: Re: [RFC PATCH 2/2] ext4: add journal cycled recording support

Hello

On 2023/1/30 17:19, kernel test robot wrote:
> Greeting,
>
> FYI, we noticed xfstests.ext4.053.fail due to commit (built with gcc-11):
>
> commit: 8ed4c906ef9a43941026aad0360d84a9338e1c4c ("[RFC PATCH 2/2] ext4: add journal cycled recording support")
> url: https://github.com/intel-lab-lkp/linux/commits/Zhang-Yi/jbd2-cycled-record-log-on-clean-journal-logging-area/20230119-131055
> base: https://git.kernel.org/cgit/linux/kernel/git/tytso/ext4.git dev
> patch link: https://lore.kernel.org/all/[email protected]/
> patch subject: [RFC PATCH 2/2] ext4: add journal cycled recording support
>
> in testcase: xfstests
> version: xfstests-x86_64-fb6575e-1_20230116
> with following parameters:
>
> disk: 4HDD
> fs: ext2
> test: ext4-group-02
>
> test-description: xfstests is a regression test suite for xfs and other files ystems.
> test-url: git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git
>
> on test machine: 4 threads Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (Skylake) with 32G memory
>
> caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):
>
>
> QA output created by 053
> Silence is golden.
> mounting ext3 "noload" checking "norecovery" (going to remount options noload) (failed remount) FAILED
> mounting ext3 "noload" checking "noload" (going to remount options noload) (failed remount) FAILED
> mounting ext3 "data=journal" (failed mount) FAILED
> mounting ext3 "data=journal" (failed mount) FAILED
> mounting ext3 "data=ordered" (failed mount) FAILED
> mounting ext3 "data=ordered" (failed mount) FAILED
> mounting ext3 "data=writeback" (failed mount) FAILED
> mounting ext3 "data=writeback" (failed mount) FAILED
> mkfs failed - /usr/sbin/mkfs.ext4 -Fq -J device=/dev/loop0 /dev/sda4 1048576k /dev/sda4
>
>

This is a separate issue and could be fixed by "[PATCH] ext4: fix incorrect options show of original mount_opt and extend mount_opt2",
https://lore.kernel.org/linux-ext4/20230130111138.76tp6pij3yhh4brh@quack3/T/#m96a1cffd567bdd844233b3115a6635391ed0b45b

Thanks,
Yi.