Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2433713imu; Sun, 18 Nov 2018 23:58:37 -0800 (PST) X-Google-Smtp-Source: AJdET5f1qnCinIdNd6OUYbZHxdOaY6vaQQUvzw/ragWZhKnTl2Em4U2hOEju3xgAP6i1nEmTvyr4 X-Received: by 2002:a63:e655:: with SMTP id p21mr19026741pgj.70.1542614317754; Sun, 18 Nov 2018 23:58:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542614317; cv=none; d=google.com; s=arc-20160816; b=QuKFhb2YqxR361c0OfADEX/+46xJmlHT/aukY/i241WhIIEkf9bcvcb9qwxj7LOyCn vXpnBG7dMlAdE7xQxuay32KRwTDNCYwwU3F7iZcWJXCwQEON14mX0vvW3QqnUFCCJVrl +Cf/ud96yhCNOkEntdVZTXjFLXP4yJgQ9LsmVGtxR+45+9AlJC3PToZKaMCo9GWIH0XN rxbpDy+n1OJBtd0piniABfgQIXccDuO1CnV7FMF6MAYjanOqd2VBDCfypFmNf1tdU7X6 4auhEybM2nee1UvIqqw2E9wsLseg0tA9BTebulnuOkvZiKygw+ht286ezM8MLPdlJ3iX fghA== 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; bh=0CeTy8Aav1M8qRZAHHfTM0d6+fhUb8Wb65zvIx8mpZc=; b=YIjZFu2VZZqw5zNLdYgs+SSlYbKPX7SunJAuPsOttvVLTg5/CRYogwS8ft7Y2zgXAN XWDwfwPLXz2aUxVONWDtbpV0rE2K2HJs5RPTkZFkWkWEwMh54lu3ZSfRXDuFRbXBKSia zWr+YWAvKK4Mqe3z8gWE01hBI0dufrKLf60djVnpyi7LpzDU4AClUeIADqnwbe5ZfyqT uHB0diASSU7HyyG6P5u999WaewOWHT+RSaDD9kL0NjfrDUlhrTtgBmNiGnZQN6KWFbbL MA6VvvmMHHZVWQCp5Mw1biba8vemz/e5jCSIZhP6AOIQmG1i3MyefKtiq5qmKiciA6zp VOCQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5-v6si40331664plp.132.2018.11.18.23.58.22; Sun, 18 Nov 2018 23:58:37 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726611AbeKSSUg (ORCPT + 99 others); Mon, 19 Nov 2018 13:20:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33834 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726348AbeKSSUg (ORCPT ); Mon, 19 Nov 2018 13:20:36 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EDC788306; Mon, 19 Nov 2018 07:57:45 +0000 (UTC) Received: from ming.t460p (ovpn-8-26.pek2.redhat.com [10.72.8.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD9925D9C8; Mon, 19 Nov 2018 07:57:25 +0000 (UTC) Date: Mon, 19 Nov 2018 15:57:21 +0800 From: Ming Lei To: Omar Sandoval 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 05/19] block: introduce bvec_last_segment() Message-ID: <20181119075720.GC16519@ming.t460p> References: <20181115085306.9910-1-ming.lei@redhat.com> <20181115085306.9910-6-ming.lei@redhat.com> <20181115232356.GA23238@vader> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181115232356.GA23238@vader> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 19 Nov 2018 07:57:45 +0000 (UTC) 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 03:23:56PM -0800, Omar Sandoval wrote: > On Thu, Nov 15, 2018 at 04:52:52PM +0800, Ming Lei wrote: > > BTRFS and guard_bio_eod() need to get the last singlepage segment > > from one multipage bvec, so introduce this helper to make them happy. > > > > 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 > > Minor comments below. > > > Signed-off-by: Ming Lei > > --- > > include/linux/bvec.h | 25 +++++++++++++++++++++++++ > > 1 file changed, 25 insertions(+) > > > > diff --git a/include/linux/bvec.h b/include/linux/bvec.h > > index 3d61352cd8cf..01616a0b6220 100644 > > --- a/include/linux/bvec.h > > +++ b/include/linux/bvec.h > > @@ -216,4 +216,29 @@ static inline bool mp_bvec_iter_advance(const struct bio_vec *bv, > > .bi_bvec_done = 0, \ > > } > > > > +/* > > + * Get the last singlepage segment from the multipage bvec and store it > > + * in @seg > > + */ > > +static inline void bvec_last_segment(const struct bio_vec *bvec, > > + struct bio_vec *seg) > > Indentation is all messed up here. Will fix it. > > > +{ > > + unsigned total = bvec->bv_offset + bvec->bv_len; > > + unsigned last_page = total / PAGE_SIZE; > > + > > + if (last_page * PAGE_SIZE == total) > > + last_page--; > > I think this could just be > > unsigned int last_page = (total - 1) / PAGE_SIZE; This way is really elegant. Thanks, Ming