summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-10-19 18:33:02 -1000
committerLinus Torvalds <torvalds@linux-foundation.org>2026-10-19 18:33:02 -1000
commit27dd2772e6c62cf0627d97fe03950710df334cf4 (patch)
treed2ed143bbf617a300444092f6ffeebed4ec1c949 /include/linux
parent00b04f4495c354cad82f96d41947aa70f71e2cc4 (diff)
parenta0f61a936b36a340998825cb945e5fdf03468988 (diff)
Merge tag 'vfs-7.4-rc1.iomap' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull iomap updates from Christian Brauner: "This contains the iomap changes for this cycle. The bulk is lazy bounce buffering for checksummed reads. XFS bounce buffers every direct read on a device that requires stable pages for checksumming so that userspace modifying the buffer while the read is in flight can't corrupt the data and fail the checksum. That burns DRAM bandwidth and CPU for copies that are almost never needed and, since the bounce buffer was a bio_vec, produced smaller and unaligned I/Os with 4k pages, i.e. 1 MB minus 4k. Now the read goes to the user buffer first and only a checksum failure allocates a bounce buffer and reads again. Integrity verification moves out of iomap into the filesystem so it can handle errors its own way, T10 PI handling for direct I/O moves into ->submit_io() to match buffered I/O, and a sysfs knob restores the old behaviour for the rare application that really does modify in-flight buffers. The block side gains bio_prepare_reissue(), exports fs_bio_integrity_{alloc,free}(), caps atomic writes by the PI buffer size and fixes an integer overflow in max_integrity_io_size() and a PI verification bug with an initial bvec offset. The old read side bounce buffering in the block layer is removed. This is a branch shared with the block tree and may also reach you through the block pull request. Three error handling regressions are fixed: - A failed ->writeback_submit() left wpc->wb_ctx pointing at an already completed ioend which was then submitted a second time and corrupted ip->i_ioend_list on XFS - iomap_fiemap() lost an iteration error when it flushed the pending extent and marked a truncated list as complete - A failed direct I/O bio lost its error when the sub-block tail zeroing succeeded. An XFS error tag to inject the writeback failure comes with it. iomap_dio_hole_iter() respects the block size alignment when iov_iter_zero() stops short at a page boundary, which btrfs with 8k blocks on 4k pages hit as an assertion since it disables page faults during direct I/O. The homegrown deferral of error completions to task context is replaced with bio_complete_in_task(). Plus an unused parameter, two typo fixes and a kernel-doc fix" * tag 'vfs-7.4-rc1.iomap' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (34 commits) fs/iomap: document ret parameter of iomap_iter_continue iomap: follow the alignment requirement for iomap_dio_hole_iter() iomap: don't lose a failed direct I/O bio's error when zeroing the tail iomap: don't lose a fiemap iteration error when emitting the last extent xfs: add an error tag to inject a ->writeback_submit() failure iomap: don't resubmit an ioend after ->writeback_submit() failed iomap: use bio_complete_in_task for buffered simple dio read failures iomap: use bio_complete_in_task for buffered write failures iomap: use bio_complete_in_task for buffered read failures block,iomap: remove the old read side bounce buffering support xfs: log a message at mount time when using integrity protection xfs: add error injection for lazy bounce buffering xfs: add support for lazy direct read bounce buffering iomap,xfs: move integrity verification to the file system xfs: use BIO_COMPLETE_IN_TASK for bounce buffered read I/Os iomap: better read bounce buffering support block,iomap: fix protection information verification with initial bvec offset xfs: move PI generation into xfs_submit_zoned_bio iomap,xfs: move T10 PI handling for direct I/O into ->submit_io iomap: add a IOMAP_IOEND_INTEGRITY flag ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bio-integrity.h3
-rw-r--r--include/linux/bio.h11
-rw-r--r--include/linux/blkdev.h8
-rw-r--r--include/linux/iomap.h38
4 files changed, 50 insertions, 10 deletions
diff --git a/include/linux/bio-integrity.h b/include/linux/bio-integrity.h
index 0ea2a8bf7efb..a954c97be0b3 100644
--- a/include/linux/bio-integrity.h
+++ b/include/linux/bio-integrity.h
@@ -151,7 +151,6 @@ void bio_integrity_setup_default(struct bio *bio);
unsigned int fs_bio_integrity_alloc(struct bio *bio);
void fs_bio_integrity_free(struct bio *bio);
void fs_bio_integrity_generate(struct bio *bio);
-int fs_bio_integrity_verify(struct bio *bio, sector_t sector,
- unsigned int size);
+int fs_bio_integrity_verify(struct bio *bio, struct bvec_iter *data_iter);
#endif /* _LINUX_BIO_INTEGRITY_H */
diff --git a/include/linux/bio.h b/include/linux/bio.h
index bb3235497e67..17944e44b584 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -479,6 +479,7 @@ static inline void bio_init_inline(struct bio *bio, struct block_device *bdev,
extern void bio_uninit(struct bio *);
void bio_reset(struct bio *bio, struct block_device *bdev, blk_opf_t opf);
void bio_reuse(struct bio *bio, blk_opf_t opf);
+void bio_prepare_reissue(struct bio *bio, struct block_device *bdev);
void bio_chain(struct bio *, struct bio *);
void bio_await(struct bio *bio, void *priv,
void (*submit)(struct bio *bio, void *priv));
@@ -516,16 +517,18 @@ int bdev_rw_virt(struct block_device *bdev, sector_t sector, void *data,
size_t len, enum req_op op);
int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter,
- unsigned mem_align_mask, unsigned len_align_mask);
+ unsigned maxlen, unsigned mem_align_mask,
+ unsigned len_align_mask);
bool bio_iov_iter_set(struct bio *bio, const struct iov_iter *iter);
void __bio_release_pages(struct bio *bio, bool mark_dirty);
extern void bio_set_pages_dirty(struct bio *bio);
extern void bio_check_pages_dirty(struct bio *bio);
-int bio_iov_iter_bounce(struct bio *bio, struct iov_iter *iter, size_t maxlen,
- size_t minsize);
-void bio_iov_iter_unbounce(struct bio *bio, bool is_error, bool mark_dirty);
+int bio_alloc_bounce_folios(struct bio *bio, size_t total_len, size_t minsize);
+void bio_free_folios(struct bio *bio);
+int bio_iov_iter_bounce_write(struct bio *bio, struct iov_iter *iter,
+ size_t maxlen, size_t minsize);
extern void bio_copy_data(struct bio *dst, struct bio *src);
extern void bio_free_pages(struct bio *bio);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 4f7905c3412b..098a65f3e48b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1816,9 +1816,11 @@ static inline int bio_split_rw_at(struct bio *bio,
*/
static inline unsigned int max_integrity_io_size(struct queue_limits *lim)
{
- return min_t(unsigned int, lim->max_segment_size,
- (BLK_INTEGRITY_MAX_SIZE / lim->integrity.metadata_size) <<
- lim->integrity.interval_exp);
+ u64 max_intervals;
+
+ max_intervals = BLK_INTEGRITY_MAX_SIZE / lim->integrity.metadata_size;
+ return min_t(u64, lim->max_segment_size,
+ max_intervals << lim->integrity.interval_exp);
}
#define DEFINE_IO_COMP_BATCH(name) struct io_comp_batch name = { }
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index bc7ae6327dbf..59718f73c15a 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -483,13 +483,35 @@ sector_t iomap_bmap(struct address_space *mapping, sector_t bno,
#define IOMAP_IOEND_BOUNDARY (1U << 2)
/* is direct I/O */
#define IOMAP_IOEND_DIRECT (1U << 3)
+/* generate integrity (PI) information */
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+#define IOMAP_IOEND_INTEGRITY (1U << 4)
+#else
+#define IOMAP_IOEND_INTEGRITY 0
+#endif /* CONFIG_BLK_DEV_INTEGRITY */
/*
* Flags that if set on either ioend prevent the merge of two ioends.
* (IOMAP_IOEND_BOUNDARY also prevents merges, but only one-way)
*/
#define IOMAP_IOEND_NOMERGE_FLAGS \
- (IOMAP_IOEND_SHARED | IOMAP_IOEND_UNWRITTEN | IOMAP_IOEND_DIRECT)
+ (IOMAP_IOEND_SHARED | IOMAP_IOEND_UNWRITTEN | IOMAP_IOEND_DIRECT | \
+ IOMAP_IOEND_INTEGRITY)
+
+/* ioend flags directly implied by iomap flags */
+static inline u16 iomap_ioend_flags(const struct iomap *iomap)
+{
+ unsigned int flags = 0;
+
+ if (iomap->type == IOMAP_UNWRITTEN)
+ flags |= IOMAP_IOEND_UNWRITTEN;
+ if (iomap->flags & IOMAP_F_SHARED)
+ flags |= IOMAP_IOEND_SHARED;
+ if (iomap->flags & IOMAP_F_INTEGRITY)
+ flags |= IOMAP_IOEND_INTEGRITY;
+
+ return flags;
+}
/*
* Structure for writeback I/O completions.
@@ -500,6 +522,7 @@ sector_t iomap_bmap(struct address_space *mapping, sector_t bno,
struct iomap_ioend {
struct list_head io_list; /* next ioend in chain */
u16 io_flags; /* IOMAP_IOEND_* */
+ u32 io_bvec_offset; /* offset into first bvec */
struct inode *io_inode; /* file being written to */
size_t io_size; /* size of the extent */
atomic_t io_remaining; /* completetion defer count */
@@ -517,6 +540,13 @@ static inline struct iomap_ioend *iomap_ioend_from_bio(struct bio *bio)
return container_of(bio, struct iomap_ioend, io_bio);
}
+#define BVEC_ITER_IOEND(_ioend) \
+{ \
+ .bi_sector = (_ioend)->io_sector, \
+ .bi_size = (_ioend)->io_size, \
+ .bi_offset = (_ioend)->io_bvec_offset, \
+}
+
struct iomap_writeback_ops {
/*
* Performs writeback on the passed in range
@@ -565,6 +595,7 @@ void iomap_finish_ioends(struct iomap_ioend *ioend, int error);
void iomap_ioend_try_merge(struct iomap_ioend *ioend,
struct list_head *more_ioends);
void iomap_sort_ioends(struct list_head *ioend_list);
+int iomap_ioend_integrity_verify(struct iomap_ioend *ioend);
ssize_t iomap_add_to_ioend(struct iomap_writepage_ctx *wpc, struct folio *folio,
loff_t pos, loff_t end_pos, unsigned int dirty_len);
int iomap_ioend_writeback_submit(struct iomap_writepage_ctx *wpc, int error);
@@ -577,6 +608,11 @@ void iomap_finish_folio_write(struct inode *inode, struct folio *folio,
int iomap_writeback_folio(struct iomap_writepage_ctx *wpc, struct folio *folio);
int iomap_writepages(struct iomap_writepage_ctx *wpc);
+void iomap_bounce_read(struct iomap_ioend *orig_ioend, unsigned int minsize,
+ void (*submit_ioend)(struct iomap_ioend *ioend));
+void iomap_bounce_read_end_io(struct iomap_ioend *ioend, struct bio *orig_bio,
+ int error);
+
struct iomap_read_folio_ctx {
const struct iomap_read_ops *ops;
struct folio *cur_folio;