File Index
Files and directories
Sign in
FILE

iomap.h

File preview with syntax highlighting.

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