]> Git Repo - linux.git/commitdiff
Merge tag 'vfs-6.12-rc6.iomap' of gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs
authorLinus Torvalds <[email protected]>
Fri, 1 Nov 2024 17:45:00 +0000 (07:45 -1000)
committerLinus Torvalds <[email protected]>
Fri, 1 Nov 2024 17:45:00 +0000 (07:45 -1000)
Pull iomap fixes from Christian Brauner:
 "Fixes for iomap to prevent data corruption bugs in the fallocate
  unshare range implementation of fsdax and a small cleanup to turn
  iomap_want_unshare_iter() into an inline function"

* tag 'vfs-6.12-rc6.iomap' of gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs:
  iomap: turn iomap_want_unshare_iter into an inline function
  fsdax: dax_unshare_iter needs to copy entire blocks
  fsdax: remove zeroing code from dax_unshare_iter
  iomap: share iomap_unshare_iter predicate code with fsdax
  xfs: don't allocate COW extents when unsharing a hole

1  2 
fs/iomap/buffered-io.c
fs/xfs/xfs_iomap.c
include/linux/iomap.h

Simple merge
Simple merge
index d0420e962ffdc27f3f4818828919882025ef3ae6,0198f36e521e27f5e16b4caaa4350fe0a62918a9..f61407e3b12192d78932d8c7ac737a5161da0bc9
@@@ -256,20 -256,25 +256,39 @@@ static inline const struct iomap *iomap
        return &i->iomap;
  }
  
 +/*
 + * Return the file offset for the first unchanged block after a short write.
 + *
 + * If nothing was written, round @pos down to point at the first block in
 + * the range, else round up to include the partially written block.
 + */
 +static inline loff_t iomap_last_written_block(struct inode *inode, loff_t pos,
 +              ssize_t written)
 +{
 +      if (unlikely(!written))
 +              return round_down(pos, i_blocksize(inode));
 +      return round_up(pos + written, i_blocksize(inode));
 +}
 +
+ /*
+  * Check if the range needs to be unshared for a FALLOC_FL_UNSHARE_RANGE
+  * operation.
+  *
+  * Don't bother with blocks that are not shared to start with; or mappings that
+  * cannot be shared, such as inline data, delalloc reservations, holes or
+  * unwritten extents.
+  *
+  * Note that we use srcmap directly instead of iomap_iter_srcmap as unsharing
+  * requires providing a separate source map, and the presence of one is a good
+  * indicator that unsharing is needed, unlike IOMAP_F_SHARED which can be set
+  * for any data that goes into the COW fork for XFS.
+  */
+ static inline bool iomap_want_unshare_iter(const struct iomap_iter *iter)
+ {
+       return (iter->iomap.flags & IOMAP_F_SHARED) &&
+               iter->srcmap.type == IOMAP_MAPPED;
+ }
  ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
                const struct iomap_ops *ops, void *private);
  int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops);
This page took 0.073791 seconds and 4 git commands to generate.