From: Jeff Moyer <jmoyer@redhat.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [patch] direct-io: propagate -ENOSPC errors
Date: Mon, 14 Mar 2016 17:10:00 -0400 [thread overview]
Message-ID: <x4960wosr4n.fsf@segfault.boston.devel.redhat.com> (raw)
dio_bio_complete turns all errors into -EIO. This is historical,
since you used to only get 1 bit precision for errors (BIO_UPTODATE).
Now that we get actual error codes, we can return the appropriate
code to userspace. File systems seem to only propagate either EIO
or ENOSPC, so I've followed suit in this patch.
This fixes an issue where -ENOSPC was being turned into -EIO when
testing dm-thin.
Reported-by: Carlos Maiolino <cmaiolin@redhat.com>
Tested-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
diff --git a/fs/direct-io.c b/fs/direct-io.c
index d6a9012..990e0aa 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -466,13 +466,15 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio)
{
struct bio_vec *bvec;
unsigned i;
- int err;
- if (bio->bi_error)
+ /* Only EIO and ENOSPC should be returned to userspace. */
+ if (bio->bi_error == 0 ||
+ bio->bi_error == -ENOSPC || bio->bi_error == -EIO)
+ dio->io_error = bio->bi_error;
+ else
dio->io_error = -EIO;
if (dio->is_async && dio->rw == READ && dio->should_dirty) {
- err = bio->bi_error;
bio_check_pages_dirty(bio); /* transfers ownership */
} else {
bio_for_each_segment_all(bvec, bio, i) {
@@ -483,10 +485,9 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio)
set_page_dirty_lock(page);
page_cache_release(page);
}
- err = bio->bi_error;
bio_put(bio);
}
- return err;
+ return dio->io_error;
}
/*
next reply other threads:[~2016-03-14 21:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-14 21:10 Jeff Moyer [this message]
2016-03-16 13:25 ` [patch] direct-io: propagate -ENOSPC errors Carlos Maiolino
2016-03-21 16:02 ` Christoph Hellwig
2016-03-21 20:22 ` Jeff Moyer
2016-04-21 14:17 ` Todd Vierling
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=x4960wosr4n.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).