iomap: pass the length of the dirty region to ->map_blocks
authorChristoph Hellwig <hch@lst.de>
Thu, 7 Dec 2023 07:27:10 +0000 (08:27 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 1 Feb 2024 13:20:13 +0000 (14:20 +0100)
Let the file system know how much dirty data exists at the passed
in offset.  This allows file systems to allocate the right amount
of space that actually is written back if they can't eagerly
convert (e.g. because they don't support unwritten extents).

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20231207072710.176093-15-hch@lst.de
Signed-off-by: Christian Brauner <brauner@kernel.org>
block/fops.c
fs/gfs2/bmap.c
fs/iomap/buffered-io.c
fs/xfs/xfs_aops.c
fs/zonefs/file.c
include/linux/iomap.h

index 0cf8cf72cdfa108926ae8fc7f53bce05a3225058..93bae17ce660c8a4db190743eb713dde6770a853 100644 (file)
@@ -482,7 +482,7 @@ static void blkdev_readahead(struct readahead_control *rac)
 }
 
 static int blkdev_map_blocks(struct iomap_writepage_ctx *wpc,
-               struct inode *inode, loff_t offset)
+               struct inode *inode, loff_t offset, unsigned int len)
 {
        loff_t isize = i_size_read(inode);
 
index d9ccfd27e4f11fe4ecc7ce36981cbef469942847..789af5c8fade9d86354f86a6a7ffe696a9f5447d 100644 (file)
@@ -2465,7 +2465,7 @@ out:
 }
 
 static int gfs2_map_blocks(struct iomap_writepage_ctx *wpc, struct inode *inode,
-               loff_t offset)
+               loff_t offset, unsigned int len)
 {
        int ret;
 
index 3dab060aed6d7b5f5917ab9cf0bbeb0c9f428112..2ad0e287c70448444b90c8db92e32855766692eb 100644 (file)
@@ -1773,7 +1773,7 @@ static int iomap_writepage_map_blocks(struct iomap_writepage_ctx *wpc,
        do {
                unsigned map_len;
 
-               error = wpc->ops->map_blocks(wpc, inode, pos);
+               error = wpc->ops->map_blocks(wpc, inode, pos, dirty_len);
                if (error)
                        break;
                trace_iomap_writepage_map(inode, &wpc->iomap);
index 4fb244bb884dc40b3150f65c140187a7891297f0..1698507d1ac73a0a4985322e00c52e61539d5317 100644 (file)
@@ -276,7 +276,8 @@ static int
 xfs_map_blocks(
        struct iomap_writepage_ctx *wpc,
        struct inode            *inode,
-       loff_t                  offset)
+       loff_t                  offset,
+       unsigned int            len)
 {
        struct xfs_inode        *ip = XFS_I(inode);
        struct xfs_mount        *mp = ip->i_mount;
index 6ab2318a9c8e80271a3f17d2ad852dacad2f2fa1..8dab4c2ad3007e581fda3cf65e6db79b91e0f8f6 100644 (file)
@@ -125,7 +125,8 @@ static void zonefs_readahead(struct readahead_control *rac)
  * which implies that the page range can only be within the fixed inode size.
  */
 static int zonefs_write_map_blocks(struct iomap_writepage_ctx *wpc,
-                                  struct inode *inode, loff_t offset)
+                                  struct inode *inode, loff_t offset,
+                                  unsigned int len)
 {
        struct zonefs_zone *z = zonefs_inode_zone(inode);
 
index 49d93f53878565753aa628c9ddce14e6d0daf02c..6fc1c858013d1e4dda4ed38fa4083acf25d16d36 100644 (file)
@@ -318,7 +318,7 @@ struct iomap_writeback_ops {
         * by the file system if it is still valid.
         */
        int (*map_blocks)(struct iomap_writepage_ctx *wpc, struct inode *inode,
-                               loff_t offset);
+                         loff_t offset, unsigned len);
 
        /*
         * Optional, allows the file systems to perform actions just before