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 <agruenba@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:

committed by
Darrick J. Wong

parent
7a77dad7e3
commit
df0db3ecdb
@@ -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);
|
||||
};
|
||||
|
Reference in New Issue
Block a user