Re: [PATCH 4/6] virtio block driver

Rusty Russell
2007-09-23T06:47:31Z

On Fri, 2007-09-21 at 14:27 +0200, Jens Axboe wrote:
> On Fri, Sep 21 2007, Rusty Russell wrote:
> > I shall look through the code and see if I can figure out how to fix it.
> > I'm assuming from your response that there's not some strange reason to
> > preserve current behaviour.
>
> It surely sounds like a bug, if you issue ioctl(fd, CDROMEJECT), the
> driver sees it and returns -ENOTTY, but userland sees a 0 retval. So if
> you have time, please do poke at it a bit.

OK, error (-ENOTTY) gets to blk_end_sync_rq(), but nothing happens to
it. This patch makes the ioctl return -EIO: I can't see a way to pass
the errno back properly.

diff -r 99e125262d6a block/ll_rw_blk.c
--- a/block/ll_rw_blk.c Sat Sep 22 15:37:22 2007 +1000
+++ b/block/ll_rw_blk.c Sun Sep 23 16:43:42 2007 +1000
@@ -2792,6 +2792,9 @@ void blk_end_sync_rq(struct request *rq,
rq->end_io_data = NULL;
__blk_put_request(rq->q, rq);

+ if (error)
+ rq->errors++;
+
/*
* complete last, if this is a stack request the process (and thus
* the rq pointer) could be invalid right after this complete()