Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2029244imu; Fri, 23 Nov 2018 03:46:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/VIxkI2HbFASKJO/L/1lLAbeUtf5V0cKBhhdXZEjCzo/O6Ja8Tu4/ZwKan9njWfoP++T6w3 X-Received: by 2002:a17:902:bf49:: with SMTP id u9mr15127583pls.4.1542973583377; Fri, 23 Nov 2018 03:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542973583; cv=none; d=google.com; s=arc-20160816; b=CmMEs99PeXWO4xURHBoy5SI36EFCLHtPtvNPw6aBrMRsI7ZSADmFqOUIc63lUN4pPk VWH/VV/wntOJlYReVH73ZiUpmhl+kPoOO9mFippDm4FjQAdK2xos5uBcHkkn9RWdSZtw 64wRApJWxVMB9TmBdj7u2y2TEYlEvh2oqEVm8pfeWOGcSBvMrQ2XCd/gD+yXYI3ujdkx s7uKT3vVLAG8bTOf3QJiIjbYm1xXcjk3EGVED/4hhA5CfUjuZ6OW/5ayVNjUEV41Cm20 +WZblYLADRkV6j8rd70a04CF4qvwTJ8rxrXb7RwqkoAcCNM9pYJHVK+i+SbREAmZ0/aP 45EQ== 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=BjSRQ/krB4S0d0fjc8b2UpIrQlgEpXljBnZjDL5DM8M=; b=mmbcxrlFeh+DlQOP6cLVXG6C1ijN6WBbsWcMq4g3M+FEhxrzpVOEoTT3k3I0j5U/Xy wKY9V/uANeyNUlODpwtqqYrSQMJQ3UB5BkCfMGThcju7vIGOvNGzCUUEHtA1C+om95k9 rQw7Vzu9S4GWpdOVYW/4rytqNdIhwjF+zWivJ4/YHHouJ8BEe/i0ISvlT0RnBkwHh3dH OfCS4m63vvQbm9+0S/oVHH2+MXHi8Do3HXfM3hT5NLHs8bcI/cs9wn9x6/myGIDwMmgl gnNCGyjPp0OQRIH1+fTcpN9sImzOahyfoSivkf/a6+eS23ozJAY3NKTQ5OgGXEHAs6eH kmNQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r196si46267779pgr.311.2018.11.23.03.46.05; Fri, 23 Nov 2018 03:46:23 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405355AbeKVVhq (ORCPT + 99 others); Thu, 22 Nov 2018 16:37:46 -0500 Received: from verein.lst.de ([213.95.11.211]:57683 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732079AbeKVVhp (ORCPT ); Thu, 22 Nov 2018 16:37:45 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id 0F65C68BC7; Thu, 22 Nov 2018 11:58:50 +0100 (CET) Date: Thu, 22 Nov 2018 11:58:49 +0100 From: Christoph Hellwig To: Ming Lei 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 , Christoph Hellwig , 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: <20181122105849.GA30066@lst.de> References: <20181121032327.8434-1-ming.lei@redhat.com> <20181121032327.8434-8-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181121032327.8434-8-ming.lei@redhat.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); +} + /* * This allows us to do IO even on the odd last sectors * of a device, even if the block size is some multiple @@ -3031,13 +3039,8 @@ void guard_bio_eod(int op, struct bio *bio) bvec->bv_len -= truncated_bytes; /* ..and clear the end of the buffer for reads */ - if (op == REQ_OP_READ) { - struct bio_vec bv; - - bvec_last_segment(bvec, &bv); - zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, - truncated_bytes); - } + if (op == REQ_OP_READ) + zero_trailing_sectors(bvec, truncated_bytes); } static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,