Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3054297rwb; Fri, 20 Jan 2023 10:33:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXtsojmJPAEh7H7XtC4Bj2lI06dsSQIeuaif7batCwlcwFCGiT1/jkM26mnkRQDZXYFa+2FI X-Received: by 2002:a05:6a20:1aa4:b0:b9:43bc:7ed8 with SMTP id ci36-20020a056a201aa400b000b943bc7ed8mr5664118pzb.16.1674239583636; Fri, 20 Jan 2023 10:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674239583; cv=none; d=google.com; s=arc-20160816; b=PY/mppTMWjAASYMEZJmrAoIHEf0B9kx4plXbR7K3Zg2K2+7YRsdzuYlsuCSKdhukh7 HLwGbpO7F0Wv9V7W6jftZEDLnUbq6My5u5SIYDvF/VS7UGY6zLJOcOzivxBukcaIOxJy T9AvF4l/rQtT5Df958L0hHwcvRi67PUca18NAlYTyugUyLbtpv7uhvnuYwDWeHu1k/Nf Kr30loknXEOLD/JKjRxueqU78yXRT3xAZr1JRvirojlSphUD7XZlYZcvlwHvSthkwiLN BoTslXgkcEHai4wF27Stc1mj1JnbTwARQZUWQqfT2oRjNIyLH70Q4I9uSJ/5u9nRngga 0SgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+g3DRHKAgrPcJigEk3L/WkOUOzIOHOHcwdPC7AZqHTY=; b=fEuHDHfFdXImbAd6GuBnIqizLK9k+AiON9Ph7HdUrVlQoUwNp8bHp5EPuiwD3ThXlC /PIzTKJGu3AC+uz9CgawjjvCduhgMw9kVbnK1dg2IKFxGnD2MygZyTGjdIp2FpN3waNb etc9FlcjRLVjrApxwpBNj8tONLo9cuhCs8aYch0KAI8ujQgCR3van1qGoQn5nr9NtpjD xD/4X6u/hSUqCqLRRztaQTMDnbgLLq5i7kr6e0lUfkZ0u4qjmfQFaml7vuqbETcaFFxt fF07j23r26lxUDMzbteIKsTtSlDbMrkvupv01YPQ2eo7pBJ+Pnozre6C4+GhtBn8S6wH 47+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YpgLdrxy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc22-20020a656d96000000b004d00fa50b0csi10196485pgb.53.2023.01.20.10.32.57; Fri, 20 Jan 2023 10:33:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YpgLdrxy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231143AbjATR5w (ORCPT + 50 others); Fri, 20 Jan 2023 12:57:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbjATR5n (ORCPT ); Fri, 20 Jan 2023 12:57:43 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B546547ECB for ; Fri, 20 Jan 2023 09:56:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674237376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+g3DRHKAgrPcJigEk3L/WkOUOzIOHOHcwdPC7AZqHTY=; b=YpgLdrxyRGc1XJTJqGZMQ1r1Qn9EQViu80XJn+rHNbDRtqIeQVZH1zMugoZKmrUb7Ug5jp OLe8VeWLq9kARbJ8Zf7b2ZRd86TxtxWTXHSJAPscivpxrEGk5L0Xeksvs+5HOWk2kS85Bb yp3l011JuIiIXgGG8dovc+Z/iBmtnZU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-355-cnhAqD6VOd6VC0a-4QNREg-1; Fri, 20 Jan 2023 12:56:11 -0500 X-MC-Unique: cnhAqD6VOd6VC0a-4QNREg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D8C1185A794; Fri, 20 Jan 2023 17:56:11 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.33.36.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C6CC1121315; Fri, 20 Jan 2023 17:56:09 +0000 (UTC) From: David Howells To: Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jens Axboe , Jan Kara , Jeff Layton , Logan Gunthorpe , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig Subject: [PATCH v7 4/8] block: Rename BIO_NO_PAGE_REF to BIO_PAGE_REFFED and invert the meaning Date: Fri, 20 Jan 2023 17:55:52 +0000 Message-Id: <20230120175556.3556978-5-dhowells@redhat.com> In-Reply-To: <20230120175556.3556978-1-dhowells@redhat.com> References: <20230120175556.3556978-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rename BIO_NO_PAGE_REF to BIO_PAGE_REFFED and invert the meaning. In a following patch I intend to add a BIO_PAGE_PINNED flag to indicate that the page needs unpinning and this way both flags have the same logic. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Jan Kara cc: Matthew Wilcox cc: Logan Gunthorpe cc: linux-block@vger.kernel.org Link: https://lore.kernel.org/r/167305166150.1521586.10220949115402059720.stgit@warthog.procyon.org.uk/ # v4 Link: https://lore.kernel.org/r/167344730802.2425628.14034153595667416149.stgit@warthog.procyon.org.uk/ # v5 Link: https://lore.kernel.org/r/167391054631.2311931.7588488803802952158.stgit@warthog.procyon.org.uk/ # v6 --- Notes: ver #5) - Split from patch that uses iov_iter_extract_pages(). block/bio.c | 9 ++++++++- fs/iomap/direct-io.c | 1 - include/linux/bio.h | 2 +- include/linux/blk_types.h | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/block/bio.c b/block/bio.c index 6a6c73d14bfd..cfe11f4799d1 100644 --- a/block/bio.c +++ b/block/bio.c @@ -243,6 +243,10 @@ static void bio_free(struct bio *bio) * Users of this function have their own bio allocation. Subsequently, * they must remember to pair any call to bio_init() with bio_uninit() * when IO has completed, or when the bio is released. + * + * We set the initial assumption that pages attached to the bio will be + * released with put_page() by setting BIO_PAGE_REFFED; if the pages + * should not be put, this flag should be cleared. */ void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table, unsigned short max_vecs, blk_opf_t opf) @@ -274,6 +278,7 @@ void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table, #ifdef CONFIG_BLK_DEV_INTEGRITY bio->bi_integrity = NULL; #endif + bio_set_flag(bio, BIO_PAGE_REFFED); bio->bi_vcnt = 0; atomic_set(&bio->__bi_remaining, 1); @@ -302,6 +307,7 @@ void bio_reset(struct bio *bio, struct block_device *bdev, blk_opf_t opf) { bio_uninit(bio); memset(bio, 0, BIO_RESET_BYTES); + bio_set_flag(bio, BIO_PAGE_REFFED); atomic_set(&bio->__bi_remaining, 1); bio->bi_bdev = bdev; if (bio->bi_bdev) @@ -812,6 +818,7 @@ EXPORT_SYMBOL(bio_put); static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp) { bio_set_flag(bio, BIO_CLONED); + bio_clear_flag(bio, BIO_PAGE_REFFED); bio->bi_ioprio = bio_src->bi_ioprio; bio->bi_iter = bio_src->bi_iter; @@ -1198,7 +1205,7 @@ void bio_iov_bvec_set(struct bio *bio, struct iov_iter *iter) bio->bi_io_vec = (struct bio_vec *)iter->bvec; bio->bi_iter.bi_bvec_done = iter->iov_offset; bio->bi_iter.bi_size = size; - bio_set_flag(bio, BIO_NO_PAGE_REF); + bio_clear_flag(bio, BIO_PAGE_REFFED); bio_set_flag(bio, BIO_CLONED); } diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 9804714b1751..c0e75900e754 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -202,7 +202,6 @@ static void iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio, bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; - get_page(page); __bio_add_page(bio, page, len, 0); iomap_dio_submit_bio(iter, dio, bio, pos); } diff --git a/include/linux/bio.h b/include/linux/bio.h index 22078a28d7cb..63bfd91793f9 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -482,7 +482,7 @@ void zero_fill_bio(struct bio *bio); static inline void bio_release_pages(struct bio *bio, bool mark_dirty) { - if (!bio_flagged(bio, BIO_NO_PAGE_REF)) + if (bio_flagged(bio, BIO_PAGE_REFFED)) __bio_release_pages(bio, mark_dirty); } diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 99be590f952f..86711fb0534a 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -318,7 +318,7 @@ struct bio { * bio flags */ enum { - BIO_NO_PAGE_REF, /* don't put release vec pages */ + BIO_PAGE_REFFED, /* Pages need refs putting (equivalent to FOLL_GET) */ BIO_CLONED, /* doesn't own data */ BIO_BOUNCED, /* bio is a bounce bio */ BIO_QUIET, /* Make BIO Quiet */