Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3036544imm; Thu, 24 May 2018 21:43:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZocdKoH1KY0E3cQkPfdXvybjRO8w33p2WqUQWnQDCJ4Z+m/Fcv20OyRfLteuycO6oN6FPvw X-Received: by 2002:a17:902:4101:: with SMTP id e1-v6mr948450pld.205.1527223387315; Thu, 24 May 2018 21:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527223387; cv=none; d=google.com; s=arc-20160816; b=xsh9xah0gOfuDFhnTSo5RUBEW1W/ayqFRe+sB9z6nD1jFYNyC/5z9y30aD7tE++jpL PZ8UjyPtaYPbRaWamMW8QZkdA+ZJaTnPjgwjlHb+dBX/ojpr6X4ZpGVLTVaO1kUeKJrS 5MbDFM87H37p4SCdQShE/tj52RPBvfFRQZwhjjtZQtKs06azv+AhPqTSy/YT9BGb4F7P AawglK6goo7S4e3ogrJNjdocT3oiKWwFFIG6CtD5tIoSQqG2QJ4ukbIwOfmoJGtz4pQT An1S6mC9yFWSbjYSWM9wAQRTs+6XaMkwoldDwwBVwAnzsatJQ+g7L+4IsvHy8UozNF5d MxRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=kYI6JYmKH4sM4IUzAi6bIUV07PSJTBXlX//CUQDoZ0c=; b=nz/0oiiL6+YS2BdyImosHggeVQs+GuPRESnrzG2A4UG7KZFnzmAavrD/jracVBlYRP WT0n7aGQai3Ys1c39FiozaPsr6iPi7c/uwJiPFV9NcUNyC2VFjxzJ3ng21Fo2R8efoyN a9KRoWjW9dFaWvNEkUCTQfm21HFG1TV/BfGe35IiJPsI3Eyz409s1H4J0jaOu6Xzd4bY T9LpVPjr8EL8Lb4cQfAkhC6mexwUWCwjyQUuG9OP0ExYIak71s/+UQuIW1DboTFhFl93 mIUlSXsHye8cJi1WViXVgWaw58AAr+5L03ueq3bsf5osYIun0K1BbU9kWggUeshUYcXk t0rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=isyrg3dP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si17793632pgd.58.2018.05.24.21.42.52; Thu, 24 May 2018 21:43:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=isyrg3dP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935111AbeEYEmh (ORCPT + 99 others); Fri, 25 May 2018 00:42:37 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:42584 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934525AbeEYEmc (ORCPT ); Fri, 25 May 2018 00:42:32 -0400 Received: by mail-qk0-f195.google.com with SMTP id j80-v6so1416326qke.9; Thu, 24 May 2018 21:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kYI6JYmKH4sM4IUzAi6bIUV07PSJTBXlX//CUQDoZ0c=; b=isyrg3dP4PflaqgJNkms+Y6/i6keji88b2RRT7bjWa6NCxQWkw5Nm5/IxF/rTbnRcn nI/H32pvDQRPkJKQOsfRK2ClULMwPZyrwot1/i5MC6aTfCXIOppsVKFlAV7idtCf0oZP I55T+c1R81B1Lkzb6Z51e5IAlT21sGML5hEdLHGfT/+DhiTfgSjlyo9A4A1aArlm2vF5 g/UW2UvfRdOcEbU7DErBdwPGGlu2jenyKvmVsFYnk++e7NWZJdE1DUIhgSwYlhaVX8Mz tB/0WZG23FklerqbzqZ2xa0YYRsmeKFnhaMPfiRgThnj4NHS87tgDQCmB3oFR5ihJKrI HyPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kYI6JYmKH4sM4IUzAi6bIUV07PSJTBXlX//CUQDoZ0c=; b=tMt8ELPaYnrKglZpVJ25rY3VVMJo6ZKfyxQpr+7rJyJFptsYzs1v4BoW13ZfP8XZO+ pdvb8axaCkJlUGE91HVvGQ+rj4RyF3Cm2tN/ElDm/QV6sAnpia3W9MVp4TRN2Z5G1vQc +yGy4ZuiIGKCSgUUS0PQRWaBKCN3hrj5ULEfSSS0D/mVG62OvVY8tr+FbcSGSmmzfaOr +KMD9H+Qu9C1e6N69nXPRMZhPqCOFXzFwRGbJn/Eh6hU8eGhocEWaF85hVqjQtKybFx9 Yw5q5/4Q2uu3FoqakGkLxjOibXNbP/QsGpxpr6TPkvoPW0KN37SPFOyCqiidKJXBEkNZ ZGHA== X-Gm-Message-State: ALKqPwftHVA8UG2T5s0nqXsbMmqnhKiYOMKJ/viASwcfm9d2sabgDdg9 MMYnbEoxlJfu/nn3hEflkw== X-Received: by 2002:a37:8f84:: with SMTP id r126-v6mr651151qkd.8.1527223350995; Thu, 24 May 2018 21:42:30 -0700 (PDT) Received: from kmo-pixel (c-71-234-172-214.hsd1.vt.comcast.net. [71.234.172.214]) by smtp.gmail.com with ESMTPSA id a64-v6sm16642296qkd.7.2018.05.24.21.42.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 May 2018 21:42:29 -0700 (PDT) Date: Fri, 25 May 2018 00:42:27 -0400 From: Kent Overstreet To: Ming Lei Cc: Jens Axboe , Christoph Hellwig , Alexander Viro , 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 Subject: Re: [RESEND PATCH V5 12/33] block: introduce bio_segments() Message-ID: <20180525044227.GA8740@kmo-pixel> References: <20180525034621.31147-1-ming.lei@redhat.com> <20180525034621.31147-13-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180525034621.31147-13-ming.lei@redhat.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 25, 2018 at 11:46:00AM +0800, Ming Lei wrote: > There are still cases in which we need to use bio_segments() for get the > number of segment, so introduce it. > > Signed-off-by: Ming Lei > --- > include/linux/bio.h | 25 ++++++++++++++++++++----- > 1 file changed, 20 insertions(+), 5 deletions(-) > > diff --git a/include/linux/bio.h b/include/linux/bio.h > index 08af9272687f..b24c00f99c9c 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -227,9 +227,9 @@ static inline bool bio_rewind_iter(struct bio *bio, struct bvec_iter *iter, > > #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len) > > -static inline unsigned bio_pages(struct bio *bio) > +static inline unsigned __bio_elements(struct bio *bio, bool seg) This is a rather silly helper function, there isn't any actual code that's shared, everything's behind an if () statement. Just open code it in bio_pages() and bio_segments() > { > - unsigned segs = 0; > + unsigned elems = 0; > struct bio_vec bv; > struct bvec_iter iter; > > @@ -249,10 +249,25 @@ static inline unsigned bio_pages(struct bio *bio) > break; > } > > - bio_for_each_page(bv, bio, iter) > - segs++; > + if (!seg) { > + bio_for_each_page(bv, bio, iter) > + elems++; > + } else { > + bio_for_each_segment(bv, bio, iter) > + elems++; > + } > + > + return elems; > +} > + > +static inline unsigned bio_pages(struct bio *bio) > +{ > + return __bio_elements(bio, false); > +} > > - return segs; > +static inline unsigned bio_segments(struct bio *bio) > +{ > + return __bio_elements(bio, true); > } > > /* > -- > 2.9.5 >