Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ static void bio_free_folios(struct bio *bio)
int i;

bio_for_each_bvec_all(bv, bio, i) {
struct folio *folio = page_folio(bv->bv_page);
struct folio *folio = bvec_folio(bv);

if (!is_zero_folio(folio))
folio_put(folio);
Expand Down Expand Up @@ -1409,7 +1409,7 @@ int bio_iov_iter_bounce(struct bio *bio, struct iov_iter *iter, size_t maxlen,

static void bvec_unpin(struct bio_vec *bv, bool mark_dirty)
{
struct folio *folio = page_folio(bv->bv_page);
struct folio *folio = bvec_folio(bv);
size_t nr_pages = (bv->bv_offset + bv->bv_len - 1) / PAGE_SIZE -
bv->bv_offset / PAGE_SIZE + 1;

Expand Down Expand Up @@ -1443,7 +1443,7 @@ static void bio_iov_iter_unbounce_read(struct bio *bio, bool is_error,
bvec_unpin(&bio->bi_io_vec[1 + i], mark_dirty);
}

folio_put(page_folio(bio->bi_io_vec[0].bv_page));
folio_put(bvec_folio(&bio->bi_io_vec[0]));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion include/linux/bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static inline void bio_first_folio(struct folio_iter *fi, struct bio *bio,
return;
}

fi->folio = page_folio(bvec->bv_page);
fi->folio = bvec_folio(bvec);
fi->offset = bvec->bv_offset +
PAGE_SIZE * folio_page_idx(fi->folio, bvec->bv_page);
fi->_seg_count = bvec->bv_len;
Expand Down
13 changes: 13 additions & 0 deletions include/linux/bvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ static inline void bvec_set_virt(struct bio_vec *bv, void *vaddr,
bvec_set_page(bv, virt_to_page(vaddr), len, offset_in_page(vaddr));
}

/**
* bvec_folio - Return the first folio referenced by this bvec
* @bv: bvec to access
*
* bvecs can span multiple folios. Unless you know that this
* bvec does not, you may be better off using something like
* bio_for_each_folio_all() which iterates over all folios.
*/
static inline struct folio *bvec_folio(const struct bio_vec *bv)
{
return page_folio(bv->bv_page);
}

struct bvec_iter {
/*
* Current device address in 512 byte sectors. Only updated by the bio
Expand Down
2 changes: 1 addition & 1 deletion io_uring/rsrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static void io_release_ubuf(void *priv)
unsigned int i;

for (i = 0; i < imu->nr_bvecs; i++) {
struct folio *folio = page_folio(imu->bvec[i].bv_page);
struct folio *folio = bvec_folio(&imu->bvec[i]);

unpin_user_folio(folio, 1);
}
Expand Down
4 changes: 2 additions & 2 deletions mm/page_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret)

if (ret == sio->len) {
for (p = 0; p < sio->pages; p++) {
struct folio *folio = page_folio(sio->bvec[p].bv_page);
struct folio *folio = bvec_folio(&sio->bvec[p]);

count_mthp_stat(folio_order(folio), MTHP_STAT_SWPIN);
count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
Expand All @@ -500,7 +500,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
count_vm_events(PSWPIN, sio->len >> PAGE_SHIFT);
} else {
for (p = 0; p < sio->pages; p++) {
struct folio *folio = page_folio(sio->bvec[p].bv_page);
struct folio *folio = bvec_folio(&sio->bvec[p]);

folio_unlock(folio);
}
Expand Down