Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: David Howells <dhowells@redhat.com>
Cc: torvalds@linux-foundation.org, linux-afs@lists.infradead.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] afs: Don't unlock fetched data pages until the op completes successfully
Date: Sun, 17 May 2020 14:08:11 -0700	[thread overview]
Message-ID: <20200517210811.GQ16070@bombadil.infradead.org> (raw)
In-Reply-To: <158974686528.785191.2525276665446566911.stgit@warthog.procyon.org.uk>

On Sun, May 17, 2020 at 09:21:05PM +0100, David Howells wrote:
> Don't call req->page_done() on each page as we finish filling it with the
> data coming from the network.  Whilst this might speed up the application a
> bit, it's a problem if there's a network failure and the operation has to
> be reissued.

It's readpages, which by definition is called for pages that the
application is _not_ currently waiting for.  Now, if the application
is multithreaded and happens to want pages that are currently under
->readpages, then that's going to be a problem (but also unlikely).
Also if the application overruns the readahead window then it'll have
to wait a little longer (but we ramp up the readahead window, so this
should be a self-correcting problem).

> If this happens, an oops occurs because afs_readpages_page_done() clears
> the pointer to each page it unlocks and when a retry happens, the pointers
> to the pages it wants to fill are now NULL (and the pages have been
> unlocked anyway).

I mean, you could check for NULL pointers and not issue the I/O for that
region ... but it doesn't seem necessary.

> Instead, wait till the operation completes successfully and only then
> release all the pages after clearing any terminal gap (the server can give
> us less data than we requested as we're allowed to ask for more than is
> available).

s/release/mark up to date/

> +	if (req->page_done)
> +		for (req->index = 0; req->index < req->nr_pages; req->index++)
> +			req->page_done(req);
> +

I'd suggest doing one call rather than N and putting the page iteration
inside the callback.  But this patch is appropriate for this late in
the -rc series, just something to consider for the future.

You might even want to use a bit in the req to indicate whether this is
a readahead request ... that's the only user of the ->page_done callback
that I can find.

Anyway,
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

  reply	other threads:[~2020-05-17 21:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 20:21 David Howells
2020-05-17 21:08 ` Matthew Wilcox [this message]
2020-05-17 22:36 ` David Howells

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=20200517210811.GQ16070@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: [PATCH] afs: Don'\''t unlock fetched data pages until the op completes successfully' \
    /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

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).