From patchwork Mon Jan 21 08:17:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773107 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 660CA13BF for ; Mon, 21 Jan 2019 08:18:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5699729DC8 for ; Mon, 21 Jan 2019 08:18:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A50729E88; Mon, 21 Jan 2019 08:18: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 C8A6C29DC8 for ; Mon, 21 Jan 2019 08:18:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CF9A8E002B; Mon, 21 Jan 2019 03:18:36 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 07F5D8E0025; Mon, 21 Jan 2019 03:18:36 -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 E89F28E002B; Mon, 21 Jan 2019 03:18: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 BACF98E0025 for ; Mon, 21 Jan 2019 03:18:35 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id w185so18684484qka.9 for ; Mon, 21 Jan 2019 00:18: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=jR/ABfQzsk4snuRwt6xiKLLtmUVGlJ+rbLpyE5UJ55c=; b=mVAO1pMNRM536U6ATVCAgk0VCaNHa1Ok+GVLwlXmsDqBZ9Sg3LoSqHjVtJC7ZQbhHN ujOkk/+MG5mC3DIzcvstBmTKenQC2ybw4YOm3tK/T1ZxDQilVYVW19qYDr/l1p17pPYV meCtLpnQALrly+VhYIUCHh+/jZfR9Dclzromshi1YSgna4v+8CMlcmZRc2FQ1QCXgrgP syYCqe4zzQgo/vOdvXqeSi05UUV/ADyV1Nl6apvEb8EBmHaQupPTQLAjAwQBEQD8lnpk zPYb7JdVJrNrttwh5K+jcWset6BotzmR5f+GF/uQQLB5+GWUEz1l5I5BtRVYOrlNByAz ZWyQ== 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: AJcUukdaMlGSJ4pJ1e87fcp187H5ujNVekuTqkEJec6EZei78Td2BQDq 1UjuqGTP7fhks0C7J1giHzLIjB6xyFNwHkxmFjnLkQN2+YoH75ZV+hmcI/cvIEsxB44lxnfSvSo Qoz7KkhiPZo6fBlnHYe7W9Y/TvH8NXBg7CpR/aFTLBPC5AM5oOkq6Y88VUzQJbbCZRQ== X-Received: by 2002:ac8:e0b:: with SMTP id a11mr26658075qti.140.1548058715551; Mon, 21 Jan 2019 00:18:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN7zAI4TglTZMLeCp+G6csk03rk3KHpFlTAia6K0sgfOX+EpxoqpQuvYgg1/rDNaRhrYkze6 X-Received: by 2002:ac8:e0b:: with SMTP id a11mr26658054qti.140.1548058715062; Mon, 21 Jan 2019 00:18:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058715; cv=none; d=google.com; s=arc-20160816; b=L7A4N3lsFaNGlSCJCR236Zbj9ZN2Zi7HNkm8245YqZMbXNIBcUkf8qK+OciBXjXgsT 0aOel7tJeY6fbioO3GwU5Or4ybejjePh6P0SrwsuxDgdGUVfE0P2UTPaPgcPE+eqHzfC P86vot/oNZNLb7+WNGATPdhB3PsP4IencjrCFvG/ka2bQO09y2fG2dm8TIRyTKSrCOJp YoXhD8CV5yenhsPdFyAwxAGD/sK6hl0spL9KWREPo3OwWnhaSNYA7coi3OD2d2CtMkTm JUNJXIsdZfTAdndcKmfzgYYyCd9mp42lyn4oB1JqRNbvk1PrreN5V7ZmgvPoNAOixvGU qyPw== 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=M47d052qJ5TMYShoMk14sBdAHe1P1lxcdYvQ0zQl0vgAs1jvmyU1KzNxgod0QuenKD N1gnvehSTkbgyIbnS/yxFkvSrl5OrnWWRbOopW4bCJ6AP7Psm/+lt6tYnS7sxXfeWHH9 2R0j8lUHIyUOJXMAo2LXyCWwISH+lR2zukj83l4Lrr33U6PW3dC2S7tkr4PQLGCPqqGb sY0eYpK/FLe2DrEzei1Wof+ch+0iz3gPLRd50sfYgdMgOGitEyDIrmbUb1JVzwBequmB 9qF4LYI2slm/wUGTlBskggwGKHThlDjm+ftUNKE6zFjYTBUNgXehixv7edUqiuN152id oGWg== 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 q7si344465qvc.195.2019.01.21.00.18.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:18:35 -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 C8F4C80F7A; Mon, 21 Jan 2019 08:18: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 6B0DB608C2; Mon, 21 Jan 2019 08:18:25 +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 V14 01/18] btrfs: look at bi_size for repair decisions Date: Mon, 21 Jan 2019 16:17:48 +0800 Message-Id: <20190121081805.32727-2-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.27]); Mon, 21 Jan 2019 08:18: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 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 Mon Jan 21 08:17:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773121 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 64D401390 for ; Mon, 21 Jan 2019 08:18:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 562B329E6A for ; Mon, 21 Jan 2019 08:18:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A00729E70; Mon, 21 Jan 2019 08:18:57 +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 DCE6E29E63 for ; Mon, 21 Jan 2019 08:18:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 206CB8E002C; Mon, 21 Jan 2019 03:18:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 190188E0025; Mon, 21 Jan 2019 03:18:56 -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 056858E002C; Mon, 21 Jan 2019 03:18:55 -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 CA75D8E0025 for ; Mon, 21 Jan 2019 03:18:55 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id n45so20394572qta.5 for ; Mon, 21 Jan 2019 00:18:55 -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=aSaHXv9GcV7Hy+0wn5pzI6axcV57oT0QQ6vcD7AvJIvDMQNwIa/4kW7pqKx9tfW88X 8v8rXK9Kwkt+8P2iSYVMGGIqArEML8V2aIH8EdneZRtBnBF4pQP2o20fGE8TeNKGIq01 CF58jIh4G5y9hGeO3kVBQ8brmcHCzAv6t1wCTrxwgf77xsilKmXDHzUATOLVkkVb/bb4 1vcCrBaF9qEL2WrB7Tl6J0ABivIgSV9vFTk5E+cfYCqJRwTxPsbqTR0ihJMAVpwFARWu +2wR3kOrmtR4iQAO+nB4cY5kTFLyF5FqIkJ76iBAHOvw6M1HaLLkekfnRKeEBWoDpSoy hAqQ== 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: AJcUukdSkzavPwoHjnTDYEgVPB42OdEBH6+sOgK6xfp08M6ggIlgftVx 2v12ozp3gbQ0xZAHV9T1bF9mNHlXKVHdP/KeIsLTnYRZLSsSJeN8xdspUvopkntCs0B8nCNVBlR TkvuTDK9ZgdywhPUvAUnpEIP/3gsELqgIJgqWIrQX1ByhO6+oeN+fNm9R1plKC9wFHA== X-Received: by 2002:aed:3a69:: with SMTP id n96mr26354689qte.246.1548058735612; Mon, 21 Jan 2019 00:18:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN69Jq/1jPPO2zzS1EmVkvhbL/2AnkEEOR/DaVw7sSVVLD5bxbPLuDBnS08TAM89vr3aB7Q/ X-Received: by 2002:aed:3a69:: with SMTP id n96mr26354668qte.246.1548058735140; Mon, 21 Jan 2019 00:18:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058735; cv=none; d=google.com; s=arc-20160816; b=cSths778IUVBYGQQiUegOgSHlIo52lfwtTG4wb3q9GXuj6gbbl/l3paFPJmb10/2BT ZROro0v5qqz0yxoVXc+H1C8YlJZvU/JCnBsIq1QZiI7uL+L63OQkyBoWT++jEwUM9BBg KdoGh5bGKRMfI2tz3BwDE8N2/YrD9z0yviyt3ROPHcFhAZgFl/x+ux9DnLvZolT509DY isc1YpOmTohxfelDc3nL4DQcJ2TA5z7BM+a4mu4Is5obXSFIGOoySLIEDOWcjDxV7gXB JwYT+UGxVjhf76lUYVrufG2OFpKpi6KQ3I6yxcJGvZoSs1URnqb6IKd7pF+SV9wxOsTB 92yA== 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=G8TG9WobJ5wHAEkcirIbVe6W9IN3Xw1FwGOgBNVqiw7auvorWdZoKCU3GdVUAwqVPU tD2dJrWvuxFPlvpG6RuDGv2mARyHdEFqtuO2P0ookhYqmwyoNMzQ6s674ngYkB+1Yxbd l7yV5f/KRal8R1X9GFWlidtabWbWkembDvfaroWRNOTO2R8GkcfioMI9RR5wejLRAkKn XjUMYBuWOTF/4UcrnlRd8SSSvn/WtmwbbImbbc01GGYO24fo1BQrXbUMeA7f5mhmVvGL RXLJHmDYnOl3BVaCrQQNcyBfCzkmnSaEy0LryeK6mluhVeSGpsBXGaQGSm594s3l3Ma/ tgzA== 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 s34si562308qtb.17.2019.01.21.00.18.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:18:55 -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 264568535D; Mon, 21 Jan 2019 08:18:54 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78F0E5D737; Mon, 21 Jan 2019 08:18: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 V14 02/18] block: don't use bio->bi_vcnt to figure out segment number Date: Mon, 21 Jan 2019 16:17:49 +0800 Message-Id: <20190121081805.32727-3-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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]); Mon, 21 Jan 2019 08:18:54 +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 Mon Jan 21 08:17:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773137 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 C289C13BF for ; Mon, 21 Jan 2019 08:19:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B470429E63 for ; Mon, 21 Jan 2019 08:19:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A879929E6A; Mon, 21 Jan 2019 08:19:17 +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 3B74629E63 for ; Mon, 21 Jan 2019 08:19:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C4B78E002D; Mon, 21 Jan 2019 03:19:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 64A4A8E0025; Mon, 21 Jan 2019 03:19:16 -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 5123B8E002D; Mon, 21 Jan 2019 03:19:16 -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 223128E0025 for ; Mon, 21 Jan 2019 03:19:16 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id x125so18328989qka.17 for ; Mon, 21 Jan 2019 00:19:16 -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=g77vUl9uFnnF+Q1ihzmqwuH6waUsPx/rYjPPtp7JRnm9NjmAZu1SCxtqjMoyqmu3PZ ldWZpxA6bdvLdOrhbdneipnOMaUq1vL2+IP/2dilE57Pw2xqDiJZ3H//YifDYRTXjj89 uhcyefo4DYA1nWEj0sBHLk9FmFOMElzwov+BCJe5O0ynp4SLNfAedepZPgmB44pSwm+y 8CEEr63sJEiXLxgUq78BuAbT8JWGtGudjnOEnjWVtXWAKW+6xw1+/7KX49E/ijoswpVB QeSxnqSWY5o2NUCWG0n7h+zwYTEwWLXF1zoWd56FpG9Vcg3xgk2zDPucXX2UtCL0w1F5 I3sA== 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: AJcUukcecaA6YruTYf1sqvjQJ7yKdbvwQpoIb1tnEfzX1ZJ6GmcJFGEk F7c7AtZe1uYPvVcrZha2TxH2+RFZDyK01jx2KybKUwmyOoSUAbu4HASRNcDBPFiLqH8V5IhJpTb YX5fFp3p0qCq0wXDY6VaulDzMfR4rHs+IBUB1CbC/91zQ9c8Ij1FaYSYcJIygz/WpyQ== X-Received: by 2002:a0c:96c9:: with SMTP id b9mr23850154qvd.238.1548058755914; Mon, 21 Jan 2019 00:19:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN6NMTrc+eSvoI5IOnXkRmfzMPWo7G93Lv9NX6WA2mx+6/VVkVttc6haaH9BSb4lXN9VwAl3 X-Received: by 2002:a0c:96c9:: with SMTP id b9mr23850110qvd.238.1548058755010; Mon, 21 Jan 2019 00:19:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058755; cv=none; d=google.com; s=arc-20160816; b=q1xXEgukwKJ8paT/f8KYYVK4fUQoMZ5kjISKg6N533A8FlX97qspr5QgRVf2WgX9// GZ/gPCT9TgdjkaLkGTO+tfW5/tVmriqPxAbM/FhXlA3ECx4sSMAqWkm0Kw/TAVeG+5YZ 3CxHVMJkQ3X2EzvPMVXNeZvE9VtRWgHNGFT0TQ9eZqt2mzREy/4uS/lFn+Pf/JOCoqqQ NV2ACJR/EDrOb8gvKQ9VcRnx3Zr4g03oa9dB35WGs14ejLcu1txpV6MO/n9P6uE3iojM /vTBcI30D88TaigndbQOfX4iOBUfTGs/KMF0jgCHnAaBf1dfKQG4PwXKlzT9U/WxCG4d 9YtQ== 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=Ijc4+d4fsPIPTv3U3kHkW94PEWevdPungPvFLZ08BYvPHl1QhHTr2bkTj84FoWoaqp 78XRsGIuz/xUVL4b7r7hjPi6VaXW1bV0AS9AeVWyQTwVgDZfAb0TldNubb7WnQ//tiUN v7BkP6lHr+zj6LmWaxaKpZCRx6dm0q6tcuJ9ePy+1og5uJbe3zk/7tjMbtGFVnnE3OS/ O0nrMNGQq+W1DObzX3VGkbeykyCSp3NWwvolkiTYNAMXicjRHKyeDQcJuvQDR8apfWfa kiptLQDDyEsYYxw4RGOzzMTmzsIA8BABJAgGvug407zn2VLLY2c7kW0Y5HkDj15s1c9H UXHg== 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 w7si1227343qte.36.2019.01.21.00.19.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:19:15 -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 111198E5A9; Mon, 21 Jan 2019 08:19:14 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A38C19C7D; Mon, 21 Jan 2019 08:18:56 +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 V14 03/18] block: remove bvec_iter_rewind() Date: Mon, 21 Jan 2019 16:17:50 +0800 Message-Id: <20190121081805.32727-4-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.28]); Mon, 21 Jan 2019 08:19:14 +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 Mon Jan 21 08:17:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773149 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 D37C814E5 for ; Mon, 21 Jan 2019 08:19:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C411B29EB5 for ; Mon, 21 Jan 2019 08:19:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6F2C29EB8; Mon, 21 Jan 2019 08:19:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=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 65F1929EB5 for ; Mon, 21 Jan 2019 08:19:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 959168E002E; Mon, 21 Jan 2019 03:19:36 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8E22D8E0025; Mon, 21 Jan 2019 03:19:36 -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 7A9558E002E; Mon, 21 Jan 2019 03:19:36 -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 4AA428E0025 for ; Mon, 21 Jan 2019 03:19:36 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id z6so20164316qtj.21 for ; Mon, 21 Jan 2019 00:19:36 -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=Q2YXeXh4V5f72Ncixsujqktsg2Ab6DDk37fwlaYaJpmBBm0JShj2GW/cuFzGDg1v6O DCmvOYtuwcJE52okyCvqrE/CNHvm8TzxtVGOPBgggR9MoruttjHTTvdhzdKefWboQuJI Z0VDDhIz0N85L1L74dHTIISUcrB6nTeQtSmC930BobBziRwWAV9vsuwPSykWQxXDhMdv xcodIYATq0afD/gzFNkNEYkAwdsELtrxtMrP1s6G9RkvAc+8zBhwymbC6A6qytAKH89b b8m7hjTJRpAgyMt0zE5n3GN3aIf6eZ/ylUY+RgysgmQYvBuPf6m8eN1IwQv9ccQZI/Wo UW2Q== 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: AJcUuke4i8u1APcB258+KgF+sEzaH8rkSu542WjUaf2meDE+5/VnOk/T uvP+HE/GV9TFOFLXNNTv9eNmwY8lOEGpcAcQ4OwiBSbhnCfWVFXs1/HHYT80o+yLWInPC1bmeBw jyJfowy6A5l1V3H8t4qryyYsyZguXjSKNwfVD7uno3mj/Q+SOHGqGQR9/Hio34TeWcg== X-Received: by 2002:ad4:5004:: with SMTP id s4mr24912542qvo.109.1548058776071; Mon, 21 Jan 2019 00:19:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN7oRJk8CV+KzYWNYU4h2UMiqCX8X33jDfbZZ376mLpN/aWjk6wWQ+b91pCQpLDq4Bz1AFR4 X-Received: by 2002:ad4:5004:: with SMTP id s4mr24912513qvo.109.1548058775411; Mon, 21 Jan 2019 00:19:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058775; cv=none; d=google.com; s=arc-20160816; b=VIDl8uDsBxxufDQsdWJ61EiTMyZykheGEDjDsKoJT/u+q+gRwYu05BbAF1zA1cpyun T1a0YwbjUTuhlt4w5jO/oaoluTDUor/DaLiXKY++u8Gkr4Kd6PmCmuAKX9cEQxVzN/Bt nsRbZFHhJUVY7v0q4zFUa3gUU+2nTd9bYvDJQoUShO6TUyxeFLZjLlzEgR/E5vAxfPvn SDmnfBxN5ZjZEXc9TmjlRpvy3sAgrc6M1N/lSaujFWdTkgXZ9pg/GoTOxmTl9GbqfDiD ZXYcGz2C0fGiYCBu+wbwlBEd0xlGJuXvx7PD+B0iLif6yVxA7DfAMeZ/O0ykKpduZOKF cElA== 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=jR34eLr8BEf+b6yFRzDCuDXeTHf8RIMZi/hyoMcc+CDp6IxgBXrgKpEU0W3q0Z7XAV hnBoXNK3enpCEEbu9BPSC0AGcH9wsoJy+WhmVqq0txxZ3EFfcoVCOpioUM7w5BxPjEii Hf4lZROAfGi0JLtOkqFJUbFCKZf2r6Ii9+dE7SoH4tMxzvJWyvu1dvmRln7bCwsv1VtJ 7SlPoHLno8gTXRqD+SPKPmcYI3KbITs+yoa8CssvH1FXDtaHGnFQ66ryR6i1ILzSQwWL E4nu89Fsn20eZhAdOnDOlvDVfcidOBIBgc0sN31aD8scBl1xIJ8Fn9ooq/RF1uQ8QDIs /vsw== 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 q4si642804qkj.161.2019.01.21.00.19.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:19:35 -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 652018535D; Mon, 21 Jan 2019 08:19:34 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8540719C7D; Mon, 21 Jan 2019 08:19:19 +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 V14 04/18] block: introduce multi-page bvec helpers Date: Mon, 21 Jan 2019 16:17:51 +0800 Message-Id: <20190121081805.32727-5-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.25]); Mon, 21 Jan 2019 08:19: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 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 Mon Jan 21 08:17:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773163 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 E723013B4 for ; Mon, 21 Jan 2019 08:19:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D84F329EB6 for ; Mon, 21 Jan 2019 08:19:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB9DF29EB8; Mon, 21 Jan 2019 08:19:57 +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 654DC29EB6 for ; Mon, 21 Jan 2019 08:19:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D0D58E002F; Mon, 21 Jan 2019 03:19:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9583F8E0025; Mon, 21 Jan 2019 03:19:56 -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 81F5A8E002F; Mon, 21 Jan 2019 03:19:56 -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 577288E0025 for ; Mon, 21 Jan 2019 03:19:56 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id w19so20356648qto.13 for ; Mon, 21 Jan 2019 00:19:56 -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=8AAv6xLmlnhHy6lrFmcykh11uSuIfhKUAirhS6/Y8Bg=; b=SiviUseoPqa7DVbu4Y7pp56wtNCv5d3IFvs8Uy+bcYed5c8XqtZokV0sWav/SziDek YFqzt1WgAYtCO0FiCzube1JzGLJ08YaII8RpBu9jW3meMmvP02Ixdwir/lzMxtF3HiWf foTvTcG6pQE+9ejE49q1tXLT7pYt4pzIUXDTmvKId3w00jv/hC1tD4g1OTAoQUKJap8j JeXX5kgV+bmq6z3UBW+eB073fp1rD1MTJ0Y2CqhM+S6gYC5WvVycYNaRFvtsl6CElLGW /4+AYdAuGsYOkP23AQnmtC0PHkeNVkgo6MhGHdXJbRZrGZZrMYJvARonvYocVagplIHP u9+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: AJcUukeu7w+U9tVJMCjukJ4OkB3jHMIf9eO1XY8e4bRCdBHLZ6oVGJFw 4ikR/zv8FAd+gHgm8viMmx+kiFDij8N75orT6vSmndNBa2fPKeHQH0IFX09jBA4lZjZGEWAP13k F6j7dt+KllZ95G7GTiwKf+IipNzL4oJUsIwgSm8i4V+BU5SPe0Ea+byv70ljv8+SohA== X-Received: by 2002:a0c:884d:: with SMTP id 13mr25034616qvm.170.1548058796129; Mon, 21 Jan 2019 00:19:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN6DmH06gA97h5XUoUiISVCRIIQfc+EeRuoT0CsLl2pzeYGNfdFm5QQDU55tajZmhxqOysmw X-Received: by 2002:a0c:884d:: with SMTP id 13mr25034601qvm.170.1548058795622; Mon, 21 Jan 2019 00:19:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058795; cv=none; d=google.com; s=arc-20160816; b=CNyHpSkAZ1vrofIQqPaQcpSIDc0q41FIQcxJ/RaSUMTI+mmsiBHkmxCXnxyba6jTOc cZMVFXa7DvxdLU0ce/vWq1vEUP14+lcBax6pAtoP/0N3QixNUDtPMJ8Um1keRR2FdzBf xs0VYa6Pe2sXgeoB2qiISig0PgWv4FXKWQsQgLjnQSWPH9/3V6OSDQRaYtgVqhgZXKtP 4FV/xcPlc/4j+xYP69fS0S+mcJ68cnik9R+3JI01Ny1WVKzxpuwq/b9i9caQqavfDYSk r8GaEzJ/rMyoB/OmtY3YcImHpKS7uyLbdjUcAPB1vYsrbny1vTY5TtPVFU50clDd78aA HrDA== 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=8AAv6xLmlnhHy6lrFmcykh11uSuIfhKUAirhS6/Y8Bg=; b=CtfQklvt+/IuB3xbag9wQrw8+NhcAIrjWtXWzg99B4ryXgTZGGmEw/sigQZGw71RjV 3+aWtYpOKqmM+F6hRheDG1yvZ1R4MMrXZN/nLmaftDGq80U5jI/Sq89P+XLYaI5BXsYX zbSxZmHWuRDjhDpqTk81ta81AJDz1ZvCcVasHyH2EJMa0DkDYIgb+wQjwOpJvudY9NB8 a5/OdRknBQeArdxkAN30gVSc/ezzkaym7GYhTCy0Y3c+kYdrf1wF0zFkZzToNcwnzTZQ mA0/2CSyEC6+LvOh2YintVtbBQNqdl8I6MrhOqvaPvHXJ95fjLBN0YY6AlVQz+SwQy+y 0TXQ== 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 f21si7252828qve.138.2019.01.21.00.19.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:19:55 -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 30609811D3; Mon, 21 Jan 2019 08:19:54 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C30935D737; Mon, 21 Jan 2019 08:19:36 +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 V14 05/18] block: introduce bio_for_each_mp_bvec() and rq_for_each_mp_bvec() Date: Mon, 21 Jan 2019 16:17:52 +0800 Message-Id: <20190121081805.32727-6-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.27]); Mon, 21 Jan 2019 08:19:54 +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_mp_bvec() is used for iterating over multi-page bvec for bio split & merge code. rq_for_each_mp_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..730288145568 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_mp_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_mp_bvec(bvl, bio, iter) \ + __bio_for_each_mp_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 338604dff7d0..6ebae3ee8f44 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -797,6 +797,10 @@ struct req_iterator { __rq_for_each_bio(_iter.bio, _rq) \ bio_for_each_segment(bvl, _iter.bio, _iter.iter) +#define rq_for_each_mp_bvec(bvl, _rq, _iter) \ + __rq_for_each_bio(_iter.bio, _rq) \ + bio_for_each_mp_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 Mon Jan 21 08:17:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773173 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 B6CEF13B4 for ; Mon, 21 Jan 2019 08:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A607529EE6 for ; Mon, 21 Jan 2019 08:20:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9936C29EEA; Mon, 21 Jan 2019 08:20:21 +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 F086729EE6 for ; Mon, 21 Jan 2019 08:20:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 230758E0030; Mon, 21 Jan 2019 03:20:20 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1B63F8E0025; Mon, 21 Jan 2019 03:20:20 -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 080C08E0030; Mon, 21 Jan 2019 03:20:20 -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 CD3708E0025 for ; Mon, 21 Jan 2019 03:20:19 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id y27so18499038qkj.21 for ; Mon, 21 Jan 2019 00:20:19 -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=WCwWGna91+tAg/4Zdp/1JFxnNkzZtaFKiqbTCiVBFTo=; b=Np9mFIX9T0VmnY0dEyfr1i6dMoMQSCQOPJop6Pyy8ujWhupm6q/ojkAXRH+koLwhfR NaAgl+y8O/NH5Wal7NnyKKGTzaCKjmzus4BYHN6mnelR6S1uGWNS45DuMV1wHjq3e4b3 pVAILXy/AOc98KDqtVhaP5+KaLnNai77/eKcwJOfdX27RegwAanE1Sg06NXJpeDWmBb/ VOnwfbeKNwWk7leocUCDrs1LfEmznnlDAUPI13UmcRKxW/wTAkULjEUjRy6q2Sh6XlDo 98FCheLOE8/RumLmsH9z1N1xaP3or5prXH/2KntMrBR9MqtKs61xNirDRkAmw3MbtvPy f00g== 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: AJcUukcR4ASBvAQehNa/qaKmBnmlBzIC3hv5MfOfPRjBIIfZQJa0mDIx bQOBL5GgjfBYr0fkqLKCpVo4xZs6RiRwimO6ynwgQkY9qRILau2AGKjpZIg9WGlY4BoWoZXdZOS o6rlWmz9Lb9UUqUxWGujxm2jMHqTHgI+mV3TJBB9nKRKgvdVCp8uB6UQP+uWXhEy5Tw== X-Received: by 2002:a0c:eb41:: with SMTP id c1mr25696445qvq.211.1548058819593; Mon, 21 Jan 2019 00:20:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ntN5NBgv/iEoJPNK0nMfYhFidgV4Q5TCCvDDjrwKiiDTMbDXSDWIXoc1Q/ktYbKWYc/u7 X-Received: by 2002:a0c:eb41:: with SMTP id c1mr25696415qvq.211.1548058818855; Mon, 21 Jan 2019 00:20:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058818; cv=none; d=google.com; s=arc-20160816; b=nLZy63vY189GJRxSdxjrCf6/JhKhI2DRUjaFh6NT99RCxPImrU96eHcbw+bmCX/96e vL/mS2zcRhAsVVaxZQnGtFtVCHjUDCFJkTCh5+UQDr0WSNRM1hd6P2hsupCpaNj4gSny iUE8gRUsf2EsFwaOmUKbgqmInFn5n55K4Jgy2qHwapeHOs2+3nkCqktOG53aEsP1LpLj sE6Sry4C7RqN7qElfYoEe9kOrWpwnB5Bznbjlw8rAEeCkVCX7v3TN8xUKW0SiZHGm5HY fbwr7eUW5ONt56wj6wJ2VHov7webUhw8d9zKObAVaJjC5FaOSLVzjdm3a8QYcg9eBeUZ mZNg== 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=WCwWGna91+tAg/4Zdp/1JFxnNkzZtaFKiqbTCiVBFTo=; b=P16o+sfn8I1gIi+rjc48084xbmwElrr/rFsB/pv67YfjB5fiWMZklQl7zAeKrxpYEf 7hj+DOJB+cIeIbcqhqDQTvwg60cxFR659dVls8E+ZELk3l9WumGEfClUrH161Pd/OZZu gZxvZCuSB8gP8IlhfeXMviMBSPecpddSMlgaX+bL7XPILawPAe27dmqLLe2/4VAbqg+l UOfXJemhc/fxwLZq6bbUGz7J27034sFVxPFvugCiBZRO0r+8cyPZL4n/pqlcM5x0LgZ7 1mbgxjcOpQomzCs3ShvinMYPP7xoRqoEFZvrlWPIGwb0mlCnno8G990yEvthdXwEZ1D1 73sA== 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 l28si1396822qtb.119.2019.01.21.00.20.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:20:18 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 98B4013822B; Mon, 21 Jan 2019 08:20:17 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47C2A5C54B; Mon, 21 Jan 2019 08:19:55 +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 V14 06/18] block: use bio_for_each_mp_bvec() to compute multi-page bvec count Date: Mon, 21 Jan 2019 16:17:53 +0800 Message-Id: <20190121081805.32727-7-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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]); Mon, 21 Jan 2019 08:20:18 +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_mp_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_mp_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..2dfc30d8bc77 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_mp_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_mp_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 Mon Jan 21 08:17:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773187 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 4A4EF1390 for ; Mon, 21 Jan 2019 08:20:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D0AA29EE6 for ; Mon, 21 Jan 2019 08:20:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3082029EEA; Mon, 21 Jan 2019 08:20:35 +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 B46DD29EE7 for ; Mon, 21 Jan 2019 08:20:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB2918E0031; Mon, 21 Jan 2019 03:20:33 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E60898E0025; Mon, 21 Jan 2019 03:20:33 -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 D299A8E0031; Mon, 21 Jan 2019 03:20:33 -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 A87F38E0025 for ; Mon, 21 Jan 2019 03:20:33 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id 41so19965681qto.17 for ; Mon, 21 Jan 2019 00:20:33 -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=THYNTeJq3Ruzmj13rq5pNugVy4Zrxh2hC2dcME2YskM=; b=XIwxRDBz46svv3AW7gXBklIBOamdlC8DmG5z4dcrrZjSbe7zZtdNUMjAtB8xcBN0wf rEWXpeS6wtBgzwEtZunvc3vcGNelzOInI3P7PCWjdBl5LG6nhlmsv92WLISZj2/oqzZe ShQAaapebGQAG2M55VaCnBFIs7idnXETlEib55nHCaP3KQMrqfIzCwO2o9l2V7fQi9cl i2BADQ1YB4cHI998bd4QhgxDFgETs6bWE/lhevsPSUyGKE8I0wJZI7xVb+qJ7Ba27h22 55HVjYp2lPdzHpsDQ98zjJYMK01SKQIfHE1x034u/4GQmJjI3THtgY6vUz8WWDJU5IjM 8bRQ== 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: AJcUukdXxF51IEQEJmjpz8nYrdC1z84ObpFMkE2Rc25N9RIw1sTW0ouB kmwGTihgAQr7kF/HlxtNqYCZ4ciLnTeRlD1OY+jkq0BgeMm253nBTjmfSwl0NVBs7J4zCufZU/s iOQMnhCoIiuzEpdcNbxqyjrr5TADlBFxCWZGoc4+HXayVmetREQCpXJmdpmEE3BSkXA== X-Received: by 2002:a37:a28d:: with SMTP id l135mr24319348qke.226.1548058833473; Mon, 21 Jan 2019 00:20:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN53+dCW2vMG6b1uzIqAlMo1PDh4rrU7X6frVtOIjMaYgraa1jCC5ekAAuaCHrrXx81Zg2X4 X-Received: by 2002:a37:a28d:: with SMTP id l135mr24319321qke.226.1548058832842; Mon, 21 Jan 2019 00:20:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058832; cv=none; d=google.com; s=arc-20160816; b=JFOyXc12oiwToLDGVYrHN6vG76/J+E4r39/v+VxynmnzbBZXkROuv7fNVd+fPV2iUt X5+nGKq3gdOtJmTG0WIxN1/vSW9Q5KZJKjRdNobhxAfUbWM9QCemY5CyOADqAihNA1ma NNMMAVgZTvOHB7Ptuh53Tm7q+Vgt5qdIGipAUQ/8L7a+Rnp+ckTxsGdV7D16mhMBMd81 3XfGIl3C+TWah5fNw6EDDhIU3dU+2v3I55N1BxAwjnuTkGue0Q0Du8tfesDn4yBDRZaP BFW6bVWRdsZHdHrh9wrFjgcOdNg5+xGHKsayv9I3jJqDvuhtpSJrbPtThzyL0iyNUK85 Xqew== 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=THYNTeJq3Ruzmj13rq5pNugVy4Zrxh2hC2dcME2YskM=; b=mls26WgONer9IDVwC9kO+eO6ZQI2KzyK1fQayQtQP4wqr4tTPnxoKEsYwyWhrf9jcC yvUl5UX3rHr25PZV58RQ7L3eJHxQAwxfmIzBZZgmBPPWWqS9k9kicPz8Fb327yXNLHgH 7QRxYJTQ6CTKsqVMvx+u8O7wYg1xErCea01DSPEGySbqMWqzJZm/3OXE4IFig2opdwsp qKkQ+4J1mJnG57QXFMJY92UdBVb501YhqO2v94IPQMSu1usfePkHNRnG0otRZ/zvdZQN 56RGPTlIP23uc3Tuwsp75NSa4Pel/tI459utMe94kUPiHVKzJs/NNpnEpYgpLlOSR/pi 0IEA== 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 a24si2736010qte.183.2019.01.21.00.20.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:20:32 -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 C02C77D0F4; Mon, 21 Jan 2019 08:20:31 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDBC019C7D; Mon, 21 Jan 2019 08:20:19 +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 V14 07/18] block: use bio_for_each_mp_bvec() to map sg Date: Mon, 21 Jan 2019 16:17:54 +0800 Message-Id: <20190121081805.32727-8-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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]); Mon, 21 Jan 2019 08:20:32 +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_mp_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 2dfc30d8bc77..8a498f29636f 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_mp_bvec(bvec, bio, iter) __blk_segment_map_sg(q, &bvec, sglist, &bvprv, sg, &nsegs); From patchwork Mon Jan 21 08:17:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773191 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 484441390 for ; Mon, 21 Jan 2019 08:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3930B29EE6 for ; Mon, 21 Jan 2019 08:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D5D429EEA; Mon, 21 Jan 2019 08:20:40 +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 C50E229EE6 for ; Mon, 21 Jan 2019 08:20:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9E2D8E0032; Mon, 21 Jan 2019 03:20:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D4EE58E0025; Mon, 21 Jan 2019 03:20:38 -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 C17458E0032; Mon, 21 Jan 2019 03:20:38 -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 969458E0025 for ; Mon, 21 Jan 2019 03:20:38 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id t18so20379706qtj.3 for ; Mon, 21 Jan 2019 00:20:38 -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=HUrAcMnGlIBk+Z6wSD5zDlLX8CNEVFkr2J6GFwrgBHb5k6RCYZKjkLVBDjMKQGeJ/r 2xG/uFN95rdpFVO1KhZwzxZ6tEJgioKlNic4dixeu/iDIhuxTpHPO61LyaUfMH9D7kmw nDV9wYO1ySmi2eH6Sliy1bm5mrEnB+08VgeX52qAwj6/lqFJNI1Jvxtx/hwFPU6Ln+NX 6ircLl0OBhwG9NBGLw4G4Y6rcgCA9NPtWPruYszbM3OT20g4MJp3LJoVcDP3Ql5zt8yQ Xz58LOyaPOwEgPfjOa6Lp3gAMxramDrQBAe8icyzEND8dAW3TUxGPHw2mfHaYmauMBH7 Tz5w== 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: AJcUuke/jIcxlQA3leeJM80Z4qoYkZGsEzqFiqGP45/1hRAhMqESAeu9 cl4bZZOWjaxSPZRLfW61HMDxLJEUvGN89ApWv1couOHwa9fr5DZyQYd+bjwUFrevLrJXKiVEY9E /IXdtrLapqYyu5g9YEIavri1DuQbPO5+5f2sbmePTmbZl9417RgubDiW54JzWh180eA== X-Received: by 2002:a37:6bc1:: with SMTP id g184mr23505366qkc.236.1548058838403; Mon, 21 Jan 2019 00:20:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN4FTlKrgVCXKIBBZCrAhsGfgFwVchxgAzkIit4Buw1XR1AdGE7Y9WZ15BazE2qlKOBcDNA3 X-Received: by 2002:a37:6bc1:: with SMTP id g184mr23505353qkc.236.1548058837693; Mon, 21 Jan 2019 00:20:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058837; cv=none; d=google.com; s=arc-20160816; b=cgM8c1pk9A+JqjAhKBM5ihCVNi7URH6cZVZ976TM/7flKjKymM2pZIQWqOiKIVO4YX 6L4G2TKbKcg2jaoUYypqP9vnFaHGQph26FNtUmhtGZYaqlmyE0ZMPD/eEFIyIC+YK69u EKtVhnDr3HDoicitKUIaBbjvyS0fHN/i0IIq9znSzXlyDjwUsLqFzmj7snQHIgnPB/UK V8I6nLn8bH7wGhtoKwAfKngZb30eOxB3D2SsiUve1N14poeSjqWNpjGAyic+OEfBX7Y2 oxK9KK0idRJMf6xPJU444oW9ir1NVtaG78D/nBxTtYR9WBQ6+OvLdh7BQccPO4TV7wlu 7e8Q== 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=Ehb08wVx5My7FiHSIZ1J1bKY1f/lJpq0kvENDLhvOysBLJPIrH9NnvW7nY3fkVw6gQ UUZhBSF3O6/ln5ayDyGGN6GGx0wod52woTqFN0rPrqY7Ln5G11EVEjU9bXJl4pXE49Z4 eIidF1t6lbjXjjpPLg3i/tGnzVzJFRwDCe/KRmOZcd1DkYmm92i+fZRnMMhrXxwEf3BB jR0WJAreHLsUIuHz+it2k4YrnnJinr8OnQP+2AdsFEqJuXqjps/kDXvVf8H5Jv4ltYnk NDwktOaJr2jEdaxhPf4mR5B37ic6+MEbvji9LtYxWa6NPgUptdi0FebgYUAEvyW4FJUw sm5g== 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 i13si1831724qtm.380.2019.01.21.00.20.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:20:37 -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 ADB8C1640; Mon, 21 Jan 2019 08:20:36 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5444D19741; Mon, 21 Jan 2019 08:20:33 +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 V14 08/18] block: introduce mp_bvec_last_segment() Date: Mon, 21 Jan 2019 16:17:55 +0800 Message-Id: <20190121081805.32727-9-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.30]); Mon, 21 Jan 2019 08:20:37 +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 Mon Jan 21 08:17:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773211 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 19E8E1390 for ; Mon, 21 Jan 2019 08:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BB6629B02 for ; Mon, 21 Jan 2019 08:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F423229EEA; Mon, 21 Jan 2019 08:20:56 +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 4937529B02 for ; Mon, 21 Jan 2019 08:20:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D2508E002E; Mon, 21 Jan 2019 03:20:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 75A3A8E0025; Mon, 21 Jan 2019 03:20:55 -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 624828E002E; Mon, 21 Jan 2019 03:20:55 -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 350AE8E0025 for ; Mon, 21 Jan 2019 03:20:55 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id 80so18730970qkd.0 for ; Mon, 21 Jan 2019 00:20:55 -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=Om3h+rqKO9EbYBX4dwZarahYiPh/FIj6iVXSlJGXSxfKx5Mt6pYgClTBjX+S8P0HAR P3NWmZqu1RhLudwNhVigVBW8hxvirJ89QUnsBpYHOuMRP7ju3qJsLgMSk5GXF7qxtWeY sTsB4kMktt+avLTedCf4Vn4e8t/EKAUCuFRMa8vCQdY0FVGkKfwh6KHM4I6aolv8xzdn VuEcyQ9xdg5wxOQP1fZMPlP+JBIxV1/Gql0L/PIOmaPRY3JQydGHbIKxKDi+yPVNr27Z hJeA30U9HQN4nW1u6MorpS9bu6AbugkGA+KIqd6z9QRIPGwcuRywHp3FFhkBQurstW+5 BgFQ== 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: AJcUukcfEyqtkJuOwGfibd8I6KkkW/BE+he96OxwVb1xDvAymo3pB7G4 DwbUqMq0hT5pQaGD2rrSVOxBXu0UCxS0pzaILJA4dJGzVf7Tcul0nsdhlSF+frk6xRBEq3MVQAW Xj0aZ849zAcQRRDeEY3W+i+bD9l1NPBWIPscIOI9U7bOxG6RQcltenkSd33pO+qJDGA== X-Received: by 2002:a37:310e:: with SMTP id x14mr24537307qkx.78.1548058854988; Mon, 21 Jan 2019 00:20:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7P3nMRUJ9ke53YV43gPojpOwaT0hHQe52eXs6Y7VdMcbooV71e3IpTiG2iVfHCQf8lNxWl X-Received: by 2002:a37:310e:: with SMTP id x14mr24537291qkx.78.1548058854549; Mon, 21 Jan 2019 00:20:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058854; cv=none; d=google.com; s=arc-20160816; b=BIM1pVZ+U3SaqVxO1THptTwfdkttYz/zAf77JKzfPIM6Sx4rb3lAQnbSIvKlBUE18X 3nh1+kgipaLq/J+RS6atjwBh8Xpl79qyjEoIZREtY3FziKmRYwyBrfpBwps4riNuHQ5g qgzuVIoXDQW/x1yXdJShYwqGz3y2QvwBw0qcpKNVsuTuL6Gtw/fdLubZ0JiOFyB8HlU0 DdUgcLAIMyq7VgV70kj234RCe4/DOIDId3KPcdk7r7mMdHQPNYQ6PTvVSrGqWOCQNK0F DDioizx9601Z5o0e+sqhiBGvHJvgD+pJ/yd65IH9H9nOzDfxeFFQ2e5NWtUaUgAEPOB2 pp1A== 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=B0XDWhO22xkkFDbLq1un4cx289O2jBz+FMJAj2emimdDN/dmmnex3x4+GV3wG+EcHT jVFqgfczLJeFKbFtEvyC9WgZZQeglSLGmk0OU/N9MVGZzlcXOyF2RQ4BJwYNpTCCOd9E v3pcbcFfB0Lisy2TbjfzCFJ0zYCj7IVgZ7Mf3l1UqQWWzbQYuhaMYFhsdCBdG6CxMeP8 4DfW9aOUjUHGiX/tgjRnqU4sGN+m3zQ5kwefkmJxHvxZ2POKPv7DVEsdKiWa6KCg23LC 8f6yWR7oe5d34aiNtaGykyq9Hgcb7zBfipz6st9XDWUnY5WtMz1FE0gtypyyaY5bXQyd Cugg== 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 l2si4203998qtf.302.2019.01.21.00.20.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:20:54 -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 6C9BC5F797; Mon, 21 Jan 2019 08:20:53 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C63F5D756; Mon, 21 Jan 2019 08:20:38 +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 V14 09/18] fs/buffer.c: use bvec iterator to truncate the bio Date: Mon, 21 Jan 2019 16:17:56 +0800 Message-Id: <20190121081805.32727-10-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.39]); Mon, 21 Jan 2019 08:20:53 +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 Mon Jan 21 08:17:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773215 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 8DA2C14E5 for ; Mon, 21 Jan 2019 08:21:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DF9F29B02 for ; Mon, 21 Jan 2019 08:21:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71DC129EEA; Mon, 21 Jan 2019 08:21:00 +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 0A69A29B02 for ; Mon, 21 Jan 2019 08:21:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F26758E0033; Mon, 21 Jan 2019 03:20:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EAD1E8E0025; Mon, 21 Jan 2019 03:20:58 -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 D76DB8E0033; Mon, 21 Jan 2019 03:20:58 -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 ABDF38E0025 for ; Mon, 21 Jan 2019 03:20:58 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id w15so20326644qtk.19 for ; Mon, 21 Jan 2019 00:20:58 -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=tUxYmDedSYGURyDoCZddR9MTB0uEDDpXVJb1FwNKbVC8Jd0wHT+MYpW9HSgAApVioh 0/Mzr7jDGJ4vzHYUD8f0dj6r6Q+I0YDT2V+yUQw9PJXsq5g+G3jVFpTzY5nUS8F42oM3 HDyFfLz8t8E33RcKwpdgBisTbvMASrLcIFn+1v3KBgfY3TACNTBf5OFwPqnF+17d9fjb 26d534/HlDeGX4cgB60Myl3jqZX64TlzwqG1bSUPngzUcYSNaHdL9x0BS1usE12lIskB hHGJu1n8D4ThpsfMelYWJ5FM63FWJ4TGilgc+6OwYeeXCLt2LlC4YY0ouffL53nlf/vP pPhQ== 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: AJcUukeCBgksv1zBIgmBEDW+lZVrNt63Vh35/qzgMsAKHfHICM86qqSh OF2iXyrRgZI0bx099xViXmPvLSP/ozemqQLcLLYFqiIIis7aeBGGg4RTLiVShxswY+U1xZYDe6M UqWRQ/FpiLKNadF6pCzxVFufG5MjChQ19pqlEM8TN4ay+8IZOhpqrgEg8gNaPPAB1XQ== X-Received: by 2002:a0c:9927:: with SMTP id h36mr24565262qvd.171.1548058858458; Mon, 21 Jan 2019 00:20:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN5GKJ9OQJ1SXcO2qp/Kz3tKMdKZTF+9eMzY5gd640c1IjOEdWm4kg3V5258Z/3BOcc4GBqM X-Received: by 2002:a0c:9927:: with SMTP id h36mr24565236qvd.171.1548058857911; Mon, 21 Jan 2019 00:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058857; cv=none; d=google.com; s=arc-20160816; b=hVJkZRpYpmzXNsgLGEIC0zPLRZl2UnlfHsGKronjyCpsIdYSGNaDHNufJ4XT3MI3Dp m/b7Dg8soSvpFEd4X0v5V69SSqRKc7GcNqUniGFHxr6JzSqyTWepRg4zfOftebmnqbPH xZdTp3g+jIKddYy0dKQweiMz4GM1Igqsw2uL7Nb2wUAtdMyQlnC0kiuk7lY4aueQZT2W M1tzJnbd8exBPiRM7vLLzbih9n3kNLNSn28fwy7ZRVenIVHh19HXpfTD8LP9Tcl2bypG 6GGUn9f7B7ZxEagibqn1wnAN2j9CBKwrSlvJdyXJaXT4Chz1B7HSz8SHZguzDaar6Fwm 73lw== 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=QImfXUzrQtH4YjcrZRoqeVhroItvNKwxd5IJ7VkDfFbjP6IPi1O1mPGaJJ+EQ5+8WJ CLWra2Xp3KmiJT+FrBqp0m7U9Bronf7b4Z8kH/AYnmzXKOLl7a8JpHETi0UYOQHkBE/J +1m1XcuxEPjgYaAPvNVOxZj5J1Fi8Tdf3I0xABZlJDbk7tf4a2OA+sQETtLnxNPgIBIg MzymSpEGXNjMvPgoQfZK1iVvRx/o7GOYffuc9YI+7K4wqy7KPoOc+vaPvQO9+2RZ1BsB bvW5XS488CtvKkTo0UGo8/1OW2QpFMtbCLt9z8aWts2Ugb78at/rMV+3ODBTdfISPWxZ ABVw== 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 m30si3465818qtg.40.2019.01.21.00.20.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:20:57 -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 CD23973A67; Mon, 21 Jan 2019 08:20:56 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBD1D6012D; Mon, 21 Jan 2019 08:20:55 +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 V14 10/18] btrfs: use mp_bvec_last_segment to get bio's last page Date: Mon, 21 Jan 2019 16:17:57 +0800 Message-Id: <20190121081805.32727-11-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.26]); Mon, 21 Jan 2019 08:20:57 +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 Mon Jan 21 08:17:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773219 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 7238C1390 for ; Mon, 21 Jan 2019 08:21:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6496429B02 for ; Mon, 21 Jan 2019 08:21:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57A7F29EEA; Mon, 21 Jan 2019 08:21:04 +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 DDA8A29B02 for ; Mon, 21 Jan 2019 08:21:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2A3E8E002F; Mon, 21 Jan 2019 03:21:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CDA908E0025; Mon, 21 Jan 2019 03:21:02 -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 BA4998E002F; Mon, 21 Jan 2019 03:21:02 -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 8BFDF8E0025 for ; Mon, 21 Jan 2019 03:21:02 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id p79so18689364qki.15 for ; Mon, 21 Jan 2019 00:21:02 -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=NAJKvHdjxb7DLCXVIzyMQVkFlr/qOzN82sw+t/1K9Ec=; b=Cg3YNAPteoA8r4Q2sLZ2YFDG4gKRIHQHeBLOOTqnbElZq6PgD7Igh2CCHpJnMIuDTu 8kzAmFPu7c351TSVRt88E5O5lSpkGuMZlfpWo523WJ+2Y5jF+VfeAUqeidWx9KRFSUNo jQlQtvCrzzTDQ8Q1HkiowG4RC4pVh1JlwW4XmavzISUbFtk7CwIN7Prpx3ckohRJ5vs9 RFnpc7NHzfF9t4Z6x3yQwKirkh8OkBXdnOPEIFWmg6itlZyj2bTlAtv5wX9ZIRT6vSZ/ ab5SkcteQ3HsxGrfiITw5fVpgsN24u4Z+5wC4jY+LYnciQ78EsKh/gMRO9HqW/Q0ImIf WGkw== 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: AJcUukcrMUbUNOUk/IbVScdhRD8Xfr4CHq05HZBeEhAXDeR8PZpBtqQK u54tjm66LsmuyYW9pp53Wi0oK8kLeeOwUeGye/VFq9M1bSp7njVn/CjdCg1QBD//kZdUJQAxN70 b3S9F0LnaYoJAA+3/jgo/tq/CW/QLW1Un/XBVlwNZIxj3uRyCrzvSdQ2f+MymnT7F6w== X-Received: by 2002:ac8:203:: with SMTP id k3mr26637684qtg.64.1548058862345; Mon, 21 Jan 2019 00:21:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7s0RBIdSlNxannykfWF/8nNM+ZKcZeGt1jb2X3MaIAAgnzIwGJ3M6U4BBIaI1sJSGeQLpE X-Received: by 2002:ac8:203:: with SMTP id k3mr26637663qtg.64.1548058861874; Mon, 21 Jan 2019 00:21:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058861; cv=none; d=google.com; s=arc-20160816; b=N/70Q2uVgJIuPEleKLnRu1eMxpxg30HZEWBHAh+cXtWtVWR1IbFfCIhaUtPpOQXd3O b6aq4+AcAADnqDg+E+BcXGNSHhHuG2X/GAmYw9N7XO1l0yTs6vuAVvAKPduN+PLH9KFn xtwOIGbpnrTXzFJqQJuVj3B7bvul6feEnY4AidSIp2+KnAb7zg92cu1fdMmk37WYdlWY h8ExslDzZ8ZNHjhuUNOuaVbfbJRzOEo+6fnZZ1rkkdQYW8xtX1Ef0j2v/Utsyb2oOTUP fRlBHLOACUdeRl/fXpeiNQpsi37XRVm9qi1IxlpULDAbd2oQStAwio1G6l0kXQLeYVTg UDAg== 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=NAJKvHdjxb7DLCXVIzyMQVkFlr/qOzN82sw+t/1K9Ec=; b=TIAAwxWqISEB3ZPJpn0J5ikfVt71Du7xhcRRNzG3mX7s3Puw/fmADGJdlY4aTuhyBq iG2+iY2tHZUiuzfiTmuXJTqGZYjbUgIk2lWsYoePbpSYiSH8gJCmVCMNQ57e/+081UPt h8k6xNsbGOwWc79o1/4FRDv04jldODx4Ru4Ap2FMMRmN8azfM46SOAWvcFj8DQGm/CJR M8Qwuat9gS1AeAVT36GBSDv96IrlSvbvUYpj3b1fa/Ou/ZVYJhD9Sh0eOOBMAxXCTvcu PdUhUTjjEb7Z0GVASaeSXiSu+VB4k6lRpMwNHMyJGkpyGDH5tQdqvpH3pAWLI3PUlGBd 2zcA== 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 g14si2282589qvj.193.2019.01.21.00.21.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:21:01 -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 97BC7C0B2014; Mon, 21 Jan 2019 08:21:00 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85D09608E1; Mon, 21 Jan 2019 08:20: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 V14 11/18] block: loop: pass multi-page bvec to iov_iter Date: Mon, 21 Jan 2019 16:17:58 +0800 Message-Id: <20190121081805.32727-12-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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]); Mon, 21 Jan 2019 08:21:01 +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..168a151aba49 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_mp_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_mp_bvec * API will take care of all details for us. */ - rq_for_each_segment(tmp, rq, iter) { + rq_for_each_mp_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 Mon Jan 21 08:17:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773235 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 54DB717FB for ; Mon, 21 Jan 2019 08:21:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4693529EE6 for ; Mon, 21 Jan 2019 08:21:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A1F629EEA; Mon, 21 Jan 2019 08:21: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=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 D5F8C29EEC for ; Mon, 21 Jan 2019 08:21:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11BC38E0030; Mon, 21 Jan 2019 03:21:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0F2BF8E0025; Mon, 21 Jan 2019 03:21:25 -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 F00A28E0030; Mon, 21 Jan 2019 03:21:24 -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 C19088E0025 for ; Mon, 21 Jan 2019 03:21:24 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id c84so18685192qkb.13 for ; Mon, 21 Jan 2019 00:21: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=ukgDCmNFQyD4LwCRcNuNwpEm9zmc0kwhjZiKsCkqI5KW9C0oY6uoMTn+aYp5zKpaMZ Vgjefdy6E6+fyftLnCDBZh7az7yJiuySRV++CkEbc5sfaIEY9uLU2Q7a+HQU4iqc7J5u 2toxvd4b9WV33r88njk0NgKrHB+wa3VJgQpLjy89TwItP6FZEouJhLlwspFEOY0MM/BB 1ErLI9rDIMigYXm3d0PCcg5fRVCEcVMjxNCaoMb8dowhafoxNoG8u2f7EhM5ktgX65s+ XtCkrk+kS5XP4TGbZuHaSWhadadWKS7uQwa0DJUc5hp3qEl5cliD5T5qLYMbQ4BPuga6 BuPw== 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: AJcUukcR0MpZou/Ek/CSDWNbnbrPbJPnFgmmaZjMuZL4JM4UDnbdp3M1 QF8ubsvr589tyM8Ri4B5lAQHr1vEOKFr1pzzulGGYyu0kxcTy6MHJYQ80aAfVOfqZebA1gVpUfJ 77FmF88BMsvyfgB5/gVu71j4eYllk/7/W3MaprjI76SHzMtD0wWihtKkR5QxQg/bqpw== X-Received: by 2002:a37:7206:: with SMTP id n6mr23552746qkc.64.1548058884557; Mon, 21 Jan 2019 00:21:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN51vw8z05wz5uWqiGtr1m6Rsh1IgLSjAcxwP7UDD3Vwtdt+iyU72VOnflFpRBOTAFFt0uID X-Received: by 2002:a37:7206:: with SMTP id n6mr23552726qkc.64.1548058884033; Mon, 21 Jan 2019 00:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058884; cv=none; d=google.com; s=arc-20160816; b=zO5B+obAoZbObp1oZlMxAItxFIrRacn9/0DRBmp9/yaR5lsJDxOl04DgAnzjoir5rx N0F09QihcPpXq4BO1Jpcj8khNhAFkkFFFyOtPYeTJxcD7niiuM+D9HC69ojXHdMsL5J+ mH5og4uWVu7Ckk3qmJ5PVUwUdFhYHATEUbrBlZ2kfjH9Bo7WJ+P1vvbPmxuK8aSl34MP XQxjwp1VnM0IXs7Fa7UqWtw2egmQg/eoScgsXlIgLK2T2jitclFxK30bJKo6zwAb5PZa JKit+hIorv6sk56l/wxVSPDEODxkM8HA2np9TJYzjxWzXdpJB/PYD72e88os8QgR99ql iCGQ== 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=zeTtep7x27UtVtkXYS10pb36hnpFWb9B6AdDXFH7uMXmoyMiKRHwajap8C3WdcAJRv Y71bfXS8QZqUJ2vU1DvrkLfdtEK5a2E9qJc/tAuwMVb1QYE2lfmsu8+cPhODq0X8hSro RZZEl0s0eE7n/45+L2nykiL5O/EGTHovB9MrK7VswJtWRDacBzWaL4BoYErtYd7mPyEJ cLjfoPB/3YQZ5Yhb1s5ttZe4sgs6wmVtNakaQbHHXVktWHjqlOqGEZuqseeT73td40l8 VymbQaU+qHdo+2rkflsmyKePpFoju/xgUMBhhbdruyVE6xDqCKi4IAt/0In57ROvlFhC fv1g== 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 j6si4028533qkk.237.2019.01.21.00.21.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:21:24 -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-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F37228E5B4; Mon, 21 Jan 2019 08:21: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 2093B10027CE; Mon, 21 Jan 2019 08:21:02 +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 V14 12/18] bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages() Date: Mon, 21 Jan 2019 16:17:59 +0800 Message-Id: <20190121081805.32727-13-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 21 Jan 2019 08:21: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 Mon Jan 21 08:18:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773255 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 4EEDC1575 for ; Mon, 21 Jan 2019 08:21:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40E8F29EE6 for ; Mon, 21 Jan 2019 08:21:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34A1429EEC; Mon, 21 Jan 2019 08:21: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 A165C29EEA for ; Mon, 21 Jan 2019 08:21:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEF478E0031; Mon, 21 Jan 2019 03:21:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BC6468E0025; Mon, 21 Jan 2019 03:21:39 -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 AB6DA8E0031; Mon, 21 Jan 2019 03:21:39 -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 7A2F18E0025 for ; Mon, 21 Jan 2019 03:21:39 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id d31so20385479qtc.4 for ; Mon, 21 Jan 2019 00:21:39 -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=mh74GLo3C7FU6+o1aLqSLYh/VDZ9Cps1hv1K7W5xy3A=; b=D53Tpw8UkDhGefScKPN0kIZqW65ZVp56yj/Ukps5yz3sCajQ7niYhjs+ih2rP9ADIU 1EdVDL0iQe57vPfTnB2rsd1FK96nCGg0XeNnvFfw6WuqG9tRjUdzGlpiO1skj+jjdjqu JMRuEhHSvTLjVXsDkCW3BoL5usvqj40Ju1J8YsCWwocIRVRxe4/8IDwa+mr26TGp7OPJ LraM4L6eIxzpuUNTMjS9GjO1/icQFidMZGe+25Qte8TaPBPLnRwCNYzffdWlt+5pLcyu 1o1AfEmdSg4x1m3eHvLeGUsLP6ODF5mJpRcPJuPTJrJgyN5LtQKJbVq+e9DKCSsrYRgx VgtA== 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: AJcUukdE/WYEm+De0sHsw37p0aoxPS6LttDxhjowUMkCIrjhAWNvp8fg tCymA9zAHwHWaP0JEE4njy3ROGTK1nB3oOZrqmaEEMkG41E66W1LxRks4ijQDIfUN2JXjHC6OGJ mzA6luIrftydiTezq0o0fUBdYWnsxSjrVbfEwtl29hvYEDNQoghcpVULyayfVs8WiJg== X-Received: by 2002:a0c:cc8c:: with SMTP id f12mr25046630qvl.102.1548058899179; Mon, 21 Jan 2019 00:21:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN5t5fb7HzA9nq6RTeUnYbQMmu3b2h/QVLjjG7XbY05B3Lqv1Q6YJkNmj6oFRgH9LN0dKVj+ X-Received: by 2002:a0c:cc8c:: with SMTP id f12mr25046586qvl.102.1548058897701; Mon, 21 Jan 2019 00:21:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058897; cv=none; d=google.com; s=arc-20160816; b=NqWC0FRvdur8Rr69OTqoPZge0PU2TQhZrH63/eVMe6CJU28dpaY86XKBr/xqTApPJF /CgfC3cNf8wiusNJkmMGq/UXv5HJ7LRcUsuHFn2X7oFfGjnn3qKhUuCiS091TW6yhmYc UhMK1AkNpuxfY8LJ1Zfor69AEhp7Hnky5Vj7jl4c8fuRdQg1F4Z1usouWiJ4R3ezPvm4 IJU2NMzh3ZJH6VE0sL33vAA4TyyhigkaKI6538t+VbfM2JVbJSDd7R0hNcpgaA9GKWxG kMpF7bj3NZt41TP5R9n9FMrAC/+YZrq2kpxgyN8fc5NvNbXTMI0WofAR6HvEPLVMdxZi fzBQ== 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=mh74GLo3C7FU6+o1aLqSLYh/VDZ9Cps1hv1K7W5xy3A=; b=yOJ618yfgmouXggTMR6Gte+E1sSiOf3hY8ARZYryre2CRWwcrG4ss6GrUJ+ebItaft YNlJmpjuH/SAcHITWBtBM/0oPzrImavhfYE/G6qfQ29aFV1Tsud8lH/iezm/XNzRBz4d J5aOn0oPlZAoBNkDTV//vYlzBBOLmzeQD7BEUO6ODPsO8D0Tt2JyKb9M2aGceY6L3U3O ROpLWsKwbVx+d1epYyiG9deoJYnQCjPOM7a7g7kTw6IELp8cVVHgxunjjBQJqqbZSBuo eCGyZFttc8P0Piqi9nPO8Z+LKFnYgEAcaEU5nookxetAfPZXgryljF9evpUGv2iuG++f YvlA== 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 p68si380512qkc.74.2019.01.21.00.21.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:21:37 -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 9E60BCA377; Mon, 21 Jan 2019 08:21:36 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89E3A60C74; Mon, 21 Jan 2019 08:21:25 +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 V14 13/18] block: allow bio_for_each_segment_all() to iterate over multi-page bvec Date: Mon, 21 Jan 2019 16:18:00 +0800 Message-Id: <20190121081805.32727-14-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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]); Mon, 21 Jan 2019 08:21:36 +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 0ff22159a0ca..856df7b959c9 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 1d54109071cc..6f74a3b06c7e 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2114,13 +2114,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 c546cdce77e6..33b6a2f03468 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -197,6 +197,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)) @@ -246,7 +247,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); @@ -315,8 +316,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 8da2f380d3c0..5cc391fc6a57 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 43eb4535319d..861593ab1cbb 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7778,6 +7778,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; @@ -7789,7 +7790,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); @@ -7868,6 +7869,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; @@ -7881,7 +7883,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 dbc1a1f080ce..47fb973b92e2 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 730288145568..e6a6f3d78afd 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 Mon Jan 21 08:18:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773259 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 CD7931390 for ; Mon, 21 Jan 2019 08:21:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD74829EE6 for ; Mon, 21 Jan 2019 08:21:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B029829EEC; Mon, 21 Jan 2019 08:21: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=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 21FB929EE6 for ; Mon, 21 Jan 2019 08:21:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 512138E0034; Mon, 21 Jan 2019 03:21:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4E92E8E0025; Mon, 21 Jan 2019 03:21: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 3D9D38E0034; Mon, 21 Jan 2019 03:21:50 -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 130398E0025 for ; Mon, 21 Jan 2019 03:21:50 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id d35so20341654qtd.20 for ; Mon, 21 Jan 2019 00:21: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=LSVuKjhcMhiZWrvOK9ONDixv4hXMBlIh3Irls2MiYDo=; b=lX+NBO56Km0KyPO/qAg6gIxpDu8eOnIDEP3PaWCtAslXbSjuSpu0f1ZEhGHQ2Kq4AF Ng23dlviRvV143mXZOSAAmi5geStcSfnlBKUiWrREoIrTySn/hBgdY4nYbLEV6ZzBnv5 7sPKbdjH7db1RZW1kg7BFvQV6XHsfZwcvi4+hg0YMKIGJHT/Lru8en4QwprewojgVE50 81SITffShxPupclpJEoFHEjTkk2ULCQgSHuorJmTXudpyTTO5CZ5RLKfCuDSOx7++AYw vE5vM4xrhnNBYe9UiOc93DBMZxy37A3i8on8EBBihgNybjJTWCh4OzwnsDnpN/YXa8Yn 6Nww== 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: AJcUukc4jllnVe5cIZ/ldiMcIrMJkUgzOS/XKFxnxawukX5EC+j/QhLm N2D5UoV+GnZCMnfTckMdKMmdpOGFbUZmhjKTbUPPgJ7W12SVvRTXKlPXh39qDXWYS++GWDBPrah Ojc9NIYJGscMKPhN2r3j2pXjYUFHk05FLJj1OY1IUbSv9kG1SVGdBU9iQFknFoBJhgg== X-Received: by 2002:ac8:7950:: with SMTP id r16mr26048097qtt.12.1548058909837; Mon, 21 Jan 2019 00:21:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN5vwbxqT9WUOjl3yef2s5TffIoeY1okFrCniSPn8AmhGxsnIUT0Y6i7TpnoCZP4bBg2mP/X X-Received: by 2002:ac8:7950:: with SMTP id r16mr26048075qtt.12.1548058909268; Mon, 21 Jan 2019 00:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058909; cv=none; d=google.com; s=arc-20160816; b=nxsb+Zd0nSin/WxcmPTtKxkhhMvoV9d2sKdvdDEuf3wBhlyG7OjCapzJ61kc2uXtEU XbHubs4ld3Juw2V3T7yTm6/97tpmypXd1AR0X8/acDtYm0WnOUOb5Rk6rG3xgGpSn0gH eHk/Xk3VwAIyFnI4Jj1Dr7UIIqljUHf1yhpHqOT4cCwfyX9R8QRI1tf9b/0FxlG8OZBc e3q0US0xlBYtbW70DVMmIuCPDSP+a2GjgjMAUxurHlVkdpNwJM/G/IUEzcXLMlJSgqcm +0W1WiQKt3cfdRkRv7mDGRbnZMp7jbKxo82X76xBVTowbeI9JWjAghibI5MoHEx+IUkR utaA== 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=LSVuKjhcMhiZWrvOK9ONDixv4hXMBlIh3Irls2MiYDo=; b=YhuMZh9+6FC2F36NWBqq2MoY3pnuutVfE49hQmH6FQ20vQqyENWRoM4/Nhg0bKuGCs CnY1NAv/OA/LEBTvpyT+IbAP5S1QiUYQ1AlwVhh5pKfiO6WZ2q3qY1UJpqpk8Ayh45Lv jUNwXGR1vcVAngDHSdl3vM78E2OBN7S5bZ97snicbkxyGrbu8DFLu1sxUyWHqx7LYaTO gqf4O3+QKjdXH9THvFAsRmmuNOXAhIZM0n0JekpFVT8ajiX2wASbGROd4BGLLBSsd3lL 1oHvOgHuBumnbm1fKcbxaF4UbFXjN5UqPr0c+/8o9VKFAMLtiklkxZFXCKjb/3JA3kk8 0GNA== 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 g24si5043773qtm.208.2019.01.21.00.21.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:21: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-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 28229C059B80; Mon, 21 Jan 2019 08:21: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 EF7825D6AA; Mon, 21 Jan 2019 08:21:38 +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 V14 14/18] block: enable multipage bvecs Date: Mon, 21 Jan 2019 16:18:01 +0800 Message-Id: <20190121081805.32727-15-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.32]); Mon, 21 Jan 2019 08:21:48 +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 --- 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 e6a6f3d78afd..af288f6e8ab0 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 Mon Jan 21 08:18:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773279 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 1E89814E5 for ; Mon, 21 Jan 2019 08:22:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 111BC29EE6 for ; Mon, 21 Jan 2019 08:22:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04E4F29EEB; Mon, 21 Jan 2019 08:22: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=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 A9BF929EE6 for ; Mon, 21 Jan 2019 08:22:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9E658E0035; Mon, 21 Jan 2019 03:22:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D74B58E0025; Mon, 21 Jan 2019 03:22:06 -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 C8B028E0035; Mon, 21 Jan 2019 03:22:06 -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 9BD138E0025 for ; Mon, 21 Jan 2019 03:22:06 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id w18so19972266qts.8 for ; Mon, 21 Jan 2019 00:22: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=PWPZT416UnDtHnTkAwGJ+1F+/W8cOEKYDjH6aqPOvFQ=; b=svXDJgJrVVAzLmhQK7UF+D8SIiE2fhugU7X0Vx9fw/cD2PpDzxnzewAYV0gYoJhHya IlDT+PnLLbMUJYfKb1hxK60BvSUHEEbYZjjsA72AIH0fVH2c1wam8rllceupgyKedDy+ Qe6KWS+ExvkiaxIROdxCJ+j8nxKan0rYIrj+HuoZIXhN15GTCQ94P4xF8cCnSZy7xsKB LPhND7btfdCOdpCDIBYtWhiV7r8AFW1AKZsuHbeNZ3jcyBbClT8dq94YILc471X56Tck V4yaihgzd7vPwuhN35Hx4kxgaGbD8YQboGvmc66p0W1E4ocb4p87wzGc2Xw5w0jjEXWf q5xQ== 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: AJcUukc5Ct0xIERVWOpIk66c1RI2Yr1qC2AAi8XiJZ1o3NAqQmSpAStS KZ1SDbTrgBL6nfYop9PPcK/fQhCRg8T+QEHFu4PR3bB2p0pQjzcFJ4JizvQgYxPjn96sli0OLXz YDjfFjSwgXp0B30h6ZYP3ns/mmZTSbJIGNM6XVlQJQ3Y+LbNB1PWVtLav6rpTj4IFXQ== X-Received: by 2002:ac8:27c8:: with SMTP id x8mr25344128qtx.352.1548058926413; Mon, 21 Jan 2019 00:22:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN7asFr7mZZsVGXydhaIoB5AgdZ+eb/RNxtKFGRNiPM5sX44+r4Y0PdYWgUUpvHgtr2Ld3k2 X-Received: by 2002:ac8:27c8:: with SMTP id x8mr25344103qtx.352.1548058925897; Mon, 21 Jan 2019 00:22:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058925; cv=none; d=google.com; s=arc-20160816; b=e9WDHi+h+yvJqe7JmAni9OtryDPJvmomVOS7s6WE6V5JPd8xnpd6n+KbcVhCeioWy3 o+EMTNyIjQLgmfPA15iX4NgE83WuDxzAMWAXGzIHZPni5bXgJAxxafv53xxe2ZEzBG4x tlQ+GfcFMlBnUG93KgCHbAxixrOJPxH3tPBX6jjqsLVfRqIUh1JmtemVhy/xH7gEcoL6 fl/QbiuRD8rQk6OCKg0BqWd1mnh0iA4BxeRc3jSGTvK6jWXmxTV8+jVnOh/RN5+kO5Gt qBPAZLGN0lDqU55+8rvUDZkGfvl1cz8zrQDW3SSdYGHE0GJJODj58CUMX5Kqu4edZjuj wEeQ== 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=PWPZT416UnDtHnTkAwGJ+1F+/W8cOEKYDjH6aqPOvFQ=; b=kVsZjUpaiwl497TNhT9/Omj0LRZMP2xGOtgKF4NVNzuPJwnGk4ZyHT/n7RE8ru4RFu TILjREdcSjytbMflM7PkN8+UAw1sbc9IKSw6EBvuEcTl+mk+lcVxKnAu3HvIVCbpa8xN JmTlbgprw+gKwbb1JOaIIMRzj5g4Y3GMgQulno9x7Rd6wOI03eUdHMaGIcfx7kq3TkVl XJyNz+NaWm6Gsb9yUn6T09/bw71Q4ZNHz5DGZbfM0TRQ1yKzoPk9YXQQyedv4hkAlqov SJDJaJEmp9v7q2JNRHvB92U5wzU0HLfbb0ZKFUS6SZewranqWVyLqinQHcpqIwH1E1jt 2bHQ== 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 l5si2046436qtr.32.2019.01.21.00.22.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:22: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-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 9B63583F51; Mon, 21 Jan 2019 08:22: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 84AA56013B; Mon, 21 Jan 2019 08:21: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 V14 15/18] block: always define BIO_MAX_PAGES as 256 Date: Mon, 21 Jan 2019 16:18:02 +0800 Message-Id: <20190121081805.32727-16-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.27]); Mon, 21 Jan 2019 08:22: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 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 af288f6e8ab0..1d279a6ae737 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 Mon Jan 21 08:18:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773291 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 4C2451390 for ; Mon, 21 Jan 2019 08:22:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D84A29DC8 for ; Mon, 21 Jan 2019 08:22:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 318F629EEE; Mon, 21 Jan 2019 08:22:21 +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 A4C8A29EEA for ; Mon, 21 Jan 2019 08:22:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC61E8E0036; Mon, 21 Jan 2019 03:22:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D9AD38E0025; Mon, 21 Jan 2019 03:22:19 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8A3C8E0036; Mon, 21 Jan 2019 03:22:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 9E8F38E0025 for ; Mon, 21 Jan 2019 03:22:19 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id w185so18690742qka.9 for ; Mon, 21 Jan 2019 00:22:19 -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=AFBqz180RnaH0e+e3HwEp17wlMlBCtNionbxJZAMblc=; b=XNGk94WkFg5XMqfbw3dh6Ea1tSaPcsU9JYbFaMijv5oEpIHYgHCSj2iGSAhE9vw5uw Sy6K0CqBkfawl2NM/JUTWFXq/y7P2cWXkYG/PVmBt6eL967u5iGtFMkwVgXBqTNo+0kV G6ZkLxxDJe07SYkv/9a8o2swHqRtqYYlO/p6FZAr4ox+bJVdIZsnAVVJ8JDY3fWS2ywb +jVi1IrnCfabzsh2mIPuLbaeM+ONdpLrcfctLzhDNU3MR4c2i+5PXTR/T3S/UKOyPZ8G g5bkvpiLpQ4U2ovj5A1SlSEAdHiW9HYZV3bR3eA0nBXve2/zTfIiOmUiOwmi/UD/Eymb S2xg== 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: AJcUukc0qLY8KpyQcvecfcQcapj5yHzx1SeGTNaKg6IFOoSlS2Ge9NgV lVw3kFCd8tR0HniuyY6QCFsJfV4RgfcveVvHLg+Et+Z+oKStfTX+/n5l2cj81grxGJrEFTQmQzv ND4Lr7worclIsGMK/f8ubXKPlfIqJa+XbbcaOUDRDaraIVp0soGpT4s8D6oi/FQ8bCg== X-Received: by 2002:a0c:e8cc:: with SMTP id m12mr25547481qvo.186.1548058939414; Mon, 21 Jan 2019 00:22:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN6ndUP+tzRDVQpTesoXGxdzZV4S5G8iIAeg6DLyAoU/fJ+pm/64mDn04KIi4Iis+OKSzyM4 X-Received: by 2002:a0c:e8cc:: with SMTP id m12mr25547464qvo.186.1548058938870; Mon, 21 Jan 2019 00:22:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058938; cv=none; d=google.com; s=arc-20160816; b=t98jL/KtqqVtZLG3pG/mV2F+szAmE907uN9cD6oI9YyOg3wI8SzZbP1XDF+9W8Za4Z 788KgBeJwu0SQZflpJCpS+fjEPp7f5hERQFbPEULdIEbLGJVhD/juc59T3i6Y5xhjWFi UikJ5Qo8Gi/tkXLHgPSjPOfU1P4XA+9dS0yB+nPbwRPpCr/lbJDu+rgB4CFXeGSJFFKF MDZDF0SUySPF/t0n4vYKA1xeL7d6zfASMsJc7EC1FoPzDNOQSZ5zKUIPSm7U7XklgW/0 ItSzwtxI6RnF/BISgFcTWg3stNRyxAasKXq+GZ1/9ZryV/4QjHk5lZM+VUncCTFJGYdS EKIg== 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=AFBqz180RnaH0e+e3HwEp17wlMlBCtNionbxJZAMblc=; b=FV503PpEJNQUCcFL6KjeiBqFN6SQWg0jhzULerdlk8b6M4vgcyAwfp5SmQm3+XPhPR LShl24GxsFX4ijGrym96O3UnBbf5Hv7lrrO5znah+RPELrbg0KaREnA3CU7ozSRrvkp2 rMmG0mu0n44rpBOfWl52CGoPlvSGV+18bsH1sgvyl+TIDYM+Mgsjd1bFX8Mi50bdNEd5 Czu5rwndjZl3KvaFOdyFZQEzWgMdNDL+GiOkRHTFEnKyfrBGytz7HcCOrxaUYFbcuCo7 I+bK12MRBZsinxa8fEPWqV1n/OYbg1W1g9YQ5A4zLCr3X/NWIIpB09Q9N56j+o3sOe4J Sd6Q== 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 k60si1995935qtd.396.2019.01.21.00.22.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:22:18 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 D46B687629; Mon, 21 Jan 2019 08:22:17 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17C405D9C9; Mon, 21 Jan 2019 08:22: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 V14 16/18] block: document usage of bio iterator helpers Date: Mon, 21 Jan 2019 16:18:03 +0800 Message-Id: <20190121081805.32727-17-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.26]); Mon, 21 Jan 2019 08:22:18 +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..4a466bcb9611 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_mp_bvec() + rq_for_each_mp_bvec() From patchwork Mon Jan 21 08:18:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773299 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 E0D5A1390 for ; Mon, 21 Jan 2019 08:22:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1FA229DC8 for ; Mon, 21 Jan 2019 08:22:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C536D29EEA; Mon, 21 Jan 2019 08:22:24 +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 36D1E29EEC for ; Mon, 21 Jan 2019 08:22:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DAC18E0037; Mon, 21 Jan 2019 03:22:23 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3AFD38E0025; Mon, 21 Jan 2019 03:22:23 -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 2C7978E0037; Mon, 21 Jan 2019 03:22:23 -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 04DAB8E0025 for ; Mon, 21 Jan 2019 03:22:23 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id d196so18540657qkb.6 for ; Mon, 21 Jan 2019 00:22:23 -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=IBxQqHlC2onUEoRnWGJ4ZdJrraJqmec6quBxISAguxk=; b=KfGrhXPietd3clXot+YK50uH1bfWBS2R/AD6mgbgWZ+5e/vmdDLS6Tct4OH3qMKNqZ ZRXCg5cu9csjFnY9dIgX1JQ4meS7WT/ZNfw/IAePvznvKH6DXGdYz4NP0XJP63gcKqrg 0tN2eCLzDOWh5BWNR+s+dvlf4irdV2EhiXoUOt8I4JUOHwA6xluy5xrLjJcT90s6kx5f LD/bXcbVseh9xDLTtQXeixncWZuF5NFxxg6cQ/yudW2Tk8kvwCs2tqW5VMkxEVVh5rpF PvmH4Qn74tlhYWRAFSmLMtEwoZtCgIxI1BBVIsAyKhtTeXUJbP2zv+1yKWXrpkdC0HyX RvCA== 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: AJcUukfx2c9T7xmjagluIbejB2JuNdW/p0f+mVTBsE4nbnh/X70KQeoT uvVfz8OiCu1uHpCF8HzbHeUDOsvAxDFMsy4sVejDgUUs4k8ZeLk3d853YbD9XRdsgZiMxzCWgkF 3Ld5Q1VlcBOh+vrgwdSjcEBD2zEDYjbVE9GIJKrKscBfxQ6PuGJrq0VvKJ2jJYIkixQ== X-Received: by 2002:ac8:34cb:: with SMTP id x11mr25731834qtb.115.1548058942779; Mon, 21 Jan 2019 00:22:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN45wO/O/iyAbPnGSGIJ2xRfefm5XxpySxuYUWg3tYRz5PhYOolr6TUdeL/zok7adwEmHHxh X-Received: by 2002:ac8:34cb:: with SMTP id x11mr25731812qtb.115.1548058942162; Mon, 21 Jan 2019 00:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058942; cv=none; d=google.com; s=arc-20160816; b=BDtkAtlQlvXNUg372ZU0+oKmEwxIvF7VvFGQ8U6vVYUNwopuKrze79DdywMMBcpA1U +SHtBE2V0Kgye1RjbGXqgtl/vLNf6JnARzrS4S6uaG95E4hA+1ThHErgsspLkXqoi4BV zwSZIvWUWLkI9qnYKpeezDl4HKSi+EhopsWwPFgX5HCNABVpewXhflQD+jG9RtY9Ag+D 1XePD7+QEFa7T4Z5RxU8iGRtZDDeoT9CnERZREk8ld6J7YO15pf2DuCo1BBCy8lF7AAj oSIBC4LUQfDkltepTsWtwfBvuTlFJ4J7iGly+fnDqRO5h7TWhRwMIY857Loy0ggiiJFq yD8w== 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=IBxQqHlC2onUEoRnWGJ4ZdJrraJqmec6quBxISAguxk=; b=yO7qG+hHt3If+vhF6qRo6OhTSuaD5xeSAm3QEaVPplN7qqX1i0jJVyp+MsogAkcRpK EX/g0g5FSI41Gg0OU1Vb/bHyVGgKcpCY9xBlwzr3crEUcCFHpd6lCu15DfPgnVS/bwGi KeDDr5AA9PXlbxOhquD8GdPSrYCTP0OJoLSqE016GfoJ3BUzFT2aLpnDcK14cCr3u7jx FkcbQNfMMMVnC3NGNeaLqGwgIzAaNGQyPy9YXTmhki/mPAFhB/tgBtSCgm9qm3WgGPac Zwog0M+r/BuLoiuF2q+j47aT0XuoTD5Egi04RmMWiPJhP6uT3HUJRZs0d/HJFIlCMN+k VknQ== 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 b9si47273qtq.169.2019.01.21.00.22.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:22:22 -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 0BF7119CF68; Mon, 21 Jan 2019 08:22:21 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 130876838F; Mon, 21 Jan 2019 08:22:19 +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 V14 17/18] block: kill QUEUE_FLAG_NO_SG_MERGE Date: Mon, 21 Jan 2019 16:18:04 +0800 Message-Id: <20190121081805.32727-18-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.29]); Mon, 21 Jan 2019 08:22:21 +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 8a498f29636f..b990853f6de7 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_mp_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 90d68760af08..2f9a11ef5bad 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 3ba37b9e15e9..fa45817a7e62 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2829,9 +2829,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 6ebae3ee8f44..2d4cdc1a7bac 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -588,7 +588,6 @@ struct request_queue { #define QUEUE_FLAG_SAME_FORCE 15 /* force complete on same CPU */ #define QUEUE_FLAG_DEAD 16 /* queue tear-down finished */ #define QUEUE_FLAG_INIT_DONE 17 /* queue is initialized */ -#define QUEUE_FLAG_NO_SG_MERGE 18 /* don't attempt to merge SG segments*/ #define QUEUE_FLAG_POLL 19 /* IO polling enabled if set */ #define QUEUE_FLAG_WC 20 /* Write back caching */ #define QUEUE_FLAG_FUA 21 /* device supports FUA writes */ From patchwork Mon Jan 21 08:18:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10773303 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 658A01575 for ; Mon, 21 Jan 2019 08:22:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55AC629DC8 for ; Mon, 21 Jan 2019 08:22:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48BD929EEB; Mon, 21 Jan 2019 08:22:28 +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 ACEB529EED for ; Mon, 21 Jan 2019 08:22:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 895708E0038; Mon, 21 Jan 2019 03:22:26 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 86CBA8E0025; Mon, 21 Jan 2019 03:22:26 -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 780D28E0038; Mon, 21 Jan 2019 03:22:26 -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 4CE9A8E0025 for ; Mon, 21 Jan 2019 03:22:26 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id w15so20329352qtk.19 for ; Mon, 21 Jan 2019 00:22:26 -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=NBJ4Kmao2Vl16pOVk5F7x9SxOEGriqE2QDUKi7cmYgY=; b=sw4VK+BVTI387oyuhjZxA9kvFiGnuMk6c06WpVMZ3lvbJ6kIdBlIuXP2NW+XiHz+1F J2gF9WK74oB00M+LuPzGHP1xEQv5wkjx4JEHy4htWhrtDMehNi8z+pb7cY+A2gVWUIIN Q7DX6Y84VvYWIJJuiwNybHce38tI/FdpCP1LphrIlaZzaM9VVJiJlXIJGRZcdNS/lmf5 XtSavh+HOc4jbdkLxD8fNAwxKzaKTG0j4fzY+kKt+BFnN4mw/rTfmrjFrNx28Fw5FzIt /AR2AMQWKIvdSx27AdggEhOoDf2cT+1XA8N2Yl0LPhoymGB+ghlJ+oh/37QT6jXyqAB0 h/cA== 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: AJcUuke3MWrDP9qPYX5yt8iVt8yYweiCTacwEn0tx62eqNl2KG7b0s0Q oO8A8GK4qzUddg5r5BC2mQBTs6Zq8MXOdFQx1ZkgnljumSMK+Tp4eWkzs/SPQ3rKSfYgQDs4D34 kxdcyKqTsDCgQ4mqrmPVQmCpXGk7CO2Hkd2TdF4Hfnh6+QzOOvGCX5EvgxiEpVcWz0A== X-Received: by 2002:a37:cf9b:: with SMTP id v27mr23330088qkl.160.1548058946069; Mon, 21 Jan 2019 00:22:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN6WfqTzODn4Ddi/1p75wNC165KZePqHpHYVM6IfWD9ikeS/Ly7fgMVQdCojt0b9TIuKaRFI X-Received: by 2002:a37:cf9b:: with SMTP id v27mr23330061qkl.160.1548058945286; Mon, 21 Jan 2019 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058945; cv=none; d=google.com; s=arc-20160816; b=qcm94WsM7/bOwy11nO7c87AZQBXPQ0rbHu9XPzyS9bOLJ+BeXz8XZRaIJV9eCfxLq9 Ce/aSXYE0jBw7J6oVLLjtcVq4AHNZvl2QLX7g/nJhc8184NB9tZtI01FFKFpZOAVGl6E 5xSBMM9Lc8tkU7uPt3uT/Hpj1WiUY7hYA/k5Fl9FFcwsaCO7jhIFtnOOIBwZwWG38h6M 3WNCP5Vksw8qde3yMtecZTSZP9Imn30jFV4Zv1uKVDyu/lCF9NgvpcoYNmNFGMM3lqXH QkBX9yoVwcQ1OmNP3Qnh3jiQhr2Gu9De905VnAG1hxnaGCaTEXQ/R+XJq5M5rkQmwjsV 6+zA== 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=NBJ4Kmao2Vl16pOVk5F7x9SxOEGriqE2QDUKi7cmYgY=; b=gE4R9sUj9EQlEAeA7oigyJa3fQQl3F/Sb1bSvlB0gkQc3eniudoMXhbFBa2jBJsThX uhLeQC+i0N4CnNirqH/DOv9Hr9vdpipQ2PvIfvpeo3LN4jRx8HH1SEcrW/eIC1GSq2ZN /qvV5ntRmql/nc39i4JXFFHIEuWEKGZxTzfXzLziuEnXY6nBE4VUBPsRqN2/PjwSwcR+ yBXjRVxOKlzQqHAbr/g0w1fGAvIK32jwYPl2gvY8Z/zq/rOxGl9hObptHTezot8IkzbM 3ljiVIiR+Mh7ldkEKsv4OIjGsCR8Go8rtgXFMTQ/AAkwOPV5G1sBUxE6DymF4+JPa8Z3 mW8Q== 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 h12si2414527qti.361.2019.01.21.00.22.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 00:22:25 -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 393A11640; Mon, 21 Jan 2019 08:22:24 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45ECB68381; Mon, 21 Jan 2019 08:22:22 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, 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 V14 18/18] block: kill BLK_MQ_F_SG_MERGE Date: Mon, 21 Jan 2019 16:18:05 +0800 Message-Id: <20190121081805.32727-19-ming.lei@redhat.com> In-Reply-To: <20190121081805.32727-1-ming.lei@redhat.com> References: <20190121081805.32727-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.30]); Mon, 21 Jan 2019 08:22:24 +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 2f9a11ef5bad..2ba0aa05ce13 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -250,7 +250,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 168a151aba49..714924cfb050 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 08696f5f00bb..999c94de78e5 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1570,7 +1570,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 b13cc9288ba0..afad57071cb6 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,