Skip to content

Commit 556e031

Browse files
harshadjstytso
authored andcommitted
ext4: disable fast commit with data journalling
Fast commits don't work with data journalling. This patch disables the fast commit support when data journalling is turned on. Suggested-by: Jan Kara <jack@suse.cz> Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20201106035911.1942128-19-harshadshirwadkar@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 1ceecb5 commit 556e031

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

fs/ext4/fast_commit.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,12 @@ void ext4_fc_track_inode(handle_t *handle, struct inode *inode)
483483
if (S_ISDIR(inode->i_mode))
484484
return;
485485

486+
if (ext4_should_journal_data(inode)) {
487+
ext4_fc_mark_ineligible(inode->i_sb,
488+
EXT4_FC_REASON_INODE_JOURNAL_DATA);
489+
return;
490+
}
491+
486492
ret = ext4_fc_track_template(handle, inode, __track_inode, NULL, 1);
487493
trace_ext4_fc_track_inode(inode, ret);
488494
}
@@ -2102,6 +2108,7 @@ const char *fc_ineligible_reasons[] = {
21022108
"Resize",
21032109
"Dir renamed",
21042110
"Falloc range op",
2111+
"Data journalling",
21052112
"FC Commit Failed"
21062113
};
21072114

fs/ext4/fast_commit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ enum {
102102
EXT4_FC_REASON_RESIZE,
103103
EXT4_FC_REASON_RENAME_DIR,
104104
EXT4_FC_REASON_FALLOC_RANGE,
105+
EXT4_FC_REASON_INODE_JOURNAL_DATA,
105106
EXT4_FC_COMMIT_FAILED,
106107
EXT4_FC_REASON_MAX
107108
};

fs/ext4/super.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4340,9 +4340,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
43404340
#endif
43414341

43424342
if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) {
4343-
printk_once(KERN_WARNING "EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, and O_DIRECT support!\n");
4343+
printk_once(KERN_WARNING "EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, O_DIRECT and fast_commit support!\n");
43444344
/* can't mount with both data=journal and dioread_nolock. */
43454345
clear_opt(sb, DIOREAD_NOLOCK);
4346+
clear_opt2(sb, JOURNAL_FAST_COMMIT);
43464347
if (test_opt2(sb, EXPLICIT_DELALLOC)) {
43474348
ext4_msg(sb, KERN_ERR, "can't mount with "
43484349
"both data=journal and delalloc");

include/trace/events/ext4.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ TRACE_DEFINE_ENUM(ES_REFERENCED_B);
104104
{ EXT4_FC_REASON_SWAP_BOOT, "SWAP_BOOT"}, \
105105
{ EXT4_FC_REASON_RESIZE, "RESIZE"}, \
106106
{ EXT4_FC_REASON_RENAME_DIR, "RENAME_DIR"}, \
107-
{ EXT4_FC_REASON_FALLOC_RANGE, "FALLOC_RANGE"})
107+
{ EXT4_FC_REASON_FALLOC_RANGE, "FALLOC_RANGE"}, \
108+
{ EXT4_FC_REASON_INODE_JOURNAL_DATA, "INODE_JOURNAL_DATA"})
108109

109110
TRACE_EVENT(ext4_other_inode_update_time,
110111
TP_PROTO(struct inode *inode, ino_t orig_ino),
@@ -2917,7 +2918,7 @@ TRACE_EVENT(ext4_fc_stats,
29172918
),
29182919

29192920
TP_printk("dev %d:%d fc ineligible reasons:\n"
2920-
"%s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d; "
2921+
"%s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d; "
29212922
"num_commits:%ld, ineligible: %ld, numblks: %ld",
29222923
MAJOR(__entry->dev), MINOR(__entry->dev),
29232924
FC_REASON_NAME_STAT(EXT4_FC_REASON_XATTR),
@@ -2928,6 +2929,7 @@ TRACE_EVENT(ext4_fc_stats,
29282929
FC_REASON_NAME_STAT(EXT4_FC_REASON_RESIZE),
29292930
FC_REASON_NAME_STAT(EXT4_FC_REASON_RENAME_DIR),
29302931
FC_REASON_NAME_STAT(EXT4_FC_REASON_FALLOC_RANGE),
2932+
FC_REASON_NAME_STAT(EXT4_FC_REASON_INODE_JOURNAL_DATA),
29312933
__entry->sbi->s_fc_stats.fc_num_commits,
29322934
__entry->sbi->s_fc_stats.fc_ineligible_commits,
29332935
__entry->sbi->s_fc_stats.fc_numblks)

0 commit comments

Comments
 (0)