Message ID | 20230322135013.197076-5-p.raghav@samsung.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [RFC,v2,1/5] zram: remove zram_page_end_io function | expand |
On Wed, Mar 22, 2023 at 02:50:12PM +0100, Pankaj Raghav wrote: > static void mpage_write_end_io(struct bio *bio) > { > - struct bio_vec *bv; > - struct bvec_iter_all iter_all; > + struct folio_iter fi; > + int err = blk_status_to_errno(bio->bi_status); > > - bio_for_each_segment_all(bv, bio, iter_all) { > - struct page *page = bv->bv_page; > - page_endio(page, REQ_OP_WRITE, > - blk_status_to_errno(bio->bi_status)); > + bio_for_each_folio_all(fi, bio) { > + struct folio *folio = fi.folio; > + > + if (err) { > + struct address_space *mapping; > + > + folio_set_error(folio); > + mapping = folio_mapping(folio); > + if (mapping) > + mapping_set_error(mapping, err); The folio is known to belong to this mapping and can't be truncated while under writeback. So it's safe to do: folio_set_error(folio); mapping_set_error(folio->mapping, err); I'm not even sure I'd bother to pull folio out of the fi. bio_for_each_folio_all(fi, bio) { if (err) { folio_set_error(fi.folio); mapping_set_error(fi.folio->mapping, err); } folio_end_writeback(fi.folio); }
diff --git a/fs/mpage.c b/fs/mpage.c index 3a545bf0f184..103505551896 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -45,13 +45,15 @@ */ static void mpage_read_end_io(struct bio *bio) { - struct bio_vec *bv; - struct bvec_iter_all iter_all; + struct folio_iter fi; + int err = blk_status_to_errno(bio->bi_status); - bio_for_each_segment_all(bv, bio, iter_all) { - struct page *page = bv->bv_page; - page_endio(page, REQ_OP_READ, - blk_status_to_errno(bio->bi_status)); + bio_for_each_folio_all(fi, bio) { + struct folio *folio = fi.folio; + + if (!err) + folio_mark_uptodate(folio); + folio_unlock(folio); } bio_put(bio); @@ -59,13 +61,21 @@ static void mpage_read_end_io(struct bio *bio) static void mpage_write_end_io(struct bio *bio) { - struct bio_vec *bv; - struct bvec_iter_all iter_all; + struct folio_iter fi; + int err = blk_status_to_errno(bio->bi_status); - bio_for_each_segment_all(bv, bio, iter_all) { - struct page *page = bv->bv_page; - page_endio(page, REQ_OP_WRITE, - blk_status_to_errno(bio->bi_status)); + bio_for_each_folio_all(fi, bio) { + struct folio *folio = fi.folio; + + if (err) { + struct address_space *mapping; + + folio_set_error(folio); + mapping = folio_mapping(folio); + if (mapping) + mapping_set_error(mapping, err); + } + folio_end_writeback(folio); } bio_put(bio);
Use folios in the bio end_io handler. This conversion does the appropriate handling on the folios in the respective end_io callback and removes the call to page_endio(), which is soon to be removed. Signed-off-by: Pankaj Raghav <p.raghav@samsung.com> --- fs/mpage.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)