Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8711782imu; Thu, 15 Nov 2018 16:28:30 -0800 (PST) X-Google-Smtp-Source: AJdET5elEJLzQAxkLhmvWMkAhjwq93Qi+TP/qZ4klNxHIZFJ4NE7fP3GwGcFDMtVG5Rh6QfMV5ZJ X-Received: by 2002:a17:902:a40f:: with SMTP id p15mr8683932plq.286.1542328109984; Thu, 15 Nov 2018 16:28:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542328109; cv=none; d=google.com; s=arc-20160816; b=YCfbO+1a+mSlHxzUraDqFOV84eZyT9NUK3a8KZTv6PiEE+WkMbVbk81F4Re5/Ynu8S HXXmoqnfpoz/BU1f0jJ5NAeNczNyE0yZxPLNmy+nqak0Njbs1zwRO+aE12r/JUjI6sm7 WtdvwV7bDlC5br9gK/HkuRvt9/7xonSwmZJRyj6lcc1r1cVUNg2XLZl3tU2jzUjv+3dr WgtptRn7cpOHQA5sHOzdXNxzKVxiCck41LfFytRBwQ3va8+nWZ4elhqv89vDuhCyKgsa 73+VQ2PV2KAmgsx+PwPWACba/n52Vxf5rVhopUa8iSCcIVxpWWPMicBV+kNRHoiQRdh0 MPjw== 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; bh=rc7fjUApD7flLlTVqa/RhgazHXBYzBAhEuXeNhvwmBU=; b=GgFO6uwk1cM7vjJSts7Ct6SaWxLWUSOFOBuighIpUv+QacubKIJBJHS2GzyjDHpAyl Snqr206z5czxnx5MtUhGJEJSFGvOVmqmbkCCPlARAHVYWdEc6Q3h3zo4b0QFPiVgjPNe opzXAWc6Yw+sv1WwjaqEp9fojT9hzcbY9eDPiQ13g0lDQ1R78BKXNcZpogtA0igklLnb 3fIh86aOYBNG4VFM0ws/4byJ05d6Vi24xE9udk4u/+raSfbajqehomOZ3pyqyTGiw5m8 gmqNoi5F4qWI55N8RydvGzl5uAJ/HmqCDMysxFTXgH/McjohsJ8CemFjrhKHsfpv97Ep gk4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=Jcb61BmO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d66si1041108pfg.36.2018.11.15.16.28.15; Thu, 15 Nov 2018 16:28:29 -0800 (PST) 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=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=Jcb61BmO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727374AbeKPKgg (ORCPT + 99 others); Fri, 16 Nov 2018 05:36:36 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36631 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726687AbeKPKgf (ORCPT ); Fri, 16 Nov 2018 05:36:35 -0500 Received: by mail-pg1-f196.google.com with SMTP id n2so2585965pgm.3 for ; Thu, 15 Nov 2018 16:26:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rc7fjUApD7flLlTVqa/RhgazHXBYzBAhEuXeNhvwmBU=; b=Jcb61BmOL2Jy+hgyO2/CuDgpSAkWFinbUNWCgcSEX11fUG/4NFpcyuoqKnENa/1Ua5 PQrnGT5h+ai+Fxp9DOzzy2Ve6wq1+3E6wccymzQ8rvqQL8QGLxt0rHSw7RIo54m5hnVx y6zabFjieEYHME8kJ3pIbuVSPB2uBmQ97htfzqKHtrlfytrO87IkKmWJLD11K8qeEblY LVUbI4hmYiHPS0Fz4xAIDJJfVrpqbRyBVM+yYPGAWyWvD0Bj04dMWG2Cu8chIoQYZ+jI lDlID/Orlb6eoayXMROJjxhsz7k6qTeyfXxPlRijju/mdxG6gNA7VSOUPUMMLlkqX/qO 07fg== 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=rc7fjUApD7flLlTVqa/RhgazHXBYzBAhEuXeNhvwmBU=; b=dAW5W1FxmRWYNaqICh2UOw6TOHb79zI8qG1KBZYpi7fZizazejeskiEWPV1k1oT/yU FJ6338SMgKs/BsGm+Rcja976Ya6uG+wSzHZjmgW2R6yGdvkW4eQ63NVG0TWeDix6ZEeR 75Bw6xS4YdxUmoZiVW6jbkQJAf3AULZhJ5J0MjbWVYmMY15UfGWNim99FkkKYL5eq9a/ p3Gw1/PeZhO2gKMtYiU6V9zuxpz6pE7UsEYrRGU+S0o5M/cgTk+L4zpcS8DRnX4kypCT tnrQfq1FM96p9m38tcuVeK0KaPVdmtk3yMaX3CJVztvEVIQDaekAOoVPmxn04zqILF/4 ztLQ== X-Gm-Message-State: AGRZ1gJTei2Mk6E8r6e2S+HM1IOvnrtJY4q+94/XUyIxJjnWGCttfih9 /HMOKrS7CUpcfZXDrmdSEaPztQ== X-Received: by 2002:a63:5518:: with SMTP id j24mr2179612pgb.208.1542327987036; Thu, 15 Nov 2018 16:26:27 -0800 (PST) Received: from vader ([64.114.255.97]) by smtp.gmail.com with ESMTPSA id t64-v6sm32749985pfd.127.2018.11.15.16.26.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 16:26:26 -0800 (PST) Date: Thu, 15 Nov 2018 16:26:25 -0800 From: Omar Sandoval To: Ming Lei Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: Re: [PATCH V10 09/19] block: introduce bio_bvecs() Message-ID: <20181116002625.GD23828@vader> References: <20181115085306.9910-1-ming.lei@redhat.com> <20181115085306.9910-10-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181115085306.9910-10-ming.lei@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 15, 2018 at 04:52:56PM +0800, Ming Lei wrote: > There are still cases in which we need to use bio_bvecs() for get the > number of multi-page segment, so introduce it. > > Cc: Dave Chinner > Cc: Kent Overstreet > Cc: Mike Snitzer > Cc: dm-devel@redhat.com > Cc: Alexander Viro > Cc: linux-fsdevel@vger.kernel.org > Cc: Shaohua Li > Cc: linux-raid@vger.kernel.org > Cc: linux-erofs@lists.ozlabs.org > Cc: David Sterba > Cc: linux-btrfs@vger.kernel.org > Cc: Darrick J. Wong > Cc: linux-xfs@vger.kernel.org > Cc: Gao Xiang > Cc: Christoph Hellwig > Cc: Theodore Ts'o > Cc: linux-ext4@vger.kernel.org > Cc: Coly Li > Cc: linux-bcache@vger.kernel.org > Cc: Boaz Harrosh > Cc: Bob Peterson > Cc: cluster-devel@redhat.com Reviewed-by: Omar Sandoval > Signed-off-by: Ming Lei > --- > include/linux/bio.h | 30 +++++++++++++++++++++++++----- > 1 file changed, 25 insertions(+), 5 deletions(-) > > diff --git a/include/linux/bio.h b/include/linux/bio.h > index 1f0dcf109841..3496c816946e 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -196,7 +196,6 @@ static inline unsigned bio_segments(struct bio *bio) > * We special case discard/write same/write zeroes, because they > * interpret bi_size differently: > */ > - > switch (bio_op(bio)) { > case REQ_OP_DISCARD: > case REQ_OP_SECURE_ERASE: > @@ -205,13 +204,34 @@ static inline unsigned bio_segments(struct bio *bio) > case REQ_OP_WRITE_SAME: > return 1; > default: > - break; > + bio_for_each_segment(bv, bio, iter) > + segs++; > + return segs; > } > +} > > - bio_for_each_segment(bv, bio, iter) > - segs++; > +static inline unsigned bio_bvecs(struct bio *bio) > +{ > + unsigned bvecs = 0; > + struct bio_vec bv; > + struct bvec_iter iter; > > - return segs; > + /* > + * We special case discard/write same/write zeroes, because they > + * interpret bi_size differently: > + */ > + switch (bio_op(bio)) { > + case REQ_OP_DISCARD: > + case REQ_OP_SECURE_ERASE: > + case REQ_OP_WRITE_ZEROES: > + return 0; > + case REQ_OP_WRITE_SAME: > + return 1; > + default: > + bio_for_each_bvec(bv, bio, iter) > + bvecs++; > + return bvecs; > + } > } > > /* > -- > 2.9.5 >