Re: [PATCH 4/4] xfs: fallback to buffered I/O for direct I/O when stable writes are required

Christoph Hellwig
2025-10-29T16:36:00Z

[Adding Qu and the btrfs list]

On Wed, Oct 29, 2025 at 08:53:06AM -0700, Darrick J. Wong wrote:
> > + if (mapping_stable_writes(iocb->ki_filp->f_mapping)) {
> > + xfs_info_once(mp,
> > + "falling back from direct to buffered I/O for write");
> > + return -ENOTBLK;
> > + }
>
> /me wonders if the other filesystems will have to implement this same
> fallback and hence this should be a common helper ala
> dio_warn_stale_pagecache? But we'll get there when we get there.

As far as I'm concerned they should. Btrfs in fact has recently done
that, as they are even more exposed due to the integrated checksumming.

So yes, a common helper might make sense. Especially if we want common
configuration for opt-outs eventually.

> > file->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT;
> > - file->f_mode |= FMODE_DIO_PARALLEL_WRITE;
> > - if (xfs_get_atomic_write_min(XFS_I(inode)) > 0)
> > - file->f_mode |= FMODE_CAN_ATOMIC_WRITE;
> > + if (!mapping_stable_writes(file->f_mapping)) {
> > + file->f_mode |= FMODE_DIO_PARALLEL_WRITE;
>
> Hrm. So parallel directio writes are disabled for writes to files on
> stable_pages devices because we have to fall back to buffered writes.
> Those serialize on i_rwsem so that's why we don't set
> FMODE_DIO_PARALLEL_WRITE, correct?

Yes.

> There's not some more subtle reason
> for not supporting it, right?

Not that I know of anyway.