Re: [PATCH 1/2] iomap: add iomap_writepages_unbound() to write beyond EOF

kernel test robot
2024-12-29T17:55:36Z

Hi Andrey,

kernel test robot noticed the following build errors:

[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on linus/master v6.13-rc4 next-20241220]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Andrey-Albershteyn/iomap-add-iomap_writepages_unbound-to-write-beyond-EOF/20241229-213942
base: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link: https://lore.kernel.org/r/20241229133640.1193578-2-aalbersh%40kernel.org
patch subject: [PATCH 1/2] iomap: add iomap_writepages_unbound() to write beyond EOF
config: s390-randconfig-002-20241229 (https://download.01.org/0day-ci/archive/20241230/202412300135.cvWMPZGf-lkp@intel.com/config)
compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241230/202412300135.cvWMPZGf-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412300135.cvWMPZGf-lkp@intel.com/

All errors (new ones prefixed by >>):

>> fs/iomap/buffered-io.c:982:23: error: use of undeclared identifier 'IOMAP_NOSIZE'
if (!(iter->flags & IOMAP_NOSIZE) && (pos + written > old_size)) {
^
fs/iomap/buffered-io.c:988:23: error: use of undeclared identifier 'IOMAP_NOSIZE'
if (!(iter->flags & IOMAP_NOSIZE) && (old_size < pos))
^
2 errors generated.

vim +/IOMAP_NOSIZE +982 fs/iomap/buffered-io.c

909
910 static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
911 {
912 loff_t length = iomap_length(iter);
913 loff_t pos = iter->pos;
914 ssize_t total_written = 0;
915 long status = 0;
916 struct address_space *mapping = iter->inode->i_mapping;
917 size_t chunk = mapping_max_folio_size(mapping);
918 unsigned int bdp_flags = (iter->flags & IOMAP_NOWAIT) ? BDP_ASYNC : 0;
919
920 do {
921 struct folio *folio;
922 loff_t old_size;
923 size_t offset; /* Offset into folio */
924 size_t bytes; /* Bytes to write to folio */
925 size_t copied; /* Bytes copied from user */
926 size_t written; /* Bytes have been written */
927
928 bytes = iov_iter_count(i);
929 retry:
930 offset = pos & (chunk - 1);
931 bytes = min(chunk - offset, bytes);
932 status = balance_dirty_pages_ratelimited_flags(mapping,
933 bdp_flags);
934 if (unlikely(status))
935 break;
936
937 if (bytes > length)
938 bytes = length;
939
940 /*
941 * Bring in the user page that we'll copy from _first_.
942 * Otherwise there's a nasty deadlock on copying from the
943 * same page as we're writing to, without it being marked
944 * up-to-date.
945 *
946 * For async buffered writes the assumption is that the user
947 * page has already been faulted in. This can be optimized by
948 * faulting the user page.
949 */
950 if (unlikely(fault_in_iov_iter_readable(i, bytes) == bytes)) {
951 status = -EFAULT;
952 break;
953 }
954
955 status = iomap_write_begin(iter, pos, bytes, &folio);
956 if (unlikely(status)) {
957 iomap_write_failed(iter->inode, pos, bytes);
958 break;
959 }
960 if (iter->iomap.flags & IOMAP_F_STALE)
961 break;
962
963 offset = offset_in_folio(folio, pos);
964 if (bytes > folio_size(folio) - offset)
965 bytes = folio_size(folio) - offset;
966
967 if (mapping_writably_mapped(mapping))
968 flush_dcache_folio(folio);
969
970 copied = copy_folio_from_iter_atomic(folio, offset, bytes, i);
971 written = iomap_write_end(iter, pos, bytes, copied, folio) ?
972 copied : 0;
973
974 /*
975 * Update the in-memory inode size after copying the data into
976 * the page cache. It's up to the file system to write the
977 * updated size to disk, preferably after I/O completion so that
978 * no stale data is exposed. Only once that's done can we
979 * unlock and release the folio.
980 */
981 old_size = iter->inode->i_size;
> 982 if (!(iter->flags & IOMAP_NOSIZE) && (pos + written > old_size)) {
983 i_size_write(iter->inode, pos + written);
984 iter->iomap.flags |= IOMAP_F_SIZE_CHANGED;
985 }
986 __iomap_put_folio(iter, pos, written, folio);
987
988 if (!(iter->flags & IOMAP_NOSIZE) && (old_size < pos))
989 pagecache_isize_extended(iter->inode, old_size, pos);
990
991 cond_resched();
992 if (unlikely(written == 0)) {
993 /*
994 * A short copy made iomap_write_end() reject the
995 * thing entirely. Might be memory poisoning
996 * halfway through, might be a race with munmap,
997 * might be severe memory pressure.
998 */
999 iomap_write_failed(iter->inode, pos, bytes);
1000 iov_iter_revert(i, copied);
1001
1002 if (chunk > PAGE_SIZE)
1003 chunk /= 2;
1004 if (copied) {
1005 bytes = copied;
1006 goto retry;
1007 }
1008 } else {
1009 pos += written;
1010 total_written += written;
1011 length -= written;
1012 }
1013 } while (iov_iter_count(i) && length);
1014
1015 if (status == -EAGAIN) {
1016 iov_iter_revert(i, total_written);
1017 return -EAGAIN;
1018 }
1019 return total_written ? total_written : status;
1020 }
1021

--
0-DAY CI Kernel Test Service