From: Rusty Russell <rusty@rustcorp.com.au>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Attempt to get eject failures back to ioctl(CDROMEJECT)
Date: Wed, 14 Nov 2007 17:39:46 +1100 [thread overview]
Message-ID: <200711141739.46960.rusty@rustcorp.com.au> (raw)
Hi Jens,
As you asked for some time ago. Of course, it turns out that the eject
command ignores the error anyway, but it's nice that it now errors.
Not entirely comfortable with this patch: there's a req->errors but
that seems to have some existing semantics I'm not sure of, so I simply
added a new way of flagging an error.
Cheers,
Rusty.
---
Currently the CDROMEJECT ioctl always succeeds; it'd be nice if we
managed to get the errno passed back through the request.
This patch tries to do that.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
diff -r a7da575b248f block/ll_rw_blk.c
--- a/block/ll_rw_blk.c Wed Nov 14 15:44:39 2007 +1100
+++ b/block/ll_rw_blk.c Wed Nov 14 17:33:55 2007 +1100
@@ -261,6 +261,7 @@ static void rq_init(struct request_queue
rq->end_io_data = NULL;
rq->completion_data = NULL;
rq->next_rq = NULL;
+ rq->errno = 0;
}
/**
@@ -2657,7 +2658,9 @@ int blk_execute_rq(struct request_queue
blk_execute_rq_nowait(q, bd_disk, rq, at_head, blk_end_sync_rq);
wait_for_completion(&wait);
- if (rq->errors)
+ if (rq->errno)
+ err = rq->errno;
+ else if (rq->errors)
err = -EIO;
return err;
@@ -3427,8 +3430,10 @@ static int __end_that_request_first(stru
* extend uptodate bool to allow < 0 value to be direct io error
*/
error = 0;
- if (end_io_error(uptodate))
+ if (end_io_error(uptodate)) {
+ req->errno = uptodate;
error = !uptodate ? -EIO : uptodate;
+ }
/*
* for a REQ_BLOCK_PC request, we want to carry any eventual
diff -r a7da575b248f drivers/block/virtio_blk.c
--- a/drivers/block/virtio_blk.c Wed Nov 14 15:44:39 2007 +1100
+++ b/drivers/block/virtio_blk.c Wed Nov 14 17:33:55 2007 +1100
@@ -51,7 +51,7 @@ static bool blk_done(struct virtqueue *v
uptodate = 1;
break;
case VIRTIO_BLK_S_UNSUPP:
- uptodate = -ENOTTY;
+ uptodate = -ENOSYS;
break;
default:
uptodate = 0;
diff -r a7da575b248f include/linux/blkdev.h
--- a/include/linux/blkdev.h Wed Nov 14 15:44:39 2007 +1100
+++ b/include/linux/blkdev.h Wed Nov 14 17:33:55 2007 +1100
@@ -281,6 +281,8 @@ struct request {
int tag;
int errors;
+ /* If this isn't set, assume -EIO. */
+ int errno;
int ref_count;
next reply other threads:[~2007-11-14 6:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-14 6:39 Rusty Russell [this message]
2007-11-14 12:39 ` [PATCH] Attempt to get eject failures back to ioctl(CDROMEJECT) Jens Axboe
2007-11-15 2:35 ` Rusty Russell
2007-11-15 8:47 ` Jens Axboe
2007-11-15 11:32 ` Rusty Russell
2007-11-15 11:35 ` Jens Axboe
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=200711141739.46960.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.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