From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f66.google.com ([209.85.221.66]:34300 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728733AbeLMMEq (ORCPT ); Thu, 13 Dec 2018 07:04:46 -0500 Received: by mail-wr1-f66.google.com with SMTP id j2so1761304wrw.1 for ; Thu, 13 Dec 2018 04:04:44 -0800 (PST) Subject: Re: [PATCH] fs: Return EOPNOTSUPP if block layer does not support REQ_NOWAIT To: Goldwyn Rodrigues , linux-fsdevel@vger.kernel.org Cc: linux-aio@kvack.org References: <20181213115306.fm2mjc3qszjiwkgf@merlin> From: Avi Kivity Message-ID: <38b8f7a9-cf95-e165-4e9a-40ddcfe6bed2@scylladb.com> Date: Thu, 13 Dec 2018 14:04:41 +0200 MIME-Version: 1.0 In-Reply-To: <20181213115306.fm2mjc3qszjiwkgf@merlin> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 12/13/18 1:53 PM, Goldwyn Rodrigues wrote: > For AIO+DIO with RWF_NOWAIT, if the block layer does not support REQ_NOWAIT, > it returns EIO. Return EOPNOTSUPP to represent the correct error code. Cc: stable@? > Signed-off-by: Goldwyn Rodrigues > --- > fs/direct-io.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/fs/direct-io.c b/fs/direct-io.c > index 41a0e97252ae..77adf33916b8 100644 > --- a/fs/direct-io.c > +++ b/fs/direct-io.c > @@ -542,10 +542,13 @@ static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio) > 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; > + dio->io_error = -EIO; > + if (bio->bi_opf & REQ_NOWAIT) { > + if (err == BLK_STS_AGAIN) > + dio->io_error = -EAGAIN; > + else if (err == BLK_STS_NOTSUPP) > + dio->io_error = -EOPNOTSUPP; > + } > } > > if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty) { Looks good. I wonder why it only shows up so rarely. Is there an alternative path that generates EOPNOTSUPP, that works most of the time?