Commit 6a3afb6a authored by Zhang Yi's avatar Zhang Yi Committed by Theodore Ts'o

jbd2: increase the journal IO's priority

Current jbd2 only add REQ_SYNC for descriptor block, metadata log
buffer, commit buffer and superblock buffer, the submitted IO could be
throttled by writeback throttle in block layer, that could lead to
priority inversion in some cases. The log IO looks like a kind of high
priority metadata IO, so it should not be throttled by WBT like QOS
policies in block layer, let's add REQ_SYNC | REQ_IDLE to exempt from
writeback throttle, and also add REQ_META together indicates it's a
metadata IO.
Signed-off-by: default avatarZhang Yi <yi.zhang@huawei.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20231129114740.2686201-2-yi.zhang@huaweicloud.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 85559227
...@@ -119,7 +119,7 @@ static int journal_submit_commit_record(journal_t *journal, ...@@ -119,7 +119,7 @@ static int journal_submit_commit_record(journal_t *journal,
struct commit_header *tmp; struct commit_header *tmp;
struct buffer_head *bh; struct buffer_head *bh;
struct timespec64 now; struct timespec64 now;
blk_opf_t write_flags = REQ_OP_WRITE | REQ_SYNC; blk_opf_t write_flags = REQ_OP_WRITE | JBD2_JOURNAL_REQ_FLAGS;
*cbh = NULL; *cbh = NULL;
...@@ -395,8 +395,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) ...@@ -395,8 +395,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
*/ */
jbd2_journal_update_sb_log_tail(journal, jbd2_journal_update_sb_log_tail(journal,
journal->j_tail_sequence, journal->j_tail_sequence,
journal->j_tail, journal->j_tail, 0);
REQ_SYNC);
mutex_unlock(&journal->j_checkpoint_mutex); mutex_unlock(&journal->j_checkpoint_mutex);
} else { } else {
jbd2_debug(3, "superblock not updated\n"); jbd2_debug(3, "superblock not updated\n");
...@@ -715,6 +714,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) ...@@ -715,6 +714,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
for (i = 0; i < bufs; i++) { for (i = 0; i < bufs; i++) {
struct buffer_head *bh = wbuf[i]; struct buffer_head *bh = wbuf[i];
/* /*
* Compute checksum. * Compute checksum.
*/ */
...@@ -727,7 +727,8 @@ void jbd2_journal_commit_transaction(journal_t *journal) ...@@ -727,7 +727,8 @@ void jbd2_journal_commit_transaction(journal_t *journal)
clear_buffer_dirty(bh); clear_buffer_dirty(bh);
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
bh->b_end_io = journal_end_buffer_io_sync; bh->b_end_io = journal_end_buffer_io_sync;
submit_bh(REQ_OP_WRITE | REQ_SYNC, bh); submit_bh(REQ_OP_WRITE | JBD2_JOURNAL_REQ_FLAGS,
bh);
} }
cond_resched(); cond_resched();
......
...@@ -1100,8 +1100,7 @@ int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block) ...@@ -1100,8 +1100,7 @@ int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
* space and if we lose sb update during power failure we'd replay * space and if we lose sb update during power failure we'd replay
* old transaction with possibly newly overwritten data. * old transaction with possibly newly overwritten data.
*/ */
ret = jbd2_journal_update_sb_log_tail(journal, tid, block, ret = jbd2_journal_update_sb_log_tail(journal, tid, block, REQ_FUA);
REQ_SYNC | REQ_FUA);
if (ret) if (ret)
goto out; goto out;
...@@ -1775,8 +1774,7 @@ static int journal_reset(journal_t *journal) ...@@ -1775,8 +1774,7 @@ static int journal_reset(journal_t *journal)
*/ */
jbd2_journal_update_sb_log_tail(journal, jbd2_journal_update_sb_log_tail(journal,
journal->j_tail_sequence, journal->j_tail_sequence,
journal->j_tail, journal->j_tail, REQ_FUA);
REQ_SYNC | REQ_FUA);
mutex_unlock(&journal->j_checkpoint_mutex); mutex_unlock(&journal->j_checkpoint_mutex);
} }
return jbd2_journal_start_thread(journal); return jbd2_journal_start_thread(journal);
...@@ -1798,6 +1796,11 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags) ...@@ -1798,6 +1796,11 @@ static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
return -EIO; return -EIO;
} }
/*
* Always set high priority flags to exempt from block layer's
* QOS policies, e.g. writeback throttle.
*/
write_flags |= JBD2_JOURNAL_REQ_FLAGS;
if (!(journal->j_flags & JBD2_BARRIER)) if (!(journal->j_flags & JBD2_BARRIER))
write_flags &= ~(REQ_FUA | REQ_PREFLUSH); write_flags &= ~(REQ_FUA | REQ_PREFLUSH);
...@@ -2052,7 +2055,7 @@ void jbd2_journal_update_sb_errno(journal_t *journal) ...@@ -2052,7 +2055,7 @@ void jbd2_journal_update_sb_errno(journal_t *journal)
jbd2_debug(1, "JBD2: updating superblock error (errno %d)\n", errcode); jbd2_debug(1, "JBD2: updating superblock error (errno %d)\n", errcode);
sb->s_errno = cpu_to_be32(errcode); sb->s_errno = cpu_to_be32(errcode);
jbd2_write_superblock(journal, REQ_SYNC | REQ_FUA); jbd2_write_superblock(journal, REQ_FUA);
} }
EXPORT_SYMBOL(jbd2_journal_update_sb_errno); EXPORT_SYMBOL(jbd2_journal_update_sb_errno);
...@@ -2173,8 +2176,7 @@ int jbd2_journal_destroy(journal_t *journal) ...@@ -2173,8 +2176,7 @@ int jbd2_journal_destroy(journal_t *journal)
++journal->j_transaction_sequence; ++journal->j_transaction_sequence;
write_unlock(&journal->j_state_lock); write_unlock(&journal->j_state_lock);
jbd2_mark_journal_empty(journal, jbd2_mark_journal_empty(journal, REQ_PREFLUSH | REQ_FUA);
REQ_SYNC | REQ_PREFLUSH | REQ_FUA);
mutex_unlock(&journal->j_checkpoint_mutex); mutex_unlock(&journal->j_checkpoint_mutex);
} else } else
err = -EIO; err = -EIO;
...@@ -2475,7 +2477,7 @@ int jbd2_journal_flush(journal_t *journal, unsigned int flags) ...@@ -2475,7 +2477,7 @@ int jbd2_journal_flush(journal_t *journal, unsigned int flags)
* the magic code for a fully-recovered superblock. Any future * the magic code for a fully-recovered superblock. Any future
* commits of data to the journal will restore the current * commits of data to the journal will restore the current
* s_start value. */ * s_start value. */
jbd2_mark_journal_empty(journal, REQ_SYNC | REQ_FUA); jbd2_mark_journal_empty(journal, REQ_FUA);
if (flags) if (flags)
err = __jbd2_journal_erase(journal, flags); err = __jbd2_journal_erase(journal, flags);
...@@ -2521,7 +2523,7 @@ int jbd2_journal_wipe(journal_t *journal, int write) ...@@ -2521,7 +2523,7 @@ int jbd2_journal_wipe(journal_t *journal, int write)
if (write) { if (write) {
/* Lock to make assertions happy... */ /* Lock to make assertions happy... */
mutex_lock_io(&journal->j_checkpoint_mutex); mutex_lock_io(&journal->j_checkpoint_mutex);
jbd2_mark_journal_empty(journal, REQ_SYNC | REQ_FUA); jbd2_mark_journal_empty(journal, REQ_FUA);
mutex_unlock(&journal->j_checkpoint_mutex); mutex_unlock(&journal->j_checkpoint_mutex);
} }
......
...@@ -1374,6 +1374,9 @@ JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2) ...@@ -1374,6 +1374,9 @@ JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3) JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT) JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT)
/* Journal high priority write IO operation flags */
#define JBD2_JOURNAL_REQ_FLAGS (REQ_META | REQ_SYNC | REQ_IDLE)
/* /*
* Journal flag definitions * Journal flag definitions
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment