From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C51AEC433DF for ; Thu, 18 Jun 2020 14:44:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8662D20888 for ; Thu, 18 Jun 2020 14:44:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="uL0fwmVf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8662D20888 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3E96E8D001C; Thu, 18 Jun 2020 10:44:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 234C38D0018; Thu, 18 Jun 2020 10:44:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F96A8D001B; Thu, 18 Jun 2020 10:44:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id EB8BB8D0018 for ; Thu, 18 Jun 2020 10:44:06 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A53F89F5D6 for ; Thu, 18 Jun 2020 14:44:06 +0000 (UTC) X-FDA: 76942602492.04.paint36_2807cd626e11 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 727FD80A4EBE for ; Thu, 18 Jun 2020 14:44:05 +0000 (UTC) X-HE-Tag: paint36_2807cd626e11 X-Filterd-Recvd-Size: 5626 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 14:44:05 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id y18so2525132plr.4 for ; Thu, 18 Jun 2020 07:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=HUMIpAnpDXTm7durxzsxq78uIppsf6NP0VS0tAu1naU=; b=uL0fwmVf7za35bF7WmhIeuLwTRYPYomNz3qpWAcNPJ4MG8GTRnh40j/G/FSQGZeqHn yQkV1IezTLpFjD50TYMgv1HY78G4RgY498zLaJMuA+l8xEee6zj/2I82z6xH0BShFzod Jw88wuY/pILeFUtVbhY9sbTrVoWY7AC3u3FJAQooqqxLaL58sSt1DjQd+DiakJiej111 3QKNAaz9kpVK0JkkwmB/tU2PK7EUI1l3/XQW2Hhdy1LlQkxSISsyAWXCpJiSM6HpaavS QcI6gfKDo0Ou2qvSuNEV0Pw2sksh+dDzkS5v9GpxMofkwta1H+6MYdHHM9azIlc5CFhg lSog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=HUMIpAnpDXTm7durxzsxq78uIppsf6NP0VS0tAu1naU=; b=BUQR4dYp5HPjW9KWQD6FlnhmFkGu+MllMV/KRpqjirxLkkPxs8EKbJb7165NgUT35u PiUX5aD3FOpD9v2jnfY7IwfHDGT8HeLVpdLnDXCefyIoLhR5xfUIazIFueqrVbL49x08 D3TVqiBG1QY1AsUpRCyWlpDiVu4ebNR37VBKh42b3/xryrp6qw/HFwDt4LVYOAFZn6sb upHU1r9t4eFl0LbB7WwevugeKo82CptUZh10/RnFqJLH/a6u98iPrSkuvplojJ8upk9H XDXhcEDe/qCJEoVoGaofLoVWRW2Z9cMx/u0irUgVQuNExRtSKLYtPQ7ECEgE5RZLmzui KmFA== X-Gm-Message-State: AOAM531+OLoqh+ur9FGIaswWQmoX/DmZe0JazPt5buPFBtpHnL2Uub7u 9Liskhtnxqj2qUoQNSV6N9taBA== X-Google-Smtp-Source: ABdhPJzURLyFzMozy7yIPWEvSTKNlwHInRbt5PeVmy/Fa+Ew58olXOewrYlOoVFbj5T5wAt30tH4HQ== X-Received: by 2002:a17:90a:de1:: with SMTP id 88mr4809422pjv.124.1592491443796; Thu, 18 Jun 2020 07:44:03 -0700 (PDT) Received: from x1.localdomain ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id g9sm3127197pfm.151.2020.06.18.07.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 07:44:03 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 03/15] io_uring: catch -EIO from buffered issue request failure Date: Thu, 18 Jun 2020 08:43:43 -0600 Message-Id: <20200618144355.17324-4-axboe@kernel.dk> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200618144355.17324-1-axboe@kernel.dk> References: <20200618144355.17324-1-axboe@kernel.dk> Reply-To: "[PATCHSET v7 0/15]"@smtpin04.hostedemail.com, Add@smtpin04.hostedemail.com, support@smtpin04.hostedemail.com, for@smtpin04.hostedemail.com, async@smtpin04.hostedemail.com, buffered@smtpin04.hostedemail.com, reads@smtpin04.hostedemail.com MIME-Version: 1.0 X-Rspamd-Queue-Id: 727FD80A4EBE X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: -EIO bubbles up like -EAGAIN if we fail to allocate a request at the lower level. Play it safe and treat it like -EAGAIN in terms of sync retry, to avoid passing back an errant -EIO. Catch some of these early for block based file, as non-mq devices generally do not support NOWAIT. That saves us some overhead by not first trying, then retrying from async context. We can go straight to async punt instead. Signed-off-by: Jens Axboe --- fs/io_uring.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index ca78dd7c79da..2e257c5a1866 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2088,6 +2088,15 @@ static struct file *__io_file_get(struct io_submit= _state *state, int fd) return state->file; } =20 +static bool io_bdev_nowait(struct block_device *bdev) +{ +#ifdef CONFIG_BLOCK + return !bdev || queue_is_mq(bdev_get_queue(bdev)); +#else + return true; +#endif +} + /* * If we tracked the file through the SCM inflight mechanism, we could s= upport * any file. For now, just ensure that anything potentially problematic = is done @@ -2097,10 +2106,19 @@ static bool io_file_supports_async(struct file *f= ile, int rw) { umode_t mode =3D file_inode(file)->i_mode; =20 - if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISSOCK(mode)) - return true; - if (S_ISREG(mode) && file->f_op !=3D &io_uring_fops) + if (S_ISBLK(mode)) { + if (io_bdev_nowait(file->f_inode->i_bdev)) + return true; + return false; + } + if (S_ISCHR(mode) || S_ISSOCK(mode)) return true; + if (S_ISREG(mode)) { + if (io_bdev_nowait(file->f_inode->i_sb->s_bdev) && + file->f_op !=3D &io_uring_fops) + return true; + return false; + } =20 /* any ->read/write should understand O_NONBLOCK */ if (file->f_flags & O_NONBLOCK) @@ -2650,7 +2668,7 @@ static int io_read(struct io_kiocb *req, bool force= _nonblock) iov_count =3D iov_iter_count(&iter); ret =3D rw_verify_area(READ, req->file, &kiocb->ki_pos, iov_count); if (!ret) { - ssize_t ret2; + ssize_t ret2 =3D 0; =20 if (req->file->f_op->read_iter) ret2 =3D call_read_iter(req->file, kiocb, &iter); @@ -2658,7 +2676,7 @@ static int io_read(struct io_kiocb *req, bool force= _nonblock) ret2 =3D loop_rw_iter(READ, req->file, kiocb, &iter); =20 /* Catch -EAGAIN return for forced non-blocking submission */ - if (!force_nonblock || ret2 !=3D -EAGAIN) { + if (!force_nonblock || (ret2 !=3D -EAGAIN && ret2 !=3D -EIO)) { kiocb_done(kiocb, ret2); } else { copy_iov: --=20 2.27.0