Re: Spurious EIO on AIO+DIO+RWF_NOWAIT

From: Avi Kivity
Date: Wed Dec 12 2018 - 07:05:47 EST


On 12/10/18 2:48 PM, Goldwyn Rodrigues wrote:
On 13:19 09/12, Avi Kivity wrote:
I have an application that receives spurious EIO when running with
RWF_NOWAIT enabled. Removing RWF_NOWAIT causes those EIOs to disappear. The
application uses AIO+DIO, and errors were seen on both xfs and ext4.


I suspect the following code:


/*
Â* Process one completed BIO. No locks are held.
Â*/
static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
{
ÂÂÂÂÂÂÂ struct bio_vec *bvec;
ÂÂÂÂÂÂÂ unsigned i;
ÂÂÂÂÂÂÂ blk_status_t err = bio->bi_status;

ÂÂÂÂÂÂÂ if (err) {
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (err == BLK_STS_AGAIN && (bio->bi_opf & REQ_NOWAIT))
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ dio->io_error = -EAGAIN;
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ else
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ dio->io_error = -EIO;
ÂÂÂÂÂÂÂ }

Could it be that REQ_NOWAIT was dropped from bio->bi_opf? or that
bio->bi_status got changed along the way?

I don't think REQ_NOWAIT is dropped. I am assuming bio->bi_status error
is set differently. Is the blk queue being stopped? Is it possible to
instrument the kernel in your testcase?


I traced the function, and I see bio->bi_status == BLK_STS_NOTSUPP and bio->bi_opf == REQ_OP_WRITE|REQ_SYNC|REQ_NOMERGE|REQ_FUA|REQ_NOWAIT. Presumably the NOTSUPP is the result of NOWAIT not being supported down the stack, but shouldn't it be detected earlier? And not converted to EIO?