Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp763792imm; Wed, 13 Jun 2018 07:58:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLxhjd2EtGxj4rV/64BOl400dV5/hpw5Z+DXTkJPheKqTwq4UQRclLUSMHq67dY/CwOrK8e X-Received: by 2002:a63:9702:: with SMTP id n2-v6mr4311981pge.88.1528901896387; Wed, 13 Jun 2018 07:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528901896; cv=none; d=google.com; s=arc-20160816; b=QtLKQW5xFDPdh5w20zuNrJKOY4kj/cv6Hb/O0Pc/z6ULx3V6VAV567CsjkRow2gD2g w92QDQYCgj2JNS+nTtJ2h/4rsLGv2gdz5RKnN3snhuqGtRTd3D42tQ/LnT+4+IySNxBP //Tmde+wjp49TksApYH2PjDt7M/zZN9LnTiN1wZECXs8wAVs3P+/Ff+PZL6mw6H0eN+3 ZTGzluS98vCHv2jULKUTkzX1h42k+lDHx1+ZOZpd2RETYTRPQQwT7COJyQVpQzUltZwn nOtm3FwlzW2Dq+Sn1tc+G19PynL5QJ/Y+AqEuL8wZnU+XtcdgAFPbZFd5tXeFOcgMD19 14gg== 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=JXOqPD9ykRA6j11QZ0bjBZxoKQX7Nu413MAVxDG9n2k=; b=yAYnWQhcUEf86l09uUT057nbMolElc8DhIMsLLlERCwQxU7UUqWV0Ol7gQxIEtEAHa y0XqrOSyfMe8wsJemsoNCrn+SbdFXVEf/RqO5R/oUJHYTo64NMv9PJ4PK/KjkayDg28I nw+tcDYZYXk7fnT99TsNoOIik438s3ci15ywLV5/E/voR258xCqR21QjB3wffUlpmq4f +Aucwg1xaTgmMYKXBK2R7lHgE8FzdSoJ1qKpjptqh7LWf3f1oQHAvjJeY5QOdEolEoUX 1kYEEx1X4LNG5HPqGkK8FDS+rPyTYwQ2IlvNOk9T6wGth3jKNomMCw153jqFYrXJVTfS XVow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EIItbh1k; 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 t25-v6si2805678pfh.101.2018.06.13.07.58.02; Wed, 13 Jun 2018 07:58:16 -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=EIItbh1k; 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 S935878AbeFMO5c (ORCPT + 99 others); Wed, 13 Jun 2018 10:57:32 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:39381 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935694AbeFMO51 (ORCPT ); Wed, 13 Jun 2018 10:57:27 -0400 Received: by mail-qt0-f194.google.com with SMTP id p23-v6so2626510qtn.6; Wed, 13 Jun 2018 07:57:26 -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=JXOqPD9ykRA6j11QZ0bjBZxoKQX7Nu413MAVxDG9n2k=; b=EIItbh1kCEIJid+evZq2cWS9kFb2zmRaTfswwu2/GPJjs9vhUVnjE2Fe9U9tAtF+0Z MVi2c4ZOv+uQvyVnZ9IfO/eKlYNYcaAemfjyXw0n3vG4KCyEA5sHcQNONCo6TH2WbxcD 67OZwGNiY7nhu9B5dww0+SGVFO8rKWvq3i/EAfyNVl0eWNhAxtxXfeugvuwI426aFFUz DWFIS9UNgvkFpFCOtlkAtGCND1dKEDNdcvw1iSzw0m184wRsu3r/bfmlXwKZbI5iclpb MQgaNuVvXQKlrgl7xDjle+Rj6b2Vyyd/QtYx3cdAxE945jK5LgZyHomp/XwvnEr0vDbJ kYIQ== 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=JXOqPD9ykRA6j11QZ0bjBZxoKQX7Nu413MAVxDG9n2k=; b=McUVzC1gW14co5CEZcUZ3VmxoBZsaoTbTKHe1DTCKLiS03Lt0wqAQGeDsBg8IaHWTX lNBarMEvIKLmuEWnGi6yCVOmoaquQ0n3r7gOjKD66RWR6UAXVBXSnAyH3TWJ0mDEYgz7 8xygh3ATIRVRrXI+i+LQxYr3URGAc5/RmUCWHX9uXe8aXtwL7KxwnpSDoP4mjU8HdHtk DwJR0OAFelB5vt5p/grC6wRP91oF05gEB2X9oZS8vX2+2MDB5BIESYNFOZyP9GsUTIm7 OYqC59/XigaR2hhpo4Dxaeq5XBY0vWb2uRrM8Mn8Ti0OELImmxzvl/zVmwkRkfTs/wo+ FpDQ== X-Gm-Message-State: APt69E0+spyYojz2BJCkkMpihg7Y3MTyJ5U8yKxS9ub1LjWkHE5RuPOF tkCLHr0je+9ZrddSKWeXzA== X-Received: by 2002:a0c:de13:: with SMTP id t19-v6mr4752154qvk.93.1528901846320; Wed, 13 Jun 2018 07:57:26 -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 d11-v6sm2051632qto.41.2018.06.13.07.57.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 07:57:25 -0700 (PDT) Date: Wed, 13 Jun 2018 10:57:22 -0400 From: Kent Overstreet To: Christoph Hellwig Cc: Ming Lei , Jens Axboe , 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 , Randy Dunlap Subject: Re: [PATCH V6 12/30] block: introduce bio_chunks() Message-ID: <20180613145722.GA17340@kmo-pixel> References: <20180609123014.8861-1-ming.lei@redhat.com> <20180609123014.8861-13-ming.lei@redhat.com> <20180613144741.GC4693@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180613144741.GC4693@infradead.org> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 13, 2018 at 07:47:41AM -0700, Christoph Hellwig wrote: > > +static inline unsigned bio_chunks(struct bio *bio) > > +{ > > + unsigned chunks = 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_chunk(bv, bio, iter) > > + chunks++; > > + return chunks; > > Shouldn't this just return bio->bi_vcnt? No. bio->bi_vcnt is only for the owner of a bio (the code that originally allocated it and filled it out) to use, and really the only legit use is bio_for_each_segment_all() (iterating over segments without using bi_iter because it's already been iterated to the end), and as a convenience thing for bio_add_page. Code that has a bio submitted to it can _not_ use bio->bi_vcnt, it's perfectly legal for it to be 0 (and it is for e.g. bio splits).