From patchwork Thu Nov 15 08:52:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683759 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 E65F814BA for ; Thu, 15 Nov 2018 08:55:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D671E299C2 for ; Thu, 15 Nov 2018 08:55:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6DD92ACBC; Thu, 15 Nov 2018 08:55:01 +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 3C842299C2 for ; Thu, 15 Nov 2018 08:55:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 646416B0277; Thu, 15 Nov 2018 03:55:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 61BC56B0278; Thu, 15 Nov 2018 03:55:00 -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 532666B0279; Thu, 15 Nov 2018 03:55:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 26C406B0277 for ; Thu, 15 Nov 2018 03:55:00 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id n68so43129068qkn.8 for ; Thu, 15 Nov 2018 00:55:00 -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=lGLdQmCulR8OC8y0KcHKnMxgou6Piswucg/kiYcQVp8=; b=BWCRd9hMMeYU+VSuryberdAA22DGcop15e+gAUxC3mp3ZYVWu95svX89O9oeof/MRO sbzw+cRvqT7tvMyRTTlFxKrb9SU3s5RrlbicCg9cwyTt6Ck21f+pV4khl54cRIkxR5Ux VJNTwxSoWjUJqUcvd15RHz1K4ZSf8eVOE2pnywviXhs9SgMgzT81shaWAsQKf1Lz+6H4 X17YmRMmoG/JOvnd01P3tCDCqErIGRFRKAk4oPtMcGwZgLBHiqhY2SMVrhGHNQj8IQIz /7JfXhko7uFxzdtNwigrmR7KxMelO1SzvLNdmre1aq6u8VgJHB4z9QvlaxPqshZ/cOWI iJkA== 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: AGRZ1gLg/JSCPgRiQaIxVgbs+pVJUaWzIR57ue0qv09ehUqFkjSjACIf tfDC0T2AG9kdeMPme+5n6HNqWsD5jNKaq12B875Ppy5b5Nv3O5YGu4pBkRSwpQhCp2rNSyL0AvP as7Y7dzc+udtI5VNDeLOWocjnfKUaYdlf7+lzdTeXMtxJ+h/Nw3BCe8PsZ7ok1HPDnA== X-Received: by 2002:a37:9d15:: with SMTP id g21mr5032234qke.171.1542272099862; Thu, 15 Nov 2018 00:54:59 -0800 (PST) X-Google-Smtp-Source: AJdET5fHi2KRC8CHf/H/qxeTYtwVlRoDDc40fVJbij/RGRqfg+fzPmIWh2nl/mH08pJxO0zvszV3 X-Received: by 2002:a37:9d15:: with SMTP id g21mr5032220qke.171.1542272099356; Thu, 15 Nov 2018 00:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272099; cv=none; d=google.com; s=arc-20160816; b=Va8XDxKddLMtkpJeRIToQ7qABDfwkigkPIihSldMuEm8VEyGz1F6cb9E7eJd9GCVCr R7rU2/m4lypgyGcYslJRL5ayu9TISLGUgzgOmEIP4ayYDeLX6mtDqx9dWA7nWr4g9hhU QFkvOLnk0fKXFGqfGZsNMWy+IHAw8Dr8K4Whl3+V64ozMg97fd2sidnCgKZ5hdM2NXrJ PFZstnggrN656hnQdNWv1fjMYeBLYkBzFbmUU5R6tdu2u9U/jyW3VZN5L3sALIIP3tOk FxRsTopEjFHw35muUSwnzG/QUVxEHqHED7kqEB8PwjuVQIiJj4ZZRvtZwncyDmsfiW1q NQ1g== 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=lGLdQmCulR8OC8y0KcHKnMxgou6Piswucg/kiYcQVp8=; b=wOkxHACFYWRcOzKGAaXlDgBt2jiP2kwX8BnXY69aKGnRXCCoZsCLjNkruRO8yNKKvS xyW1c0pEWqHG4zpOh9IRPXshpLfaQhY7fHOCNsjQXNor9SGKGgvKal576aTYJN+JHsBb QVhNYdDXfGf/8LTmHHXONDbd/0BSZ5orlV64Cc0smsFuzoXucKoL4jxvMkix6gJYuB/U vlCiANA72UCa1luFMpnsA1L+F/k8jn5cjHYv5hjG/X86IP6qxOY16i2RafO6MUNmY1Ie lEhQPhpQU2RcDmInnzIeSO9Wj9tpFJAtIgj5LNfMcTk+hhHxnjM02d4B8P+aHarKrjRv mr6g== 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 f70si4753493qke.10.2018.11.15.00.54.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:54:59 -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-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) 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. 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 Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig --- 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); } }