Skip to content

Commit 7d50f37

Browse files
Christoph Hellwigkawasaki
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]> Reviewed-by: Joanne Koong <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]>
1 parent 836555a commit 7d50f37

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

fs/iomap/buffered-io.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -661,22 +661,22 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
661661
pos + len - 1);
662662
}
663663

664-
static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,
665-
size_t poff, size_t plen, const struct iomap *iomap)
664+
static int iomap_read_folio_range(const struct iomap_iter *iter,
665+
struct folio *folio, loff_t pos, size_t len)
666666
{
667+
const struct iomap *srcmap = iomap_iter_srcmap(iter);
667668
struct bio_vec bvec;
668669
struct bio bio;
669670

670-
bio_init(&bio, iomap->bdev, &bvec, 1, REQ_OP_READ);
671-
bio.bi_iter.bi_sector = iomap_sector(iomap, block_start);
672-
bio_add_folio_nofail(&bio, folio, plen, poff);
671+
bio_init(&bio, srcmap->bdev, &bvec, 1, REQ_OP_READ);
672+
bio.bi_iter.bi_sector = iomap_sector(srcmap, pos);
673+
bio_add_folio_nofail(&bio, folio, len, offset_in_folio(folio, pos));
673674
return submit_bio_wait(&bio);
674675
}
675676

676677
static int __iomap_write_begin(const struct iomap_iter *iter, size_t len,
677678
struct folio *folio)
678679
{
679-
const struct iomap *srcmap = iomap_iter_srcmap(iter);
680680
struct iomap_folio_state *ifs;
681681
loff_t pos = iter->pos;
682682
loff_t block_size = i_blocksize(iter->inode);
@@ -725,8 +725,8 @@ static int __iomap_write_begin(const struct iomap_iter *iter, size_t len,
725725
if (iter->flags & IOMAP_NOWAIT)
726726
return -EAGAIN;
727727

728-
status = iomap_read_folio_sync(block_start, folio,
729-
poff, plen, srcmap);
728+
status = iomap_read_folio_range(iter, folio,
729+
block_start, plen);
730730
if (status)
731731
return status;
732732
}

0 commit comments

Comments
 (0)