Skip to content

Commit 995a3ed

Browse files
harshadjstytso
authored andcommitted
ext4: add fast_commit feature and handling for extended mount options
We are running out of mount option bits. Add handling for using s_mount_opt2. Add ext4 and jbd2 fast commit feature flag and also add ability to turn off the fast commit feature in Ext4. Signed-off-by: Harshad Shirwadkar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent f5b8b29 commit 995a3ed

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

fs/ext4/ext4.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,8 @@ struct ext4_inode_info {
12131213
#define EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM 0x00000008 /* User explicitly
12141214
specified journal checksum */
12151215

1216+
#define EXT4_MOUNT2_JOURNAL_FAST_COMMIT 0x00000010 /* Journal fast commit */
1217+
12161218
#define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \
12171219
~EXT4_MOUNT_##opt
12181220
#define set_opt(sb, opt) EXT4_SB(sb)->s_mount_opt |= \
@@ -1813,6 +1815,7 @@ static inline bool ext4_verity_in_progress(struct inode *inode)
18131815
#define EXT4_FEATURE_COMPAT_RESIZE_INODE 0x0010
18141816
#define EXT4_FEATURE_COMPAT_DIR_INDEX 0x0020
18151817
#define EXT4_FEATURE_COMPAT_SPARSE_SUPER2 0x0200
1818+
#define EXT4_FEATURE_COMPAT_FAST_COMMIT 0x0400
18161819
#define EXT4_FEATURE_COMPAT_STABLE_INODES 0x0800
18171820

18181821
#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
@@ -1915,6 +1918,7 @@ EXT4_FEATURE_COMPAT_FUNCS(xattr, EXT_ATTR)
19151918
EXT4_FEATURE_COMPAT_FUNCS(resize_inode, RESIZE_INODE)
19161919
EXT4_FEATURE_COMPAT_FUNCS(dir_index, DIR_INDEX)
19171920
EXT4_FEATURE_COMPAT_FUNCS(sparse_super2, SPARSE_SUPER2)
1921+
EXT4_FEATURE_COMPAT_FUNCS(fast_commit, FAST_COMMIT)
19181922
EXT4_FEATURE_COMPAT_FUNCS(stable_inodes, STABLE_INODES)
19191923

19201924
EXT4_FEATURE_RO_COMPAT_FUNCS(sparse_super, SPARSE_SUPER)

fs/ext4/super.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ enum {
17091709
Opt_dioread_nolock, Opt_dioread_lock,
17101710
Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
17111711
Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache,
1712-
Opt_prefetch_block_bitmaps,
1712+
Opt_prefetch_block_bitmaps, Opt_no_fc,
17131713
};
17141714

17151715
static const match_table_t tokens = {
@@ -1796,6 +1796,7 @@ static const match_table_t tokens = {
17961796
{Opt_init_itable, "init_itable=%u"},
17971797
{Opt_init_itable, "init_itable"},
17981798
{Opt_noinit_itable, "noinit_itable"},
1799+
{Opt_no_fc, "no_fc"},
17991800
{Opt_max_dir_size_kb, "max_dir_size_kb=%u"},
18001801
{Opt_test_dummy_encryption, "test_dummy_encryption=%s"},
18011802
{Opt_test_dummy_encryption, "test_dummy_encryption"},
@@ -1922,6 +1923,7 @@ static int clear_qf_name(struct super_block *sb, int qtype)
19221923
#define MOPT_EXT4_ONLY (MOPT_NO_EXT2 | MOPT_NO_EXT3)
19231924
#define MOPT_STRING 0x0400
19241925
#define MOPT_SKIP 0x0800
1926+
#define MOPT_2 0x1000
19251927

19261928
static const struct mount_opts {
19271929
int token;
@@ -2022,6 +2024,8 @@ static const struct mount_opts {
20222024
{Opt_nombcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET},
20232025
{Opt_prefetch_block_bitmaps, EXT4_MOUNT_PREFETCH_BLOCK_BITMAPS,
20242026
MOPT_SET},
2027+
{Opt_no_fc, EXT4_MOUNT2_JOURNAL_FAST_COMMIT,
2028+
MOPT_CLEAR | MOPT_2 | MOPT_EXT4_ONLY},
20252029
{Opt_err, 0, 0}
20262030
};
20272031

@@ -2398,10 +2402,17 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
23982402
WARN_ON(1);
23992403
return -1;
24002404
}
2401-
if (arg != 0)
2402-
sbi->s_mount_opt |= m->mount_opt;
2403-
else
2404-
sbi->s_mount_opt &= ~m->mount_opt;
2405+
if (m->flags & MOPT_2) {
2406+
if (arg != 0)
2407+
sbi->s_mount_opt2 |= m->mount_opt;
2408+
else
2409+
sbi->s_mount_opt2 &= ~m->mount_opt;
2410+
} else {
2411+
if (arg != 0)
2412+
sbi->s_mount_opt |= m->mount_opt;
2413+
else
2414+
sbi->s_mount_opt &= ~m->mount_opt;
2415+
}
24052416
}
24062417
return 1;
24072418
}
@@ -2618,6 +2629,9 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
26182629
SEQ_OPTS_PUTS("dax=inode");
26192630
}
26202631

2632+
if (test_opt2(sb, JOURNAL_FAST_COMMIT))
2633+
SEQ_OPTS_PUTS("fast_commit");
2634+
26212635
ext4_show_quota_options(seq, sb);
26222636
return 0;
26232637
}
@@ -4121,6 +4135,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
41214135
#ifdef CONFIG_EXT4_FS_POSIX_ACL
41224136
set_opt(sb, POSIX_ACL);
41234137
#endif
4138+
if (ext4_has_feature_fast_commit(sb))
4139+
set_opt2(sb, JOURNAL_FAST_COMMIT);
41244140
/* don't forget to enable journal_csum when metadata_csum is enabled. */
41254141
if (ext4_has_metadata_csum(sb))
41264142
set_opt(sb, JOURNAL_CHECKSUM);
@@ -4777,6 +4793,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
47774793
sbi->s_def_mount_opt &= ~EXT4_MOUNT_JOURNAL_CHECKSUM;
47784794
clear_opt(sb, JOURNAL_CHECKSUM);
47794795
clear_opt(sb, DATA_FLAGS);
4796+
clear_opt2(sb, JOURNAL_FAST_COMMIT);
47804797
sbi->s_journal = NULL;
47814798
needs_recovery = 0;
47824799
goto no_journal;

include/linux/jbd2.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ typedef struct journal_superblock_s
289289
#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
290290
#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
291291
#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
292+
#define JBD2_FEATURE_INCOMPAT_FAST_COMMIT 0x00000020
292293

293294
/* See "journal feature predicate functions" below */
294295

@@ -299,7 +300,8 @@ typedef struct journal_superblock_s
299300
JBD2_FEATURE_INCOMPAT_64BIT | \
300301
JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
301302
JBD2_FEATURE_INCOMPAT_CSUM_V2 | \
302-
JBD2_FEATURE_INCOMPAT_CSUM_V3)
303+
JBD2_FEATURE_INCOMPAT_CSUM_V3 | \
304+
JBD2_FEATURE_INCOMPAT_FAST_COMMIT)
303305

304306
#ifdef __KERNEL__
305307

@@ -1263,6 +1265,7 @@ JBD2_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
12631265
JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
12641266
JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
12651267
JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
1268+
JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT)
12661269

12671270
/*
12681271
* Journal flag definitions

0 commit comments

Comments
 (0)