[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBsOXWk6sKISbbfl@casper.infradead.org>
Date: Wed, 22 Mar 2023 14:19:09 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Pankaj Raghav <p.raghav@...sung.com>
Cc: senozhatsky@...omium.org, viro@...iv.linux.org.uk, axboe@...nel.dk,
brauner@...nel.org, akpm@...ux-foundation.org, minchan@...nel.org,
hubcap@...ibond.com, martin@...ibond.com, mcgrof@...nel.org,
devel@...ts.orangefs.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-block@...r.kernel.org, gost.dev@...sung.com
Subject: Re: [RFC v2 4/5] mpage: use folios in bio end_io handler
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);
}
Powered by blists - more mailing lists