mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-06-11 15:46:40 +02:00
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 <hch@lst.de> Link: https://lore.kernel.org/20250710133343.399917-13-hch@lst.de Reviewed-by: Joanne Koong <joannelkoong@gmail.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
2a5574fc57
commit
e6caf01d3f
@@ -658,22 +658,22 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
|
||||
pos + len - 1);
|
||||
}
|
||||
|
||||
static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,
|
||||
size_t poff, size_t plen, const struct iomap *iomap)
|
||||
static int iomap_read_folio_range(const struct iomap_iter *iter,
|
||||
struct folio *folio, loff_t pos, size_t len)
|
||||
{
|
||||
const struct iomap *srcmap = iomap_iter_srcmap(iter);
|
||||
struct bio_vec bvec;
|
||||
struct bio bio;
|
||||
|
||||
bio_init(&bio, iomap->bdev, &bvec, 1, REQ_OP_READ);
|
||||
bio.bi_iter.bi_sector = iomap_sector(iomap, block_start);
|
||||
bio_add_folio_nofail(&bio, folio, plen, poff);
|
||||
bio_init(&bio, srcmap->bdev, &bvec, 1, REQ_OP_READ);
|
||||
bio.bi_iter.bi_sector = iomap_sector(srcmap, pos);
|
||||
bio_add_folio_nofail(&bio, folio, len, offset_in_folio(folio, pos));
|
||||
return submit_bio_wait(&bio);
|
||||
}
|
||||
|
||||
static int __iomap_write_begin(const struct iomap_iter *iter, size_t len,
|
||||
struct folio *folio)
|
||||
{
|
||||
const struct iomap *srcmap = iomap_iter_srcmap(iter);
|
||||
struct iomap_folio_state *ifs;
|
||||
loff_t pos = iter->pos;
|
||||
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,
|
||||
if (iter->flags & IOMAP_NOWAIT)
|
||||
return -EAGAIN;
|
||||
|
||||
status = iomap_read_folio_sync(block_start, folio,
|
||||
poff, plen, srcmap);
|
||||
status = iomap_read_folio_range(iter, folio,
|
||||
block_start, plen);
|
||||
if (status)
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user