Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Christoph Hellwig | 199a31c | 2016-06-21 09:22:39 +1000 | [diff] [blame] | 2 | #ifndef LINUX_IOMAP_H |
| 3 | #define LINUX_IOMAP_H 1 |
| 4 | |
Christoph Hellwig | 9dc55f1 | 2018-07-11 22:26:05 -0700 | [diff] [blame] | 5 | #include <linux/atomic.h> |
| 6 | #include <linux/bitmap.h> |
Christoph Hellwig | 598ecfb | 2019-10-17 13:12:15 -0700 | [diff] [blame] | 7 | #include <linux/blk_types.h> |
Christoph Hellwig | 9dc55f1 | 2018-07-11 22:26:05 -0700 | [diff] [blame] | 8 | #include <linux/mm.h> |
Christoph Hellwig | 199a31c | 2016-06-21 09:22:39 +1000 | [diff] [blame] | 9 | #include <linux/types.h> |
Souptick Joarder | 5780a02 | 2018-10-26 15:02:59 -0700 | [diff] [blame] | 10 | #include <linux/mm_types.h> |
Darrick J. Wong | db07443 | 2019-07-15 08:50:59 -0700 | [diff] [blame] | 11 | #include <linux/blkdev.h> |
Christoph Hellwig | 199a31c | 2016-06-21 09:22:39 +1000 | [diff] [blame] | 12 | |
Christoph Hellwig | 89eb190 | 2018-06-01 09:03:08 -0700 | [diff] [blame] | 13 | struct address_space; |
Christoph Hellwig | 8be9f56 | 2016-06-21 09:38:45 +1000 | [diff] [blame] | 14 | struct fiemap_extent_info; |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 15 | struct inode; |
Christoph Hellwig | c3d4ed1 | 2020-09-28 08:51:08 -0700 | [diff] [blame] | 16 | struct iomap_dio; |
Christoph Hellwig | 598ecfb | 2019-10-17 13:12:15 -0700 | [diff] [blame] | 17 | struct iomap_writepage_ctx; |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 18 | struct iov_iter; |
| 19 | struct kiocb; |
Christoph Hellwig | 63899c6 | 2018-06-19 15:10:56 -0700 | [diff] [blame] | 20 | struct page; |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 21 | struct vm_area_struct; |
| 22 | struct vm_fault; |
| 23 | |
| 24 | /* |
| 25 | * Types of block ranges for iomap mappings: |
| 26 | */ |
Christoph Hellwig | eb81cf9 | 2019-10-18 16:43:08 -0700 | [diff] [blame] | 27 | #define IOMAP_HOLE 0 /* no blocks allocated, need allocation */ |
| 28 | #define IOMAP_DELALLOC 1 /* delayed allocation blocks */ |
| 29 | #define IOMAP_MAPPED 2 /* blocks allocated at @addr */ |
| 30 | #define IOMAP_UNWRITTEN 3 /* blocks allocated at @addr in unwritten state */ |
| 31 | #define IOMAP_INLINE 4 /* data inline in the inode */ |
Christoph Hellwig | 199a31c | 2016-06-21 09:22:39 +1000 | [diff] [blame] | 32 | |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 33 | /* |
Christoph Hellwig | 65a60e8 | 2019-10-18 16:40:17 -0700 | [diff] [blame] | 34 | * Flags reported by the file system from iomap_begin: |
| 35 | * |
| 36 | * IOMAP_F_NEW indicates that the blocks have been newly allocated and need |
| 37 | * zeroing for areas that no data is copied to. |
Linus Torvalds | a3841f9 | 2017-11-17 09:51:57 -0800 | [diff] [blame] | 38 | * |
Jan Kara | caa51d2 | 2017-11-01 16:36:42 +0100 | [diff] [blame] | 39 | * IOMAP_F_DIRTY indicates the inode has uncommitted metadata needed to access |
| 40 | * written data and requires fdatasync to commit them to persistent storage. |
Dave Chinner | 7684e2c | 2019-10-17 13:12:01 -0700 | [diff] [blame] | 41 | * This needs to take into account metadata changes that *may* be made at IO |
| 42 | * completion, such as file size updates from direct IO. |
Christoph Hellwig | 65a60e8 | 2019-10-18 16:40:17 -0700 | [diff] [blame] | 43 | * |
| 44 | * IOMAP_F_SHARED indicates that the blocks are shared, and will need to be |
| 45 | * unshared as part a write. |
| 46 | * |
| 47 | * IOMAP_F_MERGED indicates that the iomap contains the merge of multiple block |
| 48 | * mappings. |
| 49 | * |
| 50 | * IOMAP_F_BUFFER_HEAD indicates that the file system requires the use of |
| 51 | * buffer heads for this mapping. |
Christoph Hellwig | 17de0a9 | 2016-08-29 11:33:58 +1000 | [diff] [blame] | 52 | */ |
Christoph Hellwig | 65a60e8 | 2019-10-18 16:40:17 -0700 | [diff] [blame] | 53 | #define IOMAP_F_NEW 0x01 |
| 54 | #define IOMAP_F_DIRTY 0x02 |
| 55 | #define IOMAP_F_SHARED 0x04 |
| 56 | #define IOMAP_F_MERGED 0x08 |
| 57 | #define IOMAP_F_BUFFER_HEAD 0x10 |
Naohiro Aota | c3b0e88 | 2021-02-04 19:21:41 +0900 | [diff] [blame] | 58 | #define IOMAP_F_ZONE_APPEND 0x20 |
Christoph Hellwig | d33fd77 | 2016-10-20 15:51:28 +1100 | [diff] [blame] | 59 | |
| 60 | /* |
Christoph Hellwig | 65a60e8 | 2019-10-18 16:40:17 -0700 | [diff] [blame] | 61 | * Flags set by the core iomap code during operations: |
| 62 | * |
| 63 | * IOMAP_F_SIZE_CHANGED indicates to the iomap_end method that the file size |
| 64 | * has changed as the result of this write operation. |
Christoph Hellwig | d33fd77 | 2016-10-20 15:51:28 +1100 | [diff] [blame] | 65 | */ |
Christoph Hellwig | 65a60e8 | 2019-10-18 16:40:17 -0700 | [diff] [blame] | 66 | #define IOMAP_F_SIZE_CHANGED 0x100 |
Christoph Hellwig | 17de0a9 | 2016-08-29 11:33:58 +1000 | [diff] [blame] | 67 | |
| 68 | /* |
Christoph Hellwig | 7ee66c0 | 2018-06-01 09:03:07 -0700 | [diff] [blame] | 69 | * Flags from 0x1000 up are for file system specific usage: |
| 70 | */ |
| 71 | #define IOMAP_F_PRIVATE 0x1000 |
| 72 | |
| 73 | |
| 74 | /* |
Andreas Gruenbacher | 19fe5f6 | 2017-10-01 17:55:54 -0400 | [diff] [blame] | 75 | * Magic value for addr: |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 76 | */ |
Andreas Gruenbacher | 19fe5f6 | 2017-10-01 17:55:54 -0400 | [diff] [blame] | 77 | #define IOMAP_NULL_ADDR -1ULL /* addr is not valid */ |
Christoph Hellwig | 199a31c | 2016-06-21 09:22:39 +1000 | [diff] [blame] | 78 | |
Andreas Gruenbacher | df0db3e | 2019-04-30 08:45:34 -0700 | [diff] [blame] | 79 | struct iomap_page_ops; |
| 80 | |
Christoph Hellwig | 199a31c | 2016-06-21 09:22:39 +1000 | [diff] [blame] | 81 | struct iomap { |
Andreas Gruenbacher | 19fe5f6 | 2017-10-01 17:55:54 -0400 | [diff] [blame] | 82 | u64 addr; /* disk offset of mapping, bytes */ |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 83 | loff_t offset; /* file offset of mapping, bytes */ |
| 84 | u64 length; /* length of mapping, bytes */ |
Christoph Hellwig | 17de0a9 | 2016-08-29 11:33:58 +1000 | [diff] [blame] | 85 | u16 type; /* type of mapping */ |
| 86 | u16 flags; /* flags for mapping */ |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 87 | struct block_device *bdev; /* block device for I/O */ |
Dan Williams | fa5d932 | 2017-01-27 12:04:59 -0800 | [diff] [blame] | 88 | struct dax_device *dax_dev; /* dax_dev for dax operations */ |
Andreas Gruenbacher | 19e0c58 | 2018-06-19 15:10:56 -0700 | [diff] [blame] | 89 | void *inline_data; |
Andreas Gruenbacher | e184fde | 2018-06-19 15:10:57 -0700 | [diff] [blame] | 90 | void *private; /* filesystem private */ |
Andreas Gruenbacher | df0db3e | 2019-04-30 08:45:34 -0700 | [diff] [blame] | 91 | const struct iomap_page_ops *page_ops; |
| 92 | }; |
Christoph Hellwig | 63899c6 | 2018-06-19 15:10:56 -0700 | [diff] [blame] | 93 | |
Christoph Hellwig | 66b8165 | 2021-08-10 18:33:04 -0700 | [diff] [blame] | 94 | static inline sector_t iomap_sector(const struct iomap *iomap, loff_t pos) |
Darrick J. Wong | db07443 | 2019-07-15 08:50:59 -0700 | [diff] [blame] | 95 | { |
| 96 | return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT; |
| 97 | } |
| 98 | |
Andreas Gruenbacher | df0db3e | 2019-04-30 08:45:34 -0700 | [diff] [blame] | 99 | /* |
Gao Xiang | 69f4a26 | 2021-08-03 09:38:22 -0700 | [diff] [blame] | 100 | * Returns the inline data pointer for logical offset @pos. |
| 101 | */ |
Christoph Hellwig | 4495c33 | 2021-08-10 18:33:04 -0700 | [diff] [blame^] | 102 | static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos) |
Gao Xiang | 69f4a26 | 2021-08-03 09:38:22 -0700 | [diff] [blame] | 103 | { |
| 104 | return iomap->inline_data + pos - iomap->offset; |
| 105 | } |
| 106 | |
| 107 | /* |
| 108 | * Check if the mapping's length is within the valid range for inline data. |
| 109 | * This is used to guard against accessing data beyond the page inline_data |
| 110 | * points at. |
| 111 | */ |
| 112 | static inline bool iomap_inline_data_valid(struct iomap *iomap) |
| 113 | { |
| 114 | return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data); |
| 115 | } |
| 116 | |
| 117 | /* |
Andreas Gruenbacher | df0db3e | 2019-04-30 08:45:34 -0700 | [diff] [blame] | 118 | * When a filesystem sets page_ops in an iomap mapping it returns, page_prepare |
| 119 | * and page_done will be called for each page written to. This only applies to |
| 120 | * buffered writes as unbuffered writes will not typically have pages |
| 121 | * associated with them. |
| 122 | * |
| 123 | * When page_prepare succeeds, page_done will always be called to do any |
| 124 | * cleanup work necessary. In that page_done call, @page will be NULL if the |
| 125 | * associated page could not be obtained. |
| 126 | */ |
| 127 | struct iomap_page_ops { |
Christoph Hellwig | 1d25d0a | 2021-08-10 18:33:03 -0700 | [diff] [blame] | 128 | int (*page_prepare)(struct inode *inode, loff_t pos, unsigned len); |
Christoph Hellwig | 63899c6 | 2018-06-19 15:10:56 -0700 | [diff] [blame] | 129 | void (*page_done)(struct inode *inode, loff_t pos, unsigned copied, |
Christoph Hellwig | 1d25d0a | 2021-08-10 18:33:03 -0700 | [diff] [blame] | 130 | struct page *page); |
Christoph Hellwig | 199a31c | 2016-06-21 09:22:39 +1000 | [diff] [blame] | 131 | }; |
| 132 | |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 133 | /* |
| 134 | * Flags for iomap_begin / iomap_end. No flag implies a read. |
| 135 | */ |
Christoph Hellwig | d33fd77 | 2016-10-20 15:51:28 +1100 | [diff] [blame] | 136 | #define IOMAP_WRITE (1 << 0) /* writing, must allocate blocks */ |
| 137 | #define IOMAP_ZERO (1 << 1) /* zeroing operation, may skip holes */ |
| 138 | #define IOMAP_REPORT (1 << 2) /* report extent status, e.g. FIEMAP */ |
Jan Kara | 9484ab1 | 2016-11-10 10:26:50 +1100 | [diff] [blame] | 139 | #define IOMAP_FAULT (1 << 3) /* mapping for page fault */ |
Christoph Hellwig | ff6a929 | 2016-11-30 14:36:01 +1100 | [diff] [blame] | 140 | #define IOMAP_DIRECT (1 << 4) /* direct I/O */ |
Christoph Hellwig | 9ecac0e | 2018-06-01 09:03:07 -0700 | [diff] [blame] | 141 | #define IOMAP_NOWAIT (1 << 5) /* do not block */ |
Christoph Hellwig | 213f627 | 2021-01-23 10:06:10 -0800 | [diff] [blame] | 142 | #define IOMAP_OVERWRITE_ONLY (1 << 6) /* only pure overwrites allowed */ |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 143 | |
| 144 | struct iomap_ops { |
| 145 | /* |
| 146 | * Return the existing mapping at pos, or reserve space starting at |
| 147 | * pos for up to length, as long as we can do it as a single mapping. |
| 148 | * The actual length is returned in iomap->length. |
| 149 | */ |
| 150 | int (*iomap_begin)(struct inode *inode, loff_t pos, loff_t length, |
Goldwyn Rodrigues | c039b99 | 2019-10-18 16:44:10 -0700 | [diff] [blame] | 151 | unsigned flags, struct iomap *iomap, |
| 152 | struct iomap *srcmap); |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 153 | |
| 154 | /* |
| 155 | * Commit and/or unreserve space previous allocated using iomap_begin. |
| 156 | * Written indicates the length of the successful write operation which |
| 157 | * needs to be commited, while the rest needs to be unreserved. |
| 158 | * Written might be zero if no data was written. |
| 159 | */ |
| 160 | int (*iomap_end)(struct inode *inode, loff_t pos, loff_t length, |
| 161 | ssize_t written, unsigned flags, struct iomap *iomap); |
| 162 | }; |
| 163 | |
Christoph Hellwig | 9dc55f1 | 2018-07-11 22:26:05 -0700 | [diff] [blame] | 164 | /* |
Darrick J. Wong | 5d907307 | 2019-07-15 08:51:01 -0700 | [diff] [blame] | 165 | * Main iomap iterator function. |
| 166 | */ |
| 167 | typedef loff_t (*iomap_actor_t)(struct inode *inode, loff_t pos, loff_t len, |
Goldwyn Rodrigues | c039b99 | 2019-10-18 16:44:10 -0700 | [diff] [blame] | 168 | void *data, struct iomap *iomap, struct iomap *srcmap); |
Darrick J. Wong | 5d907307 | 2019-07-15 08:51:01 -0700 | [diff] [blame] | 169 | |
| 170 | loff_t iomap_apply(struct inode *inode, loff_t pos, loff_t length, |
| 171 | unsigned flags, const struct iomap_ops *ops, void *data, |
| 172 | iomap_actor_t actor); |
| 173 | |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 174 | ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from, |
Christoph Hellwig | 8ff6daa | 2017-01-27 23:20:26 -0800 | [diff] [blame] | 175 | const struct iomap_ops *ops); |
Christoph Hellwig | 72b4daa | 2018-06-19 15:10:57 -0700 | [diff] [blame] | 176 | int iomap_readpage(struct page *page, const struct iomap_ops *ops); |
Matthew Wilcox (Oracle) | 9d24a13 | 2020-06-01 21:47:34 -0700 | [diff] [blame] | 177 | void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops); |
Christoph Hellwig | 9dc55f1 | 2018-07-11 22:26:05 -0700 | [diff] [blame] | 178 | int iomap_is_partially_uptodate(struct page *page, unsigned long from, |
| 179 | unsigned long count); |
| 180 | int iomap_releasepage(struct page *page, gfp_t gfp_mask); |
| 181 | void iomap_invalidatepage(struct page *page, unsigned int offset, |
| 182 | unsigned int len); |
| 183 | #ifdef CONFIG_MIGRATION |
| 184 | int iomap_migrate_page(struct address_space *mapping, struct page *newpage, |
| 185 | struct page *page, enum migrate_mode mode); |
| 186 | #else |
| 187 | #define iomap_migrate_page NULL |
| 188 | #endif |
Christoph Hellwig | 3590c4d | 2019-10-18 16:41:34 -0700 | [diff] [blame] | 189 | int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len, |
Christoph Hellwig | 8ff6daa | 2017-01-27 23:20:26 -0800 | [diff] [blame] | 190 | const struct iomap_ops *ops); |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 191 | int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len, |
Christoph Hellwig | 8ff6daa | 2017-01-27 23:20:26 -0800 | [diff] [blame] | 192 | bool *did_zero, const struct iomap_ops *ops); |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 193 | int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, |
Christoph Hellwig | 8ff6daa | 2017-01-27 23:20:26 -0800 | [diff] [blame] | 194 | const struct iomap_ops *ops); |
Souptick Joarder | 5780a02 | 2018-10-26 15:02:59 -0700 | [diff] [blame] | 195 | vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, |
| 196 | const struct iomap_ops *ops); |
Christoph Hellwig | 8be9f56 | 2016-06-21 09:38:45 +1000 | [diff] [blame] | 197 | int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
Christoph Hellwig | 2732881 | 2020-05-23 09:30:12 +0200 | [diff] [blame] | 198 | u64 start, u64 len, const struct iomap_ops *ops); |
Andreas Gruenbacher | 0ed3b0d | 2017-06-29 11:43:21 -0700 | [diff] [blame] | 199 | loff_t iomap_seek_hole(struct inode *inode, loff_t offset, |
| 200 | const struct iomap_ops *ops); |
| 201 | loff_t iomap_seek_data(struct inode *inode, loff_t offset, |
| 202 | const struct iomap_ops *ops); |
Christoph Hellwig | 89eb190 | 2018-06-01 09:03:08 -0700 | [diff] [blame] | 203 | sector_t iomap_bmap(struct address_space *mapping, sector_t bno, |
| 204 | const struct iomap_ops *ops); |
Christoph Hellwig | ae259a9 | 2016-06-21 09:23:11 +1000 | [diff] [blame] | 205 | |
Christoph Hellwig | ff6a929 | 2016-11-30 14:36:01 +1100 | [diff] [blame] | 206 | /* |
Christoph Hellwig | 598ecfb | 2019-10-17 13:12:15 -0700 | [diff] [blame] | 207 | * Structure for writeback I/O completions. |
| 208 | */ |
| 209 | struct iomap_ioend { |
| 210 | struct list_head io_list; /* next ioend in chain */ |
| 211 | u16 io_type; |
| 212 | u16 io_flags; /* IOMAP_F_* */ |
| 213 | struct inode *io_inode; /* file being written to */ |
| 214 | size_t io_size; /* size of the extent */ |
| 215 | loff_t io_offset; /* offset in the file */ |
Christoph Hellwig | 598ecfb | 2019-10-17 13:12:15 -0700 | [diff] [blame] | 216 | struct bio *io_bio; /* bio being built */ |
| 217 | struct bio io_inline_bio; /* MUST BE LAST! */ |
| 218 | }; |
| 219 | |
| 220 | struct iomap_writeback_ops { |
| 221 | /* |
| 222 | * Required, maps the blocks so that writeback can be performed on |
| 223 | * the range starting at offset. |
| 224 | */ |
| 225 | int (*map_blocks)(struct iomap_writepage_ctx *wpc, struct inode *inode, |
| 226 | loff_t offset); |
| 227 | |
| 228 | /* |
| 229 | * Optional, allows the file systems to perform actions just before |
| 230 | * submitting the bio and/or override the bio end_io handler for complex |
| 231 | * operations like copy on write extent manipulation or unwritten extent |
| 232 | * conversions. |
| 233 | */ |
| 234 | int (*prepare_ioend)(struct iomap_ioend *ioend, int status); |
| 235 | |
| 236 | /* |
| 237 | * Optional, allows the file system to discard state on a page where |
| 238 | * we failed to submit any I/O. |
| 239 | */ |
Brian Foster | 763e4cd | 2020-10-29 14:30:48 -0700 | [diff] [blame] | 240 | void (*discard_page)(struct page *page, loff_t fileoff); |
Christoph Hellwig | 598ecfb | 2019-10-17 13:12:15 -0700 | [diff] [blame] | 241 | }; |
| 242 | |
| 243 | struct iomap_writepage_ctx { |
| 244 | struct iomap iomap; |
| 245 | struct iomap_ioend *ioend; |
| 246 | const struct iomap_writeback_ops *ops; |
| 247 | }; |
| 248 | |
| 249 | void iomap_finish_ioends(struct iomap_ioend *ioend, int error); |
| 250 | void iomap_ioend_try_merge(struct iomap_ioend *ioend, |
Brian Foster | 6e55249 | 2021-05-04 08:54:29 -0700 | [diff] [blame] | 251 | struct list_head *more_ioends); |
Christoph Hellwig | 598ecfb | 2019-10-17 13:12:15 -0700 | [diff] [blame] | 252 | void iomap_sort_ioends(struct list_head *ioend_list); |
| 253 | int iomap_writepage(struct page *page, struct writeback_control *wbc, |
| 254 | struct iomap_writepage_ctx *wpc, |
| 255 | const struct iomap_writeback_ops *ops); |
| 256 | int iomap_writepages(struct address_space *mapping, |
| 257 | struct writeback_control *wbc, struct iomap_writepage_ctx *wpc, |
| 258 | const struct iomap_writeback_ops *ops); |
| 259 | |
| 260 | /* |
Christoph Hellwig | ff6a929 | 2016-11-30 14:36:01 +1100 | [diff] [blame] | 261 | * Flags for direct I/O ->end_io: |
| 262 | */ |
| 263 | #define IOMAP_DIO_UNWRITTEN (1 << 0) /* covers unwritten extent(s) */ |
| 264 | #define IOMAP_DIO_COW (1 << 1) /* covers COW extent(s) */ |
Christoph Hellwig | 838c4f3 | 2019-09-19 15:32:45 -0700 | [diff] [blame] | 265 | |
| 266 | struct iomap_dio_ops { |
| 267 | int (*end_io)(struct kiocb *iocb, ssize_t size, int error, |
| 268 | unsigned flags); |
Goldwyn Rodrigues | 8cecd0b | 2019-05-14 18:54:27 -0500 | [diff] [blame] | 269 | blk_qc_t (*submit_io)(struct inode *inode, struct iomap *iomap, |
| 270 | struct bio *bio, loff_t file_offset); |
Christoph Hellwig | 838c4f3 | 2019-09-19 15:32:45 -0700 | [diff] [blame] | 271 | }; |
| 272 | |
Christoph Hellwig | 2f63296 | 2021-01-23 10:06:09 -0800 | [diff] [blame] | 273 | /* |
| 274 | * Wait for the I/O to complete in iomap_dio_rw even if the kiocb is not |
| 275 | * synchronous. |
| 276 | */ |
| 277 | #define IOMAP_DIO_FORCE_WAIT (1 << 0) |
| 278 | |
Christoph Hellwig | 213f627 | 2021-01-23 10:06:10 -0800 | [diff] [blame] | 279 | /* |
| 280 | * Do not allocate blocks or zero partial blocks, but instead fall back to |
| 281 | * the caller by returning -EAGAIN. Used to optimize direct I/O writes that |
| 282 | * are not aligned to the file system block size. |
| 283 | */ |
| 284 | #define IOMAP_DIO_OVERWRITE_ONLY (1 << 1) |
| 285 | |
Christoph Hellwig | ff6a929 | 2016-11-30 14:36:01 +1100 | [diff] [blame] | 286 | ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, |
Jan Kara | 13ef954 | 2019-10-15 08:43:42 -0700 | [diff] [blame] | 287 | const struct iomap_ops *ops, const struct iomap_dio_ops *dops, |
Christoph Hellwig | 2f63296 | 2021-01-23 10:06:09 -0800 | [diff] [blame] | 288 | unsigned int dio_flags); |
Christoph Hellwig | c3d4ed1 | 2020-09-28 08:51:08 -0700 | [diff] [blame] | 289 | struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, |
| 290 | const struct iomap_ops *ops, const struct iomap_dio_ops *dops, |
Christoph Hellwig | 2f63296 | 2021-01-23 10:06:09 -0800 | [diff] [blame] | 291 | unsigned int dio_flags); |
Christoph Hellwig | c3d4ed1 | 2020-09-28 08:51:08 -0700 | [diff] [blame] | 292 | ssize_t iomap_dio_complete(struct iomap_dio *dio); |
Christoph Hellwig | 81214ba | 2018-12-04 11:12:08 -0700 | [diff] [blame] | 293 | int iomap_dio_iopoll(struct kiocb *kiocb, bool spin); |
Christoph Hellwig | ff6a929 | 2016-11-30 14:36:01 +1100 | [diff] [blame] | 294 | |
Darrick J. Wong | 67482129 | 2018-05-10 08:38:15 -0700 | [diff] [blame] | 295 | #ifdef CONFIG_SWAP |
| 296 | struct file; |
| 297 | struct swap_info_struct; |
| 298 | |
| 299 | int iomap_swapfile_activate(struct swap_info_struct *sis, |
| 300 | struct file *swap_file, sector_t *pagespan, |
| 301 | const struct iomap_ops *ops); |
| 302 | #else |
| 303 | # define iomap_swapfile_activate(sis, swapfile, pagespan, ops) (-EIO) |
| 304 | #endif /* CONFIG_SWAP */ |
| 305 | |
Christoph Hellwig | 199a31c | 2016-06-21 09:22:39 +1000 | [diff] [blame] | 306 | #endif /* LINUX_IOMAP_H */ |