Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8659820imu; Thu, 15 Nov 2018 15:26:25 -0800 (PST) X-Google-Smtp-Source: AJdET5eW9LaS3XyZIwYQgqtQm/0Zk2g5irGveFuqP7QOtMDIXfyUU9pEnlJ2xvGpZulhZaEAlFgj X-Received: by 2002:a63:ec4b:: with SMTP id r11mr7503849pgj.44.1542324384959; Thu, 15 Nov 2018 15:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542324384; cv=none; d=google.com; s=arc-20160816; b=DAN9Lzyz75Exqahp81s1pfNREPYn/DGS4j8JVnfcJBtrv5Kt1RCFVbmIrLBa/DsFIQ lpeKG5aZxBaeOiqODHJSyYQcbjxHp2XDk3E+z2n3Td4l4UC2gCCYmwc+kvSgXhDthCYh CSubHqBC+BPlTkpUORuRzdaJO+MbsEgBXRUusEXS8Ue9KyayBL+VyN3I+ewJE2B4Htbw dNHLhAQ1Z1voQSu1AIXS3A0Sj1/qeQEWgCFmW1k+obob6YADu6sBZefgZdGUipURlLJD bpVyjKW/2JT/UJwut5MFxZvK+6vP7WWCdEZ+Ryt5pRpYZLOeWkauo//Nit1pOXjhuGh5 4mdQ== 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=jwnypmXRKe0aQmFwiDDHQvx5bHMn94jQ/OjQzX3YuJ0=; b=i0OWykpe2HgG8wuJ2B6xEiCq8mLlDJFMw+M6N0VP2x3GtO6LuMG6gyjk4HRLVuY4Gy 2vu/jFI2nUgWBD7x2V5mIqNKwY1xZ6UMEEsrMMnxW6MUoR385Q1DnXYGtPRwc/Mz/V99 OCjqoUhq3VVMtP8yzcf0CyMqiRKFPQzhaUe9B8/rQxQli06VCkmEgtt7S94bgkoBI0ng TLgJ7YUtMNkJjNl134bYAnUkYlrtKKdp5p0o6awpd42BY2dThF32uLI5732AA2hzmKvR wBQLrj+cTPzzOuA14YYvToA/hrAD8SxSNFfVIWQzRIjy7NHHbpK7SNhqM8RCCeaBcrR1 99JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=xNHPvfwn; 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 a21-v6si19378143pls.13.2018.11.15.15.26.08; Thu, 15 Nov 2018 15:26:24 -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=xNHPvfwn; 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 S1726837AbeKPJd4 (ORCPT + 99 others); Fri, 16 Nov 2018 04:33:56 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42648 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbeKPJdz (ORCPT ); Fri, 16 Nov 2018 04:33:55 -0500 Received: by mail-pf1-f194.google.com with SMTP id 64so5956005pfr.9 for ; Thu, 15 Nov 2018 15:24:00 -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=jwnypmXRKe0aQmFwiDDHQvx5bHMn94jQ/OjQzX3YuJ0=; b=xNHPvfwni0CT/Ud+WG0Z+eArtj5FLHdX5ny0CAJBgZw/w5k8sAxb3sDWxubpfB1ZS/ 7WVq1n1Fp4vLIVMGHxTYOo5cgiGZQgwqJ7uYQNM33OACNJrd6jMSaYIYIelZKKlgosfK nkEnkYrUnadWqJ43cAXSq2fMz5RDwApNaX7RGATH2cbmys5FkjmJdNzQ2hvgOQoVv/Gp c5H+d8rWap2eHHnCaFtK4alcHdtD8uBvY3LcbPJXqocRZhw2iSpIq1ao3UU6L1cjlLAN 3qaL6ExIwzLXqtDfHjK/EfEagOR/RXXe0pXUMJLjb8iAEqGmsTTgFST/ahlPUZeRcNVf m83Q== 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=jwnypmXRKe0aQmFwiDDHQvx5bHMn94jQ/OjQzX3YuJ0=; b=M/9byyC9ZFr2d5FOyffxIvH48rgs9UiKcvGPvv8tFFCEaQ9CuJwB2KfdQu5s95hLBN WEHpPBjMlFr+2jUABInfg1A9RTJD7VJVZfYPrlD1l8TXlEVy+AtnbGDe+gOkBkNCfGpm INtcIdA7X8vaP25zPXKkaF5EuwEypi3FHn4djBn2UKy+fXzYrqIIqSkVyp2veMPxoXYo t83kMyU9xrI8DtfxBhFDCDcXHTrJLYgHj3bPEqcIJ2TVD/0xcsJO8ppVAARGtjL90W4t jX3UVTbTMcS57GeQqizjzn1olEMClHdrJvH6piFxPhi+hOdzml2UP+BNIuV7YXWxl4GG /+sQ== X-Gm-Message-State: AGRZ1gJ294o8aR1M3mh+wZgnh6QyzdlQjR/0S4Zz2Kyl+m879fVsFL+j 5ED7uCyIhS2e5uwtM5ThsHkRjw== X-Received: by 2002:a63:344e:: with SMTP id b75mr7449203pga.184.1542324240224; Thu, 15 Nov 2018 15:24:00 -0800 (PST) Received: from vader ([64.114.255.97]) by smtp.gmail.com with ESMTPSA id x63-v6sm38337415pfk.14.2018.11.15.15.23.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 15:23:59 -0800 (PST) Date: Thu, 15 Nov 2018 15:23:56 -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 05/19] block: introduce bvec_last_segment() Message-ID: <20181115232356.GA23238@vader> References: <20181115085306.9910-1-ming.lei@redhat.com> <20181115085306.9910-6-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181115085306.9910-6-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: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. > +{ > + 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; > + seg->bv_page = nth_page(bvec->bv_page, last_page); > + > + /* the whole segment is inside the last page */ > + if (bvec->bv_offset >= last_page * PAGE_SIZE) { > + seg->bv_offset = bvec->bv_offset % PAGE_SIZE; > + seg->bv_len = bvec->bv_len; > + } else { > + seg->bv_offset = 0; > + seg->bv_len = total - last_page * PAGE_SIZE; > + } > +} > + > #endif /* __LINUX_BVEC_ITER_H */ > -- > 2.9.5 >