All of lore.kernel.org
 help / color / mirror / Atom feed
* question about mapping_set_error when writeback fails?
@ 2021-06-02 20:27 Darrick J. Wong
  2021-06-02 22:26 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2021-06-02 20:27 UTC (permalink / raw)
  To: Christoph Hellwig, Dave Chinner; +Cc: linux-fsdevel

In iomap_finish_page_writeback,

static void
iomap_finish_page_writeback(struct inode *inode, struct page *page,
		int error, unsigned int len)
{
	struct iomap_page *iop = to_iomap_page(page);

	if (error) {
		SetPageError(page);
		mapping_set_error(inode->i_mapping, -EIO);

Why don't we pass error to mapping_set_error here?  If the writeback
completion failed due to insufficient space (e.g. extent mapping btree
expansion hit ENOSPC while trying to perform an unwritten extent
conversion) then we set AS_EIO which causes fsync to return EIO instead
of ENOSPC like you'd expect.

The line in question was lifted from XFS; is this a historical behavior
from before we had AS_ENOSPC?  Or do we always set AS_EIO because that's
the error code that everyone understands (ha) to mean that writeback
failed and now we have no idea what's on disk vs. in the pagecache?

(I tried to figure out what ext4 and btrfs do to handle this, but ...
that was a twisty code maze and I gave up.)

--D

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question about mapping_set_error when writeback fails?
  2021-06-02 20:27 question about mapping_set_error when writeback fails? Darrick J. Wong
@ 2021-06-02 22:26 ` Matthew Wilcox
  2021-06-03 18:02   ` Jeff Layton
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2021-06-02 22:26 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, Dave Chinner, linux-fsdevel, Jeff Layton

On Wed, Jun 02, 2021 at 01:27:56PM -0700, Darrick J. Wong wrote:
> In iomap_finish_page_writeback,
> 
> static void
> iomap_finish_page_writeback(struct inode *inode, struct page *page,
> 		int error, unsigned int len)
> {
> 	struct iomap_page *iop = to_iomap_page(page);
> 
> 	if (error) {
> 		SetPageError(page);
> 		mapping_set_error(inode->i_mapping, -EIO);
> 
> Why don't we pass error to mapping_set_error here?  If the writeback
> completion failed due to insufficient space (e.g. extent mapping btree
> expansion hit ENOSPC while trying to perform an unwritten extent
> conversion) then we set AS_EIO which causes fsync to return EIO instead
> of ENOSPC like you'd expect.

Hah, I noticed the same thing a few weeks ago and didn't get round to
asking about it yet.  I'm pretty sure we should pass the real error to
mapping_set_error().

I also wonder if we shouldn't support more of the errors from
blk_errors, like -ETIMEDOUT or -EILSEQ, but that's a different
conversation.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question about mapping_set_error when writeback fails?
  2021-06-02 22:26 ` Matthew Wilcox
@ 2021-06-03 18:02   ` Jeff Layton
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2021-06-03 18:02 UTC (permalink / raw)
  To: Matthew Wilcox, Darrick J. Wong
  Cc: Christoph Hellwig, Dave Chinner, linux-fsdevel

On Wed, 2021-06-02 at 23:26 +0100, Matthew Wilcox wrote:
> On Wed, Jun 02, 2021 at 01:27:56PM -0700, Darrick J. Wong wrote:
> > In iomap_finish_page_writeback,
> > 
> > static void
> > iomap_finish_page_writeback(struct inode *inode, struct page *page,
> > 		int error, unsigned int len)
> > {
> > 	struct iomap_page *iop = to_iomap_page(page);
> > 
> > 	if (error) {
> > 		SetPageError(page);
> > 		mapping_set_error(inode->i_mapping, -EIO);
> > 
> > Why don't we pass error to mapping_set_error here?  If the writeback
> > completion failed due to insufficient space (e.g. extent mapping btree
> > expansion hit ENOSPC while trying to perform an unwritten extent
> > conversion) then we set AS_EIO which causes fsync to return EIO instead
> > of ENOSPC like you'd expect.
> 
> Hah, I noticed the same thing a few weeks ago and didn't get round to
> asking about it yet.  I'm pretty sure we should pass the real error to
> mapping_set_error().
> 
> I also wonder if we shouldn't support more of the errors from
> blk_errors, like -ETIMEDOUT or -EILSEQ, but that's a different
> conversation.

Note that whatever error you pass there is likely to bubble up to
userland via fsync/msync or whatever. Most file_check_and_advance_wb_err
callers don't vet that return code in any way. That's not a problem,
per-se, but you should be aware of the potential effects.
-- 
Jeff Layton <jlayton@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-03 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 20:27 question about mapping_set_error when writeback fails? Darrick J. Wong
2021-06-02 22:26 ` Matthew Wilcox
2021-06-03 18:02   ` Jeff Layton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.