Merge tag 'iomap-6.6-merge-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 28 Aug 2023 18:59:52 +0000 (11:59 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 28 Aug 2023 18:59:52 +0000 (11:59 -0700)
Pull iomap updates from Darrick Wong:
 "We've got some big changes for this release -- I'm very happy to be
  landing willy's work to enable large folios for the page cache for
  general read and write IOs when the fs can make contiguous space
  allocations, and Ritesh's work to track sub-folio dirty state to
  eliminate the write amplification problems inherent in using large
  folios.

  As a bonus, io_uring can now process write completions in the caller's
  context instead of bouncing through a workqueue, which should reduce
  io latency dramatically. IOWs, XFS should see a nice performance bump
  for both IO paths.

  Summary:

   - Make large writes to the page cache fill sparse parts of the cache
     with large folios, then use large memcpy calls for the large folio.

   - Track the per-block dirty state of each large folio so that a
     buffered write to a single byte on a large folio does not result in
     a (potentially) multi-megabyte writeback IO.

   - Allow some directio completions to be performed in the initiating
     task's context instead of punting through a workqueue. This will
     reduce latency for some io_uring requests"

* tag 'iomap-6.6-merge-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (26 commits)
  iomap: support IOCB_DIO_CALLER_COMP
  io_uring/rw: add write support for IOCB_DIO_CALLER_COMP
  fs: add IOCB flags related to passing back dio completions
  iomap: add IOMAP_DIO_INLINE_COMP
  iomap: only set iocb->private for polled bio
  iomap: treat a write through cache the same as FUA
  iomap: use an unsigned type for IOMAP_DIO_* defines
  iomap: cleanup up iomap_dio_bio_end_io()
  iomap: Add per-block dirty state tracking to improve performance
  iomap: Allocate ifs in ->write_begin() early
  iomap: Refactor iomap_write_delalloc_punch() function out
  iomap: Use iomap_punch_t typedef
  iomap: Fix possible overflow condition in iomap_write_delalloc_scan
  iomap: Add some uptodate state handling helpers for ifs state bitmap
  iomap: Drop ifs argument from iomap_set_range_uptodate()
  iomap: Rename iomap_page to iomap_folio_state and others
  iomap: Copy larger chunks from userspace
  iomap: Create large folios in the buffered write path
  filemap: Allow __filemap_get_folio to allocate large folios
  filemap: Add fgf_t typedef
  ...

1  2 
Documentation/filesystems/locking.rst
fs/btrfs/file.c
fs/f2fs/f2fs.h
fs/gfs2/bmap.c
fs/zonefs/file.c
include/linux/fs.h
io_uring/rw.c

Simple merge
diff --cc fs/btrfs/file.c
Simple merge
diff --cc fs/f2fs/f2fs.h
Simple merge
diff --cc fs/gfs2/bmap.c
Simple merge
Simple merge
Simple merge
diff --cc io_uring/rw.c
index 9581b90cb459d72a400c0a45ae543b7218cc0af5,e2166a9a7eaff81d17fe163143525e463c6ee852..b3435033fadfb79199f33632d906c82cf04884e9
@@@ -897,10 -914,29 +909,19 @@@ int io_write(struct io_kiocb *req, unsi
                return ret;
        }
  
 -      /*
 -       * Open-code file_start_write here to grab freeze protection,
 -       * which will be released by another thread in
 -       * io_complete_rw().  Fool lockdep by telling it the lock got
 -       * released so that it doesn't complain about the held lock when
 -       * we return to userspace.
 -       */
 -      if (req->flags & REQ_F_ISREG) {
 -              sb_start_write(file_inode(req->file)->i_sb);
 -              __sb_writers_release(file_inode(req->file)->i_sb,
 -                                      SB_FREEZE_WRITE);
 -      }
 +      if (req->flags & REQ_F_ISREG)
 +              kiocb_start_write(kiocb);
        kiocb->ki_flags |= IOCB_WRITE;
  
+       /*
+        * For non-polled IO, set IOCB_DIO_CALLER_COMP, stating that our handler
+        * groks deferring the completion to task context. This isn't
+        * necessary and useful for polled IO as that can always complete
+        * directly.
+        */
+       if (!(kiocb->ki_flags & IOCB_HIPRI))
+               kiocb->ki_flags |= IOCB_DIO_CALLER_COMP;
        if (likely(req->file->f_op->write_iter))
                ret2 = call_write_iter(req->file, kiocb, &s->iter);
        else if (req->file->f_op->write)