Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef LINUX_IOMAP_H
3#define LINUX_IOMAP_H 1
4
5#include <linux/atomic.h>
6#include <linux/bitmap.h>
7#include <linux/blk_types.h>
8#include <linux/mm.h>
9#include <linux/types.h>
10#include <linux/mm_types.h>
11#include <linux/blkdev.h>
12#include <linux/folio_batch.h>
13
14struct address_space;
15struct fiemap_extent_info;
16struct inode;
17struct iomap_iter;
18struct iomap_dio;
19struct iomap_writepage_ctx;
20struct iomap_read_folio_ctx;
21struct iov_iter;
22struct kiocb;
23struct page;
24struct vm_area_struct;
25struct vm_fault;
26
27/*
28 * Types of block ranges for iomap mappings:
29 */
30#define IOMAP_HOLE 0 /* no blocks allocated, need allocation */
31#define IOMAP_DELALLOC 1 /* delayed allocation blocks */
32#define IOMAP_MAPPED 2 /* blocks allocated at @addr */
33#define IOMAP_UNWRITTEN 3 /* blocks allocated at @addr in unwritten state */
34#define IOMAP_INLINE 4 /* data inline in the inode */
35
36/*
37 * Flags reported by the file system from iomap_begin:
38 *
39 * IOMAP_F_NEW indicates that the blocks have been newly allocated and need
40 * zeroing for areas that no data is copied to.
41 *
42 * IOMAP_F_DIRTY indicates the inode has uncommitted metadata needed to access
43 * written data and requires fdatasync to commit them to persistent storage.
44 * This needs to take into account metadata changes that *may* be made at IO
45 * completion, such as file size updates from direct IO.
46 *
47 * IOMAP_F_SHARED indicates that the blocks are shared, and will need to be
48 * unshared as part a write.
49 *
50 * IOMAP_F_MERGED indicates that the iomap contains the merge of multiple block
51 * mappings.
52 *
53 * IOMAP_F_BUFFER_HEAD indicates that the file system requires the use of
54 * buffer heads for this mapping.
55 *
56 * IOMAP_F_XATTR indicates that the iomap is for an extended attribute extent
57 * rather than a file data extent.
58 *
59 * IOMAP_F_BOUNDARY indicates that I/O and I/O completions for this iomap must
60 * never be merged with the mapping before it.
61 *
62 * IOMAP_F_ANON_WRITE indicates that (write) I/O does not have a target block
63 * assigned to it yet and the file system will do that in the bio submission
64 * handler, splitting the I/O as needed.
65 *
66 * IOMAP_F_ATOMIC_BIO indicates that (write) I/O will be issued as an atomic
67 * bio, i.e. set REQ_ATOMIC.
68 *
69 * IOMAP_F_INTEGRITY indicates that the filesystems handles integrity metadata.
70 */
71#define IOMAP_F_NEW (1U << 0)
72#define IOMAP_F_DIRTY (1U << 1)
73#define IOMAP_F_SHARED (1U << 2)
74#define IOMAP_F_MERGED (1U << 3)
75#ifdef CONFIG_BUFFER_HEAD
76#define IOMAP_F_BUFFER_HEAD (1U << 4)
77#else
78#define IOMAP_F_BUFFER_HEAD 0
79#endif /* CONFIG_BUFFER_HEAD */
80#define IOMAP_F_XATTR (1U << 5)
81#define IOMAP_F_BOUNDARY (1U << 6)
82#define IOMAP_F_ANON_WRITE (1U << 7)
83#define IOMAP_F_ATOMIC_BIO (1U << 8)
84#ifdef CONFIG_BLK_DEV_INTEGRITY
85#define IOMAP_F_INTEGRITY (1U << 9)
86#else
87#define IOMAP_F_INTEGRITY 0
88#endif /* CONFIG_BLK_DEV_INTEGRITY */
89
90/*
91 * Flag reserved for file system specific usage
92 */
93#define IOMAP_F_PRIVATE (1U << 12)
94
95/*
96 * Flags set by the core iomap code during operations:
97 *
98 * IOMAP_F_FOLIO_BATCH indicates that the folio batch mechanism is active
99 * for this operation, set by iomap_fill_dirty_folios().
100 *
101 * IOMAP_F_SIZE_CHANGED indicates to the iomap_end method that the file size
102 * has changed as the result of this write operation.
103 *
104 * IOMAP_F_STALE indicates that the iomap is not valid any longer and the file
105 * range it covers needs to be remapped by the high level before the operation
106 * can proceed.
107 */
108#define IOMAP_F_FOLIO_BATCH (1U << 13)
109#define IOMAP_F_SIZE_CHANGED (1U << 14)
110#define IOMAP_F_STALE (1U << 15)
111
112/*
113 * Magic value for addr:
114 */
115#define IOMAP_NULL_ADDR -1ULL /* addr is not valid */
116
117struct iomap {
118 u64 addr; /* disk offset of mapping, bytes */
119 loff_t offset; /* file offset of mapping, bytes */
120 u64 length; /* length of mapping, bytes */
121 u16 type; /* type of mapping */
122 u16 flags; /* flags for mapping */
123 struct block_device *bdev; /* block device for I/O */
124 struct dax_device *dax_dev; /* dax_dev for dax operations */
125 void *inline_data;
126 void *private; /* filesystem private */
127 u64 validity_cookie; /* used with .iomap_valid() */
128};
129
130static inline sector_t iomap_sector(const struct iomap *iomap, loff_t pos)
131{
132 if (iomap->flags & IOMAP_F_ANON_WRITE)
133 return U64_MAX; /* invalid */
134 return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT;
135}
136
137/*
138 * Returns the inline data pointer for logical offset @pos.
139 */
140static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos)
141{
142 return iomap->inline_data + pos - iomap->offset;
143}
144
145/*
146 * Check if the mapping's length is within the valid range for inline data.
147 * This is used to guard against accessing data beyond the page inline_data
148 * points at.
149 */
150static inline bool iomap_inline_data_valid(const struct iomap *iomap)
151{
152 return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data);
153}
154
155/*
156 * When get_folio succeeds, put_folio will always be called to do any
157 * cleanup work necessary. put_folio is responsible for unlocking and putting
158 * @folio.
159 */
160struct iomap_write_ops {
161 struct folio *(*get_folio)(struct iomap_iter *iter, loff_t pos,
162 unsigned len);
163 void (*put_folio)(struct inode *inode, loff_t pos, unsigned copied,
164 struct folio *folio);
165
166 /*
167 * Check that the cached iomap still maps correctly to the filesystem's
168 * internal extent map. FS internal extent maps can change while iomap
169 * is iterating a cached iomap, so this hook allows iomap to detect that
170 * the iomap needs to be refreshed during a long running write
171 * operation.
172 *
173 * The filesystem can store internal state (e.g. a sequence number) in
174 * iomap->validity_cookie when the iomap is first mapped to be able to
175 * detect changes between mapping time and whenever .iomap_valid() is
176 * called.
177 *
178 * This is called with the folio over the specified file position held
179 * locked by the iomap code.
180 */
181 bool (*iomap_valid)(struct inode *inode, const struct iomap *iomap);
182
183 /*
184 * Optional if the filesystem wishes to provide a custom handler for
185 * reading in the contents of a folio, otherwise iomap will default to
186 * submitting a bio read request.
187 *
188 * The read must be done synchronously.
189 */
190 int (*read_folio_range)(const struct iomap_iter *iter,
191 struct folio *folio, loff_t pos, size_t len);
192};
193
194/*
195 * Flags for iomap_begin / iomap_end. No flag implies a read.
196 */
197#define IOMAP_WRITE (1 << 0) /* writing, must allocate blocks */
198#define IOMAP_ZERO (1 << 1) /* zeroing operation, may skip holes */
199#define IOMAP_REPORT (1 << 2) /* report extent status, e.g. FIEMAP */
200#define IOMAP_FAULT (1 << 3) /* mapping for page fault */
201#define IOMAP_DIRECT (1 << 4) /* direct I/O */
202#define IOMAP_NOWAIT (1 << 5) /* do not block */
203#define IOMAP_OVERWRITE_ONLY (1 << 6) /* only pure overwrites allowed */
204#define IOMAP_UNSHARE (1 << 7) /* unshare_file_range */
205#ifdef CONFIG_FS_DAX
206#define IOMAP_DAX (1 << 8) /* DAX mapping */
207#else
208#define IOMAP_DAX 0
209#endif /* CONFIG_FS_DAX */
210#define IOMAP_ATOMIC (1 << 9) /* torn-write protection */
211#define IOMAP_DONTCACHE (1 << 10)
212
213struct iomap_ops {
214 /*
215 * Return the existing mapping at pos, or reserve space starting at
216 * pos for up to length, as long as we can do it as a single mapping.
217 * The actual length is returned in iomap->length.
218 */
219 int (*iomap_begin)(struct inode *inode, loff_t pos, loff_t length,
220 unsigned flags, struct iomap *iomap,
221 struct iomap *srcmap);
222
223 /*
224 * Commit and/or unreserve space previous allocated using iomap_begin.
225 * Written indicates the length of the successful write operation which
226 * needs to be commited, while the rest needs to be unreserved.
227 * Written might be zero if no data was written.
228 */
229 int (*iomap_end)(struct inode *inode, loff_t pos, loff_t length,
230 ssize_t written, unsigned flags, struct iomap *iomap);
231};
232
233/**
234 * struct iomap_iter - Iterate through a range of a file
235 * @inode: Set at the start of the iteration and should not change.
236 * @pos: The current file position we are operating on. It is updated by
237 * calls to iomap_iter(). Treat as read-only in the body.
238 * @len: The remaining length of the file segment we're operating on.
239 * It is updated at the same time as @pos.
240 * @iter_start_pos: The original start pos for the current iomap. Used for
241 * incremental iter advance.
242 * @status: Status of the most recent iteration. Zero on success or a negative
243 * errno on error.
244 * @flags: Zero or more of the iomap_begin flags above.
245 * @iomap: Map describing the I/O iteration
246 * @srcmap: Source map for COW operations
247 */
248struct iomap_iter {
249 struct inode *inode;
250 loff_t pos;
251 u64 len;
252 loff_t iter_start_pos;
253 int status;
254 unsigned flags;
255 struct iomap iomap;
256 struct iomap srcmap;
257 struct folio_batch *fbatch;
258 void *private;
259};
260
261int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops);
262int iomap_iter_advance(struct iomap_iter *iter, u64 count);
263
264/**
265 * iomap_length_trim - trimmed length of the current iomap iteration
266 * @iter: iteration structure
267 * @pos: File position to trim from.
268 * @len: Length of the mapping to trim to.
269 *
270 * Returns a trimmed length that the operation applies to for the current
271 * iteration.
272 */
273static inline u64 iomap_length_trim(const struct iomap_iter *iter, loff_t pos,
274 u64 len)
275{
276 u64 end = iter->iomap.offset + iter->iomap.length;
277
278 if (iter->srcmap.type != IOMAP_HOLE)
279 end = min(end, iter->srcmap.offset + iter->srcmap.length);
280 return min(len, end - pos);
281}
282
283/**
284 * iomap_length - length of the current iomap iteration
285 * @iter: iteration structure
286 *
287 * Returns the length that the operation applies to for the current iteration.
288 */
289static inline u64 iomap_length(const struct iomap_iter *iter)
290{
291 return iomap_length_trim(iter, iter->pos, iter->len);
292}
293
294/**
295 * iomap_iter_advance_full - advance by the full length of current map
296 */
297static inline int iomap_iter_advance_full(struct iomap_iter *iter)
298{
299 return iomap_iter_advance(iter, iomap_length(iter));
300}
301
302/**
303 * iomap_iter_srcmap - return the source map for the current iomap iteration
304 * @i: iteration structure
305 *
306 * Write operations on file systems with reflink support might require a
307 * source and a destination map. This function retourns the source map
308 * for a given operation, which may or may no be identical to the destination
309 * map in &i->iomap.
310 */
311static inline const struct iomap *iomap_iter_srcmap(const struct iomap_iter *i)
312{
313 if (i->srcmap.type != IOMAP_HOLE)
314 return &i->srcmap;
315 return &i->iomap;
316}
317
318/*
319 * Return the file offset for the first unchanged block after a short write.
320 *
321 * If nothing was written, round @pos down to point at the first block in
322 * the range, else round up to include the partially written block.
323 */
324static inline loff_t iomap_last_written_block(struct inode *inode, loff_t pos,
325 ssize_t written)
326{
327 if (unlikely(!written))
328 return round_down(pos, i_blocksize(inode));
329 return round_up(pos + written, i_blocksize(inode));
330}
331
332/*
333 * Check if the range needs to be unshared for a FALLOC_FL_UNSHARE_RANGE
334 * operation.
335 *
336 * Don't bother with blocks that are not shared to start with; or mappings that
337 * cannot be shared, such as inline data, delalloc reservations, holes or
338 * unwritten extents.
339 *
340 * Note that we use srcmap directly instead of iomap_iter_srcmap as unsharing
341 * requires providing a separate source map, and the presence of one is a good
342 * indicator that unsharing is needed, unlike IOMAP_F_SHARED which can be set
343 * for any data that goes into the COW fork for XFS.
344 */
345static inline bool iomap_want_unshare_iter(const struct iomap_iter *iter)
346{
347 return (iter->iomap.flags & IOMAP_F_SHARED) &&
348 iter->srcmap.type == IOMAP_MAPPED;
349}
350
351ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
352 const struct iomap_ops *ops,
353 const struct iomap_write_ops *write_ops, void *private);
354void iomap_read_folio(const struct iomap_ops *ops,
355 struct iomap_read_folio_ctx *ctx, void *private);
356void iomap_readahead(const struct iomap_ops *ops,
357 struct iomap_read_folio_ctx *ctx, void *private);
358bool iomap_is_partially_uptodate(struct folio *, size_t from, size_t count);
359struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len);
360bool iomap_release_folio(struct folio *folio, gfp_t gfp_flags);
361void iomap_invalidate_folio(struct folio *folio, size_t offset, size_t len);
362bool iomap_dirty_folio(struct address_space *mapping, struct folio *folio);
363int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,
364 const struct iomap_ops *ops,
365 const struct iomap_write_ops *write_ops);
366unsigned int iomap_fill_dirty_folios(struct iomap_iter *iter, loff_t *start,
367 loff_t end, unsigned int *iomap_flags);
368int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len,
369 bool *did_zero, const struct iomap_ops *ops,
370 const struct iomap_write_ops *write_ops, void *private);
371int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
372 const struct iomap_ops *ops,
373 const struct iomap_write_ops *write_ops, void *private);
374vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops,
375 void *private);
376typedef void (*iomap_punch_t)(struct inode *inode, loff_t offset, loff_t length,
377 struct iomap *iomap);
378void iomap_write_delalloc_release(struct inode *inode, loff_t start_byte,
379 loff_t end_byte, unsigned flags, struct iomap *iomap,
380 iomap_punch_t punch);
381
382int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
383 u64 start, u64 len, const struct iomap_ops *ops);
384loff_t iomap_seek_hole(struct inode *inode, loff_t offset,
385 const struct iomap_ops *ops);
386loff_t iomap_seek_data(struct inode *inode, loff_t offset,
387 const struct iomap_ops *ops);
388sector_t iomap_bmap(struct address_space *mapping, sector_t bno,
389 const struct iomap_ops *ops);
390
391/*
392 * Flags for iomap_ioend->io_flags.
393 */
394/* shared COW extent */
395#define IOMAP_IOEND_SHARED (1U << 0)
396/* unwritten extent */
397#define IOMAP_IOEND_UNWRITTEN (1U << 1)
398/* don't merge into previous ioend */
399#define IOMAP_IOEND_BOUNDARY (1U << 2)
400/* is direct I/O */
401#define IOMAP_IOEND_DIRECT (1U << 3)
402/* is DONTCACHE I/O */
403#define IOMAP_IOEND_DONTCACHE (1U << 4)
404
405/*
406 * Flags that if set on either ioend prevent the merge of two ioends.
407 * (IOMAP_IOEND_BOUNDARY also prevents merges, but only one-way)
408 */
409#define IOMAP_IOEND_NOMERGE_FLAGS \
410 (IOMAP_IOEND_SHARED | IOMAP_IOEND_UNWRITTEN | IOMAP_IOEND_DIRECT | \
411 IOMAP_IOEND_DONTCACHE)
412
413/*
414 * Structure for writeback I/O completions.
415 *
416 * File systems can split a bio generated by iomap. In that case the parent
417 * ioend it was split from is recorded in ioend->io_parent.
418 */
419struct iomap_ioend {
420 struct list_head io_list; /* next ioend in chain */
421 u16 io_flags; /* IOMAP_IOEND_* */
422 struct inode *io_inode; /* file being written to */
423 size_t io_size; /* size of the extent */
424 atomic_t io_remaining; /* completetion defer count */
425 int io_error; /* stashed away status */
426 struct iomap_ioend *io_parent; /* parent for completions */
427 loff_t io_offset; /* offset in the file */
428 sector_t io_sector; /* start sector of ioend */
429 void *io_private; /* file system private data */
430 struct bio io_bio; /* MUST BE LAST! */
431};
432
433static inline struct iomap_ioend *iomap_ioend_from_bio(struct bio *bio)
434{
435 return container_of(bio, struct iomap_ioend, io_bio);
436}
437
438struct iomap_writeback_ops {
439 /*
440 * Performs writeback on the passed in range
441 *
442 * Can map arbitrarily large regions, but we need to call into it at
443 * least once per folio to allow the file systems to synchronize with
444 * the write path that could be invalidating mappings.
445 *
446 * An existing mapping from a previous call to this method can be reused
447 * by the file system if it is still valid.
448 *
449 * If this succeeds, iomap_finish_folio_write() must be called once
450 * writeback completes for the range, regardless of whether the
451 * writeback succeeded or failed.
452 *
453 * Returns the number of bytes processed or a negative errno.
454 */
455 ssize_t (*writeback_range)(struct iomap_writepage_ctx *wpc,
456 struct folio *folio, u64 pos, unsigned int len,
457 u64 end_pos);
458
459 /*
460 * Submit a writeback context previously build up by ->writeback_range.
461 *
462 * Returns 0 if the context was successfully submitted, or a negative
463 * error code if not. If @error is non-zero a failure occurred, and
464 * the writeback context should be completed with an error.
465 */
466 int (*writeback_submit)(struct iomap_writepage_ctx *wpc, int error);
467};
468
469struct iomap_writepage_ctx {
470 struct iomap iomap;
471 struct inode *inode;
472 struct writeback_control *wbc;
473 const struct iomap_writeback_ops *ops;
474 u32 nr_folios; /* folios added to the ioend */
475 void *wb_ctx; /* pending writeback context */
476};
477
478struct iomap_ioend *iomap_init_ioend(struct inode *inode, struct bio *bio,
479 loff_t file_offset, u16 ioend_flags);
480struct iomap_ioend *iomap_split_ioend(struct iomap_ioend *ioend,
481 unsigned int max_len, bool is_append);
482void iomap_finish_ioends(struct iomap_ioend *ioend, int error);
483void iomap_ioend_try_merge(struct iomap_ioend *ioend,
484 struct list_head *more_ioends);
485void iomap_sort_ioends(struct list_head *ioend_list);
486ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio,
487 loff_t pos, loff_t end_pos, unsigned int dirty_len);
488int iomap_ioend_writeback_submit(struct iomap_writepage_ctx *wpc, int error);
489
490void iomap_finish_folio_read(struct folio *folio, size_t off, size_t len,
491 int error);
492void iomap_finish_folio_write(struct inode *inode, struct folio *folio,
493 size_t len);
494
495int iomap_writeback_folio(struct iomap_writepage_ctx *wpc, struct folio *folio);
496int iomap_writepages(struct iomap_writepage_ctx *wpc);
497
498struct iomap_read_folio_ctx {
499 const struct iomap_read_ops *ops;
500 struct folio *cur_folio;
501 struct readahead_control *rac;
502 void *read_ctx;
503 loff_t read_ctx_file_offset;
504};
505
506struct iomap_read_ops {
507 /*
508 * Read in a folio range.
509 *
510 * If this succeeds, iomap_finish_folio_read() must be called after the
511 * range is read in, regardless of whether the read succeeded or failed.
512 *
513 * Returns 0 on success or a negative error on failure.
514 */
515 int (*read_folio_range)(const struct iomap_iter *iter,
516 struct iomap_read_folio_ctx *ctx, size_t len);
517
518 /*
519 * Submit any pending read requests.
520 *
521 * This is optional.
522 */
523 void (*submit_read)(const struct iomap_iter *iter,
524 struct iomap_read_folio_ctx *ctx);
525
526 /*
527 * Optional, allows filesystem to specify own bio_set, so new bio's
528 * can be allocated from the provided bio_set.
529 */
530 struct bio_set *bio_set;
531};
532
533/*
534 * Flags for direct I/O ->end_io:
535 */
536#define IOMAP_DIO_UNWRITTEN (1 << 0) /* covers unwritten extent(s) */
537#define IOMAP_DIO_COW (1 << 1) /* covers COW extent(s) */
538
539struct iomap_dio_ops {
540 int (*end_io)(struct kiocb *iocb, ssize_t size, int error,
541 unsigned flags);
542 void (*submit_io)(const struct iomap_iter *iter, struct bio *bio,
543 loff_t file_offset);
544
545 /*
546 * Filesystems wishing to attach private information to a direct io bio
547 * must provide a ->submit_io method that attaches the additional
548 * information to the bio and changes the ->bi_end_io callback to a
549 * custom function. This function should, at a minimum, perform any
550 * relevant post-processing of the bio and end with a call to
551 * iomap_dio_bio_end_io.
552 */
553 struct bio_set *bio_set;
554};
555
556/*
557 * Wait for the I/O to complete in iomap_dio_rw even if the kiocb is not
558 * synchronous.
559 */
560#define IOMAP_DIO_FORCE_WAIT (1 << 0)
561
562/*
563 * Do not allocate blocks or zero partial blocks, but instead fall back to
564 * the caller by returning -EAGAIN. Used to optimize direct I/O writes that
565 * are not aligned to the file system block size.
566 */
567#define IOMAP_DIO_OVERWRITE_ONLY (1 << 1)
568
569/*
570 * When a page fault occurs, return a partial synchronous result and allow
571 * the caller to retry the rest of the operation after dealing with the page
572 * fault.
573 */
574#define IOMAP_DIO_PARTIAL (1 << 2)
575
576/*
577 * Ensure each bio is aligned to fs block size.
578 *
579 * For filesystems which need to calculate/verify the checksum of each fs
580 * block. Otherwise they may not be able to handle unaligned bios.
581 */
582#define IOMAP_DIO_FSBLOCK_ALIGNED (1 << 3)
583
584/*
585 * Bounce buffer instead of using zero copy access.
586 *
587 * This is needed if the device needs stable data to checksum or generate
588 * parity. The file system must hook into the I/O submission and offload
589 * completions to user context for reads when this is set.
590 */
591#define IOMAP_DIO_BOUNCE (1 << 4)
592
593ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
594 const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
595 unsigned int dio_flags, void *private, size_t done_before);
596struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
597 const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
598 unsigned int dio_flags, void *private, size_t done_before);
599ssize_t iomap_dio_complete(struct iomap_dio *dio);
600void iomap_dio_bio_end_io(struct bio *bio);
601
602#ifdef CONFIG_SWAP
603struct file;
604struct swap_info_struct;
605
606int iomap_swapfile_activate(struct swap_info_struct *sis,
607 struct file *swap_file, sector_t *pagespan,
608 const struct iomap_ops *ops);
609#else
610# define iomap_swapfile_activate(sis, swapfile, pagespan, ops) (-EIO)
611#endif /* CONFIG_SWAP */
612
613extern struct bio_set iomap_ioend_bioset;
614
615#ifdef CONFIG_BLOCK
616int iomap_bio_read_folio_range(const struct iomap_iter *iter,
617 struct iomap_read_folio_ctx *ctx, size_t plen);
618
619extern const struct iomap_read_ops iomap_bio_read_ops;
620
621static inline void iomap_bio_read_folio(struct folio *folio,
622 const struct iomap_ops *ops)
623{
624 struct iomap_read_folio_ctx ctx = {
625 .ops = &iomap_bio_read_ops,
626 .cur_folio = folio,
627 };
628
629 iomap_read_folio(ops, &ctx, NULL);
630}
631
632static inline void iomap_bio_readahead(struct readahead_control *rac,
633 const struct iomap_ops *ops)
634{
635 struct iomap_read_folio_ctx ctx = {
636 .ops = &iomap_bio_read_ops,
637 .rac = rac,
638 };
639
640 iomap_readahead(ops, &ctx, NULL);
641}
642#endif /* CONFIG_BLOCK */
643
644#endif /* LINUX_IOMAP_H */