History

iomap: lift the xfs writeback code to iomap

Take the xfs writeback code and move it to fs/iomap. A new structure with three methods is added as the abstraction from the generic writeback code to the file system. These methods are used to map blocks, submit an ioend, and cancel a page that encountered an error before it was added to an ioend.

Christoph Hellwig committed 7 years ago

Commit 598ecfb1 parent 9e91c577 files · +669 −648Browse files

Showing the changes to include/linux (1 of 7 files). Show all

Unified · Split

include/linux/iomap.h+59−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
44
55 #include <linux/atomic.h>
66 #include <linux/bitmap.h>
7+#include <linux/blk_types.h>
78 #include <linux/mm.h>
89 #include <linux/types.h>
910 #include <linux/mm_types.h>
@@ -12,6 +13,7 @@ · 2 unmodified lines
1213 struct address_space;
1314 struct fiemap_extent_info;
1415 struct inode;
16+struct iomap_writepage_ctx;
1517 struct iov_iter;
1618 struct kiocb;
1719 struct page;
@@ -185,6 +187,63 @@ loff_t iomap_seek_data(struct inode *inode, loff_t offset, · 167 unmodified lines
185187 sector_t iomap_bmap(struct address_space *mapping, sector_t bno,
186188 const struct iomap_ops *ops);
187189
190+/*
191+ * Structure for writeback I/O completions.
192+ */
193+struct iomap_ioend {
194+ struct list_head io_list; /* next ioend in chain */
195+ u16 io_type;
196+ u16 io_flags; /* IOMAP_F_* */
197+ struct inode *io_inode; /* file being written to */
198+ size_t io_size; /* size of the extent */
199+ loff_t io_offset; /* offset in the file */
200+ void *io_private; /* file system private data */
201+ struct bio *io_bio; /* bio being built */
202+ struct bio io_inline_bio; /* MUST BE LAST! */
203+};
204+
205+struct iomap_writeback_ops {
206+ /*
207+ * Required, maps the blocks so that writeback can be performed on
208+ * the range starting at offset.
209+ */
210+ int (*map_blocks)(struct iomap_writepage_ctx *wpc, struct inode *inode,
211+ loff_t offset);
212+
213+ /*
214+ * Optional, allows the file systems to perform actions just before
215+ * submitting the bio and/or override the bio end_io handler for complex
216+ * operations like copy on write extent manipulation or unwritten extent
217+ * conversions.
218+ */
219+ int (*prepare_ioend)(struct iomap_ioend *ioend, int status);
220+
221+ /*
222+ * Optional, allows the file system to discard state on a page where
223+ * we failed to submit any I/O.
224+ */
225+ void (*discard_page)(struct page *page);
226+};
227+
228+struct iomap_writepage_ctx {
229+ struct iomap iomap;
230+ struct iomap_ioend *ioend;
231+ const struct iomap_writeback_ops *ops;
232+};
233+
234+void iomap_finish_ioends(struct iomap_ioend *ioend, int error);
235+void iomap_ioend_try_merge(struct iomap_ioend *ioend,
236+ struct list_head *more_ioends,
237+ void (*merge_private)(struct iomap_ioend *ioend,
238+ struct iomap_ioend *next));
239+void iomap_sort_ioends(struct list_head *ioend_list);
240+int iomap_writepage(struct page *page, struct writeback_control *wbc,
241+ struct iomap_writepage_ctx *wpc,
242+ const struct iomap_writeback_ops *ops);
243+int iomap_writepages(struct address_space *mapping,
244+ struct writeback_control *wbc, struct iomap_writepage_ctx *wpc,
245+ const struct iomap_writeback_ops *ops);
246+
188247 /*
189248 * Flags for direct I/O ->end_io:
190249 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t