[PATCH 1/2] iomap: Add a page_prepare callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a page_prepare calback that's called before a page is written to.  This
will be used by gfs2 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@xxxxxxxxxx>
---
 fs/iomap.c            | 4 ++++
 include/linux/iomap.h | 9 ++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index 97cb9d486a7d..abd9aa76dbd1 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -684,6 +684,10 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
 		status = __block_write_begin_int(page, pos, len, NULL, iomap);
 	else
 		status = __iomap_write_begin(inode, pos, len, page, iomap);
+
+	if (likely(!status) && iomap->page_prepare)
+		status = iomap->page_prepare(inode, pos, len, page, iomap);
+
 	if (unlikely(status)) {
 		unlock_page(page);
 		put_page(page);
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 0fefb5455bda..0982f3e13e56 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -65,10 +65,13 @@ struct iomap {
 	void			*private; /* filesystem private */
 
 	/*
-	 * 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.
+	 * Called before / after processing a page in the mapping returned in
+	 * this iomap.  At least for now, this is only supported in the
+	 * buffered write path.  When page_prepare returns 0 for a page,
+	 * page_done is called for that page as well.
 	 */
+	int (*page_prepare)(struct inode *inode, loff_t pos, unsigned len,
+			struct page *page, struct iomap *iomap);
 	void (*page_done)(struct inode *inode, loff_t pos, unsigned copied,
 			struct page *page, struct iomap *iomap);
 };
-- 
2.20.1




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux