From patchwork Wed Jun 13 14:56:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10462381 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 7BA6F60329 for ; Wed, 13 Jun 2018 14:57:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BCED28673 for ; Wed, 13 Jun 2018 14:57:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D6D528A8C; Wed, 13 Jun 2018 14:57: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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID 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 AD28028673 for ; Wed, 13 Jun 2018 14:57:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFA0D6B0007; Wed, 13 Jun 2018 10:57:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BA8466B0008; Wed, 13 Jun 2018 10:57: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 A97AA6B000A; Wed, 13 Jun 2018 10:57:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f71.google.com (mail-pg0-f71.google.com [74.125.83.71]) by kanga.kvack.org (Postfix) with ESMTP id 6B1D46B0007 for ; Wed, 13 Jun 2018 10:57:13 -0400 (EDT) Received: by mail-pg0-f71.google.com with SMTP id n3-v6so982990pgp.21 for ; Wed, 13 Jun 2018 07:57:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:references:mime-version:content-disposition:in-reply-to :user-agent; bh=Emy3uXuN0Z1AgRSb7jkmiCl7ZhJK0o2+RUDx+bn8hJU=; b=DDF9mwRcsP6jCm78g+UsUaQCqGVwhYOsWLUce+Ds/TpQqfNASiKjOJSj7cir2F/wjs dqp9KnS+uqaH5ovnA/d00TOugrw0fDwseh1vgDbXYMa5ftHU3VB4bMSFHrhX7tQOV4Rb JdSN3UuH5b4+zepiRif5CjGdZydOQPcSm2tloiH96MQPCfFAauwDyjNfG/kHMG3mUkVU QUFfUh6HbaQnVasbW03YAocBNKJCCRoyAhXFpGi7QH0xuwuBw8ANwmOqmar0hGhv4lyW aFMDK2TK/TR1twRs6IeizthwQX1JPKiLUD/yb9BWgkx/3fC12j7eRXScf07CJCGU35ke delQ== X-Gm-Message-State: APt69E1D+iJizKbY8ogmmG9hmP/mwXOWSVHQIqyhboMYuLM6LP0Q5DAq BD6plP9f0YUzunVaADYfPvP9qnvELXKYQEfFa4cSr4vhT3t6XwjHe1D2dBssRdsaaJVkY26638O mfCeKEO+PCFkB5IRXDvXhZ8x0gzkrt+/JWLncZ2mtXaMVh2O+TN9MSCtueGmHbA+ntg== X-Received: by 2002:a63:ba56:: with SMTP id l22-v6mr4379817pgu.161.1528901833094; Wed, 13 Jun 2018 07:57:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJygZch/jesgsJ+xn08YdhBjF5wUjIHSYcHy3Vi3/LvRHm2CF8sFIIKgyjCKrGgVwHR4tl2 X-Received: by 2002:a63:ba56:: with SMTP id l22-v6mr4379759pgu.161.1528901831835; Wed, 13 Jun 2018 07:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528901831; cv=none; d=google.com; s=arc-20160816; b=Mu6Vrp3otIQgU5Gh/7jxouXHm+5/FiJq3M4QBVeAynaPMhxEOVOOFTV/ZblxvVo4MT H6ilAJ4x/WQ0bnDbKGnR68c31L0UbtUUnLcyLx454dpBisUm9CIn/cUstj1Abxe2SOaB YDm88CDvvooK6Go+BlHBtODC2/7akdbpCxxA/CDuDA/Vk8dC/plloAKG9duf9mZWNUGl pM6LbXV4OkDhlbYMiTnzLwXD2iU0zs1SQonKSS0rwGAzLvBXPQvyLaBPB5kMVW0Vep9t mLRqMNQ2gv2oiXcWAEbTkHV3tZwI0ZriBMwvxODnKngFMrnpXIKlvn3GvxIh39TGar+6 wBNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=Emy3uXuN0Z1AgRSb7jkmiCl7ZhJK0o2+RUDx+bn8hJU=; b=frC05u3AiBLlCDwYd0M09NY7/WrANs8jv2dN+hzDm75YmoqtFDEEHUWn38VhCx6eQl /l8XVKj2s8GkDN+fU92yZW8c5ujjGcXMiNwudtxFmrIJWPM3n1tmgkDgqI0ppJyCeVOL 8jQkg0xMj4coCIxawiiC5irxRAqffybKaVoPx7z5LFWipYW0wXiuPFAXj1+oyAQWBIAJ BjsGKYWEgKZMheqct65PrvdlLIAilz59Esax8AkhwPz9cYFvYsZ3Ml6Q9vVnF9kkhg3+ Oj7zX/sbVYRrSKZVXhpDv0tvk4l6azXRsj7PPYXB8zahPCDI/iFDIAt4FZK+HOPLtWDc lLhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QYhceELy; spf=pass (google.com: best guess record for domain of batv+1e44ea8f521110dda36c+5407+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+1e44ea8f521110dda36c+5407+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id c18-v6si3103858plo.185.2018.06.13.07.57.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 07:57:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+1e44ea8f521110dda36c+5407+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QYhceELy; spf=pass (google.com: best guess record for domain of batv+1e44ea8f521110dda36c+5407+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+1e44ea8f521110dda36c+5407+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Emy3uXuN0Z1AgRSb7jkmiCl7ZhJK0o2+RUDx+bn8hJU=; b=QYhceELyHdCQfWggBnrFz+BKO zoguPujAJrzhZJHveaE/mjKq77jIcF/2IENvMFCPuNSaIPknkNc7Q6B615eHEaYb42l1MhZYAEQlz Zp5dh4tQVwRAxRVlIbEGUiFhM5RrPaym8LuOMs8K6lUg2bEM/LSZVvvtQys2N4cSBbu/3NpmCYERF BspX8hn3tj0EN54Qcg8Xee1YLvZpSUkh6c8a4+Mq5FH7OiStZe25TQlDAa5wtq/CUpFbhWp+svK30 DO0e7sXOxl8OfF/j4Gi0Xe84S3dYTMFrPNJB9eg9sBAXhbJDw21Mw9PjI9u+DeszCRGcfb9oearPa Bdjl4gjGQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fT7Cg-0004gr-IN; Wed, 13 Jun 2018 14:56:54 +0000 Date: Wed, 13 Jun 2018 07:56:54 -0700 From: Christoph Hellwig To: Ming Lei Cc: Jens Axboe , Christoph Hellwig , Alexander Viro , Kent Overstreet , David Sterba , Huang Ying , 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 Subject: Re: [PATCH V6 15/30] block: introduce bio_clone_chunk_bioset() Message-ID: <20180613145654.GE4693@infradead.org> References: <20180609123014.8861-1-ming.lei@redhat.com> <20180609123014.8861-16-ming.lei@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180609123014.8861-16-ming.lei@redhat.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 On Sat, Jun 09, 2018 at 08:29:59PM +0800, Ming Lei wrote: > There is one use case(DM) which requires to clone bio chunk by > chunk, so introduce this API. I don't think DM is the special case here. The special case is the bounce code that only wants single page bios. Between that, and the fact that we only have two callers and one of them is inside the block layer I would suggest to fold in the following patch to make bio_clone_bioset clone in multi-page bvecs and make the bounce code use the low-level interface directly: diff --git a/block/bio.c b/block/bio.c index 284085ab97e7..cef45c8d0a19 100644 --- a/block/bio.c +++ b/block/bio.c @@ -644,13 +644,14 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs) } EXPORT_SYMBOL(bio_clone_fast); -static struct bio *__bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, - struct bio_set *bs, bool seg) +struct bio *__bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, + struct bio_set *bs, bool single_page_only) { struct bvec_iter iter; struct bio_vec bv; struct bio *bio; - int nr_vecs = seg ? bio_segments(bio_src) : bio_chunks(bio_src); + int nr_vecs = single_page_only ? + bio_segments(bio_src) : bio_chunks(bio_src); /* * Pre immutable biovecs, __bio_clone() used to just do a memcpy from @@ -692,7 +693,7 @@ static struct bio *__bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0]; break; default: - if (seg) { + if (single_page_only) { bio_for_each_segment(bv, bio_src, iter) bio->bi_io_vec[bio->bi_vcnt++] = bv; } else { @@ -728,26 +729,10 @@ static struct bio *__bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, */ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, struct bio_set *bs) -{ - return __bio_clone_bioset(bio_src, gfp_mask, bs, true); -} -EXPORT_SYMBOL(bio_clone_bioset); - -/** - * bio_clone_seg_bioset - clone a bio segment by segment - * @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_chunk_bioset(struct bio *bio_src, gfp_t gfp_mask, - struct bio_set *bs) { return __bio_clone_bioset(bio_src, gfp_mask, bs, false); } -EXPORT_SYMBOL(bio_clone_chunk_bioset); +EXPORT_SYMBOL(bio_clone_bioset); /** * bio_add_pc_page - attempt to add page to bio diff --git a/block/bounce.c b/block/bounce.c index c6af0bd29ec9..62dab528dc1b 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -224,8 +224,8 @@ 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 : - &bounce_bio_set); + bio = __bio_clone_bioset(*bio_orig, GFP_NOIO, passthrough ? NULL : + &bounce_bio_set, true); bio_for_each_chunk_segment_all(to, bio, i, citer) { struct page *page = to->bv_page; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 13ca3574d972..98dff36b89a3 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1582,8 +1582,8 @@ static blk_qc_t __split_and_process_bio(struct mapped_device *md, * the usage of io->orig_bio in dm_remap_zone_report() * won't be affected by this reassignment. */ - struct bio *b = bio_clone_chunk_bioset(bio, GFP_NOIO, - &md->queue->bio_split); + struct bio *b = bio_clone_bioset(bio, GFP_NOIO, + &md->queue->bio_split); ci.io->orig_bio = b; bio_advance(bio, (bio_sectors(bio) - ci.sector_count) << 9); bio_chain(b, bio); diff --git a/include/linux/bio.h b/include/linux/bio.h index 58838dc12d69..5ccafeadbe95 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -486,7 +486,8 @@ 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 *bio_clone_chunk_bioset(struct bio *, gfp_t, struct bio_set *bs); +extern struct bio *__bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, + struct bio_set *bs, bool single_page_only); extern struct bio_set fs_bio_set;