Re: [PATCH v2 3/4] minix: convert file operations to iomap and add
From: Jeremy Bingham
Date: Wed Jul 01 2026 - 14:44:54 EST
On Wed, Jul 1, 2026 at 11:21 AM Darrick J. Wong <djwong@xxxxxxxxxx> wrote:
>
> On Sat, Jun 27, 2026 at 10:15:55PM -0700, Jeremy Bingham wrote:
> > Subject: [PATCH v2 3/4] minix: convert file operations to iomap and add
>
> ...add what?
Ugh, "add direct I/O". When I was preparing the second version of the patches,
I screwed up.
> > Replace generic_file_read_iter and generic_file_write_iter with custom
> > minix_file_read_iter and minix_file_write_iter that dispatch to iomap
> > for both buffered and direct I/O.
> >
> > Buffered writes now go through iomap_file_buffered_write instead of
> > the aops write_begin/write_end path (which no longer exists for
> > regular files). Buffered reads still use generic_file_read_iter
> > for the non-DIO case.
> >
> > Direct I/O is implemented via iomap_dio_rw for both reads and writes.
> > minix_dio_read_iter takes a shared inode lock; minix_dio_write_iter
> > takes an exclusive lock, does generic_write_checks, and falls back
> > to buffered writes via iomap_file_buffered_write for the tail of a
> > DIO write that is not block-aligned. The minix_dio_write_end_io
> > callback updates i_size and marks the inode dirty.
> >
> > minix_file_open sets FMODE_CAN_ODIRECT so the VFS allows O_DIRECT
> > opens, and splice_write is added to the file operations.
>
> Ignore my question about FMODE_CAN_ODIRECT in the previous patch, then.
Noted.
> > +
> > + if (ret >= 0 && iov_iter_count(from)) {
> > + loff_t pos;
> > + loff_t endbyte;
> > + ssize_t status;
> > +
> > + iocb->ki_flags &= ~IOCB_DIRECT;
>
> Why not set IOC_DSYNC here and let generic_write_sync do all the
> flushing work for you? There's no requirement to dump the pagecache
> after a downgraded direct write, but if you want that, use
> IOCB_DONTCACHE.
>
> --D
*nod* I will also try this when I'm updating the minix patches.
Thank you again for your comments,
-j