Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7768354imu; Thu, 15 Nov 2018 00:57:43 -0800 (PST) X-Google-Smtp-Source: AJdET5ensI6YjXsZYqLs6juFeP02dF7WFYsZQWy/svcL1lFin8gakZDDGEHpQ25P+iCHibbajqAw X-Received: by 2002:a63:134f:: with SMTP id 15mr4977524pgt.19.1542272263398; Thu, 15 Nov 2018 00:57:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272263; cv=none; d=google.com; s=arc-20160816; b=GoUSsrFYMiXRSutwgwvVV273edGXQack6ZDBi/f2m4aityHHuHTGztZluKQCF22DxJ 0HRnMtrBQEtL5Y6uI6KUQz2oVCOe6J3OcmZTACVVAxbjOjQr4OgAwsuc8Hp8S2Nf6PdV 80OrAewE07cB5Nuv2u0/MHtCDp3xM7DweZEHT3pJRBVcFTXQTg2iY+utGLFAjZypsqJT AcI5jPGS8o6Oak2fDihOVc7N24j1RhLE7fy2x/f1AFZ1piiGLW3zdPo99SkccEFP0g1L UtbJf7/OyZpg1ns5CyvcoRxxBjIF4fR9lYE8hoWUev9ax3W7YVEOTGCR9R/ZjjCRVfxT K/nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=lGLdQmCulR8OC8y0KcHKnMxgou6Piswucg/kiYcQVp8=; b=s8CfW/0dPM4osD+YclWCoo8BsZKdOCYF0+O4RLfZcaUwZ55myo3qkz/sojIl0ezboF tcdYXE0EloZR7uH97snL2uEZuS0X7/B4wbF3WdwFSFJa7Evb4d8TLDCyBudjaF9jfgSU +xUO92uRWofkYWqlE21mTyGcSWa7vOt/QZPNXwnMkrPBsWrGJZdPClPMNmgRK7jTLv4M zk8AwPt2CDmZzR+NaMgVZARL2UdwdSSIXGd/h4u7s7Zfqbfm+LFih0cxS3ylOJPHU9df hl/wMfwIz5MGUtFVrd/1EWaeOFQCs4f+SDdFMsHx0bGM2b+WbrYRh582mPYwguP5OO+K 8iIg== 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 i13si26711555pgj.199.2018.11.15.00.57.29; Thu, 15 Nov 2018 00:57:43 -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 S2387911AbeKOTBw (ORCPT + 99 others); Thu, 15 Nov 2018 14:01:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49406 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728564AbeKOTBw (ORCPT ); Thu, 15 Nov 2018 14:01:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52302307D86D; Thu, 15 Nov 2018 08:54:58 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18B515D75C; Thu, 15 Nov 2018 08:54:43 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , 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: [PATCH V10 06/19] fs/buffer.c: use bvec iterator to truncate the bio Date: Thu, 15 Nov 2018 16:52:53 +0800 Message-Id: <20181115085306.9910-7-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 15 Nov 2018 08:54:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Once multi-page bvec is enabled, the last bvec may include more than one page, this patch use bvec_last_segment() to truncate the bio. 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 Signed-off-by: Ming Lei --- fs/buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 1286c2b95498..fa37ad52e962 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3032,7 +3032,10 @@ void guard_bio_eod(int op, struct bio *bio) /* ..and clear the end of the buffer for reads */ if (op == REQ_OP_READ) { - zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len, + struct bio_vec bv; + + bvec_last_segment(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } } -- 2.9.5