Skip to content

Commit e9f5335

Browse files
Daejun7Parktytso
authored andcommitted
ext4: remove expensive flush on fast commit
In the fast commit, it adds REQ_FUA and REQ_PREFLUSH on each fast commit block when barrier is enabled. However, in recovery phase, ext4 compares CRC value in the tail. So it is sufficient to add REQ_FUA and REQ_PREFLUSH on the block that has tail. Signed-off-by: Daejun Park <daejun7.park@samsung.com> Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com> Link: https://lore.kernel.org/r/20210106013242epcms2p5b6b4ed8ca86f29456fdf56aa580e74b4@epcms2p5 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 6b4b8e6 commit e9f5335

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

fs/ext4/fast_commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,13 +604,13 @@ void ext4_fc_track_range(handle_t *handle, struct inode *inode, ext4_lblk_t star
604604
trace_ext4_fc_track_range(inode, start, end, ret);
605605
}
606606

607-
static void ext4_fc_submit_bh(struct super_block *sb)
607+
static void ext4_fc_submit_bh(struct super_block *sb, bool is_tail)
608608
{
609609
int write_flags = REQ_SYNC;
610610
struct buffer_head *bh = EXT4_SB(sb)->s_fc_bh;
611611

612-
/* TODO: REQ_FUA | REQ_PREFLUSH is unnecessarily expensive. */
613-
if (test_opt(sb, BARRIER))
612+
/* Add REQ_FUA | REQ_PREFLUSH only its tail */
613+
if (test_opt(sb, BARRIER) && is_tail)
614614
write_flags |= REQ_FUA | REQ_PREFLUSH;
615615
lock_buffer(bh);
616616
set_buffer_dirty(bh);
@@ -684,7 +684,7 @@ static u8 *ext4_fc_reserve_space(struct super_block *sb, int len, u32 *crc)
684684
*crc = ext4_chksum(sbi, *crc, tl, sizeof(*tl));
685685
if (pad_len > 0)
686686
ext4_fc_memzero(sb, tl + 1, pad_len, crc);
687-
ext4_fc_submit_bh(sb);
687+
ext4_fc_submit_bh(sb, false);
688688

689689
ret = jbd2_fc_get_buf(EXT4_SB(sb)->s_journal, &bh);
690690
if (ret)
@@ -741,7 +741,7 @@ static int ext4_fc_write_tail(struct super_block *sb, u32 crc)
741741
tail.fc_crc = cpu_to_le32(crc);
742742
ext4_fc_memcpy(sb, dst, &tail.fc_crc, sizeof(tail.fc_crc), NULL);
743743

744-
ext4_fc_submit_bh(sb);
744+
ext4_fc_submit_bh(sb, true);
745745

746746
return 0;
747747
}

0 commit comments

Comments
 (0)