linux-next: manual merge of the vfs-brauner tree with the exfat tree
From: Mark Brown
Date: Tue Oct 13 2026 - 10:25:51 EST
Hi all,
Today's linux-next merge of the vfs-brauner tree got a conflict in:
fs/exfat/file.c
between commit:
9965754d857fc ("exfat: drain in-flight DIO before buffered writes")
from the exfat tree and commit:
d874f8060847c ("iomap: pass iomap_iter_next_fn directly instead of struct iomap_ops")
from the vfs-brauner tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
The fixup below is obviously part done, and I had to do subsequent
fixups on top of that due to wider semantic changes. Together with all
the other conflicts today this merge has been an absolute mess, it seems
like we could use better coordination here.
diff --cc fs/exfat/file.c
index f106db945d8dd,188d921aacd13..0000000000000
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@@ -712,42 -654,98 +712,102 @@@ int exfat_file_fsync(struct file *filp
}
/*
- * exfat_zero_new_range - zero [start, end) without overwriting uptodate blocks
+ * exfat_prepare_valid_range - populate and dirty folios covering [start, end)
*
- * Uptodate blocks may contain data written through a shared mapping beyond
- * valid_size.
+ * Populate missing blocks via the read path, which zero-fills data
+ * beyond the current valid_size and skips uptodate blocks.
+ * Mark entire folios dirty so the newly valid range is written back.
+ *
+ * Call before advancing valid_size.
*/
-static int exfat_zero_new_range(struct inode *inode, loff_t start, loff_t end)
+static int exfat_prepare_valid_range(struct inode *inode, loff_t start,
+ loff_t end)
{
struct address_space *mapping = inode->i_mapping;
- unsigned int blocksize = i_blocksize(inode);
- loff_t pos = start;
- int err;
+ loff_t next, pos = start;
+ struct folio *folio;
+ pgoff_t index;
+
+ if (pos >= end)
+ return 0;
while (pos < end) {
- loff_t next = min_t(loff_t,
- round_down(pos, PAGE_SIZE) + PAGE_SIZE, end);
- struct folio *folio;
- loff_t bpos;
+ index = pos >> PAGE_SHIFT;
+ next = min(((loff_t)index + 1) << PAGE_SHIFT, end);
++<<<<<<< HEAD
+ balance_dirty_pages_ratelimited(mapping);
++=======
+ folio = filemap_get_folio(mapping, pos >> PAGE_SHIFT);
+ if (IS_ERR(folio)) {
+ err = iomap_zero_range(inode, pos, next - pos, NULL,
+ exfat_iomap_next, NULL, NULL);
+ if (err < 0)
+ return err;
+ pos = next;
+ continue;
+ }
++>>>>>>> vfs-brauner/vfs.all
- if (folio_test_uptodate(folio)) {
- folio_lock(folio);
- if (folio->mapping == mapping)
- folio_mark_dirty(folio);
- folio_unlock(folio);
- folio_put(folio);
- pos = next;
- continue;
- }
+ folio = read_mapping_folio(mapping, index, NULL);
+ if (IS_ERR(folio))
+ return PTR_ERR(folio);
- /*
- * Zero not-uptodate block runs. iomap_zero_range() requires an
- * unlocked folio, so recheck ->mapping after each call.
- */
folio_lock(folio);
++<<<<<<< HEAD
+ if (folio->mapping == mapping) {
++=======
+ bpos = pos;
+ while (bpos < next) {
+ loff_t rstart, rend;
+
+ if (folio->mapping != mapping) {
+ folio_unlock(folio);
+ err = iomap_zero_range(inode, bpos, next - bpos,
+ NULL, exfat_iomap_next, NULL, NULL);
+ if (err < 0) {
+ folio_put(folio);
+ return err;
+ }
+ folio_lock(folio);
+ break;
+ }
+
+ if (iomap_is_partially_uptodate(folio,
+ offset_in_folio(folio, bpos), blocksize)) {
+ bpos += blocksize;
+ continue;
+ }
+
+ rstart = bpos;
+ rend = min_t(loff_t, bpos + blocksize, next);
+ while (rend < next &&
+ !iomap_is_partially_uptodate(folio,
+ offset_in_folio(folio, rend), blocksize))
+ rend = min_t(loff_t, rend + blocksize, next);
+
+ folio_unlock(folio);
+ err = iomap_zero_range(inode, rstart, rend - rstart,
+ NULL, exfat_iomap_next, NULL, NULL);
+ if (err < 0) {
+ folio_put(folio);
+ return err;
+ }
+ folio_lock(folio);
+ bpos = rend;
+ }
+
+ /*
+ * Dirty only a fully uptodate folio. Dirtying a partial folio could
+ * write uninitialised cache contents over valid on-disk blocks.
+ */
+ if (folio->mapping == mapping && folio_test_uptodate(folio))
++>>>>>>> vfs-brauner/vfs.all
folio_mark_dirty(folio);
+ pos = next;
+ }
folio_unlock(folio);
folio_put(folio);
- pos = next;
}
return 0;
@@@ -813,9 -807,7 +873,9 @@@ static ssize_t exfat_fallback_buffered_
iocb->ki_flags &= ~IOCB_DIRECT;
+ inode_dio_wait(file_inode(iocb->ki_filp));
+
- written = iomap_file_buffered_write(iocb, from, &exfat_write_iomap_ops,
+ written = iomap_file_buffered_write(iocb, from, exfat_write_iomap_next,
NULL, NULL);
if (written < 0)
return written;
@@@ -894,21 -887,13 +954,22 @@@ static ssize_t exfat_file_write_iter(st
}
if (ret < 0)
goto unlock;
+
+ pos = valid_size;
}
- if (iocb->ki_flags & IOCB_DIRECT)
+ if (iocb->ki_flags & IOCB_DIRECT) {
ret = exfat_dio_write_iter(iocb, iter);
- else
+ } else {
+ /*
+ * Prevent concurrent direct I/O and buffered I/O to the same file
+ * range. Wait for in-flight DIO to finish before dirtying pages.
+ */
+ inode_dio_wait(inode);
ret = iomap_file_buffered_write(iocb, iter,
+ &exfat_write_iomap_ops, NULL, NULL);
+ exfat_write_iomap_next, NULL, NULL);
+ }
if (ret < 0)
goto unlock;
Attachment:
signature.asc
Description: PGP signature