From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
willy@infradead.org
Subject: Re: [PATCH] [RFC] iomap: zeroing needs to be pagecache aware
Date: Fri, 23 Dec 2022 08:15:02 -0800 [thread overview]
Message-ID: <Y6XUBhYnH4P9oRt8@infradead.org> (raw)
In-Reply-To: <20221201005214.3836105-1-david@fromorbit.com>
On Thu, Dec 01, 2022 at 11:52:14AM +1100, Dave Chinner wrote:
> folio = __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT,
> fgp, mapping_gfp_mask(iter->inode->i_mapping));
> if (!folio) {
> - status = (iter->flags & IOMAP_NOWAIT) ? -EAGAIN : -ENOMEM;
> + if (!(fgp & FGP_CREAT))
> + status = -ENODATA;
> + else if (iter->flags & IOMAP_NOWAIT)
> + status = -EAGAIN;
> + else
> + status = -ENOMEM;
Trying to reverse engineer the error case based on the flags passed
seems a bit problematic, even if I think for now it mostl still
works as !FGP_CREAT is exclusive vs IOMAP_NOWAIT.
Matthew, what do you think of switching __filemap_get_folio to an
ERR_PTR return and return actual cause? Or do we have too many
callers and need ____filemap_get_folio (urrg..)?
> + status = iomap_write_begin(iter, pos, bytes, &folio, fgp);
> + if (status) {
> + if (status == -ENODATA) {
> + /*
> + * No folio was found, so skip to the start of
> + * the next potential entry in the page cache
> + * and continue from there.
> + */
> + if (bytes > PAGE_SIZE - offset_in_page(pos))
> + bytes = PAGE_SIZE - offset_in_page(pos);
> + goto loop_continue;
> + }
> return status;
> + }
Nit: I'd check for -ENODATA one level of identation out to keep
the nesting limited:
status = iomap_write_begin(iter, pos, bytes, &folio, fgp);
if (status == -ENODATA) {
...
goto loop_continue;
}
if (status)
return status;
prev parent reply other threads:[~2022-12-23 16:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 0:52 [PATCH] [RFC] iomap: zeroing needs to be pagecache aware Dave Chinner
2022-12-01 2:08 ` Darrick J. Wong
2022-12-01 2:43 ` Dave Chinner
2022-12-01 3:59 ` Darrick J. Wong
2022-12-23 16:15 ` Christoph Hellwig
2022-12-13 15:18 ` Brian Foster
2022-12-23 16:15 ` Christoph Hellwig [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=Y6XUBhYnH4P9oRt8@infradead.org \
--to=hch@infradead.org \
--cc=david@fromorbit.com \
--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;
as well as URLs for NNTP newsgroup(s).