xfs: optimize cache flushing for CIL commits on multi-device file systems

While the flush before writing a start record needs to cover data on the
data and possibly RT devices, the flush before writing the commit record
iclog only needs to ensure previous iclogs are stable on disk.

Split out a new XLOG_ICL_NEED_FLUSH_LOG flag out of XLOG_ICL_NEED_FLUSH
to signal that only the log device needs to be flushed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
Christoph Hellwig 2026-09-25 17:15:37 +02:00 committed by Carlos Maiolino
parent 5ed6d84e9d
commit fe8b1951cd
3 changed files with 16 additions and 9 deletions

View File

@ -1619,12 +1619,14 @@ xlog_write_iclog(
if (iclog->ic_flags & XLOG_ICL_NEED_FLUSH) {
if (xlog_flush_data_caches(log))
goto shutdown;
iclog->ic_bio.bi_opf |= REQ_PREFLUSH;
}
if (iclog->ic_flags & (XLOG_ICL_NEED_FLUSH | XLOG_ICL_NEED_FLUSH_LOG))
iclog->ic_bio.bi_opf |= REQ_PREFLUSH;
if (iclog->ic_flags & XLOG_ICL_NEED_FUA)
iclog->ic_bio.bi_opf |= REQ_FUA;
iclog->ic_flags &= ~(XLOG_ICL_NEED_FLUSH | XLOG_ICL_NEED_FUA);
iclog->ic_flags &= ~(XLOG_ICL_NEED_FLUSH | XLOG_ICL_NEED_FLUSH_LOG |
XLOG_ICL_NEED_FUA);
if (is_vmalloc_addr(iclog->ic_header)) {
if (!bio_add_vmalloc(&iclog->ic_bio, iclog->ic_header, count))

View File

@ -1562,10 +1562,13 @@ xlog_cil_push_work(
}
/*
* We need to issue a pre-flush so that the ordering for this
* checkpoint is correctly preserved down to stable storage.
* We need to issue a pre-flush on the device containing the log
* so that the ordering for this checkpoint is correctly
* preserved down to stable storage.
* There is no need for an extra flush on devices that only
* contain data or non-log metadata.
*/
ctx->commit_iclog->ic_flags |= XLOG_ICL_NEED_FLUSH;
ctx->commit_iclog->ic_flags |= XLOG_ICL_NEED_FLUSH_LOG;
}
/*

View File

@ -71,12 +71,14 @@ enum xlog_iclog_state {
/*
* In core log flags
*/
#define XLOG_ICL_NEED_FLUSH (1u << 0) /* iclog needs REQ_PREFLUSH */
#define XLOG_ICL_NEED_FUA (1u << 1) /* iclog needs REQ_FUA */
#define XLOG_ICL_NEED_FLUSH (1u << 0) /* all devs need REQ_PREFLUSH */
#define XLOG_ICL_NEED_FLUSH_LOG (1u << 1) /* logdev needs REQ_PREFLUSH */
#define XLOG_ICL_NEED_FUA (1u << 2) /* iclog needs REQ_FUA */
#define XLOG_ICL_STRINGS \
{ XLOG_ICL_NEED_FLUSH, "XLOG_ICL_NEED_FLUSH" }, \
{ XLOG_ICL_NEED_FUA, "XLOG_ICL_NEED_FUA" }
{ XLOG_ICL_NEED_FLUSH, "XLOG_ICL_NEED_FLUSH" }, \
{ XLOG_ICL_NEED_FLUSH_LOG, "XLOG_ICL_NEED_FLUSH_LOG" }, \
{ XLOG_ICL_NEED_FUA, "XLOG_ICL_NEED_FUA" }
/*