From patchwork Sat Nov 17 23:53:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10687665 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 6288913B5 for ; Sat, 17 Nov 2018 23:53:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 543402A13C for ; Sat, 17 Nov 2018 23:53:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48AF42A134; Sat, 17 Nov 2018 23:53: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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 D343D2A14B for ; Sat, 17 Nov 2018 23:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbeKRKL6 (ORCPT ); Sun, 18 Nov 2018 05:11:58 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46445 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbeKRKL5 (ORCPT ); Sun, 18 Nov 2018 05:11:57 -0500 Received: by mail-pf1-f194.google.com with SMTP id s9-v6so13077681pfm.13 for ; Sat, 17 Nov 2018 15:53:32 -0800 (PST) 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; bh=072f8lD4g81Vn10CWUHoUo26U/oP6o1PKTyTkqSYZgw=; b=jzN/n5sQbWENmjWCVKK+0M+4vLgxo92h8gIZYUIvwe+BC/z/0iLW4R8ekVMlr8i3Eo Sl095n2NJmfiLfv168aITDBrRwpFK9XiCJ2+0DpxSpUKLWEF3HGs/EEHp2nD4aBezZbW ufGQ9+DTDOZUAe9Uo9jETeNgz3aogPhe0NS7RxopsPvOpFpWszQ14l8sTogUvtXR/deh KSKswezeW7fOHugfCxNUom8JfWi/Jv8Y4f1303SJwTJn9zOXyPuFjoKWyqOgtIPmq6pb FAuImv+1uJb+BKSgZ0DpoAapB4ZVgTRk5SDfo8iLXJjUfrtG55wSjwMlG1FjtYUtUQuX K7hg== 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; bh=072f8lD4g81Vn10CWUHoUo26U/oP6o1PKTyTkqSYZgw=; b=Qn3RU8aCfT0NTFtG7QTwODLG3omAiuRDBAPe+KxcvZU4TaN4hr6R4iuj+ZsqduZz1v Ow24dzG+KgJKoFujtlhdOnSzAnfAxjgJ4yz2ydsnBGT2Oc58TcI5F8uDW/46qoe0C5Ue ldDIMcizd1zF/dzZ+mZBpRBepPjQc86PDGA+Vp5pqBjhZ9Y5FQXPj/Rclui0CBm6Vf5N RFYEEQ/HRbnUiz13hYsSGpAc0hRr/1UubnqqBkHvBY5aJWt5z9n27GRcSo9uKNxsM1/w K1dqpYg/qQarQU65SvYwnhRW/OzXgwS8vj2CQhl9POrz0j8alesnTQssaXFITr5Lzj2T XCKQ== X-Gm-Message-State: AGRZ1gIO6dsbKYGbAifr84o4c84LtaxGufMb/TwXo4fviUte+xzrvmV/ nHsjP1zCu6ibbwSaUTeniFfTCw== X-Google-Smtp-Source: AJdET5d6qpZ5T7P2C459Elr180i1oiRNwt+cs+PROPX8DU1HYzy0whkFBzgtUVZvprRkLHPcqQuqRg== X-Received: by 2002:a63:d157:: with SMTP id c23mr14949553pgj.170.1542498812114; Sat, 17 Nov 2018 15:53:32 -0800 (PST) Received: from x1.localdomain (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id m1sm15812345pgn.9.2018.11.17.15.53.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 15:53:31 -0800 (PST) From: Jens Axboe To: linux-block@vger.kernel.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 5/5] aio: add support for file based polled IO Date: Sat, 17 Nov 2018 16:53:17 -0700 Message-Id: <20181117235317.7366-6-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181117235317.7366-1-axboe@kernel.dk> References: <20181117235317.7366-1-axboe@kernel.dk> 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 Needs further work, but this should work fine on normal setups with a file system on a pollable block device. Signed-off-by: Jens Axboe --- fs/aio.c | 2 ++ fs/direct-io.c | 4 +++- fs/iomap.c | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 500da3ffc376..e02085fe10d7 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1310,6 +1310,8 @@ static struct block_device *aio_bdev_host(struct kiocb *req) if (S_ISBLK(inode->i_mode)) return I_BDEV(inode); + else if (inode->i_sb && inode->i_sb->s_bdev) + return inode->i_sb->s_bdev; return NULL; } diff --git a/fs/direct-io.c b/fs/direct-io.c index a5a4e5a1423e..34de494e9061 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -477,8 +477,10 @@ static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio) if (sdio->submit_io) { sdio->submit_io(bio, dio->inode, sdio->logical_offset_in_bio); dio->bio_cookie = BLK_QC_T_NONE; - } else + } else { dio->bio_cookie = submit_bio(bio); + WRITE_ONCE(dio->iocb->ki_blk_qc, dio->bio_cookie); + } sdio->bio = NULL; sdio->boundary = 0; diff --git a/fs/iomap.c b/fs/iomap.c index 74c1f37f0fd6..4cf412b6230a 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -1555,6 +1555,7 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos, struct page *page = ZERO_PAGE(0); int flags = REQ_SYNC | REQ_IDLE; struct bio *bio; + blk_qc_t qc; bio = bio_alloc(GFP_KERNEL, 1); bio_set_dev(bio, iomap->bdev); @@ -1570,7 +1571,9 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos, bio_set_op_attrs(bio, REQ_OP_WRITE, flags); atomic_inc(&dio->ref); - return submit_bio(bio); + qc = submit_bio(bio); + WRITE_ONCE(dio->iocb->ki_blk_qc, qc); + return qc; } static loff_t @@ -1680,7 +1683,7 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length, atomic_inc(&dio->ref); dio->submit.last_queue = bdev_get_queue(iomap->bdev); - dio->submit.cookie = submit_bio(bio); + dio->iocb->ki_blk_qc = dio->submit.cookie = submit_bio(bio); } while (nr_pages); if (need_zeroout) {