Return-Path: Received: from mail-pl1-f194.google.com ([209.85.214.194]:44891 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726665AbeLDXi1 (ORCPT ); Tue, 4 Dec 2018 18:38:27 -0500 Received: by mail-pl1-f194.google.com with SMTP id k8so9065788pls.11 for ; Tue, 04 Dec 2018 15:38:26 -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, Jens Axboe Subject: [PATCH 21/26] block: add BIO_HOLD_PAGES flag Date: Tue, 4 Dec 2018 16:37:24 -0700 Message-Id: <20181204233729.26776-22-axboe@kernel.dk> In-Reply-To: <20181204233729.26776-1-axboe@kernel.dk> References: <20181204233729.26776-1-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 03895cc0d74a..ab174bce5436 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1635,7 +1635,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); } } @@ -1651,7 +1652,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 1d9c3da0f2a1..344e5b61aa4e 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -227,6 +227,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 */ -- 2.17.1