From patchwork Sat Oct 27 16:48:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Raiber X-Patchwork-Id: 10658397 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 2DA6113A4 for ; Sat, 27 Oct 2018 16:48:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 119D92AC02 for ; Sat, 27 Oct 2018 16:48:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02C972AC24; Sat, 27 Oct 2018 16:48:52 +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=-5.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_MUA_MOZILLA,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 DF1F02AC02 for ; Sat, 27 Oct 2018 16:48:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728874AbeJ1BaX (ORCPT ); Sat, 27 Oct 2018 21:30:23 -0400 Received: from a4-4.smtp-out.eu-west-1.amazonses.com ([54.240.4.4]:57302 "EHLO a4-4.smtp-out.eu-west-1.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728839AbeJ1BaX (ORCPT ); Sat, 27 Oct 2018 21:30:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=vbsgq4olmwpaxkmtpgfbbmccllr2wq3g; d=urbackup.org; t=1540658928; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=lC92J4mSz/YRuPmvGUprp8hmSZN0PSlcZC6pI65hkTY=; b=gyai9jbKXjLEdmTIusQcOUfcTAxj20fRqpH80Vhc0jazbYxbQa1nUwS2ba/TbEAT 0AWRfBMd7cOFCZjw7FuOO+vPtGp6T238JSUxrUTuUAuU2ztG5kGJdmrsIwJchdocW4a 85PvsK3h0qPlkjOksVQAAOQowVlbl63dvAYCZBMY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1540658928; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=lC92J4mSz/YRuPmvGUprp8hmSZN0PSlcZC6pI65hkTY=; b=J98Cz7N6rzyCWsnSoOh3rF5je1iAZyJmylaYU4v5DMCIIpmy+3GXmVpq35a5PNDA eSykPU/sZkLwC9jxHp9qfkgrXhSW2t5k8zQm5gSo3crtPAjO9N2fC2hvAjXHHWuFE8D X/875UBZPI0IfnvSOdDhcWel4dh67SzT/oFcv/fY= Subject: [PATCH] fs: fuse: Switch to using async direct IO in fuse_direct_read/write_iter To: linux-fsdevel@vger.kernel.org, Miklos Szeredi From: Martin Raiber X-Forwarded-Message-Id: Message-ID: <01020166b66d99e7-59bda620-1b46-42f8-a2fa-81e5a3937454-000000@eu-west-1.amazonses.com> Date: Sat, 27 Oct 2018 16:48:48 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-SES-Outgoing: 2018.10.27-54.240.4.4 Feedback-ID: 1.eu-west-1.zKMZH6MF2g3oUhhjaE2f3oQ8IBjABPbvixQzV8APwT0=:AmazonSES Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch to using the async directo IO code path in fuse_direct_read_iter and fuse_direct_write_iter. This is especially important in connection with loop devices with direct IO enabled as loop assumes async direct io is actually async --- fs/fuse/file.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 32d0b883e74f..c2f5491aced9 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1426,6 +1426,14 @@ static ssize_t __fuse_direct_read(struct fuse_io_priv *io, static ssize_t fuse_direct_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb); + if(!is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) { + struct file *file = iocb->ki_filp; + struct inode *inode = file_inode(file); + + if (is_bad_inode(inode)) + return -EIO; + return inode->i_data.a_ops->direct_IO(iocb, to); + } return __fuse_direct_read(&io, to, &iocb->ki_pos); } @@ -1441,6 +1449,11 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) /* Don't allow parallel writes to the same file */ inode_lock(inode); res = generic_write_checks(iocb, from); + if(res>0 && !is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) + { + inode_unlock(inode); + return inode->i_data.a_ops->direct_IO(iocb, from); + } if (res > 0) res = fuse_direct_io(&io, from, &iocb->ki_pos, FUSE_DIO_WRITE); fuse_invalidate_attr(inode);