From patchwork Wed Jun 27 12:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10491371 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 D61C760532 for ; Wed, 27 Jun 2018 12:47:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C483628D80 for ; Wed, 27 Jun 2018 12:47:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B853E28D84; Wed, 27 Jun 2018 12:47:15 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C69728D80 for ; Wed, 27 Jun 2018 12:47:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7507F6B0273; Wed, 27 Jun 2018 08:47:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6B2AC6B0274; Wed, 27 Jun 2018 08:47:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 507216B0275; Wed, 27 Jun 2018 08:47:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id 228B56B0273 for ; Wed, 27 Jun 2018 08:47:13 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id b185-v6so1950290qkg.19 for ; Wed, 27 Jun 2018 05:47:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=CoEhYqe++N48DBkQkab6V8FThQzfX/NBRkp2/1DTchs=; b=fRnkMYWP+hgwQwj+G9q+XxErpoIwvsZCmPUODUWNwnMxhpwqlh+HXsWq29JcWtWYwD ZXGF6XHChET5l2bZULjhVn+m/I//b07toU+BCTEE213q3uyhn46yLc4rxQBftZWMWfJK 5Pk1MhR+VuZicO5TEW8Fqus36fHvMys+94Y+vOmys3E6As4Flzfm/9fdL+2+RBmtgTiD xk0ShUNPeRjiQYUGuy5Bb7Cw5FHB2W0DUiZwSyN1MukToivxorrtR1voGuDmezi6AEs5 UV6T1lI7my4u3EtysrD5dqerx04xzjn5F4thG+sHFs9kDkmYRT+31ORytTpGutUwoGLu tJGg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APt69E0BNYsTVTTFlen7OhyHaBOPTz0Y96fnlHry994zZKGo4FIFq8MY DdxrnS7Z2PiKmTjo4ArfRrk8b7eV/R2bH7ZxhlCCMr68/lermw3vLjXyb74GNEYJtozE6ry2Q0t Rl0+lvK2g+7ckQYXCcpeew9tgrkkPuFL8TVfoOXvAW7aBSwr5VJkSUPyd903cHLrhnw== X-Received: by 2002:a37:1289:: with SMTP id 9-v6mr4930335qks.151.1530103632924; Wed, 27 Jun 2018 05:47:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeSndl+dAn9qHRnF5x7FFUCucPZwckYDPrSxkrhQTw+/Z0Yhr+H8ukwB+mlbfSojqeBd7JI X-Received: by 2002:a37:1289:: with SMTP id 9-v6mr4930283qks.151.1530103631932; Wed, 27 Jun 2018 05:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530103631; cv=none; d=google.com; s=arc-20160816; b=eX/ZNa+AwF3YFt3eakRcjfrqWfE3bFFmxH/FJYXWa7elXbl5XQU1R8nCtnY/JM1dqj AxREABGNh5aEKnPPOgO/DImG8QKBvuNYWQJRAGogNQZstVh1f5Zllie6zZmQW5SW04p3 Cp5vlna10DRLNeZWeZMoSIcIekshKMTY8ry7IHU9JD9TuDsOfYKOhqw6HZTGkn1ivayU CU0unrB/9838Qbuy9RffwFtuVZZLqdTh+VCRtWX8gVvOl+6vGrBrrLwrJRnjzmQYInMq vF9igQ8FZf9MP1WX/iUL95J/Uami0aq9L3/EZ5X52Qfq+gOZDL3J1jtHlGRLYw+p0dVz CavQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=CoEhYqe++N48DBkQkab6V8FThQzfX/NBRkp2/1DTchs=; b=p8Wy519tndz50Ho2bZivteO1VeCjQ4f3d+HgeJx8QPhSLPI2hAYNX7Kt9aWvHcHv+7 yfKmrEiveLBhugK3E+XUqQ+5pL9gjks6X9uDVtSzShIrFXiSStBxLNe60dd6RTuNJqFx e0XjgCT1eLvD6dg77y9w+Hsz9jgaD2OGLkzyrNcA5MJLmo5YzqoKXPVtRBj3t/9Y19X9 7FSgFOMqxtOuzym+KGWre8SECsQ+Y4tqPojBTH5kl7/avF05ECKFZseOlezfkHWZhKpB oMNBe73ww3ZW4bqu+tVs9Kb7mZHqWhVKsYH0wE/26HDLgOuRt9Cb9h5p6aZKNEW+KOC5 C+kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id p26-v6si4039051qki.262.2018.06.27.05.47.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 05:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 mx1.redhat.com (Postfix) with ESMTPS id 6D1B3401EF04; Wed, 27 Jun 2018 12:47:11 +0000 (UTC) Received: from localhost (ovpn-12-44.pek2.redhat.com [10.72.12.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08CE411166E3; Wed, 27 Jun 2018 12:47:00 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Kent Overstreet Cc: David Sterba , Huang Ying , Mike Snitzer , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , "Darrick J . Wong" , Coly Li , Filipe Manana , Randy Dunlap , Christoph Hellwig Subject: [PATCH V7 06/24] block: unexport bio_clone_bioset Date: Wed, 27 Jun 2018 20:45:30 +0800 Message-Id: <20180627124548.3456-7-ming.lei@redhat.com> In-Reply-To: <20180627124548.3456-1-ming.lei@redhat.com> References: <20180627124548.3456-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 27 Jun 2018 12:47:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 27 Jun 2018 12:47:11 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Christoph Hellwig Now only used by the bounce code, so move it there and mark the function static. Reviewed-by: Ming Lei Signed-off-by: Christoph Hellwig --- block/bio.c | 77 ----------------------------------------------------- block/bounce.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++- include/linux/bio.h | 1 - 3 files changed, 68 insertions(+), 79 deletions(-) diff --git a/block/bio.c b/block/bio.c index 9710e275f230..43698bcff737 100644 --- a/block/bio.c +++ b/block/bio.c @@ -645,83 +645,6 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs) EXPORT_SYMBOL(bio_clone_fast); /** - * bio_clone_bioset - clone a bio - * @bio_src: bio to clone - * @gfp_mask: allocation priority - * @bs: bio_set to allocate from - * - * Clone bio. Caller will own the returned bio, but not the actual data it - * points to. Reference count of returned bio will be one. - */ -struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, - struct bio_set *bs) -{ - struct bvec_iter iter; - struct bio_vec bv; - struct bio *bio; - - /* - * Pre immutable biovecs, __bio_clone() used to just do a memcpy from - * bio_src->bi_io_vec to bio->bi_io_vec. - * - * We can't do that anymore, because: - * - * - The point of cloning the biovec is to produce a bio with a biovec - * the caller can modify: bi_idx and bi_bvec_done should be 0. - * - * - The original bio could've had more than BIO_MAX_PAGES biovecs; if - * we tried to clone the whole thing bio_alloc_bioset() would fail. - * But the clone should succeed as long as the number of biovecs we - * actually need to allocate is fewer than BIO_MAX_PAGES. - * - * - Lastly, bi_vcnt should not be looked at or relied upon by code - * that does not own the bio - reason being drivers don't use it for - * iterating over the biovec anymore, so expecting it to be kept up - * to date (i.e. for clones that share the parent biovec) is just - * asking for trouble and would force extra work on - * __bio_clone_fast() anyways. - */ - - bio = bio_alloc_bioset(gfp_mask, bio_segments(bio_src), bs); - if (!bio) - return NULL; - bio->bi_disk = bio_src->bi_disk; - bio->bi_opf = bio_src->bi_opf; - bio->bi_write_hint = bio_src->bi_write_hint; - bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; - bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; - - switch (bio_op(bio)) { - case REQ_OP_DISCARD: - case REQ_OP_SECURE_ERASE: - case REQ_OP_WRITE_ZEROES: - break; - case REQ_OP_WRITE_SAME: - bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0]; - break; - default: - bio_for_each_segment(bv, bio_src, iter) - bio->bi_io_vec[bio->bi_vcnt++] = bv; - break; - } - - if (bio_integrity(bio_src)) { - int ret; - - ret = bio_integrity_clone(bio, bio_src, gfp_mask); - if (ret < 0) { - bio_put(bio); - return NULL; - } - } - - bio_clone_blkcg_association(bio, bio_src); - - return bio; -} -EXPORT_SYMBOL(bio_clone_bioset); - -/** * bio_add_pc_page - attempt to add page to bio * @q: the target queue * @bio: destination bio diff --git a/block/bounce.c b/block/bounce.c index fd31347b7836..bc63b3a2d18c 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -195,6 +195,73 @@ static void bounce_end_io_read_isa(struct bio *bio) __bounce_end_io_read(bio, &isa_page_pool); } +static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask, + struct bio_set *bs) +{ + struct bvec_iter iter; + struct bio_vec bv; + struct bio *bio; + + /* + * Pre immutable biovecs, __bio_clone() used to just do a memcpy from + * bio_src->bi_io_vec to bio->bi_io_vec. + * + * We can't do that anymore, because: + * + * - The point of cloning the biovec is to produce a bio with a biovec + * the caller can modify: bi_idx and bi_bvec_done should be 0. + * + * - The original bio could've had more than BIO_MAX_PAGES biovecs; if + * we tried to clone the whole thing bio_alloc_bioset() would fail. + * But the clone should succeed as long as the number of biovecs we + * actually need to allocate is fewer than BIO_MAX_PAGES. + * + * - Lastly, bi_vcnt should not be looked at or relied upon by code + * that does not own the bio - reason being drivers don't use it for + * iterating over the biovec anymore, so expecting it to be kept up + * to date (i.e. for clones that share the parent biovec) is just + * asking for trouble and would force extra work on + * __bio_clone_fast() anyways. + */ + + bio = bio_alloc_bioset(gfp_mask, bio_segments(bio_src), bs); + if (!bio) + return NULL; + bio->bi_disk = bio_src->bi_disk; + bio->bi_opf = bio_src->bi_opf; + bio->bi_write_hint = bio_src->bi_write_hint; + bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; + bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; + + switch (bio_op(bio)) { + case REQ_OP_DISCARD: + case REQ_OP_SECURE_ERASE: + case REQ_OP_WRITE_ZEROES: + break; + case REQ_OP_WRITE_SAME: + bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0]; + break; + default: + bio_for_each_segment(bv, bio_src, iter) + bio->bi_io_vec[bio->bi_vcnt++] = bv; + break; + } + + if (bio_integrity(bio_src)) { + int ret; + + ret = bio_integrity_clone(bio, bio_src, gfp_mask); + if (ret < 0) { + bio_put(bio); + return NULL; + } + } + + bio_clone_blkcg_association(bio, bio_src); + + return bio; +} + static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, mempool_t *pool) { @@ -222,7 +289,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, generic_make_request(*bio_orig); *bio_orig = bio; } - bio = bio_clone_bioset(*bio_orig, GFP_NOIO, passthrough ? NULL : + bio = bounce_clone_bio(*bio_orig, GFP_NOIO, passthrough ? NULL : &bounce_bio_set); bio_for_each_segment_all(to, bio, i) { diff --git a/include/linux/bio.h b/include/linux/bio.h index 430807f9f44b..21d07858ddef 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -429,7 +429,6 @@ extern void bio_put(struct bio *); extern void __bio_clone_fast(struct bio *, struct bio *); extern struct bio *bio_clone_fast(struct bio *, gfp_t, struct bio_set *); -extern struct bio *bio_clone_bioset(struct bio *, gfp_t, struct bio_set *bs); extern struct bio_set fs_bio_set;