From patchwork Thu Nov 15 08:52:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683769 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 BACEA14D6 for ; Thu, 15 Nov 2018 08:55:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB571299C2 for ; Thu, 15 Nov 2018 08:55:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F4DA2B678; Thu, 15 Nov 2018 08:55:20 +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 16DD9299C2 for ; Thu, 15 Nov 2018 08:55:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 421086B0279; Thu, 15 Nov 2018 03:55:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3D2C46B027A; Thu, 15 Nov 2018 03:55:19 -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 2ADDB6B027B; Thu, 15 Nov 2018 03:55:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id F2C2C6B0279 for ; Thu, 15 Nov 2018 03:55:18 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id k203so43875480qke.2 for ; Thu, 15 Nov 2018 00:55:18 -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=sksoPAoBobrodaqFaviy7ZtyOdLgNXqBU8Jp1HYMzKA=; b=pDYXqtPmS0Tw+2Px8r0ZtzbJ0d9s+uycLJ+5UbODjRK3GLijAYkBRTSm8zwzS81IQ3 Z5hO0l4QgNKv+bKom2SVw5XkktHXUFmuTyL8R7jpkCBEc+Qkl2MdFci30u9utRvzv9im 6tHHpHolYhZsoml6xsFtLBI2bSwpo6xqbjxzjM1pVWAfbAij7ud0P0vomR5rBET1kulj g2OwfuQ5qgPXINwcGjbqnSh52+FrIIR7VSkO98P+kS5S/z5mFcGkVrYkCgLGw2tX9UzD OCS16DEXNZijc/ffTTOugDcXbbgjlFAYP8KIOlX1I6mc0c2Xa1ILp0a3aYzwNhjNX9yA tncQ== 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: AGRZ1gKkpXFC89T44aHA+s9oRFadyB1JlKuLHkKg4vocQVYfgGjY73W5 XkPNrya3xmJ9gQCrABlnhH+p5ixBSxPaWXIKS/uxRyBME8+Zsp7b0CNEyDlNm0FggZOg/9+U/N4 0pp3k2IqKvMpFbmoP2+5y+A5pt/EqOaj+TVq6xRZDU1HYtf/ll3YM4njhpKI+L3H7Ig== X-Received: by 2002:a0c:c350:: with SMTP id j16mr5333138qvi.201.1542272118772; Thu, 15 Nov 2018 00:55:18 -0800 (PST) X-Google-Smtp-Source: AJdET5dAIWfNWQOnomp5gLpOJjW8tcT5T6VJxSenyyNhtnqqx1YYybSMdAJCk8M27znkZQqQASlL X-Received: by 2002:a0c:c350:: with SMTP id j16mr5333122qvi.201.1542272118276; Thu, 15 Nov 2018 00:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272118; cv=none; d=google.com; s=arc-20160816; b=wZd+DaeVWBseUHBbL4OWcoD0xAMJSU3MR3D4gw5vT4dVjUSbP/2C/VskShWw9E+ESD i2Vz1ZJ5GUykjTxMKH/LE4MGpEVHPSFriYAY4pVWLwWK/h/6MWcKWf5iJBnaHDgQnUKT r7CNfTazJO74WpLQ6YS5EQi2pQKRjPXpN8Z4kVzEMgZGYJxhHQoMz6mTORDmOZ1t6O/g hAwJBS5vLPQL6CM7/uyERo7zi43O4ndAz4ij/O9hXL9JclK8GoQWwlXHRjzsTFj/t5fS kUVdGZuCD4imWAC/cRwlAj9F0/FvL6x7zcMPjIdpXF2pEgv9z5iykD+efEocIXvwvtlI fT3Q== 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=sksoPAoBobrodaqFaviy7ZtyOdLgNXqBU8Jp1HYMzKA=; b=YD3pKNuVcZ/ajeGsp/c6/lhGtw0bd5qRszpRA1bnUjKqb7S4CUA+atYKcjIMik2tXE 9lOWtFwE6D0vnEKVJHPvs57M5S787gsleqVJsROPTy4Cwajz9ecBwPcY42WvGAjQ/MYE v5mEpHu6TCepf761PcFqut3APtoUugzboa8P1T44RneGIgY41CDZLBIOhr+5Hluf3zB8 oq5muJtYtc11UmjvPS+htFEjmXm/UlectzU/n6yjluPoP/B7HWbfebwlrevnPMYrcfTO g/RYLBaqYEO+CEG7XuP+Uo1h44I1OYAAqnVZt6eBbWGuzLfZKa/+2TmAOBjvOSJK/gfY JB3A== 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 t57si291084qtj.158.2018.11.15.00.55.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:55:18 -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-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03E51C045109; Thu, 15 Nov 2018 08:55:17 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D5ED60C7E; Thu, 15 Nov 2018 08:55:00 +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 07/19] btrfs: use bvec_last_segment to get bio's last page Date: Thu, 15 Nov 2018 16:52:54 +0800 Message-Id: <20181115085306.9910-8-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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 15 Nov 2018 08:55:17 +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 Preparing for supporting multi-page bvec. 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 --- fs/btrfs/compression.c | 5 ++++- fs/btrfs/extent_io.c | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 2955a4ea2fa8..161e14b8b180 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -400,8 +400,11 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start, static u64 bio_end_offset(struct bio *bio) { struct bio_vec *last = bio_last_bvec_all(bio); + struct bio_vec bv; - return page_offset(last->bv_page) + last->bv_len + last->bv_offset; + bvec_last_segment(last, &bv); + + return page_offset(bv.bv_page) + bv.bv_len + bv.bv_offset; } static noinline int add_ra_bio_pages(struct inode *inode, diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d228f706ff3e..5d5965297e7e 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2720,11 +2720,12 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num, { blk_status_t ret = 0; struct bio_vec *bvec = bio_last_bvec_all(bio); - struct page *page = bvec->bv_page; + struct bio_vec bv; struct extent_io_tree *tree = bio->bi_private; u64 start; - start = page_offset(page) + bvec->bv_offset; + bvec_last_segment(bvec, &bv); + start = page_offset(bv.bv_page) + bv.bv_offset; bio->bi_private = NULL;