From patchwork Wed Nov 16 20:36:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9432613 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3E51560476 for ; Wed, 16 Nov 2016 20:37:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BE8A29099 for ; Wed, 16 Nov 2016 20:37:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F24F29159; Wed, 16 Nov 2016 20:37:13 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID,T_TVD_MIME_EPI 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 17CED29099 for ; Wed, 16 Nov 2016 20:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932347AbcKPUhL (ORCPT ); Wed, 16 Nov 2016 15:37:11 -0500 Received: from mail-it0-f47.google.com ([209.85.214.47]:38545 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932155AbcKPUhK (ORCPT ); Wed, 16 Nov 2016 15:37:10 -0500 Received: by mail-it0-f47.google.com with SMTP id o1so73064072ito.1 for ; Wed, 16 Nov 2016 12:37:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=56NotPV5WPVyUaoQC5a/GdtVAX0t0oYZMI/EBXw6D8s=; b=idtDToEwp+GBA5StlKYXY3fnXIE8ppF//J82297WE0AOs56iWCkbsPTRnwhtIiUDCq L10lNMM7Yz3U0P2FVecoTycyheIRVpoWQPWN+BS4HapooyGW4RiK//ex2hnzf9jrZ9fG tg9JiizVEAD2sBIOh8CwjH1PzIlIuSL9bGZXzWbG736HuJLfyRqtjaWMOODza2AOI8oW ZqKRDp7M1UxrAiiz7NN4KwwgP3cmGqyFWZ88FzOz+XClmUyderQ8DDOQk5rDBrqSMc9d 2gR7WCeDbm4An6DHzzFeXnQ4/FX8hgcD/lfAJ3CAP6kGbUuuAcmTAR7YSertWkKsmc3W XKjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=56NotPV5WPVyUaoQC5a/GdtVAX0t0oYZMI/EBXw6D8s=; b=WxdRjw5sgVzyUnu9CQoQ9Rfe1nUX+0kOFz821HowZXItDH9UYNSk/wU+DH5xYu85BK PY56meDowLr9iWfffiEhQ1g48DWVGbhBgb9VrTnjlglth0HivB3PlrwZvIlsma7edu5b eORt5QeHfFCIdeYbsAlEbXs3f2hMcrkDm3ApsalCjsi5sKTgIHFP3YrQDphux80Mb9io GBQW+MH5W3oCwqbFXdpio+G7CXIgNInV2F/nhofOkjbUAyaKI4vjWqDSHNgBzx50dqDU SwQkjpDYfBXi2UF3QtEiptPAifCJqvAiSbnLBv3tWHlufRwzCNwedDhXSJWSC/Actb1I QEog== X-Gm-Message-State: ABUngveMIC25phOnY4OPo9e+cyw+kSS6S84y9El+xqh7MxfJPUPCZ6viUG8FSJJqNmpaMw== X-Received: by 10.36.8.5 with SMTP id 5mr1794686itc.40.1479328598330; Wed, 16 Nov 2016 12:36:38 -0800 (PST) Received: from [192.168.1.129] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id x99sm43402ioi.17.2016.11.16.12.36.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Nov 2016 12:36:37 -0800 (PST) Subject: Re: [PATCHSET] Add support for simplified async direct-io To: Christoph Hellwig References: <20161114173728.GA22167@infradead.org> <71ce9ae3-214d-b248-3507-cc96bea41a9b@fb.com> <20161114180052.GA24476@infradead.org> <4f30a528-9996-4c6a-9513-8aa2054e4d4b@fb.com> <20161114180503.GA31126@infradead.org> <20161114181119.GA9396@infradead.org> <20161116163147.GA25038@infradead.org> <72b1725a-0363-d33e-f890-251b1ac88998@kernel.dk> <20161116171652.GA30008@infradead.org> Cc: linux-block@vger.kernel.org From: Jens Axboe Message-ID: Date: Wed, 16 Nov 2016 13:36:36 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: 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 On 11/16/2016 01:02 PM, Jens Axboe wrote: > On 11/16/2016 10:16 AM, Christoph Hellwig wrote: >> I've pushed out a new version of my code that avoids atomic ops >> for the single bio case: >> >> http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/new-dio >> >> I think we should take your extension of the existing >> __blkdev_direct_IO_simple to kmalloc up to BIO_MAX_PAGES and then use >> the above implementation for AIO and large synchronous I/O. >> >> I think I can also kill of blkdev_dio_pool by simply using bio_kmalloc >> as we're only doing the allocation at the beginning of the call, >> but I'd like to agree on an approach before spending too much time on >> it. >> > > I'm fine with this approach, but I would still REALLY like to see > blkdev_bio_end_io() split in two, once for sync and once for async. That > would be a lot cleaner, imho. > > Let me know how you want to do it. I added SYNC support for mine here, > the branch is here: > > http://git.kernel.dk/cgit/linux-block/log/?h=for-4.10/dio Attaching two patches here that add the BIO_MAX_PAGES extension, and the SYNC support for your branch. Latter is untested... You can add my reviewed-by to: 7bed5be4f28cc86e3929c0c0fbba24ca0344f36c 57c2cf5c2595c0054855d7402d3796b5924fd05c I'd like to get this in for 4.10. From 84629aca0c25cab79b2e03f2e046b5691255bf17 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 14 Nov 2016 10:19:47 -0700 Subject: [PATCH 1/2] block: support any sized IO for simplified bdev direct-io Just alloc the bio_vec array if we exceed the inline limit. Signed-off-by: Jens Axboe --- fs/block_dev.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 6c8b6dfac1e5..d34ec663f538 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -193,7 +193,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, struct file *file = iocb->ki_filp; struct block_device *bdev = I_BDEV(bdev_file_inode(file)); unsigned blkbits = blksize_bits(bdev_logical_block_size(bdev)); - struct bio_vec inline_vecs[DIO_INLINE_BIO_VECS], *bvec; + struct bio_vec inline_vecs[DIO_INLINE_BIO_VECS], *vecs, *bvec; loff_t pos = iocb->ki_pos; bool should_dirty = false; struct bio bio; @@ -204,9 +204,17 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, if ((pos | iov_iter_alignment(iter)) & ((1 << blkbits) - 1)) return -EINVAL; + if (nr_pages <= DIO_INLINE_BIO_VECS) + vecs = inline_vecs; + else { + vecs = kmalloc(nr_pages * sizeof(struct bio_vec), GFP_KERNEL); + if (!vecs) + return -ENOMEM; + } + bio_init(&bio); bio.bi_max_vecs = nr_pages; - bio.bi_io_vec = inline_vecs; + bio.bi_io_vec = vecs; bio.bi_bdev = bdev; bio.bi_iter.bi_sector = pos >> blkbits; bio.bi_private = current; @@ -243,6 +251,9 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, put_page(bvec->bv_page); } + if (vecs != inline_vecs) + kfree(vecs); + if (unlikely(bio.bi_error)) return bio.bi_error; iocb->ki_pos += ret; @@ -408,7 +419,7 @@ blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES); if (!nr_pages) return 0; - if (is_sync_kiocb(iocb) && nr_pages <= DIO_INLINE_BIO_VECS) + if (is_sync_kiocb(iocb)) return __blkdev_direct_IO_simple(iocb, iter, nr_pages); return __blkdev_direct_IO(iocb, iter, nr_pages); } -- 2.7.4