From: David Howells <email@example.com>
To: Linus Torvalds <firstname.lastname@example.org>
Cc: email@example.com, Matthew Wilcox <firstname.lastname@example.org>,
Jeff Layton <email@example.com>,
David Wysochanski <firstname.lastname@example.org>,
Anna Schumaker <email@example.com>,
Trond Myklebust <firstname.lastname@example.org>,
Steve French <email@example.com>,
Dominique Martinet <firstname.lastname@example.org>,
Alexander Viro <email@example.com>,
firstname.lastname@example.org, CIFS <email@example.com>,
"open list:NFS, SUNRPC, AND..." <firstname.lastname@example.org>,
Linux Kernel Mailing List <email@example.com>
Subject: Re: [GIT PULL] fscache: I/O API modernisation and netfs helper library
Date: Tue, 09 Feb 2021 21:55:26 +0000 [thread overview]
Message-ID: <firstname.lastname@example.org> (raw)
Linus Torvalds <email@example.com> wrote:
> > Yeah, I have trouble with the private2 vs fscache bit too. I've been
> > trying to persuade David that he doesn't actually need an fscache
> > bit at all; he can just increment the page's refcount to prevent it
> > from being freed while he writes data to the cache.
> Does the code not hold a refcount already?
AIUI, Willy wanted me to drop the refcount and rely on PG_locked alone during
I/O triggered by the new ->readahead() method, so when it comes to setting
PG_fscache after a successful read from the server, I don't hold any page refs
- the assumption being that the waits in releasepage and invalidatepage
suffice. If that isn't sufficient, I can make it take page refs on the pages
to be written out - that should be easy enough to do.
> Honestly, the fact that writeback doesn't take a refcount, and then
> has magic "if writeback is set, don't free" code in other parts of the
> VM layer has been a problem already, when the wakeup ended up
> "leaking" from a previous page to a new allocation.
> I very much hope the fscache bit does not make similar mistakes,
> because the rest of the VM will _not_ have special "if fscache is set,
> then we won't do X" the way we do for writeback.
The VM can't do that because PG_private_2 might not be being used for
PG_fscache. It does, however, treat PG_private_2 like PG_private when
triggering calls to releasepage and invalidatepage.
> So I think the fscache code needs to hold a refcount regardless, and
> that the fscache bit is set the page has to have a reference.
> So what are the current lifetime rules for the fscache bit?
It depends which 'current' you're referring to.
The old fscache I/O API (ie. what's upstream) - in which PG_fscache is set on
a page to note that fscache knows about the page - does not keep a separate
ref on such pages.
The new fscache I/O API simplifies things. With that, pages are only known
about for the duration of a write to the cache. I've tried to analogise the
way PG_writeback works[*], including waiting for it in places like
invalidation, releasepage, page_mkwrite (though in the netfs, not the core VM)
as it may represent DMA.
Note that with the new I/O API, fscache and cachefiles know nothing about the
PG_fscache bit or netfs pages; they just deal with an iov_iter and a
completion function. Dealing with PG_fscache is done by the netfs and the new
netfs helper lib.
[*] Though I see that 073861ed77b6b made a change to end_page_writeback() for
an issue that probably affects unlock_page_fscache() too[**].
[**] This may mean that both PG_fscache and PG_writeback need to hold a ref on
next prev parent reply other threads:[~2021-02-09 22:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 16:09 [GIT PULL] fscache: I/O API modernisation and netfs helper library David Howells
2021-02-09 19:06 ` Linus Torvalds
2021-02-09 19:45 ` Jeff Layton
2021-02-09 20:21 ` Matthew Wilcox
2021-02-09 21:19 ` Linus Torvalds
2021-02-09 21:55 ` David Howells [this message]
2021-02-10 16:36 ` David Howells
2021-02-09 21:25 ` David Howells
2021-02-09 22:42 ` David Wysochanski
2021-02-09 21:10 ` David Howells
2021-02-10 16:29 ` David Howells
2021-02-10 16:33 ` David Howells
2021-02-10 20:43 ` Linus Torvalds
2021-02-11 22:38 ` David Howells
2021-02-11 23:20 ` David Howells
2021-02-12 16:40 ` David Wysochanski
2021-02-13 1:05 ` Linus Torvalds
2021-02-15 0:22 ` David Howells
2021-02-15 1:01 ` Linus Torvalds
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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).