Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3197053imu; Fri, 23 Nov 2018 23:53:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/UcNeXTZgwRuyhRd0VH2CK0iKGGFrAOU4ImFg8k5B0hb1xdoRuAO9qrx8n4KfXU4Y0TKn8r X-Received: by 2002:a63:1c61:: with SMTP id c33mr16609799pgm.354.1543045993668; Fri, 23 Nov 2018 23:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543045993; cv=none; d=google.com; s=arc-20160816; b=t+TZROOPk1AHKcyEtI7wPbfaQvB9L1P9b/vASHc3asIK1rFpwnDNV8X3hJJMNXMns4 zvpVh152n51A+JvUt7Zo3vSlK/FXB/PFhTUbgdVWGocrJJobDutra7ZAmz8s3v3CZKnW Mi7EnOwzyDFJQ725yCJBFHz3AaM6+HFL12/RVx0Wm7cZAmZRwWV16yQC5rBAKj7cKHc3 7GcdYkiowDOlVNNv5m9iAAfRQZD7w9oTbrN+1So/1bZecv03JbfFKaPOWr5bG+7myERh K6TLLNvwkAm/zt5ZBMlKWfUSZHPMbN3SZmeDg5scY/mgCWy99oJQM4tq0yZiUHw44Fy7 o/Qg== 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=Y/QKQtbh6P7usdRUPvNoo4n8sDoKnhdSWsjUtEdeDm4=; b=eKjmYma30UKdi63L9lFEGx0Z+0OMKWV14b+F3Mc0PJxXWr9rYCNrPlSmPsJ6NQozP0 xT9OyXfFddxrGonnRsSl0NW0WG8F4KucR+i/WevG3gxKwtE5m7xm7rSKWQq8h+j1D5tq uj6b0zndyXhQQeiOkRUlIR1Zye1PR+mtmLDA2/J7g3hkD8B31HKEmwpjnIAffDukrdAk c2uNnw8wLHkSAtl/7kpmGyWQTUEYinzacb/I4ci1e+9HNKT2cFjEdDgYNPouNtZDbSb6 3Y7nURkPwNMY6DwlcByr9RXtahPLGLjqauWR1rgRyKk2sJ1LarMz0EsmwbziVGdzLM2f ddzg== 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 m142si37241962pfd.171.2018.11.23.23.52.59; Fri, 23 Nov 2018 23:53:13 -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 S2439357AbeKWMa4 (ORCPT + 99 others); Fri, 23 Nov 2018 07:30:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36152 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733028AbeKWMaz (ORCPT ); Fri, 23 Nov 2018 07:30:55 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A18C83F4C; Fri, 23 Nov 2018 01:48:46 +0000 (UTC) Received: from ming.t460p (ovpn-8-31.pek2.redhat.com [10.72.8.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7997D104C53B; Fri, 23 Nov 2018 01:48:25 +0000 (UTC) Date: Fri, 23 Nov 2018 09:48:21 +0800 From: Ming Lei To: Christoph Hellwig Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: Re: [PATCH V11 07/19] fs/buffer.c: use bvec iterator to truncate the bio Message-ID: <20181123014820.GA20110@ming.t460p> References: <20181121032327.8434-1-ming.lei@redhat.com> <20181121032327.8434-8-ming.lei@redhat.com> <20181122105849.GA30066@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181122105849.GA30066@lst.de> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 23 Nov 2018 01:48:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 22, 2018 at 11:58:49AM +0100, Christoph Hellwig wrote: > Btw, given that this is the last user of bvec_last_segment after my > other patches I think we should kill bvec_last_segment and do something > like this here: > > > diff --git a/fs/buffer.c b/fs/buffer.c > index fa37ad52e962..af5e135d2b83 100644 > --- a/fs/buffer.c > +++ b/fs/buffer.c > @@ -2981,6 +2981,14 @@ static void end_bio_bh_io_sync(struct bio *bio) > bio_put(bio); > } > > +static void zero_trailing_sectors(struct bio_vec *bvec, unsigned bytes) > +{ > + unsigned last_page = (bvec->bv_offset + bvec->bv_len - 1) >> PAGE_SHIFT; > + > + zero_user(nth_page(bvec->bv_page, last_page), > + bvec->bv_offset % PAGE_SIZE + bvec->bv_len, bytes); > +} The above 'start' parameter is figured out as wrong, and the computation isn't very obvious, so I'd suggest to keep bvec_last_segment(). Thanks, Ming