From patchwork Fri Feb 15 11:13:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814555 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 CEB3B1575 for ; Fri, 15 Feb 2019 11:14:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C67D428BAA for ; Fri, 15 Feb 2019 11:14:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA4442D54B; Fri, 15 Feb 2019 11:14: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 A263728BAA for ; Fri, 15 Feb 2019 11:14:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE07C8E0003; Fri, 15 Feb 2019 06:13:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B90878E0001; Fri, 15 Feb 2019 06:13:59 -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 AA9C78E0003; Fri, 15 Feb 2019 06:13:59 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 8431B8E0001 for ; Fri, 15 Feb 2019 06:13:59 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id r24so8647947qtj.13 for ; Fri, 15 Feb 2019 03:13:59 -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=jR/ABfQzsk4snuRwt6xiKLLtmUVGlJ+rbLpyE5UJ55c=; b=EaowXKcGTQpWQqjXQuVPe1HmxcLryJg6BehdpKwZSbiL1zCTh5mNcXUhgw6cZ8km51 ca0eajACzPatr7hx7qPeheht6n4vMgUVZi+hj1ZuAeEBqlBjBVcuBMw4ox5skBweMNeA exGhJl7866YWsDNfvneNvaZ0v6VbzBRArvBCDXGBtEefIFbOpVI7tL1IfZ4BFUVDiGyK cgUqSTsQqDbveZAuajcQtbT5uacYqkuhksFcZspaqWcZygYTE6gPmGEK2hAtoWOsuRbv R1zgmPuhFG6cj7PBLmSukgMksbHyMnylCiIt6NlY84S2He+nWnxf+0qX7EwhIbHEkixZ mC+w== 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: AHQUAuZqeUwpxBMFxqpvfE4eXp97IvSTWTvkhSspjXXcmok+IYAzW/P6 ijuCuxgGBCYNvqbSyDodl8e+I8yrCyHq42lD1dq8hsZYX5otMJ7zB8Zm/OC/XaQRr6ybRqa1/MQ 2xR5lA7bqGE6P22KPxHh/zVrBN2pGraI1fAqZP7DIrdtDjK3dOSXpaUPaSFnl67Xj6w== X-Received: by 2002:a0c:8c8d:: with SMTP id p13mr6728137qvb.48.1550229239236; Fri, 15 Feb 2019 03:13:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IbAUpJKFiRNCc0iPm7iXGr9Jc5WgezLRzaFkC1CteG9lVn22tEZdWWL0wKmwCJOmN8iAvog X-Received: by 2002:a0c:8c8d:: with SMTP id p13mr6728107qvb.48.1550229238671; Fri, 15 Feb 2019 03:13:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229238; cv=none; d=google.com; s=arc-20160816; b=D3NBsmDesov8apYKhQx++kF1mTgMqNhXgRYQuS4XxcnQ0D1bu4EnWTiI8WyNO6wYwf 9wUYvZvXwwamWzrlSFWzFVwYwWCuu7zormsfs8BSEJzC6KU15DIrnLNhteC5nkHVZdK2 5O/PDq2czMOggvVQSR5baakNzXL8b4638hIgNj31Lk3wxjbLQk6ensGow6O2u8bUQY3g M82leYwW/Z8pCp6pUuG7yRkbsHB3fp9Frkl1MeGOhLYG9qrn2AVqs0NJD+BeBLm+uUHf wZ6D9aTYe5oyztIEvpgcKQ/VNZRGloa64IKtjbqFZTEnPdK01+Cl7+3NetMXjtmMkIKV GMHQ== 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=jR/ABfQzsk4snuRwt6xiKLLtmUVGlJ+rbLpyE5UJ55c=; b=QZ0QeEQiU81hDqgIknpJX9nsa8CPCQCv06arftS0jEjv6HMcqQj0nDMLE2BD0dfJNI VK8kZwhHAvkPvBHX0pJrzD+7wOzNhXtk8R30FJCIDEH0gzDI6ZXuqVFFH+NFOOkeS2r1 MMmdHO03W1v1z2qvNjLTRibji9i6cAgmIFE+u/62mutG49QnB3eAq9yGZgZed9VIV03+ yf+HqODRsXohb50VCueVrzZMQEo/LRzzzUFH9tr9yTuf0WT8fgoziGqlKAnSUs63StWs QpAhOtCuGJ/CFwyAGUXgIeyJakz5+anOoxhK5Cthr91/Vl7xRNxlnRTxGl7ElAPhd7/b Mlrw== 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 v57si538148qtj.260.2019.02.15.03.13.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:13:58 -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 7E31DC0AD406; Fri, 15 Feb 2019 11:13:57 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id E81596090A; Fri, 15 Feb 2019 11:13:49 +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, 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 Subject: [PATCH V15 01/18] btrfs: look at bi_size for repair decisions Date: Fri, 15 Feb 2019 19:13:07 +0800 Message-Id: <20190215111324.30129-2-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-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.31]); Fri, 15 Feb 2019 11:13: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 From: Christoph Hellwig bio_readpage_error currently uses bi_vcnt to decide if it is worth retrying an I/O. But the vector count is mostly an implementation artifact - it really should figure out if there is more than a single sector worth retrying. Use bi_size for that and shift by PAGE_SHIFT. This really should be blocks/sectors, but given that btrfs doesn't support a sector size different from the PAGE_SIZE using the page size keeps the changes to a minimum. Reviewed-by: Omar Sandoval Reviewed-by: David Sterba Signed-off-by: Christoph Hellwig --- fs/btrfs/extent_io.c | 2 +- include/linux/bio.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 52abe4082680..dc8ba3ee515d 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2350,7 +2350,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, int read_mode = 0; blk_status_t status; int ret; - unsigned failed_bio_pages = bio_pages_all(failed_bio); + unsigned failed_bio_pages = failed_bio->bi_iter.bi_size >> PAGE_SHIFT; BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); diff --git a/include/linux/bio.h b/include/linux/bio.h index 7380b094dcca..72b4f7be2106 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -263,12 +263,6 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) bv->bv_len = iter.bi_bvec_done; } -static inline unsigned bio_pages_all(struct bio *bio) -{ - WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); - return bio->bi_vcnt; -} - static inline struct bio_vec *bio_first_bvec_all(struct bio *bio) { WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); From patchwork Fri Feb 15 11:13:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814571 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 1EFA96C2 for ; Fri, 15 Feb 2019 11:14:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AE032E31D for ; Fri, 15 Feb 2019 11:14:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D7FB2E2EA; Fri, 15 Feb 2019 11:14: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=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 A6AE52E31D for ; Fri, 15 Feb 2019 11:14:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C546C8E0004; Fri, 15 Feb 2019 06:14:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C04138E0001; Fri, 15 Feb 2019 06:14:18 -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 AF3128E0004; Fri, 15 Feb 2019 06:14:18 -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 8670E8E0001 for ; Fri, 15 Feb 2019 06:14:18 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id c84so7837479qkb.13 for ; Fri, 15 Feb 2019 03:14: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=slTW8uoG6sTMlKcMLmau18LMT15MeeTevHwmv3l5NcU=; b=q1nW9I825t0KaiPLMjyrF3hSRLF/s1rtAfsYdVmr9rGWQCFISEUTk/Sok+uejo1ajR 0ylVB7hj9j7r/Okx9xwbbXvF1j0ONP+pMFqKJtOxXzeL5wD4Rjx+LU71D2hn+BgfLidg VVTc/yMJgb6ByzQFX6jq4cKMJ6JnK9bHWV+kI5xy6+qrY0SiQG4WTnqxUwnGvgyJaX9u i1135svHoPnCnYXIPepCJ1On1m3SiLJtv3IqSVBtQ1iY4Fr2g/Bs3d1rNd7JWtu/kxuQ xsClylBgM4KuuDPiy8Y4iHpzQRCJJej0GvqqvQsD1VyluPR+UB0ecDYhjtLGCEnMJkq4 OGVg== 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: AHQUAuaJmnE6YmzXhZHfS0oIWQWEcZUYWx+ZbtZ/BuR4FW7HO0yYeJ/a 2NpyhkNFhtWrHoPOPwd/gaLRG7zzaFfHljQjF3MRU6d9MBolvxoev4ZjKhSe2BAjT7rfkaLpmEZ yubtxy4DMDjufAiNwRYOD2pqNp6hNO+B4xKbWoVXc7u8iVKzOwaRIgJZio/Js5JXWwA== X-Received: by 2002:ac8:dc5:: with SMTP id t5mr6883325qti.80.1550229258327; Fri, 15 Feb 2019 03:14:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IZEOlxpk8tl3iIdC3IsBH3tlAEfPi6FN89OoqWp/qyRgjoekTFTeuMpgAO5eeQqFC6l1+zK X-Received: by 2002:ac8:dc5:: with SMTP id t5mr6883293qti.80.1550229257754; Fri, 15 Feb 2019 03:14:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229257; cv=none; d=google.com; s=arc-20160816; b=kT0cS/MxvQyCLt8f30BjO6KvSgK3wKxZc3k8uUpGKUATCB1aWqUlB4g9EaAkxfJ5V4 cmCor+z0At9MiltSpH+lSj1oX31CtVbGuTRXtIVJ23aitI0iry08DDwYcI8ekUUYqfK2 gvtggWE29AqfbekhLrn1IKvNtbTq/kw/TAC2n8C02DTYK48U4MRE0K4pb6VhWRHYaL5C LWat3hb30dGel4yoRfstygtL/UEpqG0rQ5bLzvkgkKeNy+Wy+BZmwDvm1GRP+QCpJdAm m3bRcMuPUA12mC3ZjyLEMqFrQui2sti4aahH/UUhbRQHe9N1M4dt/ICmkx3jM0VLS2lq HYOA== 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=slTW8uoG6sTMlKcMLmau18LMT15MeeTevHwmv3l5NcU=; b=fpGWfbQv+mnuKuK5PgYRpmkrmeWtuKF4tXDXwNR1EQCErtfpokaYhDW0bc0M2B7VKZ Sy7/8yvEg8jqNsYoo/poB8h25z+LZspgQAtnbR1gC2PmK5ty9BMq5M7WEjyVngOLZWxz U3o+5EjOdZVHOTZL+jLXm3GS6FTHfZIpNGc+dgNkD64vlJcRG/leMLUyCJmxmNs8BVO2 S7A2RycgSRxjb+yMBPZp9LtZ8bNvN8+T5b+wOoe8qej3qlsmXltbqmWyriRUvsAQEq76 wd3ibNWJPHFTuu5+PhjPZOF4yQ9LTuo7p1iAgUkZh3yefp1n4QpQAQkVEGmWyY5wjl2W kDHg== 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 e10si1292036qth.95.2019.02.15.03.14.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:14:17 -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-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0FAE8666D; Fri, 15 Feb 2019 11:14:16 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01A5960C62; Fri, 15 Feb 2019 11:13:59 +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, 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 V15 02/18] block: don't use bio->bi_vcnt to figure out segment number Date: Fri, 15 Feb 2019 19:13:08 +0800 Message-Id: <20190215111324.30129-3-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 15 Feb 2019 11:14: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 It is wrong to use bio->bi_vcnt to figure out how many segments there are in the bio even though CLONED flag isn't set on this bio, because this bio may be splitted or advanced. So always use bio_segments() in blk_recount_segments(), and it shouldn't cause any performance loss now because the physical segment number is figured out in blk_queue_split() and BIO_SEG_VALID is set meantime since bdced438acd83ad83a6c ("block: setup bi_phys_segments after splitting"). Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Fixes: 76d8137a3113 ("blk-merge: recaculate segment if it isn't less than max segments") Signed-off-by: Ming Lei --- block/blk-merge.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 71e9ac03f621..f85d878f313d 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -367,13 +367,7 @@ void blk_recalc_rq_segments(struct request *rq) void blk_recount_segments(struct request_queue *q, struct bio *bio) { - unsigned short seg_cnt; - - /* estimate segment number by bi_vcnt for non-cloned bio */ - if (bio_flagged(bio, BIO_CLONED)) - seg_cnt = bio_segments(bio); - else - seg_cnt = bio->bi_vcnt; + unsigned short seg_cnt = bio_segments(bio); if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) && (seg_cnt < queue_max_segments(q))) From patchwork Fri Feb 15 11:13:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814583 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 D8DF56C2 for ; Fri, 15 Feb 2019 11:14:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D402D2EAF3 for ; Fri, 15 Feb 2019 11:14:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C721B2EB06; Fri, 15 Feb 2019 11:14:42 +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 6E3E12EAF3 for ; Fri, 15 Feb 2019 11:14:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AC208E0005; Fri, 15 Feb 2019 06:14:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 85A7D8E0001; Fri, 15 Feb 2019 06:14:41 -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 770778E0005; Fri, 15 Feb 2019 06:14:41 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 4DBF28E0001 for ; Fri, 15 Feb 2019 06:14:41 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id e9so7714418qka.11 for ; Fri, 15 Feb 2019 03:14:41 -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=SN4quS8rBSk+7OkD/UQdCM5DjNZfyv3PfpiunvnHKgo=; b=PpG3pIajnBXhZHJ/APZ8VSIEp0WZmpl5R8OB5A4Jx1Cvg+dQik+ZU7ByCZ016sFlWY p0waPHrlBrIEAl99nhM8tPSgdWIZIh+Mft7hZ3cv2RHG5Z2T0GVz9qMAgsC7VXTvGFC+ +QqMlivQeLfCDKEsmBXn5wxZVHbSmlYh0ILqKcaXuwZPoffaSiGWdt+9E1YhBvyR3qRx TpSVcOWXnwsv9LUWMWBYbdB3OYS7xIFqkGMq/7D/pcNxuMCPaJiTg8Ga/26rPU0UYIOn HID+bZGpjfgZxrgQFOoegfDI1cor2KdtvdIeDHzoJP/0JvnpttAGV0z57s7xtE3OiD/Z nGsQ== 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: AHQUAuaRX0HtpMZMYkmDFkDSniPr/upqM9+fMPqfrpWSCreMA2lwHQwo n+ILj49HCwwU+9FlN/tvh1cKqW3cRLxFe7hbUCC4lkWM+La8bC8FDg9VkFJ6c9Pq9CLnOxk2iWx J2U6JHO6NB9b8v4UWYMb9xKu/zJ7psOSOXeCeAtRTx08YTJ30MH3ndWTIO8I0B5DJQA== X-Received: by 2002:a0c:d1f4:: with SMTP id k49mr6916346qvh.164.1550229281106; Fri, 15 Feb 2019 03:14:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IaqgF65hN8bEwWC7DjGj2fepcQBAwaXRS8UuVpuHgllHnng46cwHiUq/mVjH+G499NOV0kR X-Received: by 2002:a0c:d1f4:: with SMTP id k49mr6916325qvh.164.1550229280697; Fri, 15 Feb 2019 03:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229280; cv=none; d=google.com; s=arc-20160816; b=F1TlHL6N5fOd5UfTntxmCsjVmv3ynFhGYGvxTalXx1lRJS+yDc+wrd9RoLxXmOwtP4 SU/T0/oey4gOb/Xs3EDBsAnuMUz6QVdc3LYP0B3Ee7ZaqhRuNg1NTWBZLHon0OD3w/1Z 58hj1dPeJ1sJ4h1sl0+fC5AspF2dVW/oY4Om2XQFMin3SxICsCLQ4j6Gokep0a8gCtKK OCLS0bTtVERGZmtc+hKQAq/4+gF8xBnoY9Pr6ilmGiQ1kf03uA7zg5f857tZ52+qLWoP wa1zVUPiTt3sOtIDCMEx0GtZMzyhz0gRgRmM55e7UgVHX2IOP13xnH3msvOxup/wfBFt lBFg== 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=SN4quS8rBSk+7OkD/UQdCM5DjNZfyv3PfpiunvnHKgo=; b=YBexlKpRPeEq7+Fsp46jRKM1qYlkhyIm3MWPadjiUYHCJkCuJZbdtEwNiRAH0h0xhS syJr4xMOF/x0DfkENI4xHHRv/+sMN5isJb9WbfYuVJmq1b0/zDQopiVOO0kt92sEfv/q C6SvwH+GUTDEy197JJHthwhrtUW17Gb/W1TBfdWGHdF2cOfJrn8EqPPDMu1MV4jTv/CN DYzb++dHJU4UTt/VWqLj+mwUmbcACh77PnGrajut0RgBL+fDhV56HXi68bHrUdcTFx2t E6lg09uP/rQwl/TEtUl1zHk/ztCeUUcTdqmGxzGSOHh3J+uXXU7QxJFHrgAkFJbdLQmY gDkQ== 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 l22si2318267qtk.384.2019.02.15.03.14.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:14:40 -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-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A4FB2FE56E; Fri, 15 Feb 2019 11:14:39 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id D72B560C62; Fri, 15 Feb 2019 11:14:18 +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, 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 V15 03/18] block: remove bvec_iter_rewind() Date: Fri, 15 Feb 2019 19:13:09 +0800 Message-Id: <20190215111324.30129-4-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 15 Feb 2019 11:14:40 +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 Commit 7759eb23fd980 ("block: remove bio_rewind_iter()") removes bio_rewind_iter(), then no one uses bvec_iter_rewind() any more, so remove it. Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- include/linux/bvec.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 02c73c6aa805..ba0ae40e77c9 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -92,30 +92,6 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, return true; } -static inline bool bvec_iter_rewind(const struct bio_vec *bv, - struct bvec_iter *iter, - unsigned int bytes) -{ - while (bytes) { - unsigned len = min(bytes, iter->bi_bvec_done); - - if (iter->bi_bvec_done == 0) { - if (WARN_ONCE(iter->bi_idx == 0, - "Attempted to rewind iter beyond " - "bvec's boundaries\n")) { - return false; - } - iter->bi_idx--; - iter->bi_bvec_done = __bvec_iter_bvec(bv, *iter)->bv_len; - continue; - } - bytes -= len; - iter->bi_size += len; - iter->bi_bvec_done -= len; - } - return true; -} - #define for_each_bvec(bvl, bio_vec, iter, start) \ for (iter = (start); \ (iter).bi_size && \ From patchwork Fri Feb 15 11:13:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814597 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 0538B6C2 for ; Fri, 15 Feb 2019 11:14:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F23772EAE8 for ; Fri, 15 Feb 2019 11:14:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5BFA2EAFE; Fri, 15 Feb 2019 11:14:54 +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 7200A2EAE8 for ; Fri, 15 Feb 2019 11:14:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A57C38E0006; Fri, 15 Feb 2019 06:14:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A08558E0001; Fri, 15 Feb 2019 06:14:53 -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 91D508E0006; Fri, 15 Feb 2019 06:14:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 6842E8E0001 for ; Fri, 15 Feb 2019 06:14:53 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id c9so768410qte.11 for ; Fri, 15 Feb 2019 03:14:53 -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=Koc+x6ZPCcpLbp0ogoXEke8ZDu3+j/1e8qVxbzGR/dQ=; b=e5p62M5j1v1q20sXT4cHakibcNrOfXvwHJfKdgnPzU9NEVSl5BVn9rSlHz5pzSmIb9 +6/xon3S6OmOkNCZBXJjif22Yt7SQIeRchHwPTjiA6YaHggkff2n7SLccj/BB1iTiaPS Rnup4yG2Yh/Dfe8wYNWC6+7fUDbSE7s7eE/PFDmjG0bJ5syr8sKXzQ71SmWpr5yaNw0Z 6DcBveNgqb0byce+vaIuPBDJuEfcXPex/LW3Fcqmtk9QQV3S0GOCOU1Ne5wZIMY/tdx3 ypGR3qTOqGkVgCkSH1hpKB1l+qP8kjCG6N/idrNinSruFgeslgmN47zLjqBOBOECnNdq /8pw== 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: AHQUAuauejrPHq+hg1An1hrVBlO6swHXDVQUA71bI7sNPxX/vqZYZgLQ pVBQisMGOwwQiAUET95+aMah1ohFNAKKDByU71yx2CkYH43nPBtpnLBrnbACgdB0js12tuVv9Hj i836eZXIQ2PxVZ7IszI/jgntVZMHELM5expPsguGUJr0wfRrhkIF4spO0flYxgl016A== X-Received: by 2002:a0c:8971:: with SMTP id 46mr6641578qvq.224.1550229293174; Fri, 15 Feb 2019 03:14:53 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia2FtKHK38+RDxB+4uMkKDO5hSR8oPL3fKmAAdvgM3KWQ8Y7S2WQf9RLQ+2RhbePIHeL1aa X-Received: by 2002:a0c:8971:: with SMTP id 46mr6641558qvq.224.1550229292668; Fri, 15 Feb 2019 03:14:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229292; cv=none; d=google.com; s=arc-20160816; b=LS49ZlYFvCSE9vyy7XFXtdLwBcdG9YZA3s2nMMTZ2n6wfn62Z4j4kEz1BOvs2aPpjK BcyJ2cBBH8UStcoDczQkKLisA9Tt8/aOESamB2Qh56tGmkw6rFPhP7RxqQdl8I6diTo8 /3N9emQPfxceJBoFfj5ZdEME49/YqDjKyZtmgFVEfYAKx5X319py0LlE0fBQu/eACmgm 8KoZK7Lf1H8GvuKYHVClh7LKIAvxB0UOSMwJg6sBy+WUUjDxX1FZtLu/hOPePwE22/OR W0GYT7ob1QCR7v4uakfHkSlxrGp74DZBvk8kJlerljFfPmRELJxdsSa7jY3ACmZ5+iqL 9Ckw== 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=Koc+x6ZPCcpLbp0ogoXEke8ZDu3+j/1e8qVxbzGR/dQ=; b=Dyz00CEl+MhOJxa6cKFIcXKgEkkeeSSW1Ct/9IvVr9PzJBBwM8eYM8U3+9hgA/Jbcd Rj68FFktvgYC/Ovot1l7AL3unJ3AldMZizE3vdlSexr54Hu7BZ56LKqd3b5nmrZAF58T U2AtfrTULg+UiyPkf0xCjjJsG1QKpnRL5zmxq8sLFQsTiJ5XJkG8eplbR4Ix3B72NnGG w/JFh53Q1F1jXiRT1LNBSMYpu8KA2VkKkcE8scKUUpSH5NFCckOom0l4JT9zxisaySYb MVh3RcK0DCScxX9UgJ7R9LtOsewGDUCjgm9tg3VHQXhNzgTuYBBUtdqQ2nZPmMvspSwL HTDw== 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 k7si2739775qtk.40.2019.02.15.03.14.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:14:52 -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-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8FF3BC0AC913; Fri, 15 Feb 2019 11:14:51 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD2F727BB3; Fri, 15 Feb 2019 11:14:41 +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, 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 V15 04/18] block: introduce multi-page bvec helpers Date: Fri, 15 Feb 2019 19:13:10 +0800 Message-Id: <20190215111324.30129-5-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 15 Feb 2019 11:14:51 +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 This patch introduces helpers of 'mp_bvec_iter_*' for multi-page bvec support. The introduced helpers treate one bvec as real multi-page segment, which may include more than one pages. The existed helpers of bvec_iter_* are interfaces for supporting current bvec iterator which is thought as single-page by drivers, fs, dm and etc. These introduced helpers will build single-page bvec in flight, so this way won't break current bio/bvec users, which needn't any change. Follows some multi-page bvec background: - bvecs stored in bio->bi_io_vec is always multi-page style - bvec(struct bio_vec) represents one physically contiguous I/O buffer, now the buffer may include more than one page after multi-page bvec is supported, and all these pages represented by one bvec is physically contiguous. Before multi-page bvec support, at most one page is included in one bvec, we call it single-page bvec. - .bv_page of the bvec points to the 1st page in the multi-page bvec - .bv_offset of the bvec is the offset of the buffer in the bvec The effect on the current drivers/filesystem/dm/bcache/...: - almost everyone supposes that one bvec only includes one single page, so we keep the sp interface not changed, for example, bio_for_each_segment() still returns single-page bvec - bio_for_each_segment_all() will return single-page bvec too - during iterating, iterator variable(struct bvec_iter) is always updated in multi-page bvec style, and bvec_iter_advance() is kept not changed - returned(copied) single-page bvec is built in flight by bvec helpers from the stored multi-page bvec Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- include/linux/bvec.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index ba0ae40e77c9..0ae729b1c9fe 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -23,6 +23,7 @@ #include #include #include +#include /* * was unsigned short, but we might as well be ready for > 64kB I/O pages @@ -50,16 +51,39 @@ struct bvec_iter { */ #define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) -#define bvec_iter_page(bvec, iter) \ +/* multi-page (mp_bvec) helpers */ +#define mp_bvec_iter_page(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_page) -#define bvec_iter_len(bvec, iter) \ +#define mp_bvec_iter_len(bvec, iter) \ min((iter).bi_size, \ __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done) -#define bvec_iter_offset(bvec, iter) \ +#define mp_bvec_iter_offset(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) +#define mp_bvec_iter_page_idx(bvec, iter) \ + (mp_bvec_iter_offset((bvec), (iter)) / PAGE_SIZE) + +#define mp_bvec_iter_bvec(bvec, iter) \ +((struct bio_vec) { \ + .bv_page = mp_bvec_iter_page((bvec), (iter)), \ + .bv_len = mp_bvec_iter_len((bvec), (iter)), \ + .bv_offset = mp_bvec_iter_offset((bvec), (iter)), \ +}) + +/* For building single-page bvec in flight */ + #define bvec_iter_offset(bvec, iter) \ + (mp_bvec_iter_offset((bvec), (iter)) % PAGE_SIZE) + +#define bvec_iter_len(bvec, iter) \ + min_t(unsigned, mp_bvec_iter_len((bvec), (iter)), \ + PAGE_SIZE - bvec_iter_offset((bvec), (iter))) + +#define bvec_iter_page(bvec, iter) \ + nth_page(mp_bvec_iter_page((bvec), (iter)), \ + mp_bvec_iter_page_idx((bvec), (iter))) + #define bvec_iter_bvec(bvec, iter) \ ((struct bio_vec) { \ .bv_page = bvec_iter_page((bvec), (iter)), \ From patchwork Fri Feb 15 11:13:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814609 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 35AD31575 for ; Fri, 15 Feb 2019 11:15:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F2582EAF3 for ; Fri, 15 Feb 2019 11:15:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 226AB2EB06; Fri, 15 Feb 2019 11:15:13 +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 BE7802EAF3 for ; Fri, 15 Feb 2019 11:15:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEBBC8E0007; Fri, 15 Feb 2019 06:15:11 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E9BD68E0001; Fri, 15 Feb 2019 06:15:11 -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 DB43B8E0007; Fri, 15 Feb 2019 06:15:11 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id AEF848E0001 for ; Fri, 15 Feb 2019 06:15:11 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id a65so7820171qkf.19 for ; Fri, 15 Feb 2019 03:15:11 -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=Fr9EnIrxI+HhD+i6K4i9/AzKSS6rcNfuTuDhUsAQpw4=; b=W1zSOaZiY91Gn9w60D5svHyFxgXAI5s8VH/seJgLU7hlruJuRKn0yzkkTGPdnQub+W QNJO0gRG9at+6YdyNIgeb8SZEbi0MUjkyJ2YtahvHOXhie0Th9hKAIghKPBqLKtp2701 8Nhu5d9o++0XZKyZyNsgLs7yFuNhwfzKcXgMCMSfAVKYY0LI6ark/dTc/dYGAikccxni CbqUrUie68R3oPd9sjsZirVeEJPit40LKMJvleh4EhuK1CmZKk8fL+zLrJ1uLneZf9Kg R0gRsLlRqUIb9vCsJYKfaL/DC8r6KZpcDQPIIxdoXMmc5W3I/AqhrgI2r+YvejV/Hk2l cD+Q== 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: AHQUAuZmbzwuIvYt7gYHRnn17wA12IOWsVGes2Y0Hpa+J7HJGW1VN31r /0tjQiFeaQbA858yuiGYPXW7hHBZh8v0Pzrb/yQNozfaMk/LkArxX2Ro/NtPt0Y9DD8ly53i2Nv D3k2/jjuDVyIhNPn5yqbgF+4FjqRo4k3qI0RxAGagW/C4U1W0nFrE9+7yVnzqlBkCNw== X-Received: by 2002:a37:8b41:: with SMTP id n62mr6517974qkd.262.1550229311467; Fri, 15 Feb 2019 03:15:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IbT1HBuRqekm2Z/LE5kXWMmInnx3aUAAPRtfYbxhOH1Tm62iXwSexTzrKjMcBLD7Jsqnat6 X-Received: by 2002:a37:8b41:: with SMTP id n62mr6517943qkd.262.1550229310833; Fri, 15 Feb 2019 03:15:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229310; cv=none; d=google.com; s=arc-20160816; b=NyxFv3z08x/2cFTSNlI1zRLlglT7x9LUMeXxqCfff5KYUb/DVD3wUNAbG+jN71L6Ql x5iO4Jb+fjH0WK2Wow+yADqsy91ajlPWc3byKJ8c75LumASgFuwocjD5k2zStFBcU/l+ j/GuAMYOLFX2ztn+JgSJ/JdcUEoCFGkFAWCx19odLJ690XUHNXqmcbhYiSC4wY0fstLe OzJY8+gbgW3Z/eQkP9HNTrg4XveJ8F3nJl8btkWo1+jUWiMV6VNb4JSGITaLmeFAYZAa +HqrVU0vvmyu4ZQqO6nFpdPosBTC/uFrz4WDqahbjPGycXzkKcBJl0j/iHJFXaYzlcpl nF/w== 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=Fr9EnIrxI+HhD+i6K4i9/AzKSS6rcNfuTuDhUsAQpw4=; b=eg+uTKnvrKkaA196vPE75wqyc4La8ywF/bt+9mv2t/9rPlv4ckmQqxfUFElfS53TLp L+7Qw3+VVKEBtsiPpuBpc0CCohhK0DA+7haJh6DwvhATY9HH70NzmkQhul6nxSH5Wnyd nq74+n8E0+eUZph0AkVWl2VMc57JSEhO0uCezIdjXBn1vokI+y/PuWFmBwcQ5pUCPQev RGcOkGTVmwSDkgWiODiCl/gYeHp7keY7BUI6s3MnIzBwJnfzWFPHw3Ln7aw08Bh9jmfI u6CJkLPvNzYU7w7gbLE0YJG27kvbDh/iPOPxN0KbuEmXM5wmlc19JKzIyp5Lnh+vOv0k KJHg== 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 a62si3309496qke.165.2019.02.15.03.15.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:15:10 -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-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E52A5C075BDF; Fri, 15 Feb 2019 11:15:08 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8457600C1; Fri, 15 Feb 2019 11:14:53 +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, 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 V15 05/18] block: introduce bio_for_each_bvec() and rq_for_each_bvec() Date: Fri, 15 Feb 2019 19:13:11 +0800 Message-Id: <20190215111324.30129-6-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 15 Feb 2019 11:15:10 +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 bio_for_each_bvec() is used for iterating over multi-page bvec for bio split & merge code. rq_for_each_bvec() can be used for drivers which may handle the multi-page bvec directly, so far loop is one perfect use case. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- include/linux/bio.h | 10 ++++++++++ include/linux/blkdev.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index 72b4f7be2106..7ef8a7505c0a 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -156,6 +156,16 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, #define bio_for_each_segment(bvl, bio, iter) \ __bio_for_each_segment(bvl, bio, iter, (bio)->bi_iter) +#define __bio_for_each_bvec(bvl, bio, iter, start) \ + for (iter = (start); \ + (iter).bi_size && \ + ((bvl = mp_bvec_iter_bvec((bio)->bi_io_vec, (iter))), 1); \ + bio_advance_iter((bio), &(iter), (bvl).bv_len)) + +/* iterate over multi-page bvec */ +#define bio_for_each_bvec(bvl, bio, iter) \ + __bio_for_each_bvec(bvl, bio, iter, (bio)->bi_iter) + #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len) static inline unsigned bio_segments(struct bio *bio) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3603270cb82d..b6292d469ea4 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -792,6 +792,10 @@ struct req_iterator { __rq_for_each_bio(_iter.bio, _rq) \ bio_for_each_segment(bvl, _iter.bio, _iter.iter) +#define rq_for_each_bvec(bvl, _rq, _iter) \ + __rq_for_each_bio(_iter.bio, _rq) \ + bio_for_each_bvec(bvl, _iter.bio, _iter.iter) + #define rq_iter_last(bvec, _iter) \ (_iter.bio->bi_next == NULL && \ bio_iter_last(bvec, _iter.iter)) From patchwork Fri Feb 15 11:13:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814623 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 9AEAA1575 for ; Fri, 15 Feb 2019 11:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 933BF2EAE8 for ; Fri, 15 Feb 2019 11:15:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86FB82EE6D; Fri, 15 Feb 2019 11:15:48 +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 EDCEB2EAE8 for ; Fri, 15 Feb 2019 11:15:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12E6F8E0008; Fri, 15 Feb 2019 06:15:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E0578E0001; Fri, 15 Feb 2019 06:15:47 -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 F386E8E0008; Fri, 15 Feb 2019 06:15:46 -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 C90BB8E0001 for ; Fri, 15 Feb 2019 06:15:46 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id q15so7838611qki.14 for ; Fri, 15 Feb 2019 03:15:46 -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=uvWYqf4GK8lhAsEaw5k4QrLmk8zZiBbvYT4KVo/7NoQ=; b=V+fOzNRcy5qMHjn7bb4voSInrU6Q3MU47OnRcKgAG+ZHzDmnA881/fjg6No/Jv7Ip1 f5aih+eaVmwegS5IiUJk2w2zrE2Nqlklnk7c0aveJljwZXo7+GjUQWuPViOcM7qGLB5W wOWff8sEVWiU5OUsM3UQ9fr24wjrPfnECH7Js7ZXOdmxBKneUrFq0JZox93Eh/c0sB+K of17XjUqgTfJFJ0LXF+7W3q1bUVQDve3h89xJYQdfVuJeenzExvFaaIFYlfN1x5Wu7mm n6hI8l2qXSe7lYgMCb+kyhHharsOneYPAQutr4WEpwVwge1egqg81F6xz1BQhEUEbVux Eu6A== 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: AHQUAuYv2rBtzreRVupudvf0iTZ5OTQKgNaE8Lk/QLKiz28wOXufaEbT r1QsBsv7dQvQnBdT85Nbscwv/gJcqK9XLs7q5GKYAvmXjXRNsg3bIIW5S7z9C84hpXxWzvhBE0u s/EupzRXhIbJ84hK6/rxWFN9b5ARbMiAwRELkdxiubtWZt/bvB9/HcRljdGzyKX8EyA== X-Received: by 2002:ac8:3474:: with SMTP id v49mr6990965qtb.132.1550229346576; Fri, 15 Feb 2019 03:15:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IZkyE8XF0xjuzQv5yQmukqCaTAgMftHdoRiYE9Anl7zwe81Eu0illHtLHV9jrDG4Igy5Ly4 X-Received: by 2002:ac8:3474:: with SMTP id v49mr6990927qtb.132.1550229345906; Fri, 15 Feb 2019 03:15:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229345; cv=none; d=google.com; s=arc-20160816; b=Fn5R/I4xc470qqq97P4fYngd31ihNycNywI1L+7JwiJrswyGIy1dviVJG60jeuMcsW 7RIF4jSDlASp1AH3wmENhG6zs5lgXKocdqyw5CBl+DYplLb2+kUQzZDsxLKl5RyxkRLn 4EeUsWOWlkoCXxR8a9ScF5hTeXevn8XhCizbjFVtwMlH9lfqAmWnXeK8vNCgyQzkRTkk tulfFxA56kOTBh6sQ+JUYRf3OViMy9iMtyVg5IIGWq5xCVoSKgpzBVcFOMbZg1YqrXIT rDSXP/Cv6GtpHbU8yFg+X4gLESt2+p0871XoHTU1N6skH17Hv3dThn5Ar9Tbqtc0A1pR R3Ew== 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=uvWYqf4GK8lhAsEaw5k4QrLmk8zZiBbvYT4KVo/7NoQ=; b=LuA1j6zguRfruA7n+ol7hvDq+PPxOXborFHM9rrvbqWRo2fjCNyhkibl4hQzrT6WCr EJbm7mwozLKN2gLVo6eQBye5i8nq4xEZzD236b5lgnLtmhmIpdgInl5GL3baKfT9KAf9 +/+NRW5L/4Ua9s33BWjUjATwGfw0kQ2A7RmWFuIPvVKetuMIAM7N7CKoRzqq9rTFUD9L W/2r+toW7L10Qpbsg1ujNpwQejL8j0kFio5TDZO5RnGRaqtBKsYp/5wIHPn9qgVmdQ3r XSksfHZ7DrwMStutEiD6ajqhCVh3HGelunL0L5M2Tx6S0UTMpeYISwFAc+K1Z5fbrS8H nDoQ== 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 j35si366472qtc.137.2019.02.15.03.15.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:15:45 -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 0A7472D6E46; Fri, 15 Feb 2019 11:15:44 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EF8E5D707; Fri, 15 Feb 2019 11:15:10 +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, 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 V15 06/18] block: use bio_for_each_bvec() to compute multi-page bvec count Date: Fri, 15 Feb 2019 19:13:12 +0800 Message-Id: <20190215111324.30129-7-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-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.29]); Fri, 15 Feb 2019 11:15:45 +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 First it is more efficient to use bio_for_each_bvec() in both blk_bio_segment_split() and __blk_recalc_rq_segments() to compute how many multi-page bvecs there are in the bio. Secondly once bio_for_each_bvec() is used, the bvec may need to be splitted because its length can be very longer than max segment size, so we have to split the big bvec into several segments. Thirdly when splitting multi-page bvec into segments, the max segment limit may be reached, so the bio split need to be considered under this situation too. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- block/blk-merge.c | 103 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 20 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index f85d878f313d..4ef56b2d2aa5 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -161,6 +161,73 @@ static inline unsigned get_max_io_size(struct request_queue *q, return sectors; } +static unsigned get_max_segment_size(struct request_queue *q, + unsigned offset) +{ + unsigned long mask = queue_segment_boundary(q); + + /* default segment boundary mask means no boundary limit */ + if (mask == BLK_SEG_BOUNDARY_MASK) + return queue_max_segment_size(q); + + return min_t(unsigned long, mask - (mask & offset) + 1, + queue_max_segment_size(q)); +} + +/* + * Split the bvec @bv into segments, and update all kinds of + * variables. + */ +static bool bvec_split_segs(struct request_queue *q, struct bio_vec *bv, + unsigned *nsegs, unsigned *last_seg_size, + unsigned *front_seg_size, unsigned *sectors) +{ + unsigned len = bv->bv_len; + unsigned total_len = 0; + unsigned new_nsegs = 0, seg_size = 0; + + /* + * Multi-page bvec may be too big to hold in one segment, so the + * current bvec has to be splitted as multiple segments. + */ + while (len && new_nsegs + *nsegs < queue_max_segments(q)) { + seg_size = get_max_segment_size(q, bv->bv_offset + total_len); + seg_size = min(seg_size, len); + + new_nsegs++; + total_len += seg_size; + len -= seg_size; + + if ((bv->bv_offset + total_len) & queue_virt_boundary(q)) + break; + } + + if (!new_nsegs) + return !!len; + + /* update front segment size */ + if (!*nsegs) { + unsigned first_seg_size; + + if (new_nsegs == 1) + first_seg_size = get_max_segment_size(q, bv->bv_offset); + else + first_seg_size = queue_max_segment_size(q); + + if (*front_seg_size < first_seg_size) + *front_seg_size = first_seg_size; + } + + /* update other varibles */ + *last_seg_size = seg_size; + *nsegs += new_nsegs; + if (sectors) + *sectors += total_len >> 9; + + /* split in the middle of the bvec if len != 0 */ + return !!len; +} + static struct bio *blk_bio_segment_split(struct request_queue *q, struct bio *bio, struct bio_set *bs, @@ -174,7 +241,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, struct bio *new = NULL; const unsigned max_sectors = get_max_io_size(q, bio); - bio_for_each_segment(bv, bio, iter) { + bio_for_each_bvec(bv, bio, iter) { /* * If the queue doesn't support SG gaps and adding this * offset would create a gap, disallow it. @@ -189,8 +256,12 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, */ if (nsegs < queue_max_segments(q) && sectors < max_sectors) { - nsegs++; - sectors = max_sectors; + /* split in the middle of bvec */ + bv.bv_len = (max_sectors - sectors) << 9; + bvec_split_segs(q, &bv, &nsegs, + &seg_size, + &front_seg_size, + §ors); } goto split; } @@ -212,14 +283,12 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, if (nsegs == queue_max_segments(q)) goto split; - if (nsegs == 1 && seg_size > front_seg_size) - front_seg_size = seg_size; - - nsegs++; bvprv = bv; bvprvp = &bvprv; - seg_size = bv.bv_len; - sectors += bv.bv_len >> 9; + + if (bvec_split_segs(q, &bv, &nsegs, &seg_size, + &front_seg_size, §ors)) + goto split; } @@ -233,8 +302,6 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, bio = new; } - if (nsegs == 1 && seg_size > front_seg_size) - front_seg_size = seg_size; bio->bi_seg_front_size = front_seg_size; if (seg_size > bio->bi_seg_back_size) bio->bi_seg_back_size = seg_size; @@ -297,6 +364,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, struct bio_vec bv, bvprv = { NULL }; int prev = 0; unsigned int seg_size, nr_phys_segs; + unsigned front_seg_size = bio->bi_seg_front_size; struct bio *fbio, *bbio; struct bvec_iter iter; @@ -316,7 +384,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, seg_size = 0; nr_phys_segs = 0; for_each_bio(bio) { - bio_for_each_segment(bv, bio, iter) { + bio_for_each_bvec(bv, bio, iter) { /* * If SG merging is disabled, each bio vector is * a segment @@ -336,20 +404,15 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, continue; } new_segment: - if (nr_phys_segs == 1 && seg_size > - fbio->bi_seg_front_size) - fbio->bi_seg_front_size = seg_size; - - nr_phys_segs++; bvprv = bv; prev = 1; - seg_size = bv.bv_len; + bvec_split_segs(q, &bv, &nr_phys_segs, &seg_size, + &front_seg_size, NULL); } bbio = bio; } - if (nr_phys_segs == 1 && seg_size > fbio->bi_seg_front_size) - fbio->bi_seg_front_size = seg_size; + fbio->bi_seg_front_size = front_seg_size; if (seg_size > bbio->bi_seg_back_size) bbio->bi_seg_back_size = seg_size; From patchwork Fri Feb 15 11:13:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814627 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 5EDBB13B5 for ; Fri, 15 Feb 2019 11:15:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55BD82EAE8 for ; Fri, 15 Feb 2019 11:15:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49B152EE6D; Fri, 15 Feb 2019 11:15:51 +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 D929B2EE56 for ; Fri, 15 Feb 2019 11:15:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2C3B8E0009; Fri, 15 Feb 2019 06:15:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BDB468E0001; Fri, 15 Feb 2019 06:15:49 -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 AF77B8E0009; Fri, 15 Feb 2019 06:15:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 811158E0001 for ; Fri, 15 Feb 2019 06:15:49 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id a199so7661940qkb.23 for ; Fri, 15 Feb 2019 03:15:49 -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=x6GvV3QaY1/jhRE59b51JpwNHXfPk01RcQDzFCAs7ko=; b=AyDaS+pkfhDZGOLaaXLrtuCkpQZUZB7BQ2hiQRVzgx/XFZPu5ucfRoVj6kYJGyXeVr qJHALPHBntwMc0aQH2sig8pACiFZBuAUQ3ZJoIoIOgfRxqfsaRXQcfOp5kMYok5pnymG A+coRz8hi7m9MCFioF4Al6rWyUb8HQQfAc7FdOZnTTbOpuHLPz8/jo9pqLBHw9+2Sqst HazO7l7ivWlp1rtzjBsaYIqUz7ftFd4fD7Km30ljzH55n2WsodnTmoJ1nbgoUPfQEcw1 FsfZAzhkPA3rGQSrGyR6AOj+jPJbntsuLM/o108nGCWDRIcs2GO2azJ/H2jYl8j4Z4Ls WrJw== 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: AHQUAuai/0/Pu4QO+lSF3kpSXnPG6l7TQDNnMJmtOUltBYqp6QbAp+CH GrmcKkpHnR+6ZdG020ezWIq5jWhb9gpbXfUX4ZircAQs1D+xRDrrMpVPdf8R7J5EmLvMUBWqn76 dk3xgbNcoI+20gMupMFJBOdq6YlxTE6hkLgiZzeG49ikfm91+3std8+lhMa3dWu80sg== X-Received: by 2002:a0c:8542:: with SMTP id n60mr6686510qva.205.1550229349274; Fri, 15 Feb 2019 03:15:49 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibok54kefhayiupgcs/h3O/D1oLUYMqY+N92A8RbEN0mCf1xQVUMnHBFb50CjK8y9wZHCY3 X-Received: by 2002:a0c:8542:: with SMTP id n60mr6686483qva.205.1550229348697; Fri, 15 Feb 2019 03:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229348; cv=none; d=google.com; s=arc-20160816; b=f3oOT2r7pVxpJ08ugDc+3snxPu4g5asEg692qjrgoHrz4og4aBsaaFJREWDNDhlC/6 lkfZ9Be3xGtFrfFxE/gZ3WO6EUvM33HjPMIjt5bZmxvSCGGSA/W6uOwjsoSl/FRRYaaL Qp4dvafeRQVMKIZZ9gM6Zvf2ldDe345imCWXs4uKV1TLyHXvoS9/285aM860ii7UZ6lr xNOV5D2k5E5tkogjVgl7t84JMXH1Tohz1qdBSlHwQFXOII94XoKWjahMzEnPXEXNOnJ7 Lop+qQXt7TpY0B51MgfW81hw6d9aK3tBYzCUkdYiLVj17QvhravdclQMGDWkLNe2eXNV IVvw== 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=x6GvV3QaY1/jhRE59b51JpwNHXfPk01RcQDzFCAs7ko=; b=MNk3Lk840XPYhCNFVwVtUQwA5/pZmMpQQdby43AaU8vyZp0KvhzPuZgpSH6YP8dKwC r235YxXoMgjzQ0Mtwo0v8ks0TSK24wH//hjvfEzXC+GwYPGOabTTd2+giom83/f/UHdB 96HVpiC6w5R0bXYUANzumsrqMi5lCrVPI+hJ/4Ty1ngiHV2ZcUYFRt725Dod6pNeIuEH ChAQ5FfsNrzcUfpDlecXTe/Go+OOLfD4RKZ+VfulruDOa36BbIKh/KTfE8tf+2Bfoxh8 Wq2RpdQVcUnT7j5DEdh5JH6fK6n2RdC7a89Vz8IMRuvQ169o4jWssIxkp5ZNCFIgLyhA F8Lw== 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 b5si3506704qti.147.2019.02.15.03.15.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:15:48 -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 9360E124564; Fri, 15 Feb 2019 11:15:47 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81D4760A9C; Fri, 15 Feb 2019 11:15:46 +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, 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 V15 07/18] block: use bio_for_each_bvec() to map sg Date: Fri, 15 Feb 2019 19:13:13 +0800 Message-Id: <20190215111324.30129-8-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-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.38]); Fri, 15 Feb 2019 11:15:47 +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 It is more efficient to use bio_for_each_bvec() to map sg, meantime we have to consider splitting multipage bvec as done in blk_bio_segment_split(). Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- block/blk-merge.c | 70 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 4ef56b2d2aa5..1912499b08b7 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -464,6 +464,54 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, return biovec_phys_mergeable(q, &end_bv, &nxt_bv); } +static struct scatterlist *blk_next_sg(struct scatterlist **sg, + struct scatterlist *sglist) +{ + if (!*sg) + return sglist; + + /* + * If the driver previously mapped a shorter list, we could see a + * termination bit prematurely unless it fully inits the sg table + * on each mapping. We KNOW that there must be more entries here + * or the driver would be buggy, so force clear the termination bit + * to avoid doing a full sg_init_table() in drivers for each command. + */ + sg_unmark_end(*sg); + return sg_next(*sg); +} + +static unsigned blk_bvec_map_sg(struct request_queue *q, + struct bio_vec *bvec, struct scatterlist *sglist, + struct scatterlist **sg) +{ + unsigned nbytes = bvec->bv_len; + unsigned nsegs = 0, total = 0, offset = 0; + + while (nbytes > 0) { + unsigned seg_size; + struct page *pg; + unsigned idx; + + *sg = blk_next_sg(sg, sglist); + + seg_size = get_max_segment_size(q, bvec->bv_offset + total); + seg_size = min(nbytes, seg_size); + + offset = (total + bvec->bv_offset) % PAGE_SIZE; + idx = (total + bvec->bv_offset) / PAGE_SIZE; + pg = nth_page(bvec->bv_page, idx); + + sg_set_page(*sg, pg, seg_size, offset); + + total += seg_size; + nbytes -= seg_size; + nsegs++; + } + + return nsegs; +} + static inline void __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec, struct scatterlist *sglist, struct bio_vec *bvprv, @@ -481,25 +529,7 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec, (*sg)->length += nbytes; } else { new_segment: - if (!*sg) - *sg = sglist; - else { - /* - * If the driver previously mapped a shorter - * list, we could see a termination bit - * prematurely unless it fully inits the sg - * table on each mapping. We KNOW that there - * must be more entries here or the driver - * would be buggy, so force clear the - * termination bit to avoid doing a full - * sg_init_table() in drivers for each command. - */ - sg_unmark_end(*sg); - *sg = sg_next(*sg); - } - - sg_set_page(*sg, bvec->bv_page, nbytes, bvec->bv_offset); - (*nsegs)++; + (*nsegs) += blk_bvec_map_sg(q, bvec, sglist, sg); } *bvprv = *bvec; } @@ -521,7 +551,7 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, int nsegs = 0; for_each_bio(bio) - bio_for_each_segment(bvec, bio, iter) + bio_for_each_bvec(bvec, bio, iter) __blk_segment_map_sg(q, &bvec, sglist, &bvprv, sg, &nsegs); From patchwork Fri Feb 15 11:13:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814629 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 AC02B13B5 for ; Fri, 15 Feb 2019 11:15:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3BE62EAE8 for ; Fri, 15 Feb 2019 11:15:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 978162EE6F; Fri, 15 Feb 2019 11:15:54 +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 399722EAE8 for ; Fri, 15 Feb 2019 11:15:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 157B78E000A; Fri, 15 Feb 2019 06:15:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 106B28E0001; Fri, 15 Feb 2019 06:15:53 -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 F3C258E000A; Fri, 15 Feb 2019 06:15:52 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id CC1A08E0001 for ; Fri, 15 Feb 2019 06:15:52 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id 65so8485804qte.18 for ; Fri, 15 Feb 2019 03:15:52 -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=UPqY5b1JqVkM1npPaeOz/GFx2XqKiaYkjhq3oYeVa/0=; b=EQha5vmxHqnN/duaFCczJ/1Z/lq1mOXYn3FSQQjE8e8aIV7uE/gvI30bRBDR1Gcnhx 1Fosv3bCOj0RG5ba74wBnPKfgux3OAe1KtqMRl3eSyfJkt9TM/gc/HPg5YiH3Wb+Ftf2 I+fxQhh/fcoxxTAi8DJlRMhyhNRYeo3TowHpBhkfbIiEq9hrrO2xSOaqlRKzfi22xqKg nenDaYgDhVHX44vNhakoCyHi97LRHaOHSo8Wf271tRI1AdvyDdRHq7fIUgBHl2xhcNDH KmB0y9f+q4u2gLq+oQ3E2HJ0fRC86DUWDEdrdTg+ovh5kL5UPfKTBlD1ZrGlJc0CcAq0 j4XQ== 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: AHQUAuYaFHgDiLf2fYCqPpQHTVDsRMK7FzH2eZ6d3hdtlDlD9s9TGLeP LOTnUJx3b8whBfiEceZ8RUfzkjsCF8lSJghTK657+NtFQftt6Q3kabgehYodiEGDHXNRx2b6WEu FWaeiRv/1khhSYegbiEh5dnpWoxOOsCfpZ5JNhzdg2NNkqULbzs+g+w1TuhRk4dVvwQ== X-Received: by 2002:a0c:ae76:: with SMTP id z51mr6910611qvc.103.1550229352603; Fri, 15 Feb 2019 03:15:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IY/vN+8lUgfupCwOVsoNZSiHK6VJSDktrqcgbVpaDi3FGSCaIlLv9rFuY9VjUEUCaN81B3b X-Received: by 2002:a0c:ae76:: with SMTP id z51mr6910580qvc.103.1550229352100; Fri, 15 Feb 2019 03:15:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229352; cv=none; d=google.com; s=arc-20160816; b=gf3Vjavu6hB4sSEPXhFabOVw9WSLSgH88zdmY19ApjPPqD7EIpix5ZTrM5jvDwItY6 BtkBXxcOX6SHEKpu6BNOfuF3pLsilzrZcAX/b37ab6XQOgWVgg7aL574W0sCMg3kg8mC ElLBJL4qVJ+xvLwbPrOXBy4XdsN+h4JocJqIYi9pSbEIEVe5b7LC82eu0p09BaqltyeI vxWROVZWkPQBkZBFCnrzSKOXTK07aGcLLUscZgWdznW7lE91XXloYxA55G7auRYiwZs/ V9zqha2iUPgUSQI1Khtu7GTaDoh3nffgFPZqq0n5Gx6bhtU5Yi1aJr0hbXIcdyQi4XFQ RNkg== 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=UPqY5b1JqVkM1npPaeOz/GFx2XqKiaYkjhq3oYeVa/0=; b=HSwSVUNO+cJKJDgyeagAy3oe0C4icJoYttNIk38yzUWrWJswc04uYzTmVsOu0O2cqB a2bF7XrvsUMdWdFzDicNUwEA6MLfjUn2xYJokSMwpAA4/jgXohYHcwWP+AZ+nfyW9mLl C8YVI+E1gF4qtcxgmaTtHl05RQRK+wlyULPplSAwHGn33Byptfi5pGdtBLsxeUDVXrny B8LxUQMAGLqb3MNzVM9jWxYn79cPYEI2uWDS8JYtN6tRr6BKT+yQ6FPu3FsDMzkIQ+tH AMKSVvkRpa2cYjPLG6YKwdjSS4UtmM5GTqDhrPEPb4GviPAYblW8gVK/hXmLRH6XYYkB vdOQ== 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 o4si551284qti.312.2019.02.15.03.15.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:15:52 -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 F39521244C3; Fri, 15 Feb 2019 11:15:50 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 312215DD6B; Fri, 15 Feb 2019 11:15:49 +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, 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 V15 08/18] block: introduce mp_bvec_last_segment() Date: Fri, 15 Feb 2019 19:13:14 +0800 Message-Id: <20190215111324.30129-9-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-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.38]); Fri, 15 Feb 2019 11:15:51 +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 BTRFS and guard_bio_eod() need to get the last singlepage segment from one multipage bvec, so introduce this helper to make them happy. Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- include/linux/bvec.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 0ae729b1c9fe..21f76bad7be2 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -131,4 +131,26 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, .bi_bvec_done = 0, \ } +/* + * Get the last single-page segment from the multi-page bvec and store it + * in @seg + */ +static inline void mp_bvec_last_segment(const struct bio_vec *bvec, + struct bio_vec *seg) +{ + unsigned total = bvec->bv_offset + bvec->bv_len; + unsigned last_page = (total - 1) / PAGE_SIZE; + + seg->bv_page = nth_page(bvec->bv_page, last_page); + + /* the whole segment is inside the last page */ + if (bvec->bv_offset >= last_page * PAGE_SIZE) { + seg->bv_offset = bvec->bv_offset % PAGE_SIZE; + seg->bv_len = bvec->bv_len; + } else { + seg->bv_offset = 0; + seg->bv_len = total - last_page * PAGE_SIZE; + } +} + #endif /* __LINUX_BVEC_ITER_H */ From patchwork Fri Feb 15 11:13:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814653 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 299BE17E0 for ; Fri, 15 Feb 2019 11:16:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21B8C2EE70 for ; Fri, 15 Feb 2019 11:16:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15B3B2EE56; Fri, 15 Feb 2019 11:16:15 +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 675CD2EE6F for ; Fri, 15 Feb 2019 11:16:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8ABA28E000B; Fri, 15 Feb 2019 06:16:13 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 80B468E0001; Fri, 15 Feb 2019 06:16:13 -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 6D5058E000B; Fri, 15 Feb 2019 06:16:13 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 3F0788E0001 for ; Fri, 15 Feb 2019 06:16:13 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id p5so8662246qtp.3 for ; Fri, 15 Feb 2019 03:16:13 -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=l7lN66KMtANDHHviPGwNxorL5gsXHpR77t2q1BoYAso=; b=lJHEikDigfbocZ/E2XgchiN9wIh+gCkrzWCWJax8eIQ/sLFQLAhejLkKFNfSRCy29+ K2yKkZ5+eqU9nVszfcT4hhpNnI2Jq/UWqPuOjFly2gM0hJPWSDg+cTSTDzg+0mRucEtx /LCpuOktwFBh7/EHmrBLRUJm99v1NCrhSlDhlvV145oX8V0Hc4wO5w3cot+QkZ2IeQkl yXXVM6s/fMWYfXLkPqpJKZfKBH2PHKSPzqd8NS29pSq5kiaFJfDg7hWd3K6cItACn/0q iKB2T90EZvIg9H101Lwr3Cf6FO4ZXaSyNJ/AKdbZhxpDLPlRTW9taQaP+jgcL1WmZVhL gNHw== 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: AHQUAubnfM4wuopw26HS7NcX6stnsLufTsJ/eEaviV2xg8ytTJZEjxbm UKk5wI152AhDFNkNKribMdiFwMiMn5Dx15j4N+JhPO4bamVr8TUnjdSFBpCMaYGq5aNAGmefnV5 Co0ddxCVqo6TdCVOkchUB8w1gpgdqH6+v3FbXtQmVQjmV9NJbnv8qOfTiWvHyPDoB9A== X-Received: by 2002:ac8:7a8f:: with SMTP id x15mr6978944qtr.36.1550229373007; Fri, 15 Feb 2019 03:16:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IYcJ9eEBAdYUJjN0vbqr18eVGiwt2uUfM8zwpC1P21CXOKhZkjmNW2LA7bixvzp5x6W5ntV X-Received: by 2002:ac8:7a8f:: with SMTP id x15mr6978921qtr.36.1550229372584; Fri, 15 Feb 2019 03:16:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229372; cv=none; d=google.com; s=arc-20160816; b=q3LCPvs53lhEQWgPVa01ahFJ6vsQoCmvzH58O1q6bmJZ3GKTGCxVpd7aDQplvedlyS 0a/sPkMOhr7j84qJT7WlO7JVrmivxNiZIKWFSWgZtXdah79NIVR3qoQlAhmcHz9NqFiS V+gfjxbzbmdDgp+C6ktNEpmJgsReuFlVv1pgjLm/uk5Hq00Vou8QZIxMRptGH9zViY27 JENK1An1N0lrZU7XKZe+07KBSbQonrbipsfNgqwTNgZMpekEtJ6n8M+uav401boBuCZ2 UsGm4+S0J0xNjZgoxXl3poAMWolshpygUG3v0xN1W4aLkgn95Lyclkf013f3cnlqLRVv wXCA== 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=l7lN66KMtANDHHviPGwNxorL5gsXHpR77t2q1BoYAso=; b=KMXO5AWsRw5b1CRbTao9uBF67Vk9fBGHJuwP+aHIUvweufWXinMM8j6Fjjewc0+Dct ql+9k18uyMj87c4M6nNZ006DWcnbJQTQAi/vdsXb6JAY1G6P3Wukws0SgHIC9D0rkxyQ v5EJa3Tntwwc1eQfhfMscAJlSfDSyYo0QfT0J3B0rbA4eNT8qgMd+M7T3PBqoaGOEqQx SwemSCpN/TPwOH7r2mQZOWaUGKvZgyaQwfrJVYv8jXc8RgVQ0BA6G17JM9RWseamwOV8 J7ltriXI2e5YhdZjzstt1gGjDNqoXxVk8mUPM7OMs1lX2DFBklWDh3Gm8PCT8/1DhXPv Gt3A== 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 132si24964qkg.155.2019.02.15.03.16.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:16:12 -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-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C8271219DF; Fri, 15 Feb 2019 11:16:11 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D9335F9C2; Fri, 15 Feb 2019 11:15:53 +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, 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 V15 09/18] fs/buffer.c: use bvec iterator to truncate the bio Date: Fri, 15 Feb 2019 19:13:15 +0800 Message-Id: <20190215111324.30129-10-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 15 Feb 2019 11:16:11 +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 mp_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 52d024bfdbc1..817871274c77 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; + + mp_bvec_last_segment(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } } From patchwork Fri Feb 15 11:13:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814663 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 EED4A17E0 for ; Fri, 15 Feb 2019 11:16:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6F7D2EAE8 for ; Fri, 15 Feb 2019 11:16:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA9B62EE6D; Fri, 15 Feb 2019 11:16:18 +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 8E5D82EE56 for ; Fri, 15 Feb 2019 11:16:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96D6E8E000C; Fri, 15 Feb 2019 06:16:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8F5F08E0001; Fri, 15 Feb 2019 06:16:17 -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 7BF0C8E000C; Fri, 15 Feb 2019 06:16:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 4F4228E0001 for ; Fri, 15 Feb 2019 06:16:17 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id a199so7662803qkb.23 for ; Fri, 15 Feb 2019 03:16:17 -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=QsyyCrPYM4mSQKLdRXgny5EZIKPBaVsU+ab/s6p3Gys=; b=HjCrG0WvzxY7TD5V2hBMJv3rXAQTYfOjZKok7DyZ9skprkzbzxVZ9iuRfc1CH2hSjS TTbgLk5iCbprJGJdNXM9WyBLWb0yBUuUGVZS0xdabwyUO/pWwZ1h0pO3o6lrBoJaXR4A rM6LdBEddQHZ2a3FNgjQEtY+mGhNs0bcqR+ppULEDSzjlZ0VUPme7AvNFbX+W3+NIWuN mmF/fCdwqljwlPa1/9JIGCwi1UMOoq/iwl3mLLPGfU7kANfSHroJI5eGWFvgQt+RqLOM eWKZCjSr4DEUbbvH+jfNwF4ptfuy3P6C2axpfwhqdbKh6DOZRA5ehyqdwBTNFjcyBTku W++Q== 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: AHQUAuaf2rPJCubmAVRVmM3c1nCfNjZNaoOEQdaTjNx2G6DQGBdXDr4R +8SjRB9BoeVEnLSkSQNwJ0tTTl1NWVZCok5o8xe+m7mORDjgEfY0sp9MAYH1Hzxg8h2h+mzCGIw q4Tjl+2KHoT9BssGfQqAOzeTbbV+YlrO1PbjLFdz+OWS6A/oYb4ty2200CPBc68bHgg== X-Received: by 2002:ae9:ddc3:: with SMTP id r186mr6531868qkf.163.1550229377105; Fri, 15 Feb 2019 03:16:17 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibw2DDDE18GImCftpz1KZ+IjTfcxi5G83X+ajSvabQ+5YmY125OoJO2OiofJbf+IgZC/kUT X-Received: by 2002:ae9:ddc3:: with SMTP id r186mr6531838qkf.163.1550229376623; Fri, 15 Feb 2019 03:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229376; cv=none; d=google.com; s=arc-20160816; b=NN5Atc3yoL0yrjX2zADRQ3K2zz+z1vawlftJGin5CVD/VRKULoiSMlPk32wC/KDEKQ ujOWWmOAPWAUyCh/U8bZAiHcwVd2tCATdmVrWzIYh+OLRqdCcSbvOXcV8Q92ovqADKIN d0fEyT8BlW2ota/HySiGzj5hjYwrKgbm42+QRYGENgSzD1vAq42mArRk5JUq650F41g7 T9PXsq+EocBe8zuUI3AsAuDLhBIn6wQK0ZtFxS34blRHRsqtc4mQSBrDrJOpl5Evqhs6 NOeNiypGD6+1YRPCNn5h6cguVqrK96ZnrIqG4zwUacvlUwyC8RKahFak4Vi88hh42qGB pTxA== 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=QsyyCrPYM4mSQKLdRXgny5EZIKPBaVsU+ab/s6p3Gys=; b=yHJ8q0r1u6YYHEFJubYhYF5YsTc+87Xh0n3kdh+Su/tnu72pXAjvGOr3VYWaBsqc5I bbtHB4JV3TCcBNzHclOu2kZy/9m3suCgHelC2QzSogDUFFdXQ2jyCvr2WNMR1mC3UqJK beTGAtH9ZpIErdrpxozS6adJFKpTqW6yO2bNYRxOKYRYPeqkEn05e5RlB+876iyZBZZB 5QfHnxcDmPmsd8+SdcWGLwEjR7K+aW/OhZLMKg7sO6ejP7HvWeZvoDUNaASB5wTuHAfI 1+3ppeKrOOzZ3s1caqg+3FUxqJQ1NJpQynckptc/TPxThH9fYawBgyRvFhjrwloo7BGC A+lA== 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 w3si3355857qth.85.2019.02.15.03.16.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:16:16 -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 0CEA2C0AD406; Fri, 15 Feb 2019 11:16:15 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 077AD60A9C; Fri, 15 Feb 2019 11:16:13 +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, 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 V15 10/18] btrfs: use mp_bvec_last_segment to get bio's last page Date: Fri, 15 Feb 2019 19:13:16 +0800 Message-Id: <20190215111324.30129-11-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-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.31]); Fri, 15 Feb 2019 11:16:15 +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. Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- fs/btrfs/extent_io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index dc8ba3ee515d..986ef49b0269 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2697,11 +2697,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; + mp_bvec_last_segment(bvec, &bv); + start = page_offset(bv.bv_page) + bv.bv_offset; bio->bi_private = NULL; From patchwork Fri Feb 15 11:13:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814667 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 CCB9913B5 for ; Fri, 15 Feb 2019 11:16:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C359D2EAE8 for ; Fri, 15 Feb 2019 11:16:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5EC02EE70; Fri, 15 Feb 2019 11:16:22 +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 4C7122EAE8 for ; Fri, 15 Feb 2019 11:16:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C9AC8E000D; Fri, 15 Feb 2019 06:16:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3292A8E0001; Fri, 15 Feb 2019 06:16:21 -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 1D0E78E000D; Fri, 15 Feb 2019 06:16:21 -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 E1A2B8E0001 for ; Fri, 15 Feb 2019 06:16:20 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id c84so7841120qkb.13 for ; Fri, 15 Feb 2019 03:16:20 -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=QDJuYdB/v5IBDbMNukxwyLgaj2zPEtaGeI+9DGb7M44=; b=WJykEW/s2w93i1sFSzcLZGmU+HAvng3fAjYqD2PPhxU99jcBVz13hq2S33IyCz8CEg cafHvb/E6z0Ye4ZlyAF/ykNiwLBdzLVYBRvr7Nv8luaPAUWKXgpOu1Dz6ycDimN5gsgg DX3KOv5pFZmnJpG7InMErnMQUuVgrF7wxpzZb8hJaZBAiLelN/MWMDvr+l2LbU2aNszY ZPaS966O4BM76++t33DHqjhLkvd7wJWqkWyiG9OrSMilpbHvy+HarGGxyYHj2SjXSNnC /qdVaa3iCmLfyOL7xhqpjaeXeidVW7+9icVCBxEbkkrgfREgvgtDb0yG4qwQmCTO2+dI t9Uw== 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: AHQUAubAq1zJEGbAZtZiqJdF8sORXq9Y+VmLV9OBL2aCSnRdiale156U Skyt4fFT5D32PG/QksN4j2mDtYtcAMRqIrM9/jgPmLzCi54oca8nDLJo8VHOIs9o6nC0J7QgBT4 G/Nt3nYW9iiSJJdZyVNcB9BAEZd4r4kwos0FbNv1/gFVox2wARuBwch2bNlCllHtxcQ== X-Received: by 2002:ae9:c303:: with SMTP id n3mr6449283qkg.49.1550229380673; Fri, 15 Feb 2019 03:16:20 -0800 (PST) X-Google-Smtp-Source: AHgI3IY4RlwLv17TfL/P9KrQXQLGTO03e0T1KPbjyJacaegeDAevm5kHFAOiXDtwLpIqMHQL8xEc X-Received: by 2002:ae9:c303:: with SMTP id n3mr6449258qkg.49.1550229380085; Fri, 15 Feb 2019 03:16:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229380; cv=none; d=google.com; s=arc-20160816; b=VAXPb5v+u61oPJpgQXLq0pA+9acpxMuxxwRSju71BvvLN7BxmFYpK/LFvWCjdYvFaA P5l24iaT62UCx2D+aXcURweZcfBohMIQJweC5TtGL+KMybQgtaCWzfK9Af7v/jUAlgbU VEr7AHeY8vcSZgYm2v+5VECn1hC11OgmThkfTsrezA9A/O7zTSCcnqf6THoP/oM28Htr MTpOhaj3pfZGrSfIB1Vk4kKfvgQ+NoTA5ed56ZBCHKStUbEv/d5C3yZLXSurFLsd4uP3 uaqZYaJ5l4Lsx7wS6BoHy9nXTQVizPXjBO0GMfiUgFjz6vsZIzmttJNApQpeFuQFMyHY yLSg== 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=QDJuYdB/v5IBDbMNukxwyLgaj2zPEtaGeI+9DGb7M44=; b=JZp484oYd49DegsJFSRaQL+uOerx/Hfmr6JivTFtreT7BiR9zgvnaSGncpGAFUrWLY 6Ug/cBIT39xWHYVlXTjSwiLxhBv2iEYUZl7KWP+6L2NM5y3KggTT8lbH6LtJrpHQsbMi LykXBqrJiWZFsCW7FYLrPqq8tMZnvg1aS5sERsrIkQ8q28hB0pCZwweC3Iy2BSAJQuwt HdDuWDxAKUqCzg8xspm5/R2y1fjuIkxvbhzavaTF0dxwa+Fdv1IBwJSwJASU0oUaEQra 1R9bP27LbTBy9OC1gs0BuIqkNlMpVwQMtEdLPwoA+TlByChXeP9IrY4DmMf8i9uY4DGx Ri0Q== 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 n66si3468547qka.101.2019.02.15.03.16.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:16:20 -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-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B6648C01DE19; Fri, 15 Feb 2019 11:16:18 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id B69A026E59; Fri, 15 Feb 2019 11:16:17 +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, 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 V15 11/18] block: loop: pass multi-page bvec to iov_iter Date: Fri, 15 Feb 2019 19:13:17 +0800 Message-Id: <20190215111324.30129-12-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 15 Feb 2019 11:16:19 +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 iov_iter is implemented on bvec itererator helpers, so it is safe to pass multi-page bvec to it, and this way is much more efficient than passing one page in each bvec. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- drivers/block/loop.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index cf5538942834..8ef583197414 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -511,21 +511,22 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, loff_t pos, bool rw) { struct iov_iter iter; + struct req_iterator rq_iter; struct bio_vec *bvec; struct request *rq = blk_mq_rq_from_pdu(cmd); struct bio *bio = rq->bio; struct file *file = lo->lo_backing_file; + struct bio_vec tmp; unsigned int offset; - int segments = 0; + int nr_bvec = 0; int ret; + rq_for_each_bvec(tmp, rq, rq_iter) + nr_bvec++; + if (rq->bio != rq->biotail) { - struct req_iterator iter; - struct bio_vec tmp; - __rq_for_each_bio(bio, rq) - segments += bio_segments(bio); - bvec = kmalloc_array(segments, sizeof(struct bio_vec), + bvec = kmalloc_array(nr_bvec, sizeof(struct bio_vec), GFP_NOIO); if (!bvec) return -EIO; @@ -534,10 +535,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, /* * The bios of the request may be started from the middle of * the 'bvec' because of bio splitting, so we can't directly - * copy bio->bi_iov_vec to new bvec. The rq_for_each_segment + * copy bio->bi_iov_vec to new bvec. The rq_for_each_bvec * API will take care of all details for us. */ - rq_for_each_segment(tmp, rq, iter) { + rq_for_each_bvec(tmp, rq, rq_iter) { *bvec = tmp; bvec++; } @@ -551,11 +552,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, */ offset = bio->bi_iter.bi_bvec_done; bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); - segments = bio_segments(bio); } atomic_set(&cmd->ref, 2); - iov_iter_bvec(&iter, rw, bvec, segments, blk_rq_bytes(rq)); + iov_iter_bvec(&iter, rw, bvec, nr_bvec, blk_rq_bytes(rq)); iter.iov_offset = offset; cmd->iocb.ki_pos = pos; From patchwork Fri Feb 15 11:13:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814677 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 8685717E0 for ; Fri, 15 Feb 2019 11:16:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DFF02EAE8 for ; Fri, 15 Feb 2019 11:16:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 712212EE6D; Fri, 15 Feb 2019 11:16:26 +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 0EEE62EAE8 for ; Fri, 15 Feb 2019 11:16:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E77C08E000E; Fri, 15 Feb 2019 06:16:24 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFDEC8E0001; Fri, 15 Feb 2019 06:16:24 -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 C9F3F8E000E; Fri, 15 Feb 2019 06:16:24 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 92E488E0001 for ; Fri, 15 Feb 2019 06:16:24 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id k1so8689536qta.2 for ; Fri, 15 Feb 2019 03:16:24 -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=xr6DahF5ogf42oUHn8yO+xHUQepi7gnUCentUFTY6cc=; b=X5l0TNDHZtTMgqRkXfXuPZ2d481rhNCROl4943BuZI0aYdjW6oHvPpYmSMVf+Q97G0 WIEphz/L9hJtC2iiRvzadYCniED5RQ6FtxB/oDlmXAzRju5vvprnJuSsU8DOuhjnFqVQ 30eGc+SU31gZnUkw56J5jkbEb4gNLsN9QDxO97scp7wdj2A3a2xgKMP4sDwaZ8LCV1dn 0reP9s3Fr2z4c2SipPh0ihxyVBAc7uNdsCyta6D785fEaX2Hg33hMvUD2Jzl3ksSfdre RRkxGqKZ3LxpEWbwVThOW+5CyaLt/WpvlWQ5vywrVh3siNXJCK5xuqptTo47a7Or22+S rG5Q== 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: AHQUAuY2K3Cj+yPqqyZD5r59rszusV2Y7t7ufgz8yFpk2zQIOWOo3OuQ VMuZtnEbxG1iULtZdBIZdXUhRfcNv1L9d1HAeJCc12Qh7E6P6QRNPgN1gssKKZE+Tjz3CH7cue5 ht0YwxW3aNuXbPbsxddCT1uTYGKzJhgjMuE2qV4JL9rl+spFzUgCFKQu3RknQlfcFYA== X-Received: by 2002:ac8:1662:: with SMTP id x31mr6989876qtk.55.1550229384401; Fri, 15 Feb 2019 03:16:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IagkkfK/wA1OZC34hE3FKhStjbhFBuZKvxUoQnrVXDOzNzsuuSBx3pIou8XR1067j/EhT/1 X-Received: by 2002:ac8:1662:: with SMTP id x31mr6989845qtk.55.1550229383911; Fri, 15 Feb 2019 03:16:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229383; cv=none; d=google.com; s=arc-20160816; b=bccHXJuaNd6rPjAoCmDxGeindPbgsP7DcSkGQ7/faARTFN9d4kMNEa+M2JS3sVA2Lw mSTdJFuSA9e/T34vloPyI3E7uZ1PpcM+ZpOzXlonBgB9Hk+GEpCrQWkchkS7s2yZfVZm dLOXUDw89yMSETsglASUK/yBJe/NuSIcqxuB2sg7Ql067maxYaEH2ytVeeWOV19HK8iL 8R70YSFNt+z95WEtsfz4HdPe8YRCGhOyKkqTxj43CTGWYVhH2hgKEkmP1eAQe9zqF4sO Natsechh5IGWDxd5eQkOATJGwlfFmdcrOzh67dpYcUcqNcJdzRsxhEDTqrrXO7HJ6nW8 gadQ== 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=xr6DahF5ogf42oUHn8yO+xHUQepi7gnUCentUFTY6cc=; b=e/O/bOnTGSXRkNd70LwfDUPSF2KXcqB67WQ7zWj9Guu8//HBeBsPSvnToIJwU1N25K jIRZ3JyCehrygvnxdOcSqZopf82ayPCMSjHupWuRJPV+PAVmtRGowRJ5vb/qPfd9jvJX MZqNociFYlL/cPg6KLmYBWuphaiauq84FHQVjBSysHwHNh+hDakYLazf7TpIgo1tu+Vc e43kPGqZhXa4HkblBdgfoFYCHhtFjVnRxdW4h3euu7jQxdS6TCXd7X6Rpi9tdReb3RsU XN7j7R/LPOZtnmjIz5Xogmc9rjchSVQdbj23BIxJ0o4nH4xpfqHL6rKt4DAN0T4U7ZSN zSWw== 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 y5si2032823qtc.187.2019.02.15.03.16.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:16:23 -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-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5204DC7857; Fri, 15 Feb 2019 11:16:22 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38D6A26E74; Fri, 15 Feb 2019 11:16:20 +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, 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 V15 12/18] bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages() Date: Fri, 15 Feb 2019 19:13:18 +0800 Message-Id: <20190215111324.30129-13-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 15 Feb 2019 11:16:23 +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 bch_bio_alloc_pages() is always called on one new bio, so it is safe to access the bvec table directly. Given it is the only kind of this case, open code the bvec table access since bio_for_each_segment_all() will be changed to support for iterating over multipage bvec. Acked-by: Coly Li Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- drivers/md/bcache/util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 20eddeac1531..62fb917f7a4f 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -270,7 +270,11 @@ int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) int i; struct bio_vec *bv; - bio_for_each_segment_all(bv, bio, i) { + /* + * This is called on freshly new bio, so it is safe to access the + * bvec table directly. + */ + for (i = 0, bv = bio->bi_io_vec; i < bio->bi_vcnt; bv++, i++) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { while (--bv >= bio->bi_io_vec) From patchwork Fri Feb 15 11:13:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814693 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 D442A1575 for ; Fri, 15 Feb 2019 11:16:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C827A2EE56 for ; Fri, 15 Feb 2019 11:16:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B89BB2EE70; Fri, 15 Feb 2019 11:16:48 +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 883DF2EE56 for ; Fri, 15 Feb 2019 11:16:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FA3F8E000F; Fri, 15 Feb 2019 06:16:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 89F6B8E0001; Fri, 15 Feb 2019 06:16:45 -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 724518E000F; Fri, 15 Feb 2019 06:16:45 -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 3ACAC8E0001 for ; Fri, 15 Feb 2019 06:16:45 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id r24so8653369qtj.13 for ; Fri, 15 Feb 2019 03:16:45 -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=iK/keQTa+g2rXBeS7+SCvlmZbsSS1FVW28sk0za4K44=; b=Mcf0WWlKtYNkpTo20pc5+C5ifZa43k1qb35QMPjb6qQXqZVk6+GwsjICQIeeeIk3vs rH10l6w368MmoTVRNhqVRKdWk/Hyt4TvzGIBXM5d9o1a4FPwcF30KRSdY6/PPSXfO+oJ UYQguU/pRbRIA5/TH390eJuMPZS4FkM4dsAxXZ452u2un2L8ijSNfsCEEdQufNrqD6Lw zClNOS5qEBroFLThLR8yeW5Cg6DEPoLNq5V1LEU/HWNhskrm8AW8tAyMMmYoA+OM79Ud YzGDqKcTTlXgO4FK0/QK0ShtKVquNX8CvVF6EtPp2vLkmqCbJWfwfemC1BjPTtWGJWhb mcAg== 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: AHQUAua0umBZBWUGqEyy8fSrY38M2LVmapeyYTv74C17k8zM+bgGF5hW dmKOwhF4t/No1N3Tf90FM93tRgjt2sw4O2p+cB4Ub3LAKx0vH3wN661gwPZATa6RWW2Ij324J2i JfJwUj0iI4rKVDe0CFmAgpdCXZCeRaIrxSJ7wjgHha2X4KK2RhvqAv4kx1YjQaBpicQ== X-Received: by 2002:a37:2d82:: with SMTP id t124mr6125464qkh.189.1550229404877; Fri, 15 Feb 2019 03:16:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IZRLDWOlwytph5BuBcE7sh6/isX4JjArdJaR9QIXYCI19Edo142uBDi+ujoDhm4niA+TuAC X-Received: by 2002:a37:2d82:: with SMTP id t124mr6125398qkh.189.1550229403447; Fri, 15 Feb 2019 03:16:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229403; cv=none; d=google.com; s=arc-20160816; b=F8n9QrpdwTaInRwZUbW1rQwMnMZ5hBdh1ovdv+toEstXJ3d9giwUiXYKZqvDh2jZ/r 4QAo318QjwLsLHAliG9p7znEfhLM0AEELWOrHMvD28iufxDo/h7/dkRE/I0Pm0NZrqqT 9jWkN908F3HGkCkzWLRINCxbTM4pWwEU1KTf2U3OXecURjtIMBh+Ctru9OpotlN10luE HVv9K4sYETruQwJzaPmQskIj5+0UHkYYu0bKuTpIxjplB7V7UE34qt4LT/li1DPeWMwo 6LUfU9i6syjAsPSD4pI1/FisiSR1EnR3B867dcQ3EdVCwCSzJNeuhjjIvX+wayUy1eO0 I0Yg== 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=iK/keQTa+g2rXBeS7+SCvlmZbsSS1FVW28sk0za4K44=; b=exRmlrjhsBrZ//Jjaz7ZkWp11pckPOF3x0JGAMowD5bAKzeqBScaApqe7trp9HWSQj JqJIOYtSilWhNf9iIhLt2wGkKn77bb9u8dvGPTTLj0dmDgC0hFI3krBawxDAeryblRoq C6y+r4qxSAXoDLpuvk2G5gHMk6h2WLBpptts7GFw+A0X5tPLAXclakbmus1L675i0PGn u1QFRWVOprpEwid1hXi2W41SiFw26l/+xelFGLhurGWgdVBJFeDaKPCl7HTqY5vbo4GE hyKoGtg4u0+gLEiHSxmqiOgFQcmtP2O65PfuJocacmz3eICQVh/Pzzv5IJ93NLpQM9bi 7Ihg== 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 j18si277092qth.388.2019.02.15.03.16.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:16:43 -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 9E6EBAD885; Fri, 15 Feb 2019 11:16:41 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8E755D6A9; Fri, 15 Feb 2019 11:16:24 +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, 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 V15 13/18] block: allow bio_for_each_segment_all() to iterate over multi-page bvec Date: Fri, 15 Feb 2019 19:13:19 +0800 Message-Id: <20190215111324.30129-14-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-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.28]); Fri, 15 Feb 2019 11:16:42 +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 This patch introduces one extra iterator variable to bio_for_each_segment_all(), then we can allow bio_for_each_segment_all() to iterate over multi-page bvec. Given it is just one mechannical & simple change on all bio_for_each_segment_all() users, this patch does tree-wide change in one single patch, so that we can avoid to use a temporary helper for this conversion. Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- block/bio.c | 27 ++++++++++++++++++--------- block/bounce.c | 6 ++++-- drivers/md/bcache/btree.c | 3 ++- drivers/md/dm-crypt.c | 3 ++- drivers/md/raid1.c | 3 ++- drivers/staging/erofs/data.c | 3 ++- drivers/staging/erofs/unzip_vle.c | 3 ++- fs/block_dev.c | 6 ++++-- fs/btrfs/compression.c | 3 ++- fs/btrfs/disk-io.c | 3 ++- fs/btrfs/extent_io.c | 9 ++++++--- fs/btrfs/inode.c | 6 ++++-- fs/btrfs/raid56.c | 3 ++- fs/crypto/bio.c | 3 ++- fs/direct-io.c | 4 +++- fs/exofs/ore.c | 3 ++- fs/exofs/ore_raid.c | 3 ++- fs/ext4/page-io.c | 3 ++- fs/ext4/readpage.c | 3 ++- fs/f2fs/data.c | 9 ++++++--- fs/gfs2/lops.c | 9 ++++++--- fs/gfs2/meta_io.c | 3 ++- fs/iomap.c | 6 ++++-- fs/mpage.c | 3 ++- fs/xfs/xfs_aops.c | 5 +++-- include/linux/bio.h | 11 +++++++++-- include/linux/bvec.h | 30 ++++++++++++++++++++++++++++++ 27 files changed, 127 insertions(+), 46 deletions(-) diff --git a/block/bio.c b/block/bio.c index 4db1008309ed..968b12fea564 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1072,8 +1072,9 @@ static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter) { int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { ssize_t ret; ret = copy_page_from_iter(bvec->bv_page, @@ -1103,8 +1104,9 @@ static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter) { int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { ssize_t ret; ret = copy_page_to_iter(bvec->bv_page, @@ -1126,8 +1128,9 @@ void bio_free_pages(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) __free_page(bvec->bv_page); } EXPORT_SYMBOL(bio_free_pages); @@ -1295,6 +1298,7 @@ struct bio *bio_map_user_iov(struct request_queue *q, struct bio *bio; int ret; struct bio_vec *bvec; + struct bvec_iter_all iter_all; if (!iov_iter_count(iter)) return ERR_PTR(-EINVAL); @@ -1368,7 +1372,7 @@ struct bio *bio_map_user_iov(struct request_queue *q, return bio; out_unmap: - bio_for_each_segment_all(bvec, bio, j) { + bio_for_each_segment_all(bvec, bio, j, iter_all) { put_page(bvec->bv_page); } bio_put(bio); @@ -1379,11 +1383,12 @@ static void __bio_unmap_user(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; /* * make sure we dirty pages we wrote to */ - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { if (bio_data_dir(bio) == READ) set_page_dirty_lock(bvec->bv_page); @@ -1475,8 +1480,9 @@ static void bio_copy_kern_endio_read(struct bio *bio) char *p = bio->bi_private; struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { memcpy(p, page_address(bvec->bv_page), bvec->bv_len); p += bvec->bv_len; } @@ -1585,8 +1591,9 @@ void bio_set_pages_dirty(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { if (!PageCompound(bvec->bv_page)) set_page_dirty_lock(bvec->bv_page); } @@ -1596,8 +1603,9 @@ static void bio_release_pages(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) put_page(bvec->bv_page); } @@ -1644,8 +1652,9 @@ void bio_check_pages_dirty(struct bio *bio) struct bio_vec *bvec; unsigned long flags; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { if (!PageDirty(bvec->bv_page) && !PageCompound(bvec->bv_page)) goto defer; } diff --git a/block/bounce.c b/block/bounce.c index ffb9e9ecfa7e..add085e28b1d 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -165,11 +165,12 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool) struct bio_vec *bvec, orig_vec; int i; struct bvec_iter orig_iter = bio_orig->bi_iter; + struct bvec_iter_all iter_all; /* * free up bounce indirect pages used */ - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { orig_vec = bio_iter_iovec(bio_orig, orig_iter); if (bvec->bv_page != orig_vec.bv_page) { dec_zone_page_state(bvec->bv_page, NR_BOUNCE); @@ -294,6 +295,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, bool bounce = false; int sectors = 0; bool passthrough = bio_is_passthrough(*bio_orig); + struct bvec_iter_all iter_all; bio_for_each_segment(from, *bio_orig, iter) { if (i++ < BIO_MAX_PAGES) @@ -313,7 +315,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, bio = bounce_clone_bio(*bio_orig, GFP_NOIO, passthrough ? NULL : &bounce_bio_set); - bio_for_each_segment_all(to, bio, i) { + bio_for_each_segment_all(to, bio, i, iter_all) { struct page *page = to->bv_page; if (page_to_pfn(page) <= q->limits.bounce_pfn) diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 23cb1dc7296b..64def336f053 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -432,8 +432,9 @@ static void do_btree_node_write(struct btree *b) int j; struct bio_vec *bv; void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, b->bio, j) + bio_for_each_segment_all(bv, b->bio, j, iter_all) memcpy(page_address(bv->bv_page), base + j * PAGE_SIZE, PAGE_SIZE); diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 47d4e0d30bf0..9a29037f5615 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1447,8 +1447,9 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) { unsigned int i; struct bio_vec *bv; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, clone, i) { + bio_for_each_segment_all(bv, clone, i, iter_all) { BUG_ON(!bv->bv_page); mempool_free(bv->bv_page, &cc->page_pool); } diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7e63ccc4ae7b..88c61d3090b0 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2112,13 +2112,14 @@ static void process_checks(struct r1bio *r1_bio) struct page **spages = get_resync_pages(sbio)->pages; struct bio_vec *bi; int page_len[RESYNC_PAGES] = { 0 }; + struct bvec_iter_all iter_all; if (sbio->bi_end_io != end_sync_read) continue; /* Now we can 'fixup' the error value */ sbio->bi_status = 0; - bio_for_each_segment_all(bi, sbio, j) + bio_for_each_segment_all(bi, sbio, j, iter_all) page_len[j] = bi->bv_len; if (!status) { diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index 5a55f0bfdfbb..4871ba7b7d9a 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -20,8 +20,9 @@ static inline void read_endio(struct bio *bio) int i; struct bio_vec *bvec; const blk_status_t err = bio->bi_status; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; /* page is already locked */ diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 4ac1099a39c6..c057c5616b1d 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -830,8 +830,9 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) #ifdef EROFS_FS_HAS_MANAGED_CACHE struct address_space *mc = NULL; #endif + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; bool cachemngd = false; diff --git a/fs/block_dev.c b/fs/block_dev.c index 58a4c1217fa8..7758adee6efe 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -211,6 +211,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, ssize_t ret; blk_qc_t qc; int i; + struct bvec_iter_all iter_all; if ((pos | iov_iter_alignment(iter)) & (bdev_logical_block_size(bdev) - 1)) @@ -260,7 +261,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, } __set_current_state(TASK_RUNNING); - bio_for_each_segment_all(bvec, &bio, i) { + bio_for_each_segment_all(bvec, &bio, i, iter_all) { if (should_dirty && !PageCompound(bvec->bv_page)) set_page_dirty_lock(bvec->bv_page); put_page(bvec->bv_page); @@ -329,8 +330,9 @@ static void blkdev_bio_end_io(struct bio *bio) } else { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) put_page(bvec->bv_page); bio_put(bio); } diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 548057630b69..6896ea60c843 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -162,13 +162,14 @@ static void end_compressed_bio_read(struct bio *bio) } else { int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; /* * we have verified the checksum already, set page * checked so the end_io handlers know about it */ ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, cb->orig_bio, i) + bio_for_each_segment_all(bvec, cb->orig_bio, i, iter_all) SetPageChecked(bvec->bv_page); bio_endio(cb->orig_bio); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 6a2a2a951705..ca1b7da6dd1b 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -832,9 +832,10 @@ static blk_status_t btree_csum_one_bio(struct bio *bio) struct bio_vec *bvec; struct btrfs_root *root; int i, ret = 0; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { root = BTRFS_I(bvec->bv_page->mapping->host)->root; ret = csum_dirty_buffer(root->fs_info, bvec->bv_page); if (ret) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 986ef49b0269..4ed58c9a94a9 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2422,9 +2422,10 @@ static void end_bio_extent_writepage(struct bio *bio) u64 start; u64 end; int i; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; struct inode *inode = page->mapping->host; struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); @@ -2493,9 +2494,10 @@ static void end_bio_extent_readpage(struct bio *bio) int mirror; int ret; int i; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; struct inode *inode = page->mapping->host; struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); @@ -3635,9 +3637,10 @@ static void end_bio_extent_buffer_writepage(struct bio *bio) struct bio_vec *bvec; struct extent_buffer *eb; int i, done; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; eb = (struct extent_buffer *)page->private; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5c349667c761..7ade5769f691 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7777,6 +7777,7 @@ static void btrfs_retry_endio_nocsum(struct bio *bio) struct bio_vec *bvec; struct extent_io_tree *io_tree, *failure_tree; int i; + struct bvec_iter_all iter_all; if (bio->bi_status) goto end; @@ -7788,7 +7789,7 @@ static void btrfs_retry_endio_nocsum(struct bio *bio) done->uptodate = 1; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) clean_io_failure(BTRFS_I(inode)->root->fs_info, failure_tree, io_tree, done->start, bvec->bv_page, btrfs_ino(BTRFS_I(inode)), 0); @@ -7867,6 +7868,7 @@ static void btrfs_retry_endio(struct bio *bio) int uptodate; int ret; int i; + struct bvec_iter_all iter_all; if (bio->bi_status) goto end; @@ -7880,7 +7882,7 @@ static void btrfs_retry_endio(struct bio *bio) failure_tree = &BTRFS_I(inode)->io_failure_tree; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { ret = __readpage_endio_check(inode, io_bio, i, bvec->bv_page, bvec->bv_offset, done->start, bvec->bv_len); diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index e74455eb42f9..1869ba8e5981 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1443,10 +1443,11 @@ static void set_bio_pages_uptodate(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; ASSERT(!bio_flagged(bio, BIO_CLONED)); - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) SetPageUptodate(bvec->bv_page); } diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 0959044c5cee..5759bcd018cd 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -30,8 +30,9 @@ static void __fscrypt_decrypt_bio(struct bio *bio, bool done) { struct bio_vec *bv; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { struct page *page = bv->bv_page; int ret = fscrypt_decrypt_page(page->mapping->host, page, PAGE_SIZE, 0, page->index); diff --git a/fs/direct-io.c b/fs/direct-io.c index ec2fb6fe6d37..9bb015bc4a83 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -551,7 +551,9 @@ static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio) if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty) { bio_check_pages_dirty(bio); /* transfers ownership */ } else { - bio_for_each_segment_all(bvec, bio, i) { + struct bvec_iter_all iter_all; + + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; if (dio->op == REQ_OP_READ && !PageCompound(page) && diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c index 5331a15a61f1..24a8e34882e9 100644 --- a/fs/exofs/ore.c +++ b/fs/exofs/ore.c @@ -420,8 +420,9 @@ static void _clear_bio(struct bio *bio) { struct bio_vec *bv; unsigned i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { unsigned this_count = bv->bv_len; if (likely(PAGE_SIZE == this_count)) diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c index 199590f36203..e83bab54b03e 100644 --- a/fs/exofs/ore_raid.c +++ b/fs/exofs/ore_raid.c @@ -468,11 +468,12 @@ static void _mark_read4write_pages_uptodate(struct ore_io_state *ios, int ret) /* loop on all devices all pages */ for (d = 0; d < ios->numdevs; d++) { struct bio *bio = ios->per_dev[d].bio; + struct bvec_iter_all iter_all; if (!bio) continue; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { struct page *page = bv->bv_page; SetPageUptodate(page); diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 2aa62d58d8dd..cff4c4aa7a9c 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -63,8 +63,9 @@ static void ext4_finish_bio(struct bio *bio) { int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; #ifdef CONFIG_EXT4_FS_ENCRYPTION struct page *data_page = NULL; diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index 6aa282ee455a..e53639784892 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c @@ -72,6 +72,7 @@ static void mpage_end_io(struct bio *bio) { struct bio_vec *bv; int i; + struct bvec_iter_all iter_all; if (ext4_bio_encrypted(bio)) { if (bio->bi_status) { @@ -81,7 +82,7 @@ static void mpage_end_io(struct bio *bio) return; } } - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { struct page *page = bv->bv_page; if (!bio->bi_status) { diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index f91d8630c9a2..da060b77f64d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -87,8 +87,9 @@ static void __read_end_io(struct bio *bio) struct page *page; struct bio_vec *bv; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { page = bv->bv_page; /* PG_error was set if any post_read step failed */ @@ -164,13 +165,14 @@ static void f2fs_write_end_io(struct bio *bio) struct f2fs_sb_info *sbi = bio->bi_private; struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; if (time_to_inject(sbi, FAULT_WRITE_IO)) { f2fs_show_injection_info(FAULT_WRITE_IO); bio->bi_status = BLK_STS_IOERR; } - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; enum count_type type = WB_DATA_TYPE(page); @@ -347,6 +349,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode, struct bio_vec *bvec; struct page *target; int i; + struct bvec_iter_all iter_all; if (!io->bio) return false; @@ -354,7 +357,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode, if (!inode && !page && !ino) return true; - bio_for_each_segment_all(bvec, io->bio, i) { + bio_for_each_segment_all(bvec, io->bio, i, iter_all) { if (bvec->bv_page->mapping) target = bvec->bv_page; diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 94dcab655bc0..15deefeaafd0 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -170,7 +170,8 @@ u64 gfs2_log_bmap(struct gfs2_sbd *sdp) * that is pinned in the pagecache. */ -static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp, struct bio_vec *bvec, +static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp, + struct bio_vec *bvec, blk_status_t error) { struct buffer_head *bh, *next; @@ -208,6 +209,7 @@ static void gfs2_end_log_write(struct bio *bio) struct bio_vec *bvec; struct page *page; int i; + struct bvec_iter_all iter_all; if (bio->bi_status) { fs_err(sdp, "Error %d writing to journal, jid=%u\n", @@ -215,7 +217,7 @@ static void gfs2_end_log_write(struct bio *bio) wake_up(&sdp->sd_logd_waitq); } - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { page = bvec->bv_page; if (page_has_buffers(page)) gfs2_end_log_write_bh(sdp, bvec, bio->bi_status); @@ -388,8 +390,9 @@ static void gfs2_end_log_read(struct bio *bio) struct page *page; struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { page = bvec->bv_page; if (bio->bi_status) { int err = blk_status_to_errno(bio->bi_status); diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index be9c0bf697fe..3201342404a7 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c @@ -190,8 +190,9 @@ static void gfs2_meta_read_endio(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all(bvec, bio, i, iter_all) { struct page *page = bvec->bv_page; struct buffer_head *bh = page_buffers(page); unsigned int len = bvec->bv_len; diff --git a/fs/iomap.c b/fs/iomap.c index a3088fae567b..af736acd9006 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -267,8 +267,9 @@ iomap_read_end_io(struct bio *bio) int error = blk_status_to_errno(bio->bi_status); struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) iomap_read_page_end_io(bvec, error); bio_put(bio); } @@ -1559,8 +1560,9 @@ static void iomap_dio_bio_end_io(struct bio *bio) } else { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) put_page(bvec->bv_page); bio_put(bio); } diff --git a/fs/mpage.c b/fs/mpage.c index c820dc9bebab..3f19da75178b 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -48,8 +48,9 @@ static void mpage_end_io(struct bio *bio) { struct bio_vec *bv; int i; + struct bvec_iter_all iter_all; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all(bv, bio, i, iter_all) { struct page *page = bv->bv_page; page_endio(page, bio_op(bio), blk_status_to_errno(bio->bi_status)); diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 338b9d9984e0..1f1829e506e8 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -62,7 +62,7 @@ xfs_find_daxdev_for_inode( static void xfs_finish_page_writeback( struct inode *inode, - struct bio_vec *bvec, + struct bio_vec *bvec, int error) { struct iomap_page *iop = to_iomap_page(bvec->bv_page); @@ -98,6 +98,7 @@ xfs_destroy_ioend( for (bio = &ioend->io_inline_bio; bio; bio = next) { struct bio_vec *bvec; int i; + struct bvec_iter_all iter_all; /* * For the last bio, bi_private points to the ioend, so we @@ -109,7 +110,7 @@ xfs_destroy_ioend( next = bio->bi_private; /* walk each page on bio, ending page IO on them */ - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all(bvec, bio, i, iter_all) xfs_finish_page_writeback(inode, bvec, error); bio_put(bio); } diff --git a/include/linux/bio.h b/include/linux/bio.h index 7ef8a7505c0a..089370eb84d9 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -128,12 +128,19 @@ static inline bool bio_full(struct bio *bio) return bio->bi_vcnt >= bio->bi_max_vecs; } +#define mp_bvec_for_each_segment(bv, bvl, i, iter_all) \ + for (bv = bvec_init_iter_all(&iter_all); \ + (iter_all.done < (bvl)->bv_len) && \ + (mp_bvec_next_segment((bvl), &iter_all), 1); \ + iter_all.done += bv->bv_len, i += 1) + /* * drivers should _never_ use the all version - the bio may have been split * before it got to the driver and the driver won't own all of it */ -#define bio_for_each_segment_all(bvl, bio, i) \ - for (i = 0, bvl = (bio)->bi_io_vec; i < (bio)->bi_vcnt; i++, bvl++) +#define bio_for_each_segment_all(bvl, bio, i, iter_all) \ + for (i = 0, iter_all.idx = 0; iter_all.idx < (bio)->bi_vcnt; iter_all.idx++) \ + mp_bvec_for_each_segment(bvl, &((bio)->bi_io_vec[iter_all.idx]), i, iter_all) static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, unsigned bytes) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 21f76bad7be2..30a57b68d017 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -45,6 +45,12 @@ struct bvec_iter { current bvec */ }; +struct bvec_iter_all { + struct bio_vec bv; + int idx; + unsigned done; +}; + /* * various member access, note that bio_data should of course not be used * on highmem page vectors @@ -131,6 +137,30 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, .bi_bvec_done = 0, \ } +static inline struct bio_vec *bvec_init_iter_all(struct bvec_iter_all *iter_all) +{ + iter_all->bv.bv_page = NULL; + iter_all->done = 0; + + return &iter_all->bv; +} + +static inline void mp_bvec_next_segment(const struct bio_vec *bvec, + struct bvec_iter_all *iter_all) +{ + struct bio_vec *bv = &iter_all->bv; + + if (bv->bv_page) { + bv->bv_page = nth_page(bv->bv_page, 1); + bv->bv_offset = 0; + } else { + bv->bv_page = bvec->bv_page; + bv->bv_offset = bvec->bv_offset; + } + bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset, + bvec->bv_len - iter_all->done); +} + /* * Get the last single-page segment from the multi-page bvec and store it * in @seg From patchwork Fri Feb 15 11:13:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814717 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 C966513B5 for ; Fri, 15 Feb 2019 11:17:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD9EE2EAE8 for ; Fri, 15 Feb 2019 11:17:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B08C72EE6F; Fri, 15 Feb 2019 11:17:08 +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 1B9602EAE8 for ; Fri, 15 Feb 2019 11:17:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3030F8E0002; Fri, 15 Feb 2019 06:17:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 28C388E0001; Fri, 15 Feb 2019 06:17:07 -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 155C38E0002; Fri, 15 Feb 2019 06:17:07 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id DA07B8E0001 for ; Fri, 15 Feb 2019 06:17:06 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id c84so7842557qkb.13 for ; Fri, 15 Feb 2019 03:17:06 -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=o364efRtKvzLvt+ZEMVS/ez57YOCJqD0TpkJltjZPDU=; b=hWatIi5D8NW3TsfPCjzEZG66fWgz3ck/3VS5a/hB0oGxbsg4u9aPtq6dyHpj6l51kM XLA3NV+3UH/4pu1qjBbPwZvVMFwzg6wKomMAmZp+vkrg+TqtmvjmJUlOupGmwFUF4Bwm kw/DJw18pD8H40p2LsBm5d10Lq9YLFuMQUbMH6vb1wXbdPX7sZAVwhXwMiRw/1dar+V4 T99PjhVo4QLn7T5VBD682hzSwFkaPHnAKy/NdyoYe1jUvrxrcn++an901Xj6Imtld9/3 Z0LS8n/Yi1f8ezJj207z3/jEeVH83uzU3ULKTvzJdpuWBlUiv9JUcQt/NyYIDWC9azya dQWA== 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: AHQUAuagRRxlhFdb9e0hL97Gx1aj997ZR/kQMjLTQXKvbMNPI0waOZgr 2HnF3j5bvSeSwM8dp207tv5eLw5CjFbFvhRqCks3aNIFfflpcSFUJQNDZsOE5JwOf8gsfPfki8F 9qAZfIehPBGS2MZRDDaFbjQNhdz/Tju/bY7NxvjTv1ut+XR6bB78UyKg0+3CBYGfAIw== X-Received: by 2002:ae9:dec5:: with SMTP id s188mr6486385qkf.127.1550229426635; Fri, 15 Feb 2019 03:17:06 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia38Ovd3GR/jWWT6P1/njYIqJtl8wlqvlUL78hV7D5OqQ/JpR/rSjaSekMSZ1B04rUDMqTJ X-Received: by 2002:ae9:dec5:: with SMTP id s188mr6486345qkf.127.1550229425975; Fri, 15 Feb 2019 03:17:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229425; cv=none; d=google.com; s=arc-20160816; b=T+GW/hkSEt/OalOJMXs64pu0WZqirX/In2z3S2gt4xwLbfcXTTNzekmBx6g8NhiP7m pubwzv77fimIgN5yyxnrOb7+7MnWwzT85StAxd5jmFiC0QjsBOxG77BRlppO9XfHHnd3 KgiMdoFFBWAyDgRZVu0SdXnjDRcyT9dUugAgKThzBUclvGaA2JFlQEfKR2EuTzg9ybxG 35rN3Wx41M8+VJ1w49JdFW7QlaJKtLjziyRThOR5NHAvxmoIYm7pDEmd6tR2K70DUUrl Sics4qIITBGflbzRVqB/gbsG7R0B5ZYCyk6M10t1DNGDEER4gshdaxLOhJqARdCBDOrE M4PA== 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=o364efRtKvzLvt+ZEMVS/ez57YOCJqD0TpkJltjZPDU=; b=vzbW+KUu8791jPKjFehbnFBblvH+H2Rs7EVTYLd2FuscjbZOV0FfcYfDyM/6wtdAL7 L7eDFsrvWT9v0pTt9w1T7LjsV6YS/4BAnEU+cwASQdilkTLMOttaUQAFaB4DbUrFW1Um phyavA5ByPaXvLUvI+WZJu5aFh/8O8c8WpicjcqijVYapr3d/mg+KSoyLsFPWZdlezHY 2NY6UVhQTtkNHRZThGYrSJrbbRGAQvjTvwVew8VzO3GybAp23L7jZcqa8uF+afAcT+Es 9SbjmGSwXs9Fw5UydX3mEQiwgCPpifIJcu/EaIpcNoVKXDdTZf6N3wv5JivX+0gNrQpi 0QQA== 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 f12si303816qvh.98.2019.02.15.03.17.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:17:05 -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 826C08E6E5; Fri, 15 Feb 2019 11:17:04 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C61CD5D6A9; Fri, 15 Feb 2019 11:16:43 +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, 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 V15 14/18] block: enable multipage bvecs Date: Fri, 15 Feb 2019 19:13:20 +0800 Message-Id: <20190215111324.30129-15-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-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.25]); Fri, 15 Feb 2019 11:17:05 +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 This patch pulls the trigger for multi-page bvecs. Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei Tested-by: Jon Hunter --- block/bio.c | 22 +++++++++++++++------- fs/iomap.c | 4 ++-- fs/xfs/xfs_aops.c | 4 ++-- include/linux/bio.h | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/block/bio.c b/block/bio.c index 968b12fea564..83a2dfa417ca 100644 --- a/block/bio.c +++ b/block/bio.c @@ -753,6 +753,8 @@ EXPORT_SYMBOL(bio_add_pc_page); * @page: page to add * @len: length of the data to add * @off: offset of the data in @page + * @same_page: if %true only merge if the new data is in the same physical + * page as the last segment of the bio. * * Try to add the data at @page + @off to the last bvec of @bio. This is a * a useful optimisation for file systems with a block size smaller than the @@ -761,19 +763,25 @@ EXPORT_SYMBOL(bio_add_pc_page); * Return %true on success or %false on failure. */ bool __bio_try_merge_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int off) + unsigned int len, unsigned int off, bool same_page) { if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED))) return false; if (bio->bi_vcnt > 0) { struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; + phys_addr_t vec_end_addr = page_to_phys(bv->bv_page) + + bv->bv_offset + bv->bv_len - 1; + phys_addr_t page_addr = page_to_phys(page); - if (page == bv->bv_page && off == bv->bv_offset + bv->bv_len) { - bv->bv_len += len; - bio->bi_iter.bi_size += len; - return true; - } + if (vec_end_addr + 1 != page_addr + off) + return false; + if (same_page && (vec_end_addr & PAGE_MASK) != page_addr) + return false; + + bv->bv_len += len; + bio->bi_iter.bi_size += len; + return true; } return false; } @@ -819,7 +827,7 @@ EXPORT_SYMBOL_GPL(__bio_add_page); int bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) { - if (!__bio_try_merge_page(bio, page, len, offset)) { + if (!__bio_try_merge_page(bio, page, len, offset, false)) { if (bio_full(bio)) return 0; __bio_add_page(bio, page, len, offset); diff --git a/fs/iomap.c b/fs/iomap.c index af736acd9006..0c350e658b7f 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -318,7 +318,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, */ sector = iomap_sector(iomap, pos); if (ctx->bio && bio_end_sector(ctx->bio) == sector) { - if (__bio_try_merge_page(ctx->bio, page, plen, poff)) + if (__bio_try_merge_page(ctx->bio, page, plen, poff, true)) goto done; is_contig = true; } @@ -349,7 +349,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, ctx->bio->bi_end_io = iomap_read_end_io; } - __bio_add_page(ctx->bio, page, plen, poff); + bio_add_page(ctx->bio, page, plen, poff); done: /* * Move the caller beyond our range so that it keeps making progress. diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 1f1829e506e8..b9fd44168f61 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -616,12 +616,12 @@ xfs_add_to_ioend( bdev, sector); } - if (!__bio_try_merge_page(wpc->ioend->io_bio, page, len, poff)) { + if (!__bio_try_merge_page(wpc->ioend->io_bio, page, len, poff, true)) { if (iop) atomic_inc(&iop->write_count); if (bio_full(wpc->ioend->io_bio)) xfs_chain_bio(wpc->ioend, wbc, bdev, sector); - __bio_add_page(wpc->ioend->io_bio, page, len, poff); + bio_add_page(wpc->ioend->io_bio, page, len, poff); } wpc->ioend->io_size += len; diff --git a/include/linux/bio.h b/include/linux/bio.h index 089370eb84d9..9f77adcfde82 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -441,7 +441,7 @@ extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, unsigned int, unsigned int); bool __bio_try_merge_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int off); + unsigned int len, unsigned int off, bool same_page); void __bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int off); int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter); From patchwork Fri Feb 15 11:13:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814729 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 E1BF513B5 for ; Fri, 15 Feb 2019 11:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D75502EE70 for ; Fri, 15 Feb 2019 11:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C94B02EE75; Fri, 15 Feb 2019 11:17:37 +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 B3FD32EE70 for ; Fri, 15 Feb 2019 11:17:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D16EB8E0003; Fri, 15 Feb 2019 06:17:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CC6518E0001; Fri, 15 Feb 2019 06:17:35 -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 B8F9C8E0003; Fri, 15 Feb 2019 06:17:35 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 8D0508E0001 for ; Fri, 15 Feb 2019 06:17:35 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id a199so7665010qkb.23 for ; Fri, 15 Feb 2019 03:17:35 -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=aF6gUNu009UZpBqyr2snXpzRNTFx8cnDNBm84vQPuaQ=; b=Ht30F7QHVydPOzN0vXzx183UVgFqLYdyW4TzUE6obzFCtw9l/oCJ+Uuy/bNtbzaJiy oQsL+aRmgg6HwSTKbIr/NEE9jBQ/L2fwFd+fAeJwKhze16TFKx/V8YqfbSgcFHh353sG ElOomeTnb/0Ivxmw3XvLTixuY9bAMdhbcriqDgDuPVhw91AC/BN36MGPMixkhfh2Dy2B nIXkrldwzHR0Ov5AOe3HTdVJM25APRwJgSQ8/qIZLbfrVa1fAvzm2rAhBpPH7QKJjhmn 7uDGtg3ATVxbSDv8nDXb93t5vgXIg+vHEp2sgzt6bSXVYB3yPg0yctBbN1EBCGLcrew0 btYw== 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: AHQUAuZDmozpZB4RPX3rZjCw/qOVvcBhCDRg26d5XLyFGGMBdSbKgZFL XND6gR68G+NLzX3ga0Drpx4halZG/ao3IsyPjT53vLZnsTvLSl/0YabAUS5x4O8NNtQ3LSuCGtc 5zbxhaB4DmbHvtk9SHCSbbe8HmlQxzHUMOP0pLocntkx3fstkjTtyyQBGnaifN7Ok9A== X-Received: by 2002:a0c:ae76:: with SMTP id z51mr6916069qvc.103.1550229455354; Fri, 15 Feb 2019 03:17:35 -0800 (PST) X-Google-Smtp-Source: AHgI3IZBOoxnicAsaZtL6NI7f95yF2uzvafo3I8dozuvm0AqgWxJaNTO/swTncxh8u7qbDDX6fnx X-Received: by 2002:a0c:ae76:: with SMTP id z51mr6916051qvc.103.1550229454945; Fri, 15 Feb 2019 03:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229454; cv=none; d=google.com; s=arc-20160816; b=aZFHLxqzhNgCOAiPjRA1DjvQiJWX1+aMq4X55FG/fdfHL8a+S0itsZcOIRwvh/ppwL aJr9Ic08SCDMl6r/98YIVQNR6qf6lI8Fam6KEPdmm1cwu/IWLDZXwjrLOIF/Or9vR4S9 /K3JNb8ML0jUyEChP2OBc+V5fCt/lwBVd9TTaQPHq84dqwutk18R2f81L+1Xk66Z60qw kALmsNw9QQgIRsJ/MSYPsg7JFPj6p37rOhU8u+YOusiQE7P0mFJYatwgf+gFKdVQs6K4 eAbtk9X5U5UucMewNa2gFpQyByDS2DXZV+ADCw/i73INn3DZeir3ZYw8bKxgH5AVBwO9 d29A== 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=aF6gUNu009UZpBqyr2snXpzRNTFx8cnDNBm84vQPuaQ=; b=xhHIF+GjaJl8nz33yARV9jZVLPRq+BNxGPG5oKmmODaJmqUrtOutvX0B55zPp1JsFq dKDZmvlSGSBd7yHE+mjCHYAuA2d9csrC67AINj2z1G1hzEMPGenNsWDX2ilN0ITQXACo quX657IoxBpShiKLklZ8NB35AQDDsis7KG6wUmLZhWU/S/ndbSWdv+OcbblqC/VDQA/u /fhvKgy5Y5E3jp+5raIB9x/m79F1kP4CjcE0Awv884pQeRXTlpKPrPMYcXrM38k3WykK T6NpXXe61/7ZOLIy+dSorVRFk1J8x1QvIunOa9dx3GPyVQx6q1myQ/y8vcplGRuDiLvE 5KmQ== 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 d39si604845qvc.142.2019.02.15.03.17.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:17:34 -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-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECFE6C0AD406; Fri, 15 Feb 2019 11:17:33 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B90A26E74; Fri, 15 Feb 2019 11:17:06 +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, 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 V15 15/18] block: always define BIO_MAX_PAGES as 256 Date: Fri, 15 Feb 2019 19:13:21 +0800 Message-Id: <20190215111324.30129-16-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 15 Feb 2019 11:17:34 +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 Now multi-page bvec can cover CONFIG_THP_SWAP, so we don't need to increase BIO_MAX_PAGES for it. CONFIG_THP_SWAP needs to split one THP into normal pages and adds them all to one bio. With multipage-bvec, it just takes one bvec to hold them all. Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- include/linux/bio.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 9f77adcfde82..bdd11d4c2f05 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -34,15 +34,7 @@ #define BIO_BUG_ON #endif -#ifdef CONFIG_THP_SWAP -#if HPAGE_PMD_NR > 256 -#define BIO_MAX_PAGES HPAGE_PMD_NR -#else #define BIO_MAX_PAGES 256 -#endif -#else -#define BIO_MAX_PAGES 256 -#endif #define bio_prio(bio) (bio)->bi_ioprio #define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio) From patchwork Fri Feb 15 11:13:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814743 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 55A5F17E0 for ; Fri, 15 Feb 2019 11:17:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BB482EE71 for ; Fri, 15 Feb 2019 11:17:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F84F2EE76; Fri, 15 Feb 2019 11:17:52 +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 C498C2EE71 for ; Fri, 15 Feb 2019 11:17:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E74E48E0004; Fri, 15 Feb 2019 06:17:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFEA38E0001; Fri, 15 Feb 2019 06:17:50 -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 CC6B48E0004; Fri, 15 Feb 2019 06:17:50 -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 9AB128E0001 for ; Fri, 15 Feb 2019 06:17:50 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id q193so7695004qke.12 for ; Fri, 15 Feb 2019 03:17:50 -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=wNodGZU7EcFMVOxNqWEpjAbmpaD39TDM+4us0d0SSCc=; b=hDSLTNng2q+TN+V/MBVcNklpn0T9K7rBPtgNWEQGpgbmCzfojNTBGjVtBheQPIUyG8 cfiu/DJEx8dYcwGJtJSe6EO/9iBDfB19vt0jgM9ZtLpL1ZeozXkiDtOrruRWa1QsD2Yk UnR6UNCaAtvlrvqg4sSbEcbT1mEiwLOXm6scpCo+GMIRlLJRDOPJ4B0KgTwdN8mGMUuE 3F4dWL0HKRe2IB3NMpoD1YS7akAxifYm9ispHIEAF5VCQLdD+NPhmx0RqyUanzO3MpVX Mrk/xhTLMahXjnYQWLb1Zrx37UY6+IwQZvgfeIrM7AuyX1Vz0KLIRDNj9tVgQs1FZIIw N7Ew== 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: AHQUAuYczx3x0WcyhCN5NgUUipzsG5RPXFAqaqJ8Ruc9WMgU6p/JJ2h7 r6mKxMplYSjxDr4yETJL/UHPYzfA7eY3nfPdXs9oTw1A8jx3JlzYzx8pJG4I4jAbIIlSp8n/JEi 2DmLlgwyTOL/5st5voOp/hycHGMMPXaZBTa0E04j0TV3rysjA/SLyU8kHt9uCKaSJMw== X-Received: by 2002:a37:9b89:: with SMTP id d131mr6290039qke.331.1550229470407; Fri, 15 Feb 2019 03:17:50 -0800 (PST) X-Google-Smtp-Source: AHgI3IYaKFLaYEAcm2n2nl2cEgDdmU4Ep17kmYWS3qPLpIETRCUOXXPbONP2tgs0J4S9KXMrZEa2 X-Received: by 2002:a37:9b89:: with SMTP id d131mr6290016qke.331.1550229469898; Fri, 15 Feb 2019 03:17:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229469; cv=none; d=google.com; s=arc-20160816; b=kXGQfKLh9MHhbYRFBQACBK0SCx37XVn13QJCKz15AmS0QsAvd7aGkf62aRQqYcMT1G PQ9RN64ai9yba0YsPqstj4ZHIWZ0ij5w8P7n9Wp2ucyIsjVvsMrVO1fUgq9iUuT988+M Zbj8Vn8TWPT7WnfGowRLQwlwssk9SUYog36qCKjFdSLXKEb0YBSFzSXXmUnFrCd+hV4a B6K5PSiiClsgvaKHvbVH4oY/9bYpBmkioDORhy9Hwr4enY8wT0n+zy8Zqb8xBDOXsp4+ IAyozPVnHyZlbYNhaoUEVWYy2vm665jIzq2fpadiNKEn4ujsgMiFdC6xm0GPhZ9DdezY vQrA== 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=wNodGZU7EcFMVOxNqWEpjAbmpaD39TDM+4us0d0SSCc=; b=d8gSBh7h+irXknl40fxA4FHI7mzAThR0P+aeWv2fYOX8+Jin5JsCtrqhyt4qiTfgLy fYjzHB3rqbQLvn+exfeKhV13L9eupnNEQhOcK1FoQguiJ2CFiwm9ZYJEOe+3fld7sx2S ChpOP3RKDlh4eY5dyV7G9l8tA05Te9rLbq13v6LDA1SzGaJgVBkT1j6OBT7SyRFwgk74 VX0PSvn9fCN9hTW/tsU4QIeveendSzNTOErcNQvRvPjbhWHESVUvXXuWqIZH9uDMfQts 4mwSNUf4eM7bsgU/s+TUSq+swRHQD6QDbcMf/RGaVIyGogPwMvF7VvBNFajaDN0bmmzD Z3zA== 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 g4si3642274qtc.344.2019.02.15.03.17.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:17:49 -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-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB8D2124556; Fri, 15 Feb 2019 11:17:48 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F51260F89; Fri, 15 Feb 2019 11:17:35 +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, 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 V15 16/18] block: document usage of bio iterator helpers Date: Fri, 15 Feb 2019 19:13:22 +0800 Message-Id: <20190215111324.30129-17-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 15 Feb 2019 11:17:49 +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 Now multi-page bvec is supported, some helpers may return page by page, meantime some may return segment by segment, this patch documents the usage. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- Documentation/block/biovecs.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Documentation/block/biovecs.txt b/Documentation/block/biovecs.txt index 25689584e6e0..ce6eccaf5df7 100644 --- a/Documentation/block/biovecs.txt +++ b/Documentation/block/biovecs.txt @@ -117,3 +117,28 @@ Other implications: size limitations and the limitations of the underlying devices. Thus there's no need to define ->merge_bvec_fn() callbacks for individual block drivers. + +Usage of helpers: +================= + +* The following helpers whose names have the suffix of "_all" can only be used +on non-BIO_CLONED bio. They are usually used by filesystem code. Drivers +shouldn't use them because the bio may have been split before it reached the +driver. + + bio_for_each_segment_all() + bio_first_bvec_all() + bio_first_page_all() + bio_last_bvec_all() + +* The following helpers iterate over single-page segment. The passed 'struct +bio_vec' will contain a single-page IO vector during the iteration + + bio_for_each_segment() + bio_for_each_segment_all() + +* The following helpers iterate over multi-page bvec. The passed 'struct +bio_vec' will contain a multi-page IO vector during the iteration + + bio_for_each_bvec() + rq_for_each_bvec() From patchwork Fri Feb 15 11:13:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814757 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 C95B517E9 for ; Fri, 15 Feb 2019 11:18:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFE482EE75 for ; Fri, 15 Feb 2019 11:18:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B35622EE71; Fri, 15 Feb 2019 11:18: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=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 2292F2EE7B for ; Fri, 15 Feb 2019 11:18:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4185A8E0005; Fri, 15 Feb 2019 06:18:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3C4308E0001; Fri, 15 Feb 2019 06:18:01 -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 2658D8E0005; Fri, 15 Feb 2019 06:18:01 -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 F0C758E0001 for ; Fri, 15 Feb 2019 06:18:00 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id 207so7850092qkf.9 for ; Fri, 15 Feb 2019 03:18: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=JdFCPIv8/ZohHW7Z9bynsznzb31S+LQgq2A7alDik90=; b=mNL2Dv2z6V/MLO14dV7HOZRsgOtWaS1+vmQynMxzn/cqCghGwbk/7YAnV9MrNVHRio wjGmr/LM/h1KSV/f4pRCTmj3pLhWdyndCgRE7WcFYsvNObIoamieeA+ydiqafopS8WK5 yZlAXGG8mBZCMPYJ8hgIVBYiqjRTYX3jsR5lDu72lVUygBcGyqeCMOKIe+SpDlveN8qn AFNezPxLMsef3WX23hTw5M9i5iHodWVvpFh6oLthhzwxgrQ8xY032ZbmUFuPRvjjIgzJ +68+DCMD5JCCwfTl3NFij2TI4AR3o1BTionOLZhVJq31wpiVZT9BYYcb1pJC7LUZxAs4 1oxA== 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: AHQUAuZOYipdrh3FVU2G6U7W2YPJEAxZkvGbf3oh/CybeHFrlnID3efD 8QQ7zyuhZCqG3dsjxWZ8jpzs5VnAI2JQUUIjCrtrlMYxTPPNzpY8cS9/KToKjtK5vgWDA2LWeNr IUjBsfS7g5nIcHSoVuRLBb5CTGtzeeSeeE8HeOM9NxVyce7NjAwxaMy6JSoFNk1me+A== X-Received: by 2002:a37:6d44:: with SMTP id i65mr6397455qkc.73.1550229480705; Fri, 15 Feb 2019 03:18:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IbyGRWKFN0EQEPfjiHb9HsLOYH/qzDXS9YdHhpvzl1Gym2JItm+HYDl5E3dxHI/r55AumbT X-Received: by 2002:a37:6d44:: with SMTP id i65mr6397419qkc.73.1550229479948; Fri, 15 Feb 2019 03:17:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229479; cv=none; d=google.com; s=arc-20160816; b=a8hROWAnkeCq0K9Llv6kPJUsEZ+f/u5H6MtX1RJoUVPEetlskMPmb3LAkz+5l+9CBT b1jGMcMzJhkySyxYmL3SWMIRbyOEC/m7d395UlZ5QusEDZxOWJQcIE6n7WoQJoypJ74f 54YTvp2tJko8dTnXIblO+PZo++jGpRm35b0HaSXGdU8RtcoF2KiU+AYFaHzhVOnPlihU AY/7xFQghkJGBQvu3ZEr+L/dUscNN8T050zdvjRKQY2UfLTdZYHLOZ58wCispBZZhEFg h+1qq6JS7psZvdy/mz5TbtUGClsvDPbbPcRmpSffuLO/VKSZ4es6DrI0HKQ4tW5jljX8 rf2g== 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=JdFCPIv8/ZohHW7Z9bynsznzb31S+LQgq2A7alDik90=; b=P3F3cLp79wJMTFRFJXsO8TwctV+2gtGp9p4z59ZEIFL1DEGm/9t+V4fcZ+xtLd4ua0 s22tQOxNUoCgCLZ/1g718WGrsz15FoJumBQVmjqiZj6RRCFM+hJbZOeybJUayzO9ejJ8 O3LPeNYTHyLb0Dj0u8960tn5bGm9gEZiNmmOBdtYj9vU1DqNNp2pku9aTCFIFWd4j0eW c4iNMIQfFDrf42Zn8kSO4qY9rGoHbkkH0fBDPIhC7kY16SPPaSh7K2ul+ukVWw/pWc32 xmQD9Gq85ETtCVLITYkoVrWNCXMyO6z44M177ViE68M2CEJ6Y1NaQLyw2usg3XHhRDNe xG1A== 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 z54si257650qth.152.2019.02.15.03.17.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:17: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-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC0DB83F51; Fri, 15 Feb 2019 11:17:58 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 210A25F9C6; Fri, 15 Feb 2019 11:17:50 +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, 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 V15 17/18] block: kill QUEUE_FLAG_NO_SG_MERGE Date: Fri, 15 Feb 2019 19:13:23 +0800 Message-Id: <20190215111324.30129-18-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 15 Feb 2019 11:17:59 +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 Since bdced438acd83ad83a6c ("block: setup bi_phys_segments after splitting"), physical segment number is mainly figured out in blk_queue_split() for fast path, and the flag of BIO_SEG_VALID is set there too. Now only blk_recount_segments() and blk_recalc_rq_segments() use this flag. Basically blk_recount_segments() is bypassed in fast path given BIO_SEG_VALID is set in blk_queue_split(). For another user of blk_recalc_rq_segments(): - run in partial completion branch of blk_update_request, which is an unusual case - run in blk_cloned_rq_check_limits(), still not a big problem if the flag is killed since dm-rq is the only user. Multi-page bvec is enabled now, not doing S/G merging is rather pointless with the current setup of the I/O path, as it isn't going to save you a significant amount of cycles. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- block/blk-merge.c | 31 ++++++------------------------- block/blk-mq-debugfs.c | 1 - block/blk-mq.c | 3 --- drivers/md/dm-table.c | 13 ------------- include/linux/blkdev.h | 1 - 5 files changed, 6 insertions(+), 43 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 1912499b08b7..bed065904677 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -358,8 +358,7 @@ void blk_queue_split(struct request_queue *q, struct bio **bio) EXPORT_SYMBOL(blk_queue_split); static unsigned int __blk_recalc_rq_segments(struct request_queue *q, - struct bio *bio, - bool no_sg_merge) + struct bio *bio) { struct bio_vec bv, bvprv = { NULL }; int prev = 0; @@ -385,13 +384,6 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, nr_phys_segs = 0; for_each_bio(bio) { bio_for_each_bvec(bv, bio, iter) { - /* - * If SG merging is disabled, each bio vector is - * a segment - */ - if (no_sg_merge) - goto new_segment; - if (prev) { if (seg_size + bv.bv_len > queue_max_segment_size(q)) @@ -421,27 +413,16 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, void blk_recalc_rq_segments(struct request *rq) { - bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE, - &rq->q->queue_flags); - - rq->nr_phys_segments = __blk_recalc_rq_segments(rq->q, rq->bio, - no_sg_merge); + rq->nr_phys_segments = __blk_recalc_rq_segments(rq->q, rq->bio); } void blk_recount_segments(struct request_queue *q, struct bio *bio) { - unsigned short seg_cnt = bio_segments(bio); - - if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) && - (seg_cnt < queue_max_segments(q))) - bio->bi_phys_segments = seg_cnt; - else { - struct bio *nxt = bio->bi_next; + struct bio *nxt = bio->bi_next; - bio->bi_next = NULL; - bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, false); - bio->bi_next = nxt; - } + bio->bi_next = NULL; + bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio); + bio->bi_next = nxt; bio_set_flag(bio, BIO_SEG_VALID); } diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index c782e81db627..697d6213c82b 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -128,7 +128,6 @@ static const char *const blk_queue_flag_name[] = { QUEUE_FLAG_NAME(SAME_FORCE), QUEUE_FLAG_NAME(DEAD), QUEUE_FLAG_NAME(INIT_DONE), - QUEUE_FLAG_NAME(NO_SG_MERGE), QUEUE_FLAG_NAME(POLL), QUEUE_FLAG_NAME(WC), QUEUE_FLAG_NAME(FUA), diff --git a/block/blk-mq.c b/block/blk-mq.c index 44d471ff8754..fa508ee31742 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2837,9 +2837,6 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, set->map[HCTX_TYPE_POLL].nr_queues) blk_queue_flag_set(QUEUE_FLAG_POLL, q); - if (!(set->flags & BLK_MQ_F_SG_MERGE)) - blk_queue_flag_set(QUEUE_FLAG_NO_SG_MERGE, q); - q->sg_reserved_size = INT_MAX; INIT_DELAYED_WORK(&q->requeue_work, blk_mq_requeue_work); diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 4b1be754cc41..ba9481f1bf3c 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1698,14 +1698,6 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev, return q && !blk_queue_add_random(q); } -static int queue_supports_sg_merge(struct dm_target *ti, struct dm_dev *dev, - sector_t start, sector_t len, void *data) -{ - struct request_queue *q = bdev_get_queue(dev->bdev); - - return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags); -} - static bool dm_table_all_devices_attribute(struct dm_table *t, iterate_devices_callout_fn func) { @@ -1902,11 +1894,6 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, if (!dm_table_supports_write_zeroes(t)) q->limits.max_write_zeroes_sectors = 0; - if (dm_table_all_devices_attribute(t, queue_supports_sg_merge)) - blk_queue_flag_clear(QUEUE_FLAG_NO_SG_MERGE, q); - else - blk_queue_flag_set(QUEUE_FLAG_NO_SG_MERGE, q); - dm_table_verify_integrity(t); /* diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index b6292d469ea4..faed9d9eb84c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -588,7 +588,6 @@ struct request_queue { #define QUEUE_FLAG_SAME_FORCE 12 /* force complete on same CPU */ #define QUEUE_FLAG_DEAD 13 /* queue tear-down finished */ #define QUEUE_FLAG_INIT_DONE 14 /* queue is initialized */ -#define QUEUE_FLAG_NO_SG_MERGE 15 /* don't attempt to merge SG segments*/ #define QUEUE_FLAG_POLL 16 /* IO polling enabled if set */ #define QUEUE_FLAG_WC 17 /* Write back caching */ #define QUEUE_FLAG_FUA 18 /* device supports FUA writes */ From patchwork Fri Feb 15 11:13:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10814759 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 AFCA313B5 for ; Fri, 15 Feb 2019 11:18:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A38702EE71 for ; Fri, 15 Feb 2019 11:18:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 961F92EE7B; Fri, 15 Feb 2019 11:18:06 +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 E2A6B2EE71 for ; Fri, 15 Feb 2019 11:18:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D65768E0006; Fri, 15 Feb 2019 06:18:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CECC48E0001; Fri, 15 Feb 2019 06:18:04 -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 BB5648E0006; Fri, 15 Feb 2019 06:18:04 -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 85F208E0001 for ; Fri, 15 Feb 2019 06:18:04 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id k66so7902190qkf.1 for ; Fri, 15 Feb 2019 03:18:04 -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=g1Djg1X1NcqtCABohTLxUrXqjefG6jTDiXkVVbfL1ng=; b=UlTZ+zceX83OtrcqKT24TzB2G/cBoRHg4mjYUrTswa608Had9Wnh4NATmlHKzdBRIp IKXt24fAm42BtU84oewigxMgi/GdMyYcmaccpOgaGOCALzn2vi7vM+J+S75s9/Mw8dbz xyOKjq8jMFMPWjSxWzX3q0zHm9V16B99wLGqIhYHmySoqch8dEX/FI6m1Vii/I5LPf+J 2Gl6hWpUYGDinBWKajtdoZUOiS2WFU03fmYXR8fHjnKLsm9MgjotjbprBCq+cUTMMeUM BEWx5tuLVPNMTMMNoSOTENefPGWCf7KxjOdJisaLFUNCUxsdoymu8ef328VQgegDbwbB Zn9Q== 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: AHQUAuasSlUOWxwq591Lex5XZzIooWdkk9WV2fY9awiBg+HmQ6aIk3am mRcYsvIHMiwbZ+1S7mexBov9QXyXfEP5rOoeIBXsR0pRqqK/b4YXW80QbJzywXbU4oFEpgBDJ4o XzQPsYGJH+Pm9eBapL0x6ivDEvnaisBP6yAKcxma2D1qPTJY90y/tjfPS8WCFf3y+SQ== X-Received: by 2002:a37:7707:: with SMTP id s7mr6505604qkc.252.1550229484310; Fri, 15 Feb 2019 03:18:04 -0800 (PST) X-Google-Smtp-Source: AHgI3IbVFNUq5LXl2XUOMZnS7vUyBnb44frnPYW9g5Ov/lOjOwqwIwIYB3+7QE64HHOf2V+bzEnm X-Received: by 2002:a37:7707:: with SMTP id s7mr6505559qkc.252.1550229483453; Fri, 15 Feb 2019 03:18:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550229483; cv=none; d=google.com; s=arc-20160816; b=cBgLCcvxXIbcpZoXjGa9D9lgcKNCbO+rJySgdqwhVBXLdhp48DcJuidaz4gvqQDuEJ Ambj3JPLNj/z+QsulAPBZE86r6U/XvUyGKjSu0b+5PfxgNJcQ9ymeZHaTIEhsWBpRutA YOabopqPJkYlNa3kY9aAq3A/pUihMUj1CUcvYJXeaIwG0jceQFCZ1HRWFxx5WCzGlomG nYaEIGsGb83POjqm3nyoTm65uXiPSIqww7uKU8XiUmdGySgLMxyQMoWQiSUcsA5DbJjc 4YHhKQhm3a2jhWB31dPookjKjvt+SAUDLM/svQx7gkedrFuz3LLaqpM2T3uTyt+jS4u0 HJ9g== 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=g1Djg1X1NcqtCABohTLxUrXqjefG6jTDiXkVVbfL1ng=; b=xptpK+dbIt3qXonNKlHdvyMkngt8vUi8c3IYSNKCXgpudxcoli3L1abhhYqiUlOzXt m2aeQX85J58PyzrP/xCsBqEcWFcpQEjexFcWlHMdsjSQqF8yE1W2RAtZWB0RXHQeCClg qNIWvnxSHnz69vFGdqp9FxVq3TcMV8XwjO0M2ElU6YP5Q0SgrgEg5/k1IPVGiTX+eECl danH8nHLHsTiBH1v6/qI8m2pcfBITdSI3jjwm3DafW09ti9dSzBet382MuMWZONctPwT dFzLld/9OjpR/Q7w6ZuiYYVxXjelnZr/C4NcZ9w4sNqnB2VEtOHCUz/WQKEWO8Ya+z2O ui6Q== 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 i67si2818394qke.61.2019.02.15.03.18.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 03:18:03 -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-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C3C8C0E012A; Fri, 15 Feb 2019 11:18:02 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D2E95F9C1; Fri, 15 Feb 2019 11:18:01 +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, 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 V15 18/18] block: kill BLK_MQ_F_SG_MERGE Date: Fri, 15 Feb 2019 19:13:24 +0800 Message-Id: <20190215111324.30129-19-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 15 Feb 2019 11:18:02 +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 QUEUE_FLAG_NO_SG_MERGE has been killed, so kill BLK_MQ_F_SG_MERGE too. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 1 - drivers/block/loop.c | 2 +- drivers/block/nbd.c | 2 +- drivers/block/rbd.c | 2 +- drivers/block/skd_main.c | 1 - drivers/block/xen-blkfront.c | 2 +- drivers/md/dm-rq.c | 2 +- drivers/mmc/core/queue.c | 3 +-- drivers/scsi/scsi_lib.c | 2 +- include/linux/blk-mq.h | 1 - 10 files changed, 7 insertions(+), 11 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 697d6213c82b..c39247c5ddb6 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -249,7 +249,6 @@ static const char *const alloc_policy_name[] = { static const char *const hctx_flag_name[] = { HCTX_FLAG_NAME(SHOULD_MERGE), HCTX_FLAG_NAME(TAG_SHARED), - HCTX_FLAG_NAME(SG_MERGE), HCTX_FLAG_NAME(BLOCKING), HCTX_FLAG_NAME(NO_SCHED), }; diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 8ef583197414..3d63ad036398 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1937,7 +1937,7 @@ static int loop_add(struct loop_device **l, int i) lo->tag_set.queue_depth = 128; lo->tag_set.numa_node = NUMA_NO_NODE; lo->tag_set.cmd_size = sizeof(struct loop_cmd); - lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; lo->tag_set.driver_data = lo; err = blk_mq_alloc_tag_set(&lo->tag_set); diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 7c9a949e876b..32a7ba1674b7 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1571,7 +1571,7 @@ static int nbd_dev_add(int index) nbd->tag_set.numa_node = NUMA_NO_NODE; nbd->tag_set.cmd_size = sizeof(struct nbd_cmd); nbd->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | - BLK_MQ_F_SG_MERGE | BLK_MQ_F_BLOCKING; + BLK_MQ_F_BLOCKING; nbd->tag_set.driver_data = nbd; err = blk_mq_alloc_tag_set(&nbd->tag_set); diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 1e92b61d0bd5..abe9e1c89227 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3988,7 +3988,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev) rbd_dev->tag_set.ops = &rbd_mq_ops; rbd_dev->tag_set.queue_depth = rbd_dev->opts->queue_depth; rbd_dev->tag_set.numa_node = NUMA_NO_NODE; - rbd_dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + rbd_dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; rbd_dev->tag_set.nr_hw_queues = 1; rbd_dev->tag_set.cmd_size = sizeof(struct work_struct); diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index ab893a7571a2..7d3ad6c22ee5 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -2843,7 +2843,6 @@ static int skd_cons_disk(struct skd_device *skdev) skdev->sgs_per_request * sizeof(struct scatterlist); skdev->tag_set.numa_node = NUMA_NO_NODE; skdev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | - BLK_MQ_F_SG_MERGE | BLK_ALLOC_POLICY_TO_MQ_FLAG(BLK_TAG_ALLOC_FIFO); skdev->tag_set.driver_data = skdev; rc = blk_mq_alloc_tag_set(&skdev->tag_set); diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 0ed4b200fa58..d43a5677ccbc 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -977,7 +977,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, } else info->tag_set.queue_depth = BLK_RING_SIZE(info); info->tag_set.numa_node = NUMA_NO_NODE; - info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; info->tag_set.cmd_size = sizeof(struct blkif_req); info->tag_set.driver_data = info; diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 4eb5f8c56535..b2f8eb2365ee 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -527,7 +527,7 @@ int dm_mq_init_request_queue(struct mapped_device *md, struct dm_table *t) md->tag_set->ops = &dm_mq_ops; md->tag_set->queue_depth = dm_get_blk_mq_queue_depth(); md->tag_set->numa_node = md->numa_node_id; - md->tag_set->flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + md->tag_set->flags = BLK_MQ_F_SHOULD_MERGE; md->tag_set->nr_hw_queues = dm_get_blk_mq_nr_hw_queues(); md->tag_set->driver_data = md; diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index 35cc138b096d..cc19e71c71d4 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -410,8 +410,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) else mq->tag_set.queue_depth = MMC_QUEUE_DEPTH; mq->tag_set.numa_node = NUMA_NO_NODE; - mq->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE | - BLK_MQ_F_BLOCKING; + mq->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING; mq->tag_set.nr_hw_queues = 1; mq->tag_set.cmd_size = sizeof(struct mmc_queue_req); mq->tag_set.driver_data = mq; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 6d65ac584eba..6cadbe945bdb 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1899,7 +1899,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) shost->tag_set.queue_depth = shost->can_queue; shost->tag_set.cmd_size = cmd_size; shost->tag_set.numa_node = NUMA_NO_NODE; - shost->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; + shost->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; shost->tag_set.flags |= BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy); shost->tag_set.driver_data = shost; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 0e030f5f76b6..b0c814bcc7e3 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -218,7 +218,6 @@ struct blk_mq_ops { enum { BLK_MQ_F_SHOULD_MERGE = 1 << 0, BLK_MQ_F_TAG_SHARED = 1 << 1, - BLK_MQ_F_SG_MERGE = 1 << 2, BLK_MQ_F_BLOCKING = 1 << 5, BLK_MQ_F_NO_SCHED = 1 << 6, BLK_MQ_F_ALLOC_POLICY_START_BIT = 8,