From patchwork Wed Nov 21 03:23:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10691673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 138AE1923 for ; Wed, 21 Nov 2018 03:26:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 010F82B409 for ; Wed, 21 Nov 2018 03:26:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E88682B412; Wed, 21 Nov 2018 03:26:38 +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=unavailable 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 9CCA82B409 for ; Wed, 21 Nov 2018 03:26:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD3E96B239F; Tue, 20 Nov 2018 22:26:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B82766B23A1; Tue, 20 Nov 2018 22:26:37 -0500 (EST) 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 A23B56B23A2; Tue, 20 Nov 2018 22:26:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id 735406B239F for ; Tue, 20 Nov 2018 22:26:37 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id n45so2207964qta.5 for ; Tue, 20 Nov 2018 19:26:37 -0800 (PST) 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=c2SF5KIPKkkjYa6soG59vjMHK08LElFkLaPhpIbMqOY=; b=Q99DoT8NDX5eh0MlpgWmjRbw26EmiNwYquLTdri+dWl9CKJ7viwamXfI0rrnkA6d4s OuAxayCwjnj+7QtE4+rsSgSxPc2KDtzjrHhBdxyllYhs/5Kr29Fve2aj6RpAHHWGOviN LVzfvqCyJ7vXBqSwzCQ6wRKfUBtZPU57y8/mIq/MMPFCbObF/g5KaSSJtkHntLL8sL/P spTLYx7R9KVQCRLQNYRWib2NRx1GGV9ar+Ub6+jcoi8qhsW4tkb9TXPwAh9e0M94cWvG 8PkLc85o+sZ5pn99zGJ6kkmIUyd8u0LNvAJR2AUPEmsEk1NawKgLjjqYB6ccbhjNvnoH QWUA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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: AA+aEWa9s4HvikX+FIuKSO2V0xPQUBeq8WTc3gdTZ1yBirfSZwjd4n4W HKyqP0jrzkfVAF9BykLWBlLsATjaeE8QxcZov3eRoKqkr8z0L5TaL+VapyEEnxZ2sLgQWK205uY gU1F5nbE9FtiMHsU+29OvttjeyOxEkt2No105wazu9okDmuDY9JV9YCX7EmYUoHALKg== X-Received: by 2002:a37:492:: with SMTP id 140mr4036238qke.95.1542770797220; Tue, 20 Nov 2018 19:26:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/VzfBelotGg7BWoQXe3zDFk55O1tW2GnWu18AxDASCBlNXasLFJ+AusXbVyirl0dLDtfEQ2 X-Received: by 2002:a37:492:: with SMTP id 140mr4036218qke.95.1542770796493; Tue, 20 Nov 2018 19:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542770796; cv=none; d=google.com; s=arc-20160816; b=ZAKX+VBRbwXko7wGCTZEWzvf7BTu7k2umSxqRIgoQN8bkR4aw4vDTlZR/+gnx6Jgqu 0gALopCrh9xXidhoY5DCH6HtxF1rU4y18FA7febtdMG0FxmH5LFAfEaVYFVEiRSckYNY ObOXlQXmuj18urJB1/jldjRGu6LoIXfCURPLhXtGlJKwhAvRyDGSJZKP0YVmNdnx80ae 4upD55+Q7FfgEzkVIY0ZTEL90UkRpkJdgwiiwi8s9uuaPZEr7H7THzYnwf1mEsrbSpgR 6X4KLfFnPl56ojr/qdlHodOI66otE15Z2JMXMXZwqi3F/mxtKeqLKo/bg/3nm+zz018s Jb3w== 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; bh=c2SF5KIPKkkjYa6soG59vjMHK08LElFkLaPhpIbMqOY=; b=QnygpCuEbtipknziLelrdEbQajQgt8WIfCTs8Yu3Re/iTUpEVE8PlWE6xPvVai2gnZ c5xTKI0Dr0Q468Rndobqttxp8MCUhpBaEUE/fCqRrEfIuiT6V5wZL1YSbfvWOzqZwjUH 5eEj6595l/NRevQaCv2QnvX6YvIIjcU3mS72v0nUBZDJ/kwBfIbj686V4y+Bc3dopKxX WNNduB5liC0W7ghs1pAGoq7IVCMcKu7EWpM15LSeFmDQ/9e/7AL18XdbnLSimDwS+gPS 0B+BR3RMraROaSo1DSuiGqVtIBl13Bo+nnhmVgPZBwcQdlqUxMSB0B9CM2YADoCDxPD4 A3wA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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 (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id v184si5858200qkh.60.2018.11.20.19.26.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 19:26:36 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C75B7F6A8; Wed, 21 Nov 2018 03:26:35 +0000 (UTC) Received: from localhost (ovpn-8-21.pek2.redhat.com [10.72.8.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17CC25DD86; Wed, 21 Nov 2018 03:26:22 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: 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, Ming Lei Subject: [PATCH V11 07/19] fs/buffer.c: use bvec iterator to truncate the bio Date: Wed, 21 Nov 2018 11:23:15 +0800 Message-Id: <20181121032327.8434-8-ming.lei@redhat.com> In-Reply-To: <20181121032327.8434-1-ming.lei@redhat.com> References: <20181121032327.8434-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 21 Nov 2018 03:26:35 +0000 (UTC) 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 multi-page bvec is enabled, the last bvec may include more than one page, this patch use bvec_last_segment() to truncate the bio. Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig 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); } }