From patchwork Wed Jun 27 12:45:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10491419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 56ABB60325 for ; Wed, 27 Jun 2018 12:49:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 449FC28D84 for ; Wed, 27 Jun 2018 12:49:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 388FF28D86; Wed, 27 Jun 2018 12:49:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA8ED28D85 for ; Wed, 27 Jun 2018 12:49:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1A496B0285; Wed, 27 Jun 2018 08:49:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CF16A6B0286; Wed, 27 Jun 2018 08:49:00 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C08536B0287; Wed, 27 Jun 2018 08:49:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id 9331A6B0285 for ; Wed, 27 Jun 2018 08:49:00 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id l71-v6so1873583qke.11 for ; Wed, 27 Jun 2018 05:49:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=Ayo5UfI0cGmrn8pfqvtPYpghquA+32uoRFp7qXbDIoI=; b=l2+k3Jdz74aZ8voqdaGbqHepE4lkWf8Z4m8t/MWHiDtPTANkkd+XK/Zb1ZZtbhRxyY gZPnhmu7suoXJzlP2BW5v4XaAOURkKDo5tkK4nCV78e/lAjVonSlD0bGkPpP2M3hjuoH 3n0qpGalZC6DMRsxqPhwtDwLAdTkT56eSIIIWyHOzKlj63N+E8f+jlAMVIVjo7udmCNt cOSesp95WkxJvkHsmQAbx+rOUrO4unOohlLqTCvXBn/xRGb8UzWEsyuq6FUNOJKuISR+ nCtiKw64HK+e1/S6x7lZ1IZOcg5rDnmBSAXPbG4FlRR6x602cArWtsddU53Hpk0XhgdL w1Uw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APt69E1a54GUE6zZ/yZOLX4A3Ubcol5AqdMXUcblzS3Rbtq2B0sSTO1J puf0dUPX8PSFnA9ubw0jCwz9PleC6koqpsNo0MEfIDDPKQNmJuFnlyE7VodicEu/3e8+9WsKtQ9 jSEWp3+kqlkVGrhxoTsSTD5fDbFCF9+cwdy+Jd+Zel/3XWPgVi2Y917OSNcPuSGhfUw== X-Received: by 2002:ac8:7195:: with SMTP id w21-v6mr5324353qto.111.1530103740399; Wed, 27 Jun 2018 05:49:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe8/1WqAu/lltyfav2CE7u0gFwmh8r9qaRs4BrjslkmE5QzC6K3BI+7aUFvp6C+JR9g/iED X-Received: by 2002:ac8:7195:: with SMTP id w21-v6mr5324334qto.111.1530103739884; Wed, 27 Jun 2018 05:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530103739; cv=none; d=google.com; s=arc-20160816; b=DAQt4kaR8l0MEL+YDJ21XYXvsUSuvky0VXIMteQp9h0UCtTngjh9/QOa4bXkntaxNM j62AwJIiDRXmnYQ5qweJ+jI1NZvs0WrJclZcxEXIgXxcTcUqBGPXT7qca5F4I8JNoMSh azXRxxP+tJm2rx73r0zu/j51CS51R/sz28hFUOddjD0FlxIeSd+rc72Garu6+6OUDWSE CUFUqD2VjslB75naWRyF1lzFpIwm40uLVGJKnFs6N8OMwLuhY32bvWUQm+Kcw+IiVfOA UX621x0tbPl2939VUgDdyMyDbGd5SXlZDVcEMQ3GyMtUN4cJgefoXsgThpqZ8bhalA0U Rn4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Ayo5UfI0cGmrn8pfqvtPYpghquA+32uoRFp7qXbDIoI=; b=wDoYPLvGNUW5nvJQ/o1OgE5jWBF4ZAT8yRc+n9Kr0Mio2logMM/9BhK7sgC381xIXp MBFbBYgMsWGC0qarNULMb0yUYnuxhvQbBZDDAkhMai3soPasVcxYyz8hquIgT3NUoXdB qP10UUepgW0Q0mc8fw1ZaUCB5MQwAAaQGb1zk2l/TTbo+Ayqlqqf1DXEIztLQunHaDV+ HrGBPQQMQL9iQ4rIKk3mMmlse+NVQpl3qISuGuLSxtjpNLWTqwPuNqEz6IQr8rEWy25k b7Ed93qz5OAvkH2nM6S7cCw5zOWOUdPB4C7+0Ht0/JXEHciRpsKhChpmUYsqj7VXbMfY mP8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id t138-v6si2335189qke.48.2018.06.27.05.48.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 05:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F2B74021CC1; Wed, 27 Jun 2018 12:48:59 +0000 (UTC) Received: from localhost (ovpn-12-44.pek2.redhat.com [10.72.12.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEB2B1117658; Wed, 27 Jun 2018 12:48:47 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Kent Overstreet Cc: David Sterba , Huang Ying , Mike Snitzer , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , "Darrick J . Wong" , Coly Li , Filipe Manana , Randy Dunlap , Ming Lei Subject: [PATCH V7 15/24] fs/buffer.c: use bvec iterator to truncate the bio Date: Wed, 27 Jun 2018 20:45:39 +0800 Message-Id: <20180627124548.3456-16-ming.lei@redhat.com> In-Reply-To: <20180627124548.3456-1-ming.lei@redhat.com> References: <20180627124548.3456-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 27 Jun 2018 12:48:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 27 Jun 2018 12:48:59 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Once multipage bvec is enabled, the last bvec may include more than one page, this patch use bvec_last_segment() to truncate the bio. 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 cabc045f483d..0660b7813315 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3021,7 +3021,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); } }