From df0db3ecdb8fc942e9d812558b8e15ecd3e050b1 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Tue, 30 Apr 2019 08:45:34 -0700 Subject: iomap: Add a page_prepare callback Move the page_done callback into a separate iomap_page_ops structure and add a page_prepare calback to be called before the next page is written to. In gfs2, we'll want to start a transaction in page_prepare and end it in page_done. Other filesystems that implement data journaling will require the same kind of mechanism. Signed-off-by: Andreas Gruenbacher Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- include/linux/iomap.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'include/linux/iomap.h') diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 0fefb5455bda..2103b94cb1bf 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -53,6 +53,8 @@ struct vm_fault; */ #define IOMAP_NULL_ADDR -1ULL /* addr is not valid */ +struct iomap_page_ops; + struct iomap { u64 addr; /* disk offset of mapping, bytes */ loff_t offset; /* file offset of mapping, bytes */ @@ -63,12 +65,22 @@ struct iomap { struct dax_device *dax_dev; /* dax_dev for dax operations */ void *inline_data; void *private; /* filesystem private */ + const struct iomap_page_ops *page_ops; +}; - /* - * Called when finished processing a page in the mapping returned in - * this iomap. At least for now this is only supported in the buffered - * write path. - */ +/* + * When a filesystem sets page_ops in an iomap mapping it returns, page_prepare + * and page_done will be called for each page written to. This only applies to + * buffered writes as unbuffered writes will not typically have pages + * associated with them. + * + * When page_prepare succeeds, page_done will always be called to do any + * cleanup work necessary. In that page_done call, @page will be NULL if the + * associated page could not be obtained. + */ +struct iomap_page_ops { + int (*page_prepare)(struct inode *inode, loff_t pos, unsigned len, + struct iomap *iomap); void (*page_done)(struct inode *inode, loff_t pos, unsigned copied, struct page *page, struct iomap *iomap); }; -- cgit v1.2.3-59-g8ed1b