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.
Showing the changes to include/linux (1 of 3 files). Show all
Unified · Split
| @@ -53,6 +53,8 @@ struct vm_fault; · 52 unmodified lines | ||
| 53 | 53 | */ |
| 54 | 54 | #define IOMAP_NULL_ADDR -1ULL /* addr is not valid */ |
| 55 | 55 | |
| 56 | +struct iomap_page_ops; | |
| 57 | + | |
| 56 | 58 | struct iomap { |
| 57 | 59 | u64 addr; /* disk offset of mapping, bytes */ |
| 58 | 60 | loff_t offset; /* file offset of mapping, bytes */ |
| @@ -63,12 +65,22 @@ struct iomap { · 4 unmodified lines | ||
| 63 | 65 | struct dax_device *dax_dev; /* dax_dev for dax operations */ |
| 64 | 66 | void *inline_data; |
| 65 | 67 | void *private; /* filesystem private */ |
| 68 | + const struct iomap_page_ops *page_ops; | |
| 69 | +}; | |
| 66 | 70 | |
| 67 | − /* | |
| 68 | − * Called when finished processing a page in the mapping returned in | |
| 69 | − * this iomap. At least for now this is only supported in the buffered | |
| 70 | − * write path. | |
| 71 | − */ | |
| 71 | +/* | |
| 72 | + * When a filesystem sets page_ops in an iomap mapping it returns, page_prepare | |
| 73 | + * and page_done will be called for each page written to. This only applies to | |
| 74 | + * buffered writes as unbuffered writes will not typically have pages | |
| 75 | + * associated with them. | |
| 76 | + * | |
| 77 | + * When page_prepare succeeds, page_done will always be called to do any | |
| 78 | + * cleanup work necessary. In that page_done call, @page will be NULL if the | |
| 79 | + * associated page could not be obtained. | |
| 80 | + */ | |
| 81 | +struct iomap_page_ops { | |
| 82 | + int (*page_prepare)(struct inode *inode, loff_t pos, unsigned len, | |
| 83 | + struct iomap *iomap); | |
| 72 | 84 | void (*page_done)(struct inode *inode, loff_t pos, unsigned copied, |
| 73 | 85 | struct page *page, struct iomap *iomap); |
| 74 | 86 | }; |