From patchwork Sat May 11 16:57:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Stefan_B=C3=BChler?= X-Patchwork-Id: 10939773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3AC514B6 for ; Sat, 11 May 2019 16:57:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6281212D9 for ; Sat, 11 May 2019 16:57:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA8A8212DB; Sat, 11 May 2019 16:57:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E9C9212D9 for ; Sat, 11 May 2019 16:57:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728686AbfEKQ5d (ORCPT ); Sat, 11 May 2019 12:57:33 -0400 Received: from mail.stbuehler.de ([5.9.32.208]:54240 "EHLO mail.stbuehler.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728524AbfEKQ5b (ORCPT ); Sat, 11 May 2019 12:57:31 -0400 Received: from chromobil.fritz.box (unknown [IPv6:2a02:8070:a29c:5000:823f:5dff:fe0f:b5b6]) by mail.stbuehler.de (Postfix) with ESMTPSA id 598B3C030C4; Sat, 11 May 2019 16:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=stbuehler.de; s=stbuehler1; t=1557593849; bh=MWXSBGxPaBW/HBIO9l9nup2qTJSSGAZJVidtIRfiMQ0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HwCGi4ypIvMndly4XoW4wATu+dOxmlFQxV8388KTImdQ0/V6mwZv9b1raA/C7cLYE 3DSGBiqUq8FsxNgpbPQRzCRYgOfkbG5J+Kh8n52deNce/d/jXo7T8Wgkjf/JwhLpwW la3NmUZcVD9eIQP7RCyXSIJyBs+jq+EN6XgOHUn8= From: =?utf-8?q?Stefan_B=C3=BChler?= To: Jens Axboe , Alexander Viro , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 5/5] io_uring: use FMODE_NOWAIT to detect files supporting IOCB_NOWAIT Date: Sat, 11 May 2019 18:57:27 +0200 Message-Id: <20190511165727.31599-5-source@stbuehler.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190511165727.31599-1-source@stbuehler.de> References: <20190511165727.31599-1-source@stbuehler.de> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This replaces the magic check looking for S_ISBLK(mode) || S_ISCHR(mode); given the io_uring file doesn't support read/write the check for io_uring_fops is useless anyway. Signed-off-by: Stefan Bühler --- fs/io_uring.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index e1c6ab63628f..396ce6804977 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -867,23 +867,6 @@ static struct file *io_file_get(struct io_submit_state *state, int fd) return state->file; } -/* - * If we tracked the file through the SCM inflight mechanism, we could support - * any file. For now, just ensure that anything potentially problematic is done - * inline. - */ -static bool io_file_supports_async(struct file *file) -{ - umode_t mode = file_inode(file)->i_mode; - - if (S_ISBLK(mode) || S_ISCHR(mode)) - return true; - if (S_ISREG(mode) && file->f_op != &io_uring_fops) - return true; - - return false; -} - static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s, bool force_nonblock) { @@ -896,7 +879,13 @@ static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s, if (!req->file) return -EBADF; - if (force_nonblock && !io_file_supports_async(req->file)) + /* + * don't set IOCB_NOWAIT if not supported (forces async punt) + * + * we don't punt if NOWAIT is not supported but requested as + * kiocb_set_rw_flags will return EOPNOTSUPP + */ + if (force_nonblock && !(req->file->f_mode & FMODE_NOWAIT)) force_nonblock = false; kiocb->ki_pos = READ_ONCE(sqe->off);