On Fri, Aug 02, 2019 at 05:00:36PM -0500, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
>
> Introduces a new type IOMAP_COW, which means the data at offset
> must be read from a srcmap and copied before performing the
> write on the offset.
>
> The srcmap is used to identify where the read is to be performed
> from. This is passed to iomap->begin() of the respective
> filesystem, which is supposed to put in the details for
> reading before performing the copy for CoW.
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
> ---
> fs/dax.c | 8 +++++---
> fs/ext2/inode.c | 2 +-
> fs/ext4/inode.c | 2 +-
> fs/gfs2/bmap.c | 3 ++-
> fs/iomap/apply.c | 5 +++--
> fs/iomap/buffered-io.c | 14 +++++++-------
> fs/iomap/direct-io.c | 2 +-
> fs/iomap/fiemap.c | 4 ++--
> fs/iomap/seek.c | 4 ++--
> fs/iomap/swapfile.c | 3 ++-
> fs/xfs/xfs_iomap.c | 9 ++++++---
> include/linux/iomap.h | 6 ++++--
> 12 files changed, 36 insertions(+), 26 deletions(-)
>
> diff --git a/fs/dax.c b/fs/dax.c
> index a237141d8787..b21d9a9cde2b 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -1090,7 +1090,7 @@ EXPORT_SYMBOL_GPL(__dax_zero_page_range);
>
> static loff_t
> dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
> - struct iomap *iomap)
> + struct iomap *iomap, struct iomap *srcmap)
> {
> struct block_device *bdev = iomap->bdev;
> struct dax_device *dax_dev = iomap->dax_dev;
> @@ -1248,6 +1248,7 @@ static vm_fault_t dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp,
> unsigned long vaddr = vmf->address;
> loff_t pos = (loff_t)vmf->pgoff << PAGE_SHIFT;
> struct iomap iomap = { 0 };
> + struct iomap srcmap = { 0 };
I'm not found of defining multiple iomaps everywhere and passing
them explicitly to every function that might need them. Perhaps
something like:
DEFINE_IOMAP(iomap);
#define IOMAP_BASE_MAP 0
#define IOMAP_SOURCE_MAP 1
#define IOMAP_MAX_MAPS 2
#define DEFINE_IOMAP(name) \
(struct iomap #name[IOMAP_MAX_MAPS] = {{0}})
#define IOMAP_B(name) ((name)[IOMAP_BASE_MAP])
#define IOMAP_S(name) ((name)[IOMAP_SOURCE_MAP])
And now we only have to pass a single iomap parameter to each
function as "struct iomap **iomap". This makes the code somewhat
simpler, and we only ever need to use IOMAP_S(iomap) when
IOMAP_B(iomap)->type == IOMAP_COW.
The other advantage of this is that if we even need new
functionality that requires 2 (or more) iomaps, we don't have to
change APIs again....
Cheers,
Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx