linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/2] iomap: simplify iomap_readpage_actor
Date: Tue, 20 Jul 2021 13:27:24 +0100	[thread overview]
Message-ID: <YPbBLCphExqjig1O@casper.infradead.org> (raw)
In-Reply-To: <20210720084320.184877-1-hch@lst.de>

On Tue, Jul 20, 2021 at 10:43:19AM +0200, Christoph Hellwig wrote:
> Now that the outstanding reads are counted in bytes, there is no need
> to use the low-level __bio_try_merge_page API, we can switch back to
> always using bio_add_page and simply iomap_readpage_actor again.

I don't think this quite works.  You need to check the return value
from bio_add_page(), otherwise you can be in a situation where you try
to add a page to the last bvec and it's not contiguous, so it fails.

I was imagining something more like this:

-       bool same_page = false, is_contig = false;
+       bool is_contig = false;
...
        /* Try to merge into a previous segment if we can */
        sector = iomap_sector(iomap, pos);
-       if (ctx->bio && bio_end_sector(ctx->bio) == sector) {
-               if (__bio_try_merge_page(ctx->bio, page, plen, poff,
-                               &same_page))
-                       goto done;
-               is_contig = true;
-       }
+       if (ctx->bio && bio_end_sector(ctx->bio) == sector)
+               is_contig = bio_add_page(ctx->bio, page, plen, poff) > 0;

-       if (!is_contig || bio_full(ctx->bio, plen)) {
+       if (!is_contig) {
                gfp_t gfp = mapping_gfp_constraint(page->mapping, GFP_KERNEL);
                gfp_t orig_gfp = gfp;
...
                bio_set_dev(ctx->bio, iomap->bdev);
                ctx->bio->bi_end_io = iomap_read_end_io;
+               bio_add_page(ctx->bio, page, plen, poff);
        }

-       bio_add_page(ctx->bio, page, plen, poff);
 done:
        /*


  parent reply	other threads:[~2021-07-20 12:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20  8:43 [PATCH 1/2] iomap: simplify iomap_readpage_actor Christoph Hellwig
2021-07-20  8:43 ` [PATCH 2/2] iomap: simplify iomap_add_to_ioend Christoph Hellwig
2021-07-20 12:10   ` Matthew Wilcox
2021-07-20 12:16     ` Christoph Hellwig
2021-07-20 12:27 ` Matthew Wilcox [this message]
2021-07-20 13:26   ` [PATCH 1/2] iomap: simplify iomap_readpage_actor Christoph Hellwig
2021-07-20 13:41     ` Matthew Wilcox
  -- strict thread matches above, loose matches on Subject: below --
2021-07-22  5:42 cleanup the bio handling in iomap v2 Christoph Hellwig
2021-07-22  5:42 ` [PATCH 1/2] iomap: simplify iomap_readpage_actor Christoph Hellwig
2021-07-22 19:34   ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YPbBLCphExqjig1O@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).