From patchwork Mon Jan 16 23:09:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 44360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1447522wrn; Mon, 16 Jan 2023 15:12:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXufvWwXxLFYyUxhwN8M2c62AGht/tPVa9TNmwG+sXbbkgBWwJWU6GWnDapCyux4wPaAAXag X-Received: by 2002:aa7:cfc4:0:b0:49e:1d59:7942 with SMTP id r4-20020aa7cfc4000000b0049e1d597942mr977354edy.13.1673910769993; Mon, 16 Jan 2023 15:12:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673910769; cv=none; d=google.com; s=arc-20160816; b=BkGG4DNofPeFhvO8F3gSC//8BcLIGfj7a+g/7K6HRuVmmH8vZAW+Q9/p5YeKpELeuY MRtci5uQSeNLzG5rxQqpYuvSUD20cYh1Pe5oThr2jBsEQvWiNXb3gYTCXlVGe3UAWT3t N1d1z+LMrktpf2EEZd0hlQ1FsWtdrTJDYRyxdb9PxSgVE+HmceKQoIYsfhHGsHD8IqEV xHAgwylzwTCw/QnLxYNvMoM3DJE+H70kKxwZ0CsrkFhUb2Yse0a0dolGwW0f7718/MpO ZGsqy22/+l+eiPi3lmNabSZAEiz0WkIqaolMPlyox8cvPEHfCo1zvSDo5TbPtuonQL2F 84fw== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=oIg4SI8jd35c8Kgm0gG6JOeWye+BZTFoEmJg3h8S5uc=; b=dZMeK/ddGGwTHZU/bNHlsSaNzRtprXRhZOsTN97E96iUs6vqhpzxQcKnrVhdiigxKK QSQKwucZIUBZwbHqUCp351m/s320o2tTe+srCCWPcIooiOc1YnisT9H1nlncicrU/SZp Ug+NhcVW75C0NX6QsLOMS2dW+aEAVa8ddsM9tOLJAIxT2WZZuqxPy3ptT9nq6XnqgYN7 8MBkQOPDYUS5bvruIOW+e06sRhtWKzqi9NKyPzogawOZ4TLAZiHr0sCgYYfv/HYbS3xH 2zDSkFf/bq6Bt+M9YjIICCTIvMO13dUjLfOcPF69HQ5dpd3J8fHKP40yL+H/o3nIQFWb cKDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U2tzO5L3; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m14-20020a056402510e00b004876785ef7esi1786917edd.489.2023.01.16.15.12.26; Mon, 16 Jan 2023 15:12:49 -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=U2tzO5L3; 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 S233038AbjAPXLj (ORCPT + 99 others); Mon, 16 Jan 2023 18:11:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235274AbjAPXKW (ORCPT ); Mon, 16 Jan 2023 18:10:22 -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 E98D62BEF9 for ; Mon, 16 Jan 2023 15:09:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673910554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oIg4SI8jd35c8Kgm0gG6JOeWye+BZTFoEmJg3h8S5uc=; b=U2tzO5L3eVNH/bQdMw6iswVDw9ustmx7Epejj7BdzETs54WzgrtNc9UrOplwKgbcyEavA3 eMx2DVnwi4i8JKpy2CszKB05h0s32PoiWHY18Ou6d3Jh245F3arAT+yniYgB86//dRteOM ERWiUN43pqSVHfsRs+nw/dFxOSpllvs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-21-t5kEwhkRNwqeCqPIKbDeXQ-1; Mon, 16 Jan 2023 18:09:08 -0500 X-MC-Unique: t5kEwhkRNwqeCqPIKbDeXQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F7A22A59556; Mon, 16 Jan 2023 23:09:08 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id D489D492B00; Mon, 16 Jan 2023 23:09:06 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH v6 09/34] bio: Rename BIO_NO_PAGE_REF to BIO_PAGE_REFFED and invert the meaning From: David Howells To: Al Viro Cc: Jens Axboe , Jan Kara , Christoph Hellwig , Matthew Wilcox , Logan Gunthorpe , linux-block@vger.kernel.org, dhowells@redhat.com, Christoph Hellwig , 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 Date: Mon, 16 Jan 2023 23:09:06 +0000 Message-ID: <167391054631.2311931.7588488803802952158.stgit@warthog.procyon.org.uk> In-Reply-To: <167391047703.2311931.8115712773222260073.stgit@warthog.procyon.org.uk> References: <167391047703.2311931.8115712773222260073.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755222659740058249?= X-GMAIL-MSGID: =?utf-8?q?1755222659740058249?= 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. Changes ======= ver #5) - Split from patch that uses iov_iter_extract_pages(). Signed-off-by: David Howells cc: Al Viro cc: Jens Axboe cc: Jan Kara cc: Christoph Hellwig 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 Reviewed-by: Christoph Hellwig --- block/bio.c | 9 ++++++++- include/linux/bio.h | 2 +- include/linux/blk_types.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/block/bio.c b/block/bio.c index 867cf4db87ea..5b6a76c3e620 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/include/linux/bio.h b/include/linux/bio.h index 3f7ba7fe48ac..69b32c5532f6 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -496,7 +496,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 */