From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:50228 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728354AbeLMLxL (ORCPT ); Thu, 13 Dec 2018 06:53:11 -0500 Date: Thu, 13 Dec 2018 05:53:06 -0600 From: Goldwyn Rodrigues To: linux-fsdevel@vger.kernel.org Cc: linux-aio@kvack.org, avi@scylladb.com Subject: [PATCH] fs: Return EOPNOTSUPP if block layer does not support REQ_NOWAIT Message-ID: <20181213115306.fm2mjc3qszjiwkgf@merlin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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. 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) { -- 2.16.4