Skip to content

Commit f2d77a4

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: "Darrick J. Wong" <[email protected]> Reviewed-by: Joanne Koong <[email protected]>
1 parent ee85c84 commit f2d77a4

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
@@ -657,22 +657,22 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
657657
pos + len - 1);
658658
}
659659

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

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

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

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

0 commit comments

Comments
 (0)