RE:(2) [PATCH 2/2] xfs: skip the fsync flush when a later flush has completed

From: Daejun Park

Date: Tue Nov 10 2026 - 20:10:30 EST


On Mon, Nov 09, 2026 at 12:44:57PM -0500, Brian Foster wrote:
> > 16 fio jobs of 4k append + fsync, QEMU guest on a 990 PRO without
> > power loss protection (virtio-blk, cache=none): 809 -> 4185 fsyncs/s,
> > mean fsync latency 19.8 -> 3.8 ms.
>
> Can you include this in the commit log so we have a record of the perf
> impact?

Thanks, will do in v2. I measured both kernels again on the current
for-next, so the numbers differ from the ones above, and added a single
job line.

[...]
> I think it would be helpful if the comment here and perhaps above
> xfs_buftarg_flush_seq() referred to the submit/completion ordering logic
> being applied. Maybe even rename seq -> submit_seq as well to make it
> more clear. For example, something like:
>
> "Return true if a flush has been submitted and completed since
> @submit_seq was sampled. If so, this guarantees writes completed before
> @submit_seq are flushed to disk."

Agreed. v2 will rename the argument of xfs_buftarg_flushed_since() to
submit_seq and reword its comment along those lines. The comment above
xfs_buftarg_flush_seq() will say that it samples the submit counter, and
that a flush numbered above the sample was submitted after the sample.

[...]
> Ok, so I think I follow the logic. We write the file, sample the submit
> sequence (after write completes), then can optimize away our own flush
> if we can confirm that a flush submitted after write completion has
> already completed. Right?

Yes, that is the logic.

> That kind of makes me wonder whether we could do something like "flush
> or wait on any flush submitted after this seq," but maybe that's
> something for another day. ;)

I'd like to leave waiting for an in-flight flush to a follow-up.

[...]
> > - * If the log force was a no-op, we may still need to flush the
> > - * file data target cache here. This can happen for fdatasync/O_DSYNC
> > - * when no metadata needed to be committed.
>
> Did we intend to remove the comment on why we flush in the first place?

No, that was not intended. Thanks for catching it. The paragraph was
deleted while I was cleaning up the comment changes. v2 keeps it and
adds the new condition after it.