From patchwork Fri Dec 7 22:20:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10718915 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 CFD7E1750 for ; Fri, 7 Dec 2018 22:21:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1E262F719 for ; Fri, 7 Dec 2018 22:21:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5D872F72F; Fri, 7 Dec 2018 22:21:05 +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 646C52F719 for ; Fri, 7 Dec 2018 22:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbeLGWVE (ORCPT ); Fri, 7 Dec 2018 17:21:04 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43779 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbeLGWVE (ORCPT ); Fri, 7 Dec 2018 17:21:04 -0500 Received: by mail-pg1-f193.google.com with SMTP id v28so2293121pgk.10 for ; Fri, 07 Dec 2018 14:21:03 -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=qHGUyfMFPUHePmcCM/30R2Nq4Nobfnj5bVLJuuayYxs=; b=HLYj8QAKuvg6vFqQeQEjbn1uUwvS+3UwseMPUNQE3zRB2IuTFM27kHoHS83wKDo3Hf CtlmScrJoZfZDq0u/sFgDqnUYEdWxG0Bjt7glgz/OGOMPEXBZ4P7EtilTSThq9j+F+fU 4jmf/GTkspYhOGGZSKg7h97vVOEhqiefG4tUbF8mfmzrTWERJHjsqbtLXquonwgLR0UL oVqgqTmeh1hO5n2HTH+jtGeX0FH6vlgv9BJf26X90f8uTx7URf0REFk41kEU/QoPYC1j hR5tD/0PE9/8sy1dYZDyjNq1SIm6k+EEi5VIp1+Ey+zMTNuB3DXrDL5mi5nVyahkTzB1 wTFQ== 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=qHGUyfMFPUHePmcCM/30R2Nq4Nobfnj5bVLJuuayYxs=; b=cModdYGQ2oCPpRZnI5dOe47G17OZQK8JzqHht/n0rVeu+K3qwHBUYPxXppV0RBYcC8 geS9daQ0X9e30meLIVunfHs2Iq3Ay/QfR7Z2q69fY1demcxXIY02Jt7c/XvdhCLrWRRj ZcaZmta97hJ8ESY0OdzuvN6GDEIBc49HYFP9XO57yx3vAFZNf4T0kSIgYUrszhNXmT5l hmD2slesILfefkwfTzrug6VsXu9nbxJ9KbMkmSuSUcKmo1k/UJtvUSUeTV2VWhWriv5Q Ofl4Leplo/uv7syXwYhPg26zJ3dPk71vQnoMO199uFyRWUi8P7Tgtc9fwYa/QKD/e5iN adOw== X-Gm-Message-State: AA+aEWZF6bOigVmKJtCQMcayacvT8poFyygOylIdQvnhKKby+VRMirUr 97blD9kF5Br/WTQiLXFuQ39e4z1zdHQ= X-Google-Smtp-Source: AFSGD/UdNL9M+7tBMv1YOKzwTcKOdwgKr9dJ/Bk8jdy8STrmHXnTOVgxqL9MMwEBbqM/Usr7jgdGTQ== X-Received: by 2002:a63:cf08:: with SMTP id j8mr3552907pgg.113.1544221262694; Fri, 07 Dec 2018 14:21:02 -0800 (PST) Received: from x1.localdomain (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id e9sm5282511pff.5.2018.12.07.14.21.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Dec 2018 14:21:01 -0800 (PST) From: Jens Axboe To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org Cc: hch@lst.de, jmoyer@redhat.com, clm@fb.com, Jens Axboe Subject: [PATCH 21/26] block: add BIO_HOLD_PAGES flag Date: Fri, 7 Dec 2018 15:20:11 -0700 Message-Id: <20181207222016.29387-22-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181207222016.29387-1-axboe@kernel.dk> References: <20181207222016.29387-1-axboe@kernel.dk> 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 For user mapped IO, we do get_user_pages() upfront, and then do a put_page() on each page at end_io time to release the page reference. In preparation for having permanently mapped pages, add a BIO_HOLD_PAGES flag that tells us not to release the pages, the caller will do that. Signed-off-by: Jens Axboe --- block/bio.c | 6 ++++-- include/linux/blk_types.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/block/bio.c b/block/bio.c index 06760543ec81..3e45e5650265 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1636,7 +1636,8 @@ static void bio_dirty_fn(struct work_struct *work) next = bio->bi_private; bio_set_pages_dirty(bio); - bio_release_pages(bio); + if (!bio_flagged(bio, BIO_HOLD_PAGES)) + bio_release_pages(bio); bio_put(bio); } } @@ -1652,7 +1653,8 @@ void bio_check_pages_dirty(struct bio *bio) goto defer; } - bio_release_pages(bio); + if (!bio_flagged(bio, BIO_HOLD_PAGES)) + bio_release_pages(bio); bio_put(bio); return; defer: diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 921d734d6b5d..356a4c89b0d9 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -228,6 +228,7 @@ struct bio { #define BIO_TRACE_COMPLETION 10 /* bio_endio() should trace the final completion * of this bio. */ #define BIO_QUEUE_ENTERED 11 /* can use blk_queue_enter_live() */ +#define BIO_HOLD_PAGES 12 /* don't put O_DIRECT pages */ /* See BVEC_POOL_OFFSET below before adding new flags */