Skip to content

Commit e8f9cf0

Browse files
Christoph Hellwigbrauner
authored andcommitted
iomap: support ioends for buffered reads
Support using the ioend structure to defer I/O completion for buffered reads by calling into the buffered read I/O completion handler from iomap_finish_ioend. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260223132021.292832-15-hch@lst.de Tested-by: Anuj Gupta <anuj20.g@samsung.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 5728777 commit e8f9cf0

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

fs/iomap/bio.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,27 @@
88
#include "internal.h"
99
#include "trace.h"
1010

11-
static void iomap_read_end_io(struct bio *bio)
11+
static u32 __iomap_read_end_io(struct bio *bio, int error)
1212
{
13-
int error = blk_status_to_errno(bio->bi_status);
1413
struct folio_iter fi;
14+
u32 folio_count = 0;
1515

16-
bio_for_each_folio_all(fi, bio)
16+
bio_for_each_folio_all(fi, bio) {
1717
iomap_finish_folio_read(fi.folio, fi.offset, fi.length, error);
18+
folio_count++;
19+
}
1820
bio_put(bio);
21+
return folio_count;
22+
}
23+
24+
static void iomap_read_end_io(struct bio *bio)
25+
{
26+
__iomap_read_end_io(bio, blk_status_to_errno(bio->bi_status));
27+
}
28+
29+
u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend)
30+
{
31+
return __iomap_read_end_io(&ioend->io_bio, ioend->io_error);
1932
}
2033

2134
static void iomap_bio_submit_read(const struct iomap_iter *iter,

fs/iomap/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#define IOEND_BATCH_SIZE 4096
66

7+
u32 iomap_finish_ioend_buffered_read(struct iomap_ioend *ioend);
78
u32 iomap_finish_ioend_direct(struct iomap_ioend *ioend);
89

910
#ifdef CONFIG_BLOCK

fs/iomap/ioend.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ EXPORT_SYMBOL_GPL(iomap_init_ioend);
3737
* state, release holds on bios, and finally free up memory. Do not use the
3838
* ioend after this.
3939
*/
40-
static u32 iomap_finish_ioend_buffered(struct iomap_ioend *ioend)
40+
static u32 iomap_finish_ioend_buffered_write(struct iomap_ioend *ioend)
4141
{
4242
struct inode *inode = ioend->io_inode;
4343
struct bio *bio = &ioend->io_bio;
@@ -87,7 +87,7 @@ iomap_fail_ioends(
8787
while ((ioend = list_first_entry_or_null(&tmp, struct iomap_ioend,
8888
io_list))) {
8989
list_del_init(&ioend->io_list);
90-
iomap_finish_ioend_buffered(ioend);
90+
iomap_finish_ioend_buffered_write(ioend);
9191
cond_resched();
9292
}
9393
}
@@ -120,7 +120,7 @@ static void ioend_writeback_end_bio(struct bio *bio)
120120
return;
121121
}
122122

123-
iomap_finish_ioend_buffered(ioend);
123+
iomap_finish_ioend_buffered_write(ioend);
124124
}
125125

126126
/*
@@ -313,7 +313,9 @@ static u32 iomap_finish_ioend(struct iomap_ioend *ioend, int error)
313313
return 0;
314314
if (ioend->io_flags & IOMAP_IOEND_DIRECT)
315315
return iomap_finish_ioend_direct(ioend);
316-
return iomap_finish_ioend_buffered(ioend);
316+
if (bio_op(&ioend->io_bio) == REQ_OP_READ)
317+
return iomap_finish_ioend_buffered_read(ioend);
318+
return iomap_finish_ioend_buffered_write(ioend);
317319
}
318320

319321
/*

0 commit comments

Comments
 (0)