From: Matthew Wilcox <willy@infradead.org>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Linux FS Devel <linux-fsdevel@vger.kernel.org>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
"dm-devel@redhat.com" <dm-devel@redhat.com>
Subject: Re: Better read bio error granularity?
Date: Sun, 13 Mar 2022 17:44:44 +0000 [thread overview]
Message-ID: <Yi4tjPfXd6ZkRmbW@casper.infradead.org> (raw)
In-Reply-To: <d8ea4246-8271-d3c4-2e4d-70d2c1369a05@gmx.com>
On Sun, Mar 13, 2022 at 07:03:39PM +0800, Qu Wenruo wrote:
> > Specifically for the page cache (which I hope is what you meant by
> > "page error status", because we definitely can't use that for DIO),
>
> Although what I exactly mean is PageError flag.
>
> For DIO the pages are not mapping to any inode, but it shouldn't prevent
> us from using PageError flag I guess?
For DIO, *it is not your page*. It belongs to somebody else, and you
can't even look at the flags, or the ->mapping, or anything, really.
You have a refcount on the page to prevent it from going away, but the
only thing you can do to the page is use its address and put your refcount
when you're done with it. It might be an anonymous page, the ZERO_PAGE,
a pagecache page for another filesystem, a pagecache page for your own
filesystem, or even a pagecache page for the same file you're writing to.
The DIO might only be 512-byte aligned, so different parts of the page can
be being written to by different DIOs, or parts or the entire page might
be being read by multiple DIOs. It might be registered to an RDMA device.
I haven't been keeping up, but I think it's even possible that the page
of memory might be on a graphics card.
> > the intent is that ->readahead can just fail and not set any of the
> > pages Uptodate. Then we come along later, notice there's a page in
> > the cache and call ->readpage on it and get the error for that one
> > page. The other 31 pages should read successfully.
>
> This comes a small question, what is prevent the fs to submit a large
> bio containing the 32 pages again, other than reading them page by page?
>
> Just because of that page is there, but not Uptodate?
This would be a bad idea. Pages can be !Uptodate and Dirty, if they've
been partially written by a block-aligned write. So mindlessly
expanding a read of a single page to be a read of multiple pages will
result in data loss. Also we might not have pages in
the page cache for the surrounding pages, and we might be low enough on
memory that we can't allocate them. And pages have to be locked before
we do I/O. They have to be locked in order of file index, so you would
need to cope with trylocking the pages before this one and those
trylocks maybe failing.
In short, this would be prohibitively complex.
> >
> > (There's an awkward queston to ask about large folios here, and what
> > we might be able to do around sub-folio or even sub-page or sub-block
> > reads that happen to not touch the bytes which are in an error region,
> > but let's keep the conversation about pages for now).
> >
> Yeah, that can go crazy pretty soon.
>
> Like iomap or btrfs, they all use page::private to store extra bitmaps
> for those cases, thus it really impossible to use PageError flag.
> Thus I intentionally skip them here.
I'm actually looking to get rid of PageError, but I think the other
points stand by themselves even without that intention ;-)
> Thank you very much for the quick and helpful reply,
You're welcome! Thanks for starting the discussion rather than rushing
off to implement it ;-)
prev parent reply other threads:[~2022-03-13 17:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-13 10:24 Better read bio error granularity? Qu Wenruo
2022-03-13 10:55 ` Matthew Wilcox
2022-03-13 11:03 ` Qu Wenruo
2022-03-13 17:44 ` Matthew Wilcox [this message]
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=Yi4tjPfXd6ZkRmbW@casper.infradead.org \
--to=willy@infradead.org \
--cc=dm-devel@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
/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).