Skip to content

Commit e6caf01

Browse files
Christoph Hellwigbrauner
authored andcommitted
iomap: improve argument passing to iomap_read_folio_sync
Pass the iomap_iter and derive the map inside iomap_read_folio_sync instead of in the caller, and use the more descriptive srcmap name for the source iomap. Stop passing the offset into folio argument as it can be derived from the folio and the file offset. Rename the variables for the offset into the file and the length to be more descriptive and match the rest of the code. Rename the function itself to iomap_read_folio_range to make the use more clear. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/[email protected] Reviewed-by: Joanne Koong <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 2a5574f commit e6caf01

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/iomap/buffered-io.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,22 +658,22 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
658658
pos + len - 1);
659659
}
660660

661-
static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,
662-
size_t poff, size_t plen, const struct iomap *iomap)
661+
static int iomap_read_folio_range(const struct iomap_iter *iter,
662+
struct folio *folio, loff_t pos, size_t len)
663663
{
664+
const struct iomap *srcmap = iomap_iter_srcmap(iter);
664665
struct bio_vec bvec;
665666
struct bio bio;
666667

667-
bio_init(&bio, iomap->bdev, &bvec, 1, REQ_OP_READ);
668-
bio.bi_iter.bi_sector = iomap_sector(iomap, block_start);
669-
bio_add_folio_nofail(&bio, folio, plen, poff);
668+
bio_init(&bio, srcmap->bdev, &bvec, 1, REQ_OP_READ);
669+
bio.bi_iter.bi_sector = iomap_sector(srcmap, pos);
670+
bio_add_folio_nofail(&bio, folio, len, offset_in_folio(folio, pos));
670671
return submit_bio_wait(&bio);
671672
}
672673

673674
static int __iomap_write_begin(const struct iomap_iter *iter, size_t len,
674675
struct folio *folio)
675676
{
676-
const struct iomap *srcmap = iomap_iter_srcmap(iter);
677677
struct iomap_folio_state *ifs;
678678
loff_t pos = iter->pos;
679679
loff_t block_size = i_blocksize(iter->inode);
@@ -722,8 +722,8 @@ static int __iomap_write_begin(const struct iomap_iter *iter, size_t len,
722722
if (iter->flags & IOMAP_NOWAIT)
723723
return -EAGAIN;
724724

725-
status = iomap_read_folio_sync(block_start, folio,
726-
poff, plen, srcmap);
725+
status = iomap_read_folio_range(iter, folio,
726+
block_start, plen);
727727
if (status)
728728
return status;
729729
}

0 commit comments

Comments
 (0)