From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] iomap: Handle memory allocation failure in readahead
Date: Tue, 31 Mar 2020 21:31:25 -0700 [thread overview]
Message-ID: <20200401043125.GD56958@magnolia> (raw)
In-Reply-To: <20200401030421.17195-1-willy@infradead.org>
On Tue, Mar 31, 2020 at 08:04:21PM -0700, Matthew Wilcox wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
>
> bio_alloc() can fail when we use GFP_NORETRY. If it does, allocate
> a bio large enough for a single page like mpage_readpages() does.
Why does mpage_readpages() do that?
Is this a means to guarantee some kind of forward (readahead?) progress?
Forgive my ignorance, but if memory is so tight we can't allocate a bio
for readahead then why not exit having accomplished nothing?
--D
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> fs/iomap/buffered-io.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 417115bfaf6b..c258801f18d4 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -302,6 +302,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
>
> if (!ctx->bio || !is_contig || bio_full(ctx->bio, plen)) {
> gfp_t gfp = mapping_gfp_constraint(page->mapping, GFP_KERNEL);
> + gfp_t orig_gfp = gfp;
> int nr_vecs = (length + PAGE_SIZE - 1) >> PAGE_SHIFT;
>
> if (ctx->bio)
> @@ -310,6 +311,8 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
> if (ctx->is_readahead) /* same as readahead_gfp_mask */
> gfp |= __GFP_NORETRY | __GFP_NOWARN;
> ctx->bio = bio_alloc(gfp, min(BIO_MAX_PAGES, nr_vecs));
> + if (!ctx->bio)
> + ctx->bio = bio_alloc(orig_gfp, 1);
> ctx->bio->bi_opf = REQ_OP_READ;
> if (ctx->is_readahead)
> ctx->bio->bi_opf |= REQ_RAHEAD;
> --
> 2.25.1
>
next prev parent reply other threads:[~2020-04-01 4:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 3:04 [PATCH] iomap: Handle memory allocation failure in readahead Matthew Wilcox
2020-04-01 4:31 ` Darrick J. Wong [this message]
2020-04-01 11:23 ` Matthew Wilcox
2020-04-01 16:48 ` Darrick J. Wong
2020-04-01 16:58 ` Matthew Wilcox
2020-04-01 15:50 ` Christoph Hellwig
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=20200401043125.GD56958@magnolia \
--to=darrick.wong@oracle.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=willy@infradead.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