Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1357635 > unrolled thread
| Started by | Jeff Moyer <jmoyer@redhat.com> |
|---|---|
| First post | 2016-03-14 22:20 +0100 |
| Last post | 2016-03-16 14:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[patch] direct-io: propagate -ENOSPC errors Jeff Moyer <jmoyer@redhat.com> - 2016-03-14 22:20 +0100
Re: [patch] direct-io: propagate -ENOSPC errors Carlos Maiolino <cmaiolino@redhat.com> - 2016-03-16 14:30 +0100
| From | Jeff Moyer <jmoyer@redhat.com> |
|---|---|
| Date | 2016-03-14 22:20 +0100 |
| Subject | [patch] direct-io: propagate -ENOSPC errors |
| Message-ID | <rcI4a-P4-9@gated-at.bofh.it> |
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;
}
/*
[toc] | [next] | [standalone]
| From | Carlos Maiolino <cmaiolino@redhat.com> |
|---|---|
| Date | 2016-03-16 14:30 +0100 |
| Message-ID | <rdjGq-136-37@gated-at.bofh.it> |
| In reply to | #1357635 |
This looks good to me.
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
On Mon, Mar 14, 2016 at 05:10:00PM -0400, Jeff Moyer wrote:
> 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;
> }
>
> /*
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Carlos
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web