From patchwork Fri Jan 11 11:01:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757633 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 2A8911399 for ; Fri, 11 Jan 2019 11:02:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CB6129B7F for ; Fri, 11 Jan 2019 11:02:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10B0D29BD1; Fri, 11 Jan 2019 11:02:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A27CD29BD9 for ; Fri, 11 Jan 2019 11:02:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3D058E0003; Fri, 11 Jan 2019 06:02:11 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AEE078E0001; Fri, 11 Jan 2019 06:02:11 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B8288E0003; Fri, 11 Jan 2019 06:02:11 -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 6DC458E0001 for ; Fri, 11 Jan 2019 06:02:11 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id w19so16241235qto.13 for ; Fri, 11 Jan 2019 03:02:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=jR/ABfQzsk4snuRwt6xiKLLtmUVGlJ+rbLpyE5UJ55c=; b=pCWg71ceHguyXtlXhcKn9MQOZDJSLcZN/hy7We0xYK0pN40DqSMkD5zwGlq/vrTnEt kbaq0guAo/LYxoaAjQl3gzn9j3zkIjgQEejXXjJsszO3TiIx+C9xTrCd3TQw8f13vkcs sHxA7DiGV9/HmJnFsMCwc5FFskwE6/wXlH72GIIFBH/+Tro0eUo3k30Fj9B2IVFhECyC AlJVfIc6ZyL3mSokgR8NnCuxoEbAG0vk384+wI+0xqMafmmNtS0idvpg6ZftyOTCtWc7 AoAyEGkAW5gw2aC7ZFCn5TGkThaP6sX0m7D3eUYFNyftOWhoV57YCCsiH0h4SAS5wswt mClw== 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: AJcUukcetUVi+MKd7ge+xZJM44j1VUImzrxMWzkMUmRD5p61uz91++kQ QkXNlK++WY2Ll1AhYKGnmOLapXDeftys35qI3s5HQ9FQ7ly+tNiVoikz369oF447z/Pqp8sUuyQ TRQZ2+ogvQ0CaLs2DpoFyweTfiQN81jSP3GO1MaqH6JgEqszO5Tj9bn4uhBWjMr3idQ== X-Received: by 2002:ac8:76c3:: with SMTP id q3mr13132124qtr.48.1547204531217; Fri, 11 Jan 2019 03:02:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN4FFzSjmkEULHPlfBaL9R7nafLHQSa6vuTP8csRdupQfZJVpbcmYEHMuXgHiGUE6DY1An6r X-Received: by 2002:ac8:76c3:: with SMTP id q3mr13132094qtr.48.1547204530676; Fri, 11 Jan 2019 03:02:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204530; cv=none; d=google.com; s=arc-20160816; b=WZuzsSVej+VyxBmHPCfXgc8JlTHfeHzMVoXUiZF2FQOHSFDrdHCVRV7yFtVR8uUZF7 ctrdCp6AbxZCN5efTwQ8owNX4BcGEEupCFfZl+tre1sGEY+0e0aLMvKB0RRVeiJGUWoI owd+YeNK3D8fIvXE2d+ifrytZkEDKJAtEPw0atiIxPw7fGxicZpNN/k+gvA1r0iZgLBK WKJ3yhBnmOFhp3ZHkPt3V2WZZ7qPUFa40EivM90tETe/RSdEw7/soptmE5cNbgqn97Dm 58qaYe9Bbl4hI/XV8ttyYCI/lbf7mY1n/Z83smZyOtOsV8kzAXW4jWULPBXonaaFj9kS vh5w== 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=Tp5XAubAYVhEuNQulEKg0GcyjX2gO1w5Sic0eJQ6DAaiADZuEGV5KB+b8q4zyAd5vz PTuYgeKy3fumBwfKgbYYv6wV4R/0xrClBi/XvtiBnVHCUHH3vR1cwub4MONSkV62IbqX zMsa8Metn4dRoLgnIFC2F3yCBkmyfaA+IyOpikTY2lZnIV8CF9X/Y8DkrYneRcKjNX7F IjWX7qEV0f1QGSrTi62ArjovKBda9X6e0acQUzVJ63vGw8hMaWQrqv0MMHFq7ihaEj6i 8dytWLXSt/cXBigW6KLt8A/QBk1QP8+oF2iris1ifnqGVNH9E8G98g1cAYmnz6e/AmoG tjMQ== 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 y18si818933qvo.12.2019.01.11.03.02.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:02:10 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 7D2B82DC347; Fri, 11 Jan 2019 11:02:09 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CEC21E7; Fri, 11 Jan 2019 11:01: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 Subject: [PATCH V13 01/19] btrfs: look at bi_size for repair decisions Date: Fri, 11 Jan 2019 19:01:09 +0800 Message-Id: <20190111110127.21664-2-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.29]); Fri, 11 Jan 2019 11:02:10 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Christoph Hellwig bio_readpage_error currently uses bi_vcnt to decide if it is worth retrying an I/O. But the vector count is mostly an implementation artifact - it really should figure out if there is more than a single sector worth retrying. Use bi_size for that and shift by PAGE_SHIFT. This really should be blocks/sectors, but given that btrfs doesn't support a sector size different from the PAGE_SIZE using the page size keeps the changes to a minimum. Reviewed-by: Omar Sandoval Reviewed-by: David Sterba Signed-off-by: Christoph Hellwig --- fs/btrfs/extent_io.c | 2 +- include/linux/bio.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 52abe4082680..dc8ba3ee515d 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2350,7 +2350,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, int read_mode = 0; blk_status_t status; int ret; - unsigned failed_bio_pages = bio_pages_all(failed_bio); + unsigned failed_bio_pages = failed_bio->bi_iter.bi_size >> PAGE_SHIFT; BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); diff --git a/include/linux/bio.h b/include/linux/bio.h index 7380b094dcca..72b4f7be2106 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -263,12 +263,6 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) bv->bv_len = iter.bi_bvec_done; } -static inline unsigned bio_pages_all(struct bio *bio) -{ - WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); - return bio->bi_vcnt; -} - static inline struct bio_vec *bio_first_bvec_all(struct bio *bio) { WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); From patchwork Fri Jan 11 11:01:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757643 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 DCB4E1399 for ; Fri, 11 Jan 2019 11:02:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCF5529C2A for ; Fri, 11 Jan 2019 11:02:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0DCB29C1B; Fri, 11 Jan 2019 11:02: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=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 5BFE329C06 for ; Fri, 11 Jan 2019 11:02:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F79C8E0004; Fri, 11 Jan 2019 06:02:27 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A6EB8E0001; Fri, 11 Jan 2019 06:02:27 -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 5BE438E0004; Fri, 11 Jan 2019 06:02:27 -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 33BC68E0001 for ; Fri, 11 Jan 2019 06:02:27 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id b16so15942710qtc.22 for ; Fri, 11 Jan 2019 03:02:27 -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=kgAfY1HEbqNSMiieT7oOyFavhmPgP8oQkn+rEkTMTAoEFCVB3u8maOfzuaukbBzlGt 6nrmuhLaG/nMOb/6ifYbjk32cAzYDTsfahVXu3uWOanEAAgeWGkEH4xo2jmHg38RqU2d qdQ6JeDzdOfB45cqSsSJ9KGmHBPDEVrixpWjyn5O7+7fkaF4kKl/RlltfVj5eSP7U6e7 unewMGF9Vl+6ZFc0+2kcR168W0o/30Yp89m7GbLIHVgFeET+NZ2LDbtKAA4JBDbCxQId p7IxxkXwxRQXi64Gewj1NfBkAGoZhrlSJe+ULGjp+Eybe6L9P/8915eA15n38EBARVwC 6c6Q== 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: AJcUukeXFPJbvcE8RdIMSOuqCrW9OwMinHuF50fgrxl0/i6R7fUvZAHZ rJtSSQshqyNhk+tQ5/8UvdXJYIOnq5cHnfXHSVeLbAGnfJfOJrIdPUwGC02YBjjlOfYg2kGLYHY SqmpcpwQ+DBNlbIkAa14aRGfXDSKROFuEZhtsXc5vQ8YRbxqId+tlGY+DCvLqxhXP+g== X-Received: by 2002:ac8:18fa:: with SMTP id o55mr13536849qtk.256.1547204546995; Fri, 11 Jan 2019 03:02:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN4UaEvJX+47KnRauO4LxYWE0Gi13Zdb+7HQz0brqFqJqer1fd5EC88dCNqhoLnl2pIbntSu X-Received: by 2002:ac8:18fa:: with SMTP id o55mr13536822qtk.256.1547204546519; Fri, 11 Jan 2019 03:02:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204546; cv=none; d=google.com; s=arc-20160816; b=ohs+KJuxEIvOGBpCplWeZPrpuklLtYhvuI42G8OkImB+Nu+O82MIQOJHKLxAVBD41q gnnHUx3/In/fCpZLXj9XWUYBgTdjSSCWbDxz475LR1qLtK8ceC5FW5xeqDhVYQo++/uD IxhgfXm6nv+CsnWCwml3VVlyU6yeDOKRXrRjh5OLj8jcYxshojrtAP8YEjmH5C61+w4P sDotcrggRGEJYIChqedLRJdbGS+czr22aECibBym+PHVMskl+3PjkXG/HVkj7Nx0qbR8 NCpCkLkA+BC5gUBNpsLHDOOChqCyGlNrvlq3WG+CtKSbB1CP2/w7/RevdjLe1C+cV54s 5RpA== 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=X57q7bUW3w5VPoMBAmxHl0MnGKy0t6e6TqfWA09bxvt7P7v5jf0w/hzn3l3MHfvgKy NX+3L61qjTHcqteoCVK2jnRRQZBd8Kwy3i3RHg3dIZKph8O81oP5oYDDohjK8hdlrA2q 6CpKo/8A/m3aBFEUAG3AXaWZBzLm5CUCUhew1T20DcMs0KCgS0ib/7yHKxygUeQx1fAh EKwjlZ+N4gN/C91mdu4k93GB5OQtMsQdUXsoiqqNb83buowGj3rvE0eHGNnFIwq6+Dla PPUyJiEOiZkEI9/t8M4nW0F6ef08l1BA9mPfzktyvB9HMb0aXmvQipTv7zoaVfiXpz1Q dqrg== 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 a18si311002qtd.222.2019.01.11.03.02.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:02:26 -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 6BF0CC01CB7D; Fri, 11 Jan 2019 11:02:25 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33172605AE; Fri, 11 Jan 2019 11:02:11 +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 V13 02/19] block: don't use bio->bi_vcnt to figure out segment number Date: Fri, 11 Jan 2019 19:01:10 +0800 Message-Id: <20190111110127.21664-3-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.32]); Fri, 11 Jan 2019 11:02:25 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It is wrong to use bio->bi_vcnt to figure out how many segments there are in the bio even though CLONED flag isn't set on this bio, because this bio may be splitted or advanced. So always use bio_segments() in blk_recount_segments(), and it shouldn't cause any performance loss now because the physical segment number is figured out in blk_queue_split() and BIO_SEG_VALID is set meantime since bdced438acd83ad83a6c ("block: setup bi_phys_segments after splitting"). Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Fixes: 76d8137a3113 ("blk-merge: recaculate segment if it isn't less than max segments") Signed-off-by: Ming Lei --- block/blk-merge.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 71e9ac03f621..f85d878f313d 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -367,13 +367,7 @@ void blk_recalc_rq_segments(struct request *rq) void blk_recount_segments(struct request_queue *q, struct bio *bio) { - unsigned short seg_cnt; - - /* estimate segment number by bi_vcnt for non-cloned bio */ - if (bio_flagged(bio, BIO_CLONED)) - seg_cnt = bio_segments(bio); - else - seg_cnt = bio->bi_vcnt; + unsigned short seg_cnt = bio_segments(bio); if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) && (seg_cnt < queue_max_segments(q))) From patchwork Fri Jan 11 11:01:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757647 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 4E84F1399 for ; Fri, 11 Jan 2019 11:02:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DC6029B18 for ; Fri, 11 Jan 2019 11:02:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31E2229C07; Fri, 11 Jan 2019 11:02:34 +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 644C329B1C for ; Fri, 11 Jan 2019 11:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AAEB8E0005; Fri, 11 Jan 2019 06:02:31 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 659E88E0001; Fri, 11 Jan 2019 06:02:31 -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 521F28E0005; Fri, 11 Jan 2019 06:02:31 -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 29D5D8E0001 for ; Fri, 11 Jan 2019 06:02:31 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id p24so16249875qtl.2 for ; Fri, 11 Jan 2019 03:02:31 -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=t+BTlWLqMmyjJtKnGADUiwLK70Gt2SAKLTVU9U2hurxXa9CvfnNIDNtjbeYqkMGrAG iznlgxrnacbEoF38m01XQrnF6HwksmgDcskSHP5xCiFdDVLTX4c3PcaRkScGipGNTyEu 65+MElPGoEjz6y0isxd15cgmh4ze1W1AA9zqdkEGfi+UsrpoSQ/2HuoOMSgdwBrFvYgW DWA0QvahaBPaHyo6E4bwMUFnFZz+OyyeFqBL6YekDwsNkYjYllFOH+Az14oREDn+cPQ6 HpVf8pMwLC/brnCwL9FpKZBl1UvV7Qj98CuBqEepWHh2omZkEbnDmurlEp2a/fyDNzJB gnDw== 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: AJcUukfXl5coNH/crQOvde8dV0LI5pt/HRQ/qEAm3oahx4UUiO1jiYcf iWlbvoM1YgyWSmqW26PqiqTIDjlN/KWXTpynlNcS74r6MktcHGm753bUsVC9Id1lLR46hOxkjpf Uf2Z2+UITV9YD5TpLq9lW1Q9bojH8UM2us/cb1SPN9Br+jCCF+Bcn7T7SkdL2GNnfyQ== X-Received: by 2002:aed:314b:: with SMTP id 69mr13537489qtg.247.1547204550964; Fri, 11 Jan 2019 03:02:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN4eVdldhdqMItlnwjrFKpOG4Uhw9DbddO2a3CGMyUrb2fsJcEUq3A06mvSMzBjmHivWQNde X-Received: by 2002:aed:314b:: with SMTP id 69mr13537462qtg.247.1547204550485; Fri, 11 Jan 2019 03:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204550; cv=none; d=google.com; s=arc-20160816; b=PfGy4Cg1yKBMWnUAzbTsR57s+cuKVxzuL0LBosJopVy724L7zwF6nL4xs9rB4Whd7/ IzlTz6DJS1+fpKMFUYTjfTbjSUzEO+SHWn7UaXwL5UXpmyHYzAEYa3kmFmGQyKgPuBCm 1ppXv5fnEnKRCVE2e7gF0AM9ztr6kKh2NEYqOp4ndwbRDiTWJIAPXQ/BEUFLVNT8rYYH HnUu6dlyWKNc/pHSpIa/UmIU+m3Eyn8EosrvlPea/AlfEhN0VyL9f/ShnHFRVzz9mH12 zFvWyZnpt0uFeftDyig4tVCUOI5Qx6uuqs8X7yws7BljBNCoZCZB9vIMXHcvjS8nALNb 1pyQ== 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=c+KWi9mqmE0hm/69oe0yhHdM3AXtsbKfU43E4wkVR5Jg9UweGZoNpC6YbbDJk9zR6g LI22BFRykIa/GnXM9BedzPUpMyDynvznPEox/3E8Jba1MRJRsLD+duOwyNoIe6GFKbNs mVvn5H+c2+5w8kkB7AB4yVAx2R71rimck1/8GZjq6wkY7oJowomZoUSF2VIums2PKV6Y poTRXHejMFwhYBwSVvScQnC/VeeFqVeZt8HMFTeqlC46SciNu2FQLbCKwtLIn+YdLQQ+ 8ioIU3NvHLCUfiK231wRRMrEZ4y/tbhx9p2eD0KYjMogVnDgOvrKUJOgDoZEJDHPWX5Y jzyA== 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 v2si5352213qtf.321.2019.01.11.03.02.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:02:30 -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 4F62237EEF; Fri, 11 Jan 2019 11:02:29 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CE26600C4; Fri, 11 Jan 2019 11:02:27 +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 V13 03/19] block: remove bvec_iter_rewind() Date: Fri, 11 Jan 2019 19:01:11 +0800 Message-Id: <20190111110127.21664-4-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.29]); Fri, 11 Jan 2019 11:02:29 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Commit 7759eb23fd980 ("block: remove bio_rewind_iter()") removes bio_rewind_iter(), then no one uses bvec_iter_rewind() any more, so remove it. Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- include/linux/bvec.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 02c73c6aa805..ba0ae40e77c9 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -92,30 +92,6 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, return true; } -static inline bool bvec_iter_rewind(const struct bio_vec *bv, - struct bvec_iter *iter, - unsigned int bytes) -{ - while (bytes) { - unsigned len = min(bytes, iter->bi_bvec_done); - - if (iter->bi_bvec_done == 0) { - if (WARN_ONCE(iter->bi_idx == 0, - "Attempted to rewind iter beyond " - "bvec's boundaries\n")) { - return false; - } - iter->bi_idx--; - iter->bi_bvec_done = __bvec_iter_bvec(bv, *iter)->bv_len; - continue; - } - bytes -= len; - iter->bi_size += len; - iter->bi_bvec_done -= len; - } - return true; -} - #define for_each_bvec(bvl, bio_vec, iter, start) \ for (iter = (start); \ (iter).bi_size && \ From patchwork Fri Jan 11 11:01:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757669 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 9A3461399 for ; Fri, 11 Jan 2019 11:02:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BA1B29C39 for ; Fri, 11 Jan 2019 11:02:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F2F429C51; Fri, 11 Jan 2019 11:02:55 +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 ACB9C29C39 for ; Fri, 11 Jan 2019 11:02:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B64658E0006; Fri, 11 Jan 2019 06:02:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B143C8E0001; Fri, 11 Jan 2019 06:02:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DCA18E0006; Fri, 11 Jan 2019 06:02:53 -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 6DDA78E0001 for ; Fri, 11 Jan 2019 06:02:53 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id u20so16143045qtk.6 for ; Fri, 11 Jan 2019 03:02:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=WViSAVM/NAOuf5wj1zWFpiKtQ8lTX45iJq+VzBW7mSc=; b=aaUSB9GAcK9VRTEiv9OAsdSLz3BBOd/AB932M8aqkGw+75xKVlSRnyqdfY66RKCXLR i1zfsTca8u2LGbaWNf6fxqiUIsPI2Fzqru2ljh5TOHRLCXGPRl1Ba5JT0vYd+zfG+j/t jI8VUs+Q21+MIP+xhA8qFO8WYnEBzWiXzO0C83mtu7I6TmotqLPzVPY5U3KcAr/ySMhN rjdMQZAL4ZbYKrUWZpCUiobE8bg3bcXmON2pSBd988dfwBPE/R2OlM1TNsNk17NY7pI7 vl87DH+PQ1eAEbHUZHZCMfiuBz6DVVXvl6Vm2Fi02W/XWSRR3p8KeB2BLzY3nBP8XKC4 G8PA== 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: AJcUukfClJgd+NmC101knixQU3oQJboondLvRvo3eJbMmvJ2Eo5zmhqZ Q6DU0w9k404wG8x1w9yBi/lmRv7er+G6095hvO2fboEeMdTCgnlKXNxelpUktO1Uza0sUizbmj8 zphsvZO5x6vo7tAnpwGxR8FFu6GMLxfDZ+iv0nm4Z5Ps0DVA+YLysOzmDjiPaNJkpQQ== X-Received: by 2002:a37:97c1:: with SMTP id z184mr12548151qkd.39.1547204573194; Fri, 11 Jan 2019 03:02:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Cr37L/mrD/i41B4r+PFwoiokej61YY/lfXWvRvMy3ZiHkFJ3+LmUQziQi2wnZwqUGzFp8 X-Received: by 2002:a37:97c1:: with SMTP id z184mr12548104qkd.39.1547204572133; Fri, 11 Jan 2019 03:02:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204572; cv=none; d=google.com; s=arc-20160816; b=gF2ybc3oeRs63KJ1YPZQTg2B9EgBbP7c70oLlWFGI5XfoZpne2NIuPixn2svJusY6i wpZo4N182c5CEvNrDKieQi066NIhdo1Xh4GxYdiJnz5hbd0IjqvAcuMBP8i4QIX2u5V2 ALiA1StHjP2nW68TQGBbRHeTxSM3s1pD8Px2AFYvvoop3MPq3oGg+yr8aD5AekYzuBjT tB5IfuTLVBz8vdJSKl2L4ssWVtYZMq8hUtzqqDSQBbeb1upXlyn2mP00PSPJGdC4yhwJ pKzAPeWhSujLCPZyBe/udGNG1XUOiWQJV7oTYYCRD04CdloHX72kBcMSJNMwXbA2kSP2 8QnA== 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=WViSAVM/NAOuf5wj1zWFpiKtQ8lTX45iJq+VzBW7mSc=; b=F5CWUP2ijjg0X6NfNYyGPqf+BBcTGRR/WXzZJ8CTaY2gYUvtJ8YfmJy1fMc1dbTLNv i4+ZQghfA2y2NLrmj/tGbzcDojwv+ed3KRPYlPU6zDNBld8kCOTaCJrux0+KO4kulgRE kMccB3ygXmkS6BNPX+MPCh6JRXTabO2VaxtG2OJacYMm2tXdkARBUlaFjoVQXWNeCzUH 1Er/FdxlBRRV9jqRdm4ft+yn8RedNuvciRGWLlU7/vg28ScmQYuvQxn/BhHIVE0kXtws AvbC1u1e9EYk5poZ04kaJgx82hnXUp9akxkd7ZCfgFh29IGzC1Dh9vagu3eEvRatF80o 8shg== 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 v7si2375861qvl.15.2019.01.11.03.02.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:02:52 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 0CA8C89AC2; Fri, 11 Jan 2019 11:02:51 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D5695D738; Fri, 11 Jan 2019 11:02:31 +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 V13 04/19] block: rename bvec helpers Date: Fri, 11 Jan 2019 19:01:12 +0800 Message-Id: <20190111110127.21664-5-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.26]); Fri, 11 Jan 2019 11:02:51 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We will support multi-page bvec soon, and have to deal with single-page vs multi-page bvec. This patch follows Christoph's suggestion to rename all the following helpers: for_each_bvec bvec_iter_bvec bvec_iter_len bvec_iter_page bvec_iter_offset into: for_each_segment segment_iter_bvec segment_iter_len segment_iter_page segment_iter_offset so that these helpers named with 'segment' only deal with single-page bvec, or called segment. We will introduce helpers named with 'bvec' for multi-page bvec. bvec_iter_advance() isn't renamed becasue this helper is always operated on real bvec even though multi-page bvec is supported. Acked-by: Miguel Ojeda Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Suggested-by: Christoph Hellwig Signed-off-by: Ming Lei --- .clang-format | 2 +- drivers/md/dm-integrity.c | 2 +- drivers/md/dm-io.c | 4 ++-- drivers/nvdimm/blk.c | 4 ++-- drivers/nvdimm/btt.c | 4 ++-- include/linux/bio.h | 10 +++++----- include/linux/bvec.h | 20 +++++++++++--------- include/linux/ceph/messenger.h | 2 +- lib/iov_iter.c | 2 +- net/ceph/messenger.c | 14 +++++++------- 10 files changed, 33 insertions(+), 31 deletions(-) diff --git a/.clang-format b/.clang-format index e6080f5834a3..049200fbab94 100644 --- a/.clang-format +++ b/.clang-format @@ -120,7 +120,7 @@ ForEachMacros: - 'for_each_available_child_of_node' - 'for_each_bio' - 'for_each_board_func_rsrc' - - 'for_each_bvec' + - 'for_each_segment' - 'for_each_child_of_node' - 'for_each_clear_bit' - 'for_each_clear_bit_from' diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 457200ca6287..046b7785e3f6 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -1574,7 +1574,7 @@ static bool __journal_read_write(struct dm_integrity_io *dio, struct bio *bio, char *tag_ptr = journal_entry_tag(ic, je); if (bip) do { - struct bio_vec biv = bvec_iter_bvec(bip->bip_vec, bip->bip_iter); + struct bio_vec biv = segment_iter_bvec(bip->bip_vec, bip->bip_iter); unsigned tag_now = min(biv.bv_len, tag_todo); char *tag_addr; BUG_ON(PageHighMem(biv.bv_page)); diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index 81ffc59d05c9..d72ec2bdd333 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c @@ -208,8 +208,8 @@ static void list_dp_init(struct dpages *dp, struct page_list *pl, unsigned offse static void bio_get_page(struct dpages *dp, struct page **p, unsigned long *len, unsigned *offset) { - struct bio_vec bvec = bvec_iter_bvec((struct bio_vec *)dp->context_ptr, - dp->context_bi); + struct bio_vec bvec = segment_iter_bvec((struct bio_vec *)dp->context_ptr, + dp->context_bi); *p = bvec.bv_page; *len = bvec.bv_len; diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c index db45c6bbb7bb..dfae945216bb 100644 --- a/drivers/nvdimm/blk.c +++ b/drivers/nvdimm/blk.c @@ -89,9 +89,9 @@ static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk, struct bio_vec bv; void *iobuf; - bv = bvec_iter_bvec(bip->bip_vec, bip->bip_iter); + bv = segment_iter_bvec(bip->bip_vec, bip->bip_iter); /* - * The 'bv' obtained from bvec_iter_bvec has its .bv_len and + * The 'bv' obtained from segment_iter_bvec has its .bv_len and * .bv_offset already adjusted for iter->bi_bvec_done, and we * can use those directly */ diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index b123b0dcf274..2bbbc90c7b91 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1154,9 +1154,9 @@ static int btt_rw_integrity(struct btt *btt, struct bio_integrity_payload *bip, struct bio_vec bv; void *mem; - bv = bvec_iter_bvec(bip->bip_vec, bip->bip_iter); + bv = segment_iter_bvec(bip->bip_vec, bip->bip_iter); /* - * The 'bv' obtained from bvec_iter_bvec has its .bv_len and + * The 'bv' obtained from segment_iter_bvec has its .bv_len and * .bv_offset already adjusted for iter->bi_bvec_done, and we * can use those directly */ diff --git a/include/linux/bio.h b/include/linux/bio.h index 72b4f7be2106..16a65361535f 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -48,14 +48,14 @@ #define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio) #define bio_iter_iovec(bio, iter) \ - bvec_iter_bvec((bio)->bi_io_vec, (iter)) + segment_iter_bvec((bio)->bi_io_vec, (iter)) #define bio_iter_page(bio, iter) \ - bvec_iter_page((bio)->bi_io_vec, (iter)) + segment_iter_page((bio)->bi_io_vec, (iter)) #define bio_iter_len(bio, iter) \ - bvec_iter_len((bio)->bi_io_vec, (iter)) + segment_iter_len((bio)->bi_io_vec, (iter)) #define bio_iter_offset(bio, iter) \ - bvec_iter_offset((bio)->bi_io_vec, (iter)) + segment_iter_offset((bio)->bi_io_vec, (iter)) #define bio_page(bio) bio_iter_page((bio), (bio)->bi_iter) #define bio_offset(bio) bio_iter_offset((bio), (bio)->bi_iter) @@ -738,7 +738,7 @@ static inline bool bioset_initialized(struct bio_set *bs) #if defined(CONFIG_BLK_DEV_INTEGRITY) #define bip_for_each_vec(bvl, bip, iter) \ - for_each_bvec(bvl, (bip)->bip_vec, iter, (bip)->bip_iter) + for_each_segment(bvl, (bip)->bip_vec, iter, (bip)->bip_iter) #define bio_for_each_integrity_vec(_bvl, _bio, _iter) \ for_each_bio(_bio) \ diff --git a/include/linux/bvec.h b/include/linux/bvec.h index ba0ae40e77c9..716a87b26a6a 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -50,23 +50,25 @@ struct bvec_iter { */ #define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) -#define bvec_iter_page(bvec, iter) \ +#define segment_iter_page(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_page) -#define bvec_iter_len(bvec, iter) \ +#define segment_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 segment_iter_offset(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) -#define bvec_iter_bvec(bvec, iter) \ +#define segment_iter_bvec(bvec, iter) \ ((struct bio_vec) { \ - .bv_page = bvec_iter_page((bvec), (iter)), \ - .bv_len = bvec_iter_len((bvec), (iter)), \ - .bv_offset = bvec_iter_offset((bvec), (iter)), \ + .bv_page = segment_iter_page((bvec), (iter)), \ + .bv_len = segment_iter_len((bvec), (iter)), \ + .bv_offset = segment_iter_offset((bvec), (iter)), \ }) +#define bvec_iter_len segment_iter_len + static inline bool bvec_iter_advance(const struct bio_vec *bv, struct bvec_iter *iter, unsigned bytes) { @@ -92,10 +94,10 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, return true; } -#define for_each_bvec(bvl, bio_vec, iter, start) \ +#define for_each_segment(bvl, bio_vec, iter, start) \ for (iter = (start); \ (iter).bi_size && \ - ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \ + ((bvl = segment_iter_bvec((bio_vec), (iter))), 1); \ bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len)) /* for iterating one bio from start to end */ diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h index 800a2128d411..c7e37a7229c4 100644 --- a/include/linux/ceph/messenger.h +++ b/include/linux/ceph/messenger.h @@ -155,7 +155,7 @@ struct ceph_bvec_iter { \ __cur_iter = (it)->iter; \ __cur_iter.bi_size = (n); \ - for_each_bvec(bv, (it)->bvecs, __cur_iter, __cur_iter) \ + for_each_segment(bv, (it)->bvecs, __cur_iter, __cur_iter) \ (void)(BVEC_STEP); \ })) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index be4bd627caf0..017eba58489c 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -66,7 +66,7 @@ __start.bi_size = n; \ __start.bi_bvec_done = skip; \ __start.bi_idx = 0; \ - for_each_bvec(__v, i->bvec, __bi, __start) { \ + for_each_segment(__v, i->bvec, __bi, __start) { \ if (!__v.bv_len) \ continue; \ (void)(STEP); \ diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index d5718284db57..7cda449752b1 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -878,17 +878,17 @@ static void ceph_msg_data_bvecs_cursor_init(struct ceph_msg_data_cursor *cursor, cursor->bvec_iter = data->bvec_pos.iter; cursor->bvec_iter.bi_size = cursor->resid; - BUG_ON(cursor->resid < bvec_iter_len(bvecs, cursor->bvec_iter)); + BUG_ON(cursor->resid < segment_iter_len(bvecs, cursor->bvec_iter)); cursor->last_piece = - cursor->resid == bvec_iter_len(bvecs, cursor->bvec_iter); + cursor->resid == segment_iter_len(bvecs, cursor->bvec_iter); } static struct page *ceph_msg_data_bvecs_next(struct ceph_msg_data_cursor *cursor, size_t *page_offset, size_t *length) { - struct bio_vec bv = bvec_iter_bvec(cursor->data->bvec_pos.bvecs, - cursor->bvec_iter); + struct bio_vec bv = segment_iter_bvec(cursor->data->bvec_pos.bvecs, + cursor->bvec_iter); *page_offset = bv.bv_offset; *length = bv.bv_len; @@ -901,7 +901,7 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor, struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs; BUG_ON(bytes > cursor->resid); - BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter)); + BUG_ON(bytes > segment_iter_len(bvecs, cursor->bvec_iter)); cursor->resid -= bytes; bvec_iter_advance(bvecs, &cursor->bvec_iter, bytes); @@ -914,9 +914,9 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor, return false; /* more bytes to process in this segment */ BUG_ON(cursor->last_piece); - BUG_ON(cursor->resid < bvec_iter_len(bvecs, cursor->bvec_iter)); + BUG_ON(cursor->resid < segment_iter_len(bvecs, cursor->bvec_iter)); cursor->last_piece = - cursor->resid == bvec_iter_len(bvecs, cursor->bvec_iter); + cursor->resid == segment_iter_len(bvecs, cursor->bvec_iter); return true; } From patchwork Fri Jan 11 11:01:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757683 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 4F4061515 for ; Fri, 11 Jan 2019 11:03:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4031129C3B for ; Fri, 11 Jan 2019 11:03:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3353B29C53; Fri, 11 Jan 2019 11:03:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD6EA29C4D for ; Fri, 11 Jan 2019 11:03:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C28368E0007; Fri, 11 Jan 2019 06:03:11 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD7078E0001; Fri, 11 Jan 2019 06:03:11 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC61B8E0007; Fri, 11 Jan 2019 06:03:11 -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 847FB8E0001 for ; Fri, 11 Jan 2019 06:03:11 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id u32so16313724qte.1 for ; Fri, 11 Jan 2019 03:03:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=G8vlK5fTgPdKG8GwH3WjVGRyxTzVLYwFzbdjiyTWY4A=; b=JHoojOMhq/OyzWetR1mJb4AsPXOQlVGBsO5fJfZqdbEj1Yx3V9T3UjMUcWhd3l2AJL QUh6qY7zqS8pzVpXh88JxgDfXuLo6l8Tc36QHfOt5dq3v7qW05B8PVCFSykPgBXk0paU Wj/jma8r5CLAhfk1kl910ZBwNaSFSIQ3ae3OOd6FV0PVY2HI6JNtIZgC2Z0E2OtzBmhz vJ4MKPjijmQonTrA92wbIc+K0tdXqp0Ixa/aYDQCTkBY8eh6/mkNs3Q6igJbSRpuyLUu XCwQ+3UC22uPextJ7oR1jkwgpaxeNQQ7ksxZuWs7sxRly/29QTOpeTgEoB+1e3FOM30h K9tw== 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: AJcUukeABkX9WSUfAqcq1biey4tdfdnX6JaKUo313SzaqGcjil6vgQoV 4EQwt/n5Wt01b8+skrh+5Abpl/E8gQPB0y7Vci+AH5b0TJGIuhKZ+Nm1KsHHuFhQd3LKtQ6JtA2 oD0ebsQhEYuiDeRqjFp9xZUFBXuzPyymd0T6P/3TUS7Ad6Mb93RnXvnBKBGMfG2e5XA== X-Received: by 2002:ac8:1a08:: with SMTP id v8mr12790649qtj.362.1547204591312; Fri, 11 Jan 2019 03:03:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN4BCTZBnnup2DhYwToUA1axIKJwy8MlkWbMY9JHGpGeypELcJGAegvnw2qQ4oRcVxD64uSI X-Received: by 2002:ac8:1a08:: with SMTP id v8mr12790617qtj.362.1547204590697; Fri, 11 Jan 2019 03:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204590; cv=none; d=google.com; s=arc-20160816; b=NksN8AwkoFUlWEvroiM4EFa9O4JHbavroVMxcBkhYDYjNClhjqwC2K4TdDafLSrpIm 6wmHXj6iD7LnO09EPzyfudfmUKaZcCVGZ/oBj/KwkypJsaznIqNDVjTRFJrEFkOOtk0F +VSQFn3Hc9qSekGL1zI48SivzyeDLseg6kM7jjHY6nnoUvqovuwO01LmI4Ii/HU3Zj0D YUlNwjhNqLzRi+C5fjnWLlATUO5N399Y0/I/J4FEn86/3gTmGPP7YMeGIHrRKGJ5Xr0K FgrP8DOo4hFCWzPvooTC2lnQFJOZD8LhOBBO0CgCMVGnal7v1IavGvLr+47vW8nM9q/A aYAw== 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=G8vlK5fTgPdKG8GwH3WjVGRyxTzVLYwFzbdjiyTWY4A=; b=smDX7zr60aK7RU2hKb+rTZLsVjJsUtIKyzKUsHAp9CgecG1OGtESmmlR0zo1DJUBFj TAPHSzesc3LhV/jCBNLhkxC27zObYxMKj+3ZHnRtX+puSTAxKZk4uSEFz7zR/0ZxLIt+ oESOqPnbPZvkQJY2VKH94LkZFMH34dnTTPpl5CnHHEqiL3OXhBKsfkdMxtntgP0kAcpO SXAzQQNCutfrNVi9iaw93gb/sdIfoxDpwd0GzkNWMCojSwPMtjsyeR4U5kNlW7DP6eEa UtF5HIO+TB4UEkQqGAL3P6hP+fJP+scYPO3f3LPzFKgo1XUZ8lSAYdTebuItdNHj+tuW 0ckw== 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 z2si8779353qtf.343.2019.01.11.03.03.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:03:10 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 4F9972D7E0; Fri, 11 Jan 2019 11:03:09 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E06717DFE; Fri, 11 Jan 2019 11:02:53 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com, Ming Lei Subject: [PATCH V13 05/19] block: introduce multi-page bvec helpers Date: Fri, 11 Jan 2019 19:01:13 +0800 Message-Id: <20190111110127.21664-6-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.30]); Fri, 11 Jan 2019 11:03:09 +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 '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 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 716a87b26a6a..babc6316c117 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,32 @@ struct bvec_iter { */ #define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) -#define segment_iter_page(bvec, iter) \ +/* multi-page (segment) helpers */ +#define bvec_iter_page(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_page) -#define segment_iter_len(bvec, iter) \ +#define bvec_iter_len(bvec, iter) \ min((iter).bi_size, \ __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done) -#define segment_iter_offset(bvec, iter) \ +#define bvec_iter_offset(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) +#define bvec_iter_page_idx(bvec, iter) \ + (bvec_iter_offset((bvec), (iter)) / PAGE_SIZE) + +/* For building single-page bvec(segment) in flight */ + #define segment_iter_offset(bvec, iter) \ + (bvec_iter_offset((bvec), (iter)) % PAGE_SIZE) + +#define segment_iter_len(bvec, iter) \ + min_t(unsigned, bvec_iter_len((bvec), (iter)), \ + PAGE_SIZE - segment_iter_offset((bvec), (iter))) + +#define segment_iter_page(bvec, iter) \ + nth_page(bvec_iter_page((bvec), (iter)), \ + bvec_iter_page_idx((bvec), (iter))) + #define segment_iter_bvec(bvec, iter) \ ((struct bio_vec) { \ .bv_page = segment_iter_page((bvec), (iter)), \ @@ -67,8 +84,6 @@ struct bvec_iter { .bv_offset = segment_iter_offset((bvec), (iter)), \ }) -#define bvec_iter_len segment_iter_len - static inline bool bvec_iter_advance(const struct bio_vec *bv, struct bvec_iter *iter, unsigned bytes) { From patchwork Fri Jan 11 11:01:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757693 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 97B146C5 for ; Fri, 11 Jan 2019 11:03:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89EEB29B7F for ; Fri, 11 Jan 2019 11:03:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E30529C0E; Fri, 11 Jan 2019 11:03:27 +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 1626929B7F for ; Fri, 11 Jan 2019 11:03:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3274C8E0008; Fri, 11 Jan 2019 06:03:26 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2D5D68E0001; Fri, 11 Jan 2019 06:03: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 1C68C8E0008; Fri, 11 Jan 2019 06:03: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 E33D18E0001 for ; Fri, 11 Jan 2019 06:03:25 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id 42so15970234qtr.7 for ; Fri, 11 Jan 2019 03:03:25 -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=rGjI+V/4rg/dWoUNu9x64XeJFFqTvq16W4s9QZuA0vA=; b=Af+6lD9xyI0cpyU0VKH0MKeOZNVu5Yh/2HP/f2EW8vHQ1IKetHA0YTPKdbJqi3jn/k NxpHjiDiwy0DWepxipu+pR+AGssrrODOqj3v85uI7jVLycwiWspTrhwpPI9OCb1f1C// hlzR4Stpn1Wlv2zEs7AB+e84t+8PsbTEh2V/GUjuiKpeuH32zy9cCiLh5ZZxHR5qSivi Z5meCK93KIbLk9P86e07Y7a0xsuxM4sD2g7eiS1WNCUyMDHJtz3UjtA2xg74kpCr9iY0 Tei0liLGNa4nGU0u0T5BKc8WZur1aarWOUitEtkMlQYGDGu+oNcdrC7bxyO7yQkOpfA/ OPOw== 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: AJcUukeWiCHHF4NkWtjs5FiYHBuUaKveK+Z/Am5C1BMwH+tLAqiGP7za S1uwdDV/Yf4I6FDRQqHSSy6lvrNP+2SVcqHgUSAmeUL3VSYhHBfTvpuVUMKfy0+gGkbbhoAA1vR a7d+vYBCF4p6FqmosImbONxMR7CFbBsKJ3qCPzY+GTzroC0sWWhyF1avQmmI/5Xfj9g== X-Received: by 2002:ac8:e0b:: with SMTP id a11mr13580511qti.140.1547204605711; Fri, 11 Jan 2019 03:03:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN4aky3WcCouA3OMm1r1tSsnQUiVuJKn0QRu1B1uZDpfAxA/gyYcNVE8gNQn9qM/Jsd9Flw8 X-Received: by 2002:ac8:e0b:: with SMTP id a11mr13580494qti.140.1547204605213; Fri, 11 Jan 2019 03:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204605; cv=none; d=google.com; s=arc-20160816; b=ggHUbhirYkwEXlmjRPNv3xK9DtbQjFwrNcLG4ljnNxKo4ksEJ56qEvhhIhi3t49qZZ L/hath9yu9J8pO3B3crF/6sclmk4XvbacDdMZ452Bcy8KL6kYmLdHar9xbSar3jvlJAl UViPpWDgASFBx/OsJERKTn+ZnLWcbHmlTqHSPMyJ3PV0gF5O1RZpXOZSsZjhxczH1EDd vJy5WKn5rhFbjE9S3q+jdfnERl2ckpk8tVcDRjNnWOSLlMQkFY+7y2tHqItRxivVIhZM qu3DaOunmBiKA9hLzHUWRt/VC7Tkwe5KL5cYYNocT/w8B1wscTlddmLfkFWs++iS8Hk2 Wobg== 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=rGjI+V/4rg/dWoUNu9x64XeJFFqTvq16W4s9QZuA0vA=; b=YL13dAg1njf/fTRLu/e56UYeQrK3UTW5pn7iOGuRwYf/Kg1ebSRpmfd11tvaIjbDyZ HoqHAbSFsI3YCyszv9aO+kFxIub+jmkbqJx5fn0TnQ6FqIX4tkVAdtHmd37m77IjH6OP usH2TI5wELPytP0fuYwudeXAl0w5zG5hTMfWNYnLK1P8aBH2HjlIaP7Bc4UZdCB5t9vs hzG3iG4oAH90vnhCqnOvf6MsiiDGM0MWvpM89JOTAQVUvnbL/lEa/4TYdBEs/pA92ZQ2 f5CmC9eEa/RB9+UXlEIYMIXmmmzR/TJluV4nSSCm7M7cpip+danoZ3ktL2XGw9CC74KI XSqw== 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 r72si1385583qkl.162.2019.01.11.03.03.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:03: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-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 0DCC8432D0; Fri, 11 Jan 2019 11:03:24 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id A73E1600C4; Fri, 11 Jan 2019 11:03:11 +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 V13 06/19] block: introduce bio_for_each_bvec() and rq_for_each_bvec() Date: Fri, 11 Jan 2019 19:01:14 +0800 Message-Id: <20190111110127.21664-7-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.30]); Fri, 11 Jan 2019 11:03: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 bio_for_each_bvec() is used for iterating over multi-page bvec for bio split & merge code. rq_for_each_bvec() can be used for drivers which may handle the multi-page bvec directly, so far loop is one perfect use case. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- include/linux/bio.h | 10 ++++++++++ include/linux/blkdev.h | 4 ++++ include/linux/bvec.h | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index 16a65361535f..06888d45beb4 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -156,6 +156,16 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, #define bio_for_each_segment(bvl, bio, iter) \ __bio_for_each_segment(bvl, bio, iter, (bio)->bi_iter) +#define __bio_for_each_bvec(bvl, bio, iter, start) \ + for (iter = (start); \ + (iter).bi_size && \ + ((bvl = bvec_iter_bvec((bio)->bi_io_vec, (iter))), 1); \ + bio_advance_iter((bio), &(iter), (bvl).bv_len)) + +/* iterate over multi-page bvec */ +#define bio_for_each_bvec(bvl, bio, iter) \ + __bio_for_each_bvec(bvl, bio, iter, (bio)->bi_iter) + #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len) static inline unsigned bio_segments(struct bio *bio) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 338604dff7d0..7f4ca073e2f3 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_bvec(bvl, _rq, _iter) \ + __rq_for_each_bio(_iter.bio, _rq) \ + bio_for_each_bvec(bvl, _iter.bio, _iter.iter) + #define rq_iter_last(bvec, _iter) \ (_iter.bio->bi_next == NULL && \ bio_iter_last(bvec, _iter.iter)) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index babc6316c117..d441486db605 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -65,6 +65,13 @@ struct bvec_iter { #define bvec_iter_page_idx(bvec, iter) \ (bvec_iter_offset((bvec), (iter)) / PAGE_SIZE) +#define bvec_iter_bvec(bvec, iter) \ +((struct bio_vec) { \ + .bv_page = bvec_iter_page((bvec), (iter)), \ + .bv_len = bvec_iter_len((bvec), (iter)), \ + .bv_offset = bvec_iter_offset((bvec), (iter)), \ +}) + /* For building single-page bvec(segment) in flight */ #define segment_iter_offset(bvec, iter) \ (bvec_iter_offset((bvec), (iter)) % PAGE_SIZE) From patchwork Fri Jan 11 11:01:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757705 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 0AE4A1515 for ; Fri, 11 Jan 2019 11:03:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0C3A29C07 for ; Fri, 11 Jan 2019 11:03:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4AB229C0E; Fri, 11 Jan 2019 11:03:39 +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 4EB9D29C07 for ; Fri, 11 Jan 2019 11:03:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A8828E0009; Fri, 11 Jan 2019 06:03:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 657F78E0001; Fri, 11 Jan 2019 06:03: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 56F278E0009; Fri, 11 Jan 2019 06:03:38 -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 2FD2F8E0001 for ; Fri, 11 Jan 2019 06:03:38 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id n39so15928591qtn.18 for ; Fri, 11 Jan 2019 03:03: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=QdLd93Jb3gVSIaMuMlz5f3nxe2ES1ehL7zzHVfeXmV8=; b=QDq2SXScw2677rF+B0DtGX0Eqf7Ut75JoWUAxUNMS/o7VGUWwRUK7ub/MxGuyMSnbp ASW5G0vodth/TC+R7aKZ5uUqwN7My0+zVVOuKptiK+2kkVN05OJn/SAM9rEm4bBnnx2d n5gnk5zhtkKPFHS6fJKLFlSF3nu+gZp0izficBfaS8auf+JFJPYPEg5bRqBG0y3ohtTG ornz+JSq+3O4DRMpikjKPdysLTN7vf/w7UTuq2wbDGoVjViwVWeZK/dKugwbW99tYOv/ KHWIq/twNcCbBlciPQ2UsyoaAJTScOAwNb2wjqQWPXBV8JRaMrBgPi2WzeU/6BqZRBdJ E4/g== 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: AJcUukepJbBi37nwSjuOOgnpTyAufb+aJM2jrn5LJ0Hb5FHi0crPHYFl REgqlBbmd9jG+T+f8hWRLeMDBexYlBOzNzo6rnpHYdW+wDZIaj/aoir/ughM4kujRz4WZLq0DS0 4PbUTa9a0P2QhKnzzbeKcsBBYt9kObl3ZPi3hNkEZ34WHiNNPbjfAEQ+MPLtj1F87ag== X-Received: by 2002:a0c:afd1:: with SMTP id t17mr13314509qvc.93.1547204617957; Fri, 11 Jan 2019 03:03:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN5K35BPiId59YbSJuzLTfSkieWw08UpNZxXhjaXGBGulNSwO+lL0r6gwfyeui+YG65QU5mi X-Received: by 2002:a0c:afd1:: with SMTP id t17mr13314470qvc.93.1547204617316; Fri, 11 Jan 2019 03:03:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204617; cv=none; d=google.com; s=arc-20160816; b=J1NG1uh+1UDYce7rwjxm+olKoRgAK83qmRoG7nq+pDTTr2i1Cpuq8QL3w+1v62Yv/t AW27Du6TLbdeTJ/VFW4aPV6T1agsiEUlJD2KeQmGge+iLIMAUrGr9mhzTOtJdhSJh1WR vC1qSJEKLyfA+rsuTnhyursgCzlsFKyXPA5OWTDN7i3S1WssKE8gUjjlmasywVdOQN0c JN4OOffgh0J0w55OEkFYZHySnCG0NgjKg7hD4qpN2uF7HOkjPYivTaqOFwiACkIzUCRu hg68C+kgOmImSS4C84O/9f9thdoU8WFuiCe6djuK6tnsbYCahGVPVBNSfpb2hnCdpfxG dvGw== 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=QdLd93Jb3gVSIaMuMlz5f3nxe2ES1ehL7zzHVfeXmV8=; b=n2QycnzlFMeWROYiDyyJ3dQxb+fUR+lw/DA/L17ZVhGO+158REPxQLMhIsVziAsbsX l8WtCyyLlt0nPJrfjOlbg3EcsvW+nWaJd4LT6igPI01zABVBJDZUHDPRMIYzshEGvB/0 wsaTjgkSCat1q0rD1qHLGITPyPxUwj7FiRFDWgvrvLCfa7KwfNygEFVeq7Y0ytCijr+C NvIpGFJRSvi+12C8j4e76m1VUtqY+RlDI1GeA8sksuqhpK8+pf/ZjjfKtvcy8ZjFdcA6 W83iwRKygxuXBiaR1xfOj1lxQUZPhKeeGtfk4n7LRKIyKVzd6sT9/7f/hEUlrGLY/m5d qwYg== 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 k124si1342834qkd.2.2019.01.11.03.03.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:03: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-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 40A661F8EC; Fri, 11 Jan 2019 11:03:36 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DA3B1059580; Fri, 11 Jan 2019 11:03:26 +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 V13 07/19] block: use bio_for_each_bvec() to compute multi-page bvec count Date: Fri, 11 Jan 2019 19:01:15 +0800 Message-Id: <20190111110127.21664-8-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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]); Fri, 11 Jan 2019 11:03: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 First it is more efficient to use bio_for_each_bvec() in both blk_bio_segment_split() and __blk_recalc_rq_segments() to compute how many multi-page bvecs there are in the bio. Secondly once bio_for_each_bvec() is used, the bvec may need to be splitted because its length can be very longer than max segment size, so we have to split the big bvec into several segments. Thirdly when splitting multi-page bvec into segments, the max segment limit may be reached, so the bio split need to be considered under this situation too. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- block/blk-merge.c | 99 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 20 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index f85d878f313d..abe1c89c1253 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -161,6 +161,69 @@ 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); + + 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 +237,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, struct bio *new = NULL; const unsigned max_sectors = get_max_io_size(q, bio); - bio_for_each_segment(bv, bio, iter) { + bio_for_each_bvec(bv, bio, iter) { /* * If the queue doesn't support SG gaps and adding this * offset would create a gap, disallow it. @@ -189,8 +252,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 +279,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 +298,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 +360,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 +380,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, seg_size = 0; nr_phys_segs = 0; for_each_bio(bio) { - bio_for_each_segment(bv, bio, iter) { + bio_for_each_bvec(bv, bio, iter) { /* * If SG merging is disabled, each bio vector is * a segment @@ -336,20 +400,15 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, continue; } new_segment: - if (nr_phys_segs == 1 && seg_size > - fbio->bi_seg_front_size) - fbio->bi_seg_front_size = seg_size; - - nr_phys_segs++; bvprv = bv; prev = 1; - seg_size = bv.bv_len; + bvec_split_segs(q, &bv, &nr_phys_segs, &seg_size, + &front_seg_size, NULL); } bbio = bio; } - if (nr_phys_segs == 1 && seg_size > fbio->bi_seg_front_size) - fbio->bi_seg_front_size = seg_size; + fbio->bi_seg_front_size = front_seg_size; if (seg_size > bbio->bi_seg_back_size) bbio->bi_seg_back_size = seg_size; From patchwork Fri Jan 11 11:01:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757717 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 74A896C5 for ; Fri, 11 Jan 2019 11:03:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65D40297AD for ; Fri, 11 Jan 2019 11:03:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5905729AFF; Fri, 11 Jan 2019 11:03:55 +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 E6727297AD for ; Fri, 11 Jan 2019 11:03:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B5958E000A; Fri, 11 Jan 2019 06:03:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0663B8E0001; Fri, 11 Jan 2019 06:03:54 -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 E96EA8E000A; Fri, 11 Jan 2019 06:03:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id C108D8E0001 for ; Fri, 11 Jan 2019 06:03:53 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id p24so16257027qtl.2 for ; Fri, 11 Jan 2019 03:03:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=dv2zTT5j9Kliwl2a1KtuPlUD/HGSgxeCq2uXhV+cA1s=; b=ecgV99zgUPpSaxdChTzysrkjQ+9JR5WSOLNxas9H+uoHQ0XNh5aclMmwlTz24JXRHH XrWf+TKcfdiO5yiBHpgyIo6851mACJAQpQZF24JFhQZDyL1TCdLAB0rLL/0gFH0P2S0q 4PR/teepeELSW9LnsZCOjJ2xs8Q71tHbDwG3I9B7c7KKTeQomZXtZeL3OBByMCi7V6q5 T/Mr7vWPxCDd1o4BsRyyKFtKCqSxg75JhB3fI9FWU04nfeJPBZe1h1+mRqB0MqsOF+Bc 5lV+XwG9BnQUmYLybe+q6z0RPNsxYcy40f1hCL0yChEWOPmSS/Tl5vzk962oV2xrYEEh 5dRw== 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: AJcUukecrVCJhU4VqTu3ojBbaVCW5WD54hXNwmkFBfvUHcVg4KGqqEp2 QiPMODMA5bafLzpd9OjkCv9epO7Y+NI3rO/mmlosHLmAVfF0L6uZvBgdDk35q9hB+rG6g73wdDN YnX3k5ycAIEMAmEMEb9DkKHTM2OoBopSzoM53hluhjgEMZtJetg80h0GXJjIWsHxKZQ== X-Received: by 2002:a0c:aa56:: with SMTP id e22mr13746266qvb.158.1547204633554; Fri, 11 Jan 2019 03:03:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN55zppJ1zkUNlh/oou3mAgx+RW1Q2BE9uRf68FPOZd9WyaSvdVx5uP9MqUCKJKbZGJqttxx X-Received: by 2002:a0c:aa56:: with SMTP id e22mr13746229qvb.158.1547204632952; Fri, 11 Jan 2019 03:03:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204632; cv=none; d=google.com; s=arc-20160816; b=c06+O7BLUKLwjy+udMfsazU2ZamQn2wl4zBGrWWmYMI1W86GVydFqpQX4KRPt1oeIX GUTyr1An5ZjZjw8mVp40to5sLOWhz00YJopgs0Xoz+SDVLgr1CgWBok/qzGKwP5jyjjs /5W2YZy/bmjbvRJo63z4NteV6RDTKDislTVriB+THyKHbC0CNcIV8tQuakzrZyBW8lFU M7ejMaxqcCFnK48CBchmsKONQDzv0Ny4PKr20I39ro1q4/GbEjK5anL6pLXFadVql+i/ Q6E58a8Elqu06C4V1E2JQYbCuVguS8/7z17n+8pcgtRAvRHpUStkhFdU7VaGwiaf1ROq kwZg== 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=dv2zTT5j9Kliwl2a1KtuPlUD/HGSgxeCq2uXhV+cA1s=; b=jjQFoMH+Aw8H5kwxHN0JIocwyl5jfWFBCQwM4jH2NvKkjFNrxNkwT90d5aHW9Y9+P+ OZFBpdNM/icBxSbWqqFkuEADoFsgHrm2W+1G4IsXrUlES8Uze3bLLRQS/PL8qWc97EWb sox22Drw8warPVGRyjsVoP48zlkf9Xi5dNRsRku7+pHrZJ12LPDIZ8slTnf2H5LICTY3 BJOyQ3pfA1SeIRA8dRBUsiV7uN0/MGtbeuJmj11AK9r2DauM1hg9FjHH106ATLcQ1UJ/ EqZH43HDGPKV7o55VdabWALk6Ye6P/JiVu3EObZrfrExdUskECw4psz/7pBCyxGBiIlk 509g== 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 v6si3022376qte.364.2019.01.11.03.03.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:03:52 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A2DF824C9D; Fri, 11 Jan 2019 11:03:51 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8656B27C57; Fri, 11 Jan 2019 11:03: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 V13 08/19] block: use bio_for_each_bvec() to map sg Date: Fri, 11 Jan 2019 19:01:16 +0800 Message-Id: <20190111110127.21664-9-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 11 Jan 2019 11:03:52 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It is more efficient to use bio_for_each_bvec() to map sg, meantime we have to consider splitting multipage bvec as done in blk_bio_segment_split(). Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- block/blk-merge.c | 70 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index abe1c89c1253..bf736d2b3710 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -460,6 +460,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, @@ -477,25 +525,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; } @@ -517,7 +547,7 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, int nsegs = 0; for_each_bio(bio) - bio_for_each_segment(bvec, bio, iter) + bio_for_each_bvec(bvec, bio, iter) __blk_segment_map_sg(q, &bvec, sglist, &bvprv, sg, &nsegs); From patchwork Fri Jan 11 11:01:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757727 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 579DC6C5 for ; Fri, 11 Jan 2019 11:04:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 469C9297AD for ; Fri, 11 Jan 2019 11:04:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A7B229AFF; Fri, 11 Jan 2019 11:04:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4099297AD for ; Fri, 11 Jan 2019 11:04:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D86418E000B; Fri, 11 Jan 2019 06:04:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D358F8E0001; Fri, 11 Jan 2019 06:04: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 C26018E000B; Fri, 11 Jan 2019 06:04: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 955848E0001 for ; Fri, 11 Jan 2019 06:04:06 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id z6so16114396qtj.21 for ; Fri, 11 Jan 2019 03:04: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=NqRnUsjWXdLCn3+BBd1E+TE68uZNAdSmdjd3DOkgrrI=; b=rVuv8G5IzGIxz80i47kF2LMs1DUZBo46LCTYPEmo6r22O1mG3LJrjsBMsKt24Nduvl vZxB6uxV5L1GuDgveun1vWEhiBvaD4UkcJUfxsZxq5Khj6dWf1vbQC/2tESZULaMm26e G/9OukPRkk2hX3ap4dUvwvHJDCiz0YJFj+XBQGD1XvSfq4xpmwz9cfUd6Eh++9zIAZi4 wDt2hMvPBsNdQEAUblwPxFBBmg/svkqwMJSGGdZ4qsyCvvvBmg/I6prgmF2AUknm7/PU CSrKEqN1FvIKspec0Q/WF2RjiO+k3+UNJ2XycDHJ6XBwqfkKg0yf8Yl42VqJR34Mr3RO rmHQ== 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: AJcUukfP7ISJ+JRDvd/+AmVKzm9HdqbmWJwVAJOHeL3gA7pes64rahMT YVc4oXXF7RPm8QUNrXvVBSuRcFgQQCqdoU/kJUUZp8naKgldIqNEN/4iL2HyQWtSmD/DSu5yisv QsL9Sg3ClVXXfk+JD7WifiJuJCaD+tgRj7TOxkNnsPP5jmgok4pt7n9djYPXBok6rTA== X-Received: by 2002:a0c:9e05:: with SMTP id p5mr13259077qve.246.1547204646396; Fri, 11 Jan 2019 03:04:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN6rKFCOdzZd/PP/e0s/KH+DiKuEKFYFfqxNwjMzXb+63r9Lg34YS3vEIAWHuUzjC+asr9K0 X-Received: by 2002:a0c:9e05:: with SMTP id p5mr13259045qve.246.1547204645946; Fri, 11 Jan 2019 03:04:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204645; cv=none; d=google.com; s=arc-20160816; b=OfUoqbV9Gd2hRWTi7ucHMiBjZGo8dQ/kqu8j45fuGCV+147I3hZXLo7x3/AW/ak59E oj1IyXlcR9oIUd/woq9v4wXg1cq6WOKm9gunIUIAxsAmzVcgG7ZwwapyB9xomLupX7SN mhbP3TVkBkynLsEWzUMx0ea0fcg62VnkV/OLNBu+4oGUkZUBEjjsNSYqJGF9+bdmffOI GKuQRVORfvKlfXcTueAj2csVUbFWwSufhShO1AIbD/wzrTljpELM5zshMAwiYVpYFo4p XpJCkPAatGqCe6srkcaHD+JnYE7+QxFwPl0DUaj33KpdXAod0qYtV9Oa6VK8mYesyYkJ sbKQ== 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=NqRnUsjWXdLCn3+BBd1E+TE68uZNAdSmdjd3DOkgrrI=; b=P++KJUSC1mWppyHsIfCOH1WAEmKvKfc3wn48VxItEzHaGlikRyXL6H1DTh/XlD4lHB TX3l7MnPDYsecZt+zZFu+N2QZyX6fGlGgdujfRFzYQMpputwAi9W4eaghAp8/dWn7GXD 6TDIU1PjEbfFlX9nx0BPZU6z3beuH/Ef86gXmRSCrlmSIY2N8ejTJ0Xg45Amo5jEoZwY qRUjQmxJ9YVJ8Ndl4tFLtnAC/JDjKIlDi/tkM9chfTl6eiy2Zy8jjzZz9JYO5BuKJncw 4JntWbbyDr+A50WeusdbK3RTdgDxdryleCusKgcxQDWmvglLS4IAAglV62s8ML/7O+A4 LwVA== 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 p8si2509811qki.221.2019.01.11.03.04.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:04: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-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 C297F7E45A; Fri, 11 Jan 2019 11:04:04 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 368A71019626; Fri, 11 Jan 2019 11:03:53 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com, Ming Lei Subject: [PATCH V13 09/19] block: introduce bvec_last_segment() Date: Fri, 11 Jan 2019 19:01:17 +0800 Message-Id: <20190111110127.21664-10-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.27]); Fri, 11 Jan 2019 11:04: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 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 d441486db605..ca6e630f88ab 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 bvec_last_segment(const struct bio_vec *bvec, + struct bio_vec *seg) +{ + unsigned total = bvec->bv_offset + bvec->bv_len; + unsigned last_page = (total - 1) / PAGE_SIZE; + + seg->bv_page = nth_page(bvec->bv_page, last_page); + + /* the whole segment is inside the last page */ + if (bvec->bv_offset >= last_page * PAGE_SIZE) { + seg->bv_offset = bvec->bv_offset % PAGE_SIZE; + seg->bv_len = bvec->bv_len; + } else { + seg->bv_offset = 0; + seg->bv_len = total - last_page * PAGE_SIZE; + } +} + #endif /* __LINUX_BVEC_ITER_H */ From patchwork Fri Jan 11 11:01:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757741 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 483C41515 for ; Fri, 11 Jan 2019 11:04:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A82C29AF7 for ; Fri, 11 Jan 2019 11:04:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E6F029B7F; Fri, 11 Jan 2019 11:04:23 +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 BE90829AF7 for ; Fri, 11 Jan 2019 11:04:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD4158E000C; Fri, 11 Jan 2019 06:04:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D83EB8E0001; Fri, 11 Jan 2019 06:04:21 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4E438E000C; Fri, 11 Jan 2019 06:04:21 -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 9CE7A8E0001 for ; Fri, 11 Jan 2019 06:04:21 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id q3so16261481qtq.15 for ; Fri, 11 Jan 2019 03:04:21 -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=KDOxgUQA1eq12LTIJGFOvJl6oox1oM46t4Al3oSWylY=; b=Ssb6gYGSWaPGeJBzzJRZyD57Wj2duO6eMcYMsdx9JKiJo0xlMS3bSfAAvvJ+4TCpbn Th28dnA2Vdx/pryHup0uXebyDsuMxUdOYrgMNriY2/dPTizlHp+R/Dmb9igWdU/o4IJh WbHcCFCE+NslC3XMzawYZejfz9TRUkjlpJu/yjaW9eIPaVNoWdj+36D7buN8Xp//xq0I 3910bqXovY10QwoE4U6jM0la9Nqx6u7K+0c3SpeAbafFdbny3fmHROTqP7nyJaotrkzk zsMUHmRmW4U6QuC3XVjlE9T7VGJR8hTFUq7eHArrAszCgs+f1fzXRpccrF7S9sDmGN61 oF/g== 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: AJcUukfFu4To513X4MsHVtAgAqBAEiQHk6lZhvPGAsmrkZjIZ2zRhQQb HYHtBDku6Nbz6wZCTjAEXPSGNmQs9pF/BP27OKs2Td9gLXWpmhUTJATTjhnjmqv3644QtKcuSRc 3Czl6YDYsG9cY1WXp2miHFp5IIqFJ3OVymm9X3PX+uCoK65f9dut6pqa0f7wKSeFjdQ== X-Received: by 2002:ac8:60cb:: with SMTP id i11mr13517361qtm.360.1547204661439; Fri, 11 Jan 2019 03:04:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN6mRHLSSOHzOQ7w4jvajnfzyKCoD+eRV7KsFkU/zj3fZcuCWeF8FYYx467/OUlUR/GvATVg X-Received: by 2002:ac8:60cb:: with SMTP id i11mr13517331qtm.360.1547204660910; Fri, 11 Jan 2019 03:04:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204660; cv=none; d=google.com; s=arc-20160816; b=ZEwBhIG8Y+yOGxCjcgYuG6jusaxRHVZEUvm2myC7XA8NGAGTTR403xSdDDvcxM96jj Rsah4sK0hrvo04HVlE9/yA0WLKzB7Ta3ZwQcUCP/r+aZHUC2C/bEBe16RQvXXrISbnJX Icr5Hpr1CgovVDsrk2JcrQF4o8boFMalAGmC11DP5BMMVzkzMSV9YV+HTaZAYjjk/vV+ g8Ir8zxQjdBh/FQET3Fm1fWuPdUzjsLqlTE4YkaAIEhcyFg+qJCANSFW0BfXzwN8S5ZM R4oCA0BfoqyOOqEivFXHfwu740B9fGZgNYa+WnzuLss9XK4y5FGTr9S0Q5E5umjZVqQc /4ig== 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=KDOxgUQA1eq12LTIJGFOvJl6oox1oM46t4Al3oSWylY=; b=iY8VLhhIy87HPLjKob94UV1f1RHvMa6AsJkKP7NzC8RkTOhMy4l1EdPwFHhw6Qy72f S98vGiBGCc/ljKsQT2X42+nIPOhtnUnqx3l3RT9vXPKoD/sU6vPiYsBQH5M3PRiV+DhC 62wXZf2PYT9BczR0NYsEohk3NqZvALn0djr86B479O1Dq0fl73sg6eSfK2C32clK36P+ lDD9WtmNKR8aDkm77uK2Y8vJD6p4J4NF4tg8dqxIzZu3GYVijbxLZDRItGDYtedxmNHz nm6XSo4WJHkY550n836aXO4GILhLmnmX/ca9lxL1zIRMQxcuRLguwo920GrNSEngRawz plWg== 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 l28si1244811qtb.119.2019.01.11.03.04.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 CF9EE12F8F9; Fri, 11 Jan 2019 11:04:19 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22A2B605C8; Fri, 11 Jan 2019 11:04: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 V13 10/19] fs/buffer.c: use bvec iterator to truncate the bio Date: Fri, 11 Jan 2019 19:01:18 +0800 Message-Id: <20190111110127.21664-11-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.38]); Fri, 11 Jan 2019 11:04:20 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Once multi-page bvec is enabled, the last bvec may include more than one page, this patch use bvec_last_segment() to truncate the bio. Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- fs/buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 52d024bfdbc1..fb72ac21f2b1 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3032,7 +3032,10 @@ void guard_bio_eod(int op, struct bio *bio) /* ..and clear the end of the buffer for reads */ if (op == REQ_OP_READ) { - zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len, + struct bio_vec bv; + + bvec_last_segment(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } } From patchwork Fri Jan 11 11:01:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757753 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 4BD7A14E5 for ; Fri, 11 Jan 2019 11:04:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FA8229AF7 for ; Fri, 11 Jan 2019 11:04:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D7A29BEE; Fri, 11 Jan 2019 11:04: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=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 BD1F129BC7 for ; Fri, 11 Jan 2019 11:04:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D85688E000D; Fri, 11 Jan 2019 06:04:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D673E8E0001; Fri, 11 Jan 2019 06:04:35 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4E5A8E000D; Fri, 11 Jan 2019 06:04:35 -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 9B5C18E0001 for ; Fri, 11 Jan 2019 06:04:35 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id q3so16262477qtq.15 for ; Fri, 11 Jan 2019 03:04: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=XsPc+1MY7uPsNa4DIKA+z9obYPPIRMYTuVF6XbdsXSw=; b=R9+Sp49wv+uIU9GbY1SdVIQ8rNp8Yr5+sooSTpvOjea8EXdxSanZAi/9crBdrB33c3 Ny6Q21vcEdssfmoTipZpyL+NWbK8bjuLT8AF3kaLJuTqJtYy/k1SPgjx6nvd2a+WstyH C1kDBREOFHgaxfHyWICfU4l+M8brRCSs3/hzZosY6d7dHdwXOVjpqgpcPUyZR9y1gPKb NGP+nJaRWnFCKJc+A+vBtMGyfgV6wIkqM4ZdajXomazkzkdUqLX74aQLgcBFRqNlTUas MUnCvnWbwsg8EJYK2aOx7rLEKurAwyvLDgEHsP+aOIgJNDAbRRsRvj80k8VjxIuTCsPF 1q1g== 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: AJcUukfE4k8OE8S8uNND5CmwDwMFQCB5w6+wK8R8iEemc4C7YLAwuNlN 4CFYzQBgitTJpVXMHPJRWvX8z298Y5dey8v0blwbYJ8JpvzwIT1zCVdb8dZA76lAOaHwmfdRSPB a3L8wDzmCJdkdzsNGv9BRK7HK3MuXuU9HMItwzvTJt0LwQk89A0FT6iE9auTq2YHYAQ== X-Received: by 2002:a0c:89e9:: with SMTP id 38mr13552754qvs.31.1547204675431; Fri, 11 Jan 2019 03:04:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN5UIGhKwpTZMWSmAuGOUUwrcJJ0zq81Y0Uq2mFD1CuT33OoQoXpNq93qlK96fHaCv/UBxGQ X-Received: by 2002:a0c:89e9:: with SMTP id 38mr13552723qvs.31.1547204674962; Fri, 11 Jan 2019 03:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204674; cv=none; d=google.com; s=arc-20160816; b=jcX3ZEKVCYUxUSEJ8UX/gbeTDMrnPnq5BGhliFyoj6xhXP+2ZrHa3z3b9swLu7Y6y6 IVMYiJXYLRA/BgL3SLUCfxPAOVStmHB+jnKR2i7SRp7M1UJP/gtr3QALy3d+v+t5zzaI QVL59ti3GoWeYyUKr7K25Gaz3kQWYhtZWOoBwjXtH1vt7+vEvcv05JNbheyqLuMGZErx 5A9phJtj2ot4ufwItOEJMsoBCtJO+KDFtXz+EO5myBMx6iuZLEs0p6GMZ/VDIZ50+2j9 pMYz2FTuVOuEJMvswBrQPNIuQQ/0f/Z1h+mjIWfGaOOGF4DwASBBgMuH3yjpXUWkdzdD 4FjQ== 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=XsPc+1MY7uPsNa4DIKA+z9obYPPIRMYTuVF6XbdsXSw=; b=LpPNLlNt1RkxGMRwhWL0Q8ZozEEoJ4HTN9OBaA/yGEKUb/uw8aQxYa0YJfsqvaKH9H 4rChC3xEa5y6Ra4ZO0NxeZ07FBE/EeEJ4PeHbkTG+/fpsUivZ0xPqaNu96H60TA3MBTL NsMDLp2p+NtTk0UXYl5nqZIk37S0qd0Bh7x5KMAOpBTx/JiQgR9XsniXz76LlsFEizDi kW87BFl/2nYNbHhDMSNeERS6IN6XTIKEUznEESdcjMHerK4rkKi0//jdhJNVd1AvsgzJ uOhjzv58vKgSrtuBESc1jhuBD8EUmdlYCojHN2l+tEIFlzUATyNvaJLkHmwqptYkBMCd 8x8g== 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 v67si1738896qkd.63.2019.01.11.03.04.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:04:34 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 C4ADBC0C9A8B; Fri, 11 Jan 2019 11:04:33 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E72360603; Fri, 11 Jan 2019 11:04:21 +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 V13 11/19] btrfs: use bvec_last_segment to get bio's last page Date: Fri, 11 Jan 2019 19:01:19 +0800 Message-Id: <20190111110127.21664-12-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 11 Jan 2019 11:04: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 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..c092f88700bd 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; + bvec_last_segment(bvec, &bv); + start = page_offset(bv.bv_page) + bv.bv_offset; bio->bi_private = NULL; From patchwork Fri Jan 11 11:01:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757765 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 E55AC14E5 for ; Fri, 11 Jan 2019 11:04:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64D9129AF7 for ; Fri, 11 Jan 2019 11:04:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55DF029BC7; Fri, 11 Jan 2019 11:04:53 +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 EC3F429BC4 for ; Fri, 11 Jan 2019 11:04:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 150C48E000E; Fri, 11 Jan 2019 06:04:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1014E8E0001; Fri, 11 Jan 2019 06:04:52 -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 017798E000E; Fri, 11 Jan 2019 06:04:51 -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 CE5548E0001 for ; Fri, 11 Jan 2019 06:04:51 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id d31so16264293qtc.4 for ; Fri, 11 Jan 2019 03:04:51 -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=E1/V22YK1RqnSgKHi3tHzYVp+KRqmLHwTzVJ4IlRnC4=; b=d/eoSjZlEyH3lhJ73NVzu+t7/ulM7f86EYrhGKR9AqpZNf/wcAz3kYhvRi4z3QGb3K eVXoZq0ll1NpX9J+B9wucJFRVQynxIzMrR5yxPJTccVw5ZPesFbcNl3F5TWJXLKXD3w+ 2CVpPzgFQ4ZXHP962+5iB1KwPj8hpQSzhFWPkhmVVKiPf7nlsivimIRYgoeg/U6skAT9 iszt3Q05/HuxHmHagk/o9OqmPDGjugRCfc31TQmHNOWZ3B9J0NE0mUYIYm8XXufPnr+u 0WwLg8Jj+YDk1OkxQnX5FNZOgKqzvGvp7hiiPBekpZmcycrCrVUvCWWk48CtfbsRDAM7 0Iqw== 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: AJcUukdZjZCdyA5X09W8ZMpi2z0EpYgG+MyzF4VuYY0GhESeJ06zjlxq q5U3QxODbbDxZd99zrQSwshuuCvVdBXFAMh7Ih9qEmXymILGqMYf5Ca+JBmvEsmivCD9ZPYJgAw 4eVT4BiH++PA9sjKsOKstm9zb2zZ4PQIQFxc5gGclk/AQDhTsZOn8Lg4Gibk+h/lmyw== X-Received: by 2002:a37:b703:: with SMTP id h3mr12155811qkf.33.1547204691612; Fri, 11 Jan 2019 03:04:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN5d8pKBu3hlqE2/3sq5BxnLjQc0YCIs6NxJg0JDrJeDepgpnMvKz6f2gTry2PKmTX+l7DFI X-Received: by 2002:a37:b703:: with SMTP id h3mr12155787qkf.33.1547204691047; Fri, 11 Jan 2019 03:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204691; cv=none; d=google.com; s=arc-20160816; b=E/XM51P6QajUcbOmTGIQPKUYECxBv1DrUZja86vgMpzhIb3wB2La6N8503Mc4z3z1e 9IDU0LCEblMeCE25os2uS5Rn35XlyAc+zmPU3umrNGKXa8qZPSIZA0wMgrVHpIiftBHb PkOJBRbjcbG1DVRS43jbnYwcKpoQVUQse3da5hFpp+7zoZcSD6++sonE1iYRNHri91ud sHHFIAKiRTaEl/X93KGy0jvLpHQAAWrbwF29FUy04JT0nhrWZ7swpveI83ljiUi/Mpgf 2BWR+RJzcZOQQQ8JXt66Mqn7PDoV0Ht94kBaxmLoEWgfib1yLPtgkfe951v//ULO8MoS qo3g== 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=E1/V22YK1RqnSgKHi3tHzYVp+KRqmLHwTzVJ4IlRnC4=; b=EH1qKCarxa34WyVY2ajbSLQt9xIE3bCMeFzQOMGXhwoSym2GQqZuJPwbgouomT+YEU TeQI39gtN5FBfvzZN5I1Zfk/xKgL7K3ycPHHPBRXYS/o2eFevM8Wq20OwdpxCyCsWTKp xgzyS/1Ytuow0E/jFQ5zGR6oliNut+VbeQnppuGAo5DLyugcwOUU6i0SbxWQQVRtBN6I aGl21CMLAgALxZsKruX4yYBdmrIs6pjEvEnEc3w0Y/QUVzTopKz7aKCq8y4MexATWBk8 wH6FCkWn2un+lgvK3M/W83PmYLXevItS0T13J9UWXevU/0qupdA9EPhFMC87GeYJ2rC2 Jbtw== 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 l23si1010038qkg.227.2019.01.11.03.04.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:04:51 -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 EF600AB439; Fri, 11 Jan 2019 11:04:49 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 277195D6B3; Fri, 11 Jan 2019 11:04: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 V13 12/19] block: loop: pass multi-page bvec to iov_iter Date: Fri, 11 Jan 2019 19:01:20 +0800 Message-Id: <20190111110127.21664-13-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 11 Jan 2019 11:04:50 +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 b8a0720d3653..28dd22c6f83f 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -511,21 +511,22 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, loff_t pos, bool rw) { struct iov_iter iter; + struct req_iterator rq_iter; struct bio_vec *bvec; struct request *rq = blk_mq_rq_from_pdu(cmd); struct bio *bio = rq->bio; struct file *file = lo->lo_backing_file; + struct bio_vec tmp; unsigned int offset; - int segments = 0; + int nr_bvec = 0; int ret; + rq_for_each_bvec(tmp, rq, rq_iter) + nr_bvec++; + if (rq->bio != rq->biotail) { - struct req_iterator iter; - struct bio_vec tmp; - __rq_for_each_bio(bio, rq) - segments += bio_segments(bio); - bvec = kmalloc_array(segments, sizeof(struct bio_vec), + bvec = kmalloc_array(nr_bvec, sizeof(struct bio_vec), GFP_NOIO); if (!bvec) return -EIO; @@ -534,10 +535,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, /* * The bios of the request may be started from the middle of * the 'bvec' because of bio splitting, so we can't directly - * copy bio->bi_iov_vec to new bvec. The rq_for_each_segment + * copy bio->bi_iov_vec to new bvec. The rq_for_each_bvec * API will take care of all details for us. */ - rq_for_each_segment(tmp, rq, iter) { + rq_for_each_bvec(tmp, rq, rq_iter) { *bvec = tmp; bvec++; } @@ -551,11 +552,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, */ offset = bio->bi_iter.bi_bvec_done; bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); - segments = bio_segments(bio); } atomic_set(&cmd->ref, 2); - iov_iter_bvec(&iter, rw, bvec, segments, blk_rq_bytes(rq)); + iov_iter_bvec(&iter, rw, bvec, nr_bvec, blk_rq_bytes(rq)); iter.iov_offset = offset; cmd->iocb.ki_pos = pos; From patchwork Fri Jan 11 11:01:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757777 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 A430A1515 for ; Fri, 11 Jan 2019 11:05:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D626297AD for ; Fri, 11 Jan 2019 11:05:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6103529BEE; Fri, 11 Jan 2019 11:05:09 +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 E8E0B297AD for ; Fri, 11 Jan 2019 11:05:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1ED7C8E000F; Fri, 11 Jan 2019 06:05:08 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 19BFF8E0001; Fri, 11 Jan 2019 06:05:08 -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 0B3128E000F; Fri, 11 Jan 2019 06:05:08 -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 D67618E0001 for ; Fri, 11 Jan 2019 06:05:07 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id p24so16262396qtl.2 for ; Fri, 11 Jan 2019 03:05:07 -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=FxYM2WJ94WbsVEYLMk8g+pQ9poCWv3dYDIICNdthtR3pfVKDv47hdxbMQ2msWIIkD8 d8DFLHFz8CTuqfTVMUIML91yrG4h2WoLeXQJLpwCmcmX9HtM+abGj3OqsMHRLE3rCiuo MQEkfPajXhnHg0ltB2AwhdaXCLOEBqMn9mTgri+PVa4aAE3JASM+AHHkZ3Tc65Rig5wp lNUARatjvc2APXekiCgkELFhCFpjW98xuazZOTWBaycwCpizaSLxiXgqd207w1PIiWfp fXp2WPBdUl1FG2FvSGgNVncGSVFX82nKSxCt+RFga9PJiJCgWqXMxram5YzaY3N4h+Oz DtxA== 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: AJcUukdj8TCmMNl2hg9lqsilghY0k0kLqPfS5cDpOu48aKU7t2c/l4Tn /K7qEb0DVl/gjuYI6Z5IhofbjZTGYm+YwIJAGGWy8eIS90BE7OFxTWvNEsi4iB1nTNUHcOxHpxo kQyzi2HvD0oiRlPz2shhN/UqsMvcr/C9GUNhR0mTDi6yzYBRfAIre2Q9hkM2/rnPibA== X-Received: by 2002:a37:c808:: with SMTP id c8mr11892899qkj.243.1547204707658; Fri, 11 Jan 2019 03:05:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN6+pfS2NGut46CbI8d+kKr4S1X9D57iJULhP3gejbI9rnyisKdQ+W+LmsJq8naVKdPoT++D X-Received: by 2002:a37:c808:: with SMTP id c8mr11892871qkj.243.1547204707180; Fri, 11 Jan 2019 03:05:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204707; cv=none; d=google.com; s=arc-20160816; b=FKToe9lEYxfseWl1+CN6ELEAVOrgNzyykkP3ZzFZtp0/lzuFD4O586WZIgfmH1HmKT gex/oP0xUJT5mNgl43DqXxf7ebiqFZjvAem/iqDOLvqX6YEeIiEXlGi7X7DvLYgeKoJk 0HieOAuR25zpwTw4sg1zkJgg2+Wa0V0C00wwf4OX7S8Cv0P4/qAaRiaUjIZFSVQR7Lud DfN9dJUyxQz6jQeaOGiVgJr4g/BLaDSu820C3ZCpjVIjeu6W04dLoXhMaKMAuMSIwDOY y/qEqdkFW1ZzD+BWCcgbj8BVnLstWuXNFPTtxu6pzMNXYWN/Bv7wai8RbV8iEGs+TsRi il/A== 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=d62TAlePpE28GFD1fHBOF763EZWyuQkiVLGg5MX3948MeIocglvG1pWy3TNVpyI/D2 AxRKtpqDVaSPGc/5NqaeqrWygNyqXbSQY2HmSRtZFqTdeNOuijaomWgJOJ0utReSCGAl 2cw9u+oB+U0OYey0LEsQaG81KFebH4W98nL2AubYM1heewkL0TfIeckz/uy2MPJi9PaG SDeivHfzArWHYlGWq6oq1p9X5AfOyGF4h5cuyEktVNZR18qGDdkA24k94wfD3pCBgOny YulovhkVl/2YM7m13BRMRw6u2bDwmC5EkHmQNS7PaNlPQdEQ4loJN1bfyhcAVvLUU/cp a4Pg== 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 e3si2833726qkg.54.2019.01.11.03.05.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:05:07 -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 EBD9BC7901; Fri, 11 Jan 2019 11:05:05 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55BE45D9C8; Fri, 11 Jan 2019 11:04:52 +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 V13 13/19] bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages() Date: Fri, 11 Jan 2019 19:01:21 +0800 Message-Id: <20190111110127.21664-14-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.39]); Fri, 11 Jan 2019 11:05:06 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP bch_bio_alloc_pages() is always called on one new bio, so it is safe to access the bvec table directly. Given it is the only kind of this case, open code the bvec table access since bio_for_each_segment_all() will be changed to support for iterating over multipage bvec. Acked-by: Coly Li Reviewed-by: Omar Sandoval Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- drivers/md/bcache/util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 20eddeac1531..62fb917f7a4f 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -270,7 +270,11 @@ int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) int i; struct bio_vec *bv; - bio_for_each_segment_all(bv, bio, i) { + /* + * This is called on freshly new bio, so it is safe to access the + * bvec table directly. + */ + for (i = 0, bv = bio->bi_io_vec; i < bio->bi_vcnt; bv++, i++) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { while (--bv >= bio->bi_io_vec) From patchwork Fri Jan 11 11:01:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757791 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 5A61E14E5 for ; Fri, 11 Jan 2019 11:05:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B41929C0B for ; Fri, 11 Jan 2019 11:05:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DF2F29C31; Fri, 11 Jan 2019 11:05:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2C2629C0B for ; Fri, 11 Jan 2019 11:05:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9F9B8E0010; Fri, 11 Jan 2019 06:05:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A288E8E0001; Fri, 11 Jan 2019 06:05:48 -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 8C9A08E0010; Fri, 11 Jan 2019 06:05:48 -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 5634C8E0001 for ; Fri, 11 Jan 2019 06:05:48 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id 41so15974589qto.17 for ; Fri, 11 Jan 2019 03:05:48 -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=c+Np1VCPObbvTsxc4clA/eZ9dvJO3LGMgz/pRXWbzDs=; b=XpNOqEWFTML1d5zGP1Aso5u/sGrbk0XBcWz0ceOpLcbLy84IYlEaN1UPcIVlyVPXk4 M5GYIAIUcXBjAlP11B/1mc0QdqHCeghuVu3jC9/kLLijymweUc3QEXp09NiHeJjdEt5I 8jm2DYqrdRtcMvwrXfaJftXmXOpmGYAoDVTnbTgv1wKAVUSu0ZpovgH5NBEDPYNWiaJv P+z5mLAvPiIsI5rvFOt3k7ibyXK49JiKpwEYaHfTnhAMZHsJXlZttjKym6ZAV8aesRtZ 5L0h0Clm+n2SVkC39LyIkUX6FljF3tIqFWjaLECubk1XiM7dkuuESxZc1lELvdTYEdtt J+lQ== 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: AJcUukeOKimsBkyRYzfywTrO3bIhVdP3wpX1H37HF5KkX6qhWSZN1xz8 hVEVqC5w/x/ILjosKlupuliQ/MNm91EJgFrZPCt+vtXICsDQTRklsd7EfA64RuQjq3duo5o0Wfl XEvRddoW9FXvDmIEXzpXwNO+5gMfIpUkZZIeAHXmdj0Ji0IZvXMJUj67tTniML5qjIg== X-Received: by 2002:a37:9ed7:: with SMTP id h206mr12381242qke.128.1547204748063; Fri, 11 Jan 2019 03:05:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN72thyFuwOfB1h39G93d0ENMt9cd3tpGl26tFyaeLxo1ACVxocpkv87YbRGwBDnOxlz1nRC X-Received: by 2002:a37:9ed7:: with SMTP id h206mr12381162qke.128.1547204746340; Fri, 11 Jan 2019 03:05:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204746; cv=none; d=google.com; s=arc-20160816; b=ISjt44ueoO41PFpcBWWN+KJcmTHGL2YuPtHIiaIg/xLnP09uVpvdLd5nErUn/fn7Qy ak3DCMT/AxlKn2U9dXEwoIrDDr925d44QXQUup9hEEaVrhMxBiEDO3ujhcJSJSfVeiIf rlPHDMowRinbE0Lb3fgA2Er+9jozYMxWPCggpLLmbFJlHQTIL4qeGq9i96bpXE6ntoMh AecuJU/Hg9MjeMNRixLh1yhqeBNbrdpCmWx0+TQUP5kXK/gk+FqsSvkz0QEHA3+axPKD oIN1KcZeQSkiTDQIXXke5eR5N9r9tvUbMGC0Z184ciWisOf9Hi02p0P77DCw4gYpvUr4 aRog== 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=c+Np1VCPObbvTsxc4clA/eZ9dvJO3LGMgz/pRXWbzDs=; b=eQEcoIRIhObAq6Brxflq52nEoHtz2ylxUpRAwHMZpCnB3/ZcrOsRjIokTyAaRnjnem YTyYDjA0i8s1Kopkf+fNh1Lh93XPkaI8U4ZzQFKVKHqM0ryWHgzwt5COpd2Q+/om5PFB RQvFDq6q3QMajKo9Oi7LG/AO8uVu0+VbuYm/5/foob6nuZhTe0HFTE/4DvBRrTKDatUu xwCdOLvSMgwg2prTSAHNuKzbdG4dij9U9rnZ3tKmRyybCbdqv1/yX1UzUIGagndWfRab Xd4T87vLsvCqVZZnCxfKOSy8+A++nZbAD9mHjUl/5vs8h0/SUmj9Alz4jU18tMKkiZqt MNOQ== 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 u2si1235935qvd.172.2019.01.11.03.05.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:05:46 -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 0D631486CD; Fri, 11 Jan 2019 11:05:45 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 294D36A69E; Fri, 11 Jan 2019 11:05:07 +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 V13 14/19] block: allow bio_for_each_segment_all() to iterate over multi-page bvec Date: Fri, 11 Jan 2019 19:01:22 +0800 Message-Id: <20190111110127.21664-15-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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]); Fri, 11 Jan 2019 11:05:45 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 | 6 ++++-- 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, 125 insertions(+), 45 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 c092f88700bd..e4c39f0e8c8e 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..ef68bf6232e7 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); 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 06888d45beb4..c5231e5c7e85 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 bvec_for_each_segment(bv, bvl, i, iter_all) \ + for (bv = bvec_init_iter_all(&iter_all); \ + (iter_all.done < (bvl)->bv_len) && \ + (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++) \ + 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 ca6e630f88ab..94620cf01762 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 bvec_next_segment(const struct bio_vec *bvec, + struct bvec_iter_all *iter_all) +{ + struct bio_vec *bv = &iter_all->bv; + + if (bv->bv_page) { + bv->bv_page = nth_page(bv->bv_page, 1); + bv->bv_offset = 0; + } else { + bv->bv_page = bvec->bv_page; + bv->bv_offset = bvec->bv_offset; + } + bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset, + bvec->bv_len - iter_all->done); +} + /* * Get the last single-page segment from the multi-page bvec and store it * in @seg From patchwork Fri Jan 11 11:01:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757803 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 18A0613B5 for ; Fri, 11 Jan 2019 11:06:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 088FE29C0E for ; Fri, 11 Jan 2019 11:06:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFD4629C13; Fri, 11 Jan 2019 11:06:09 +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 7D58C29C0F for ; Fri, 11 Jan 2019 11:06:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B65C8E0011; Fri, 11 Jan 2019 06:06:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 93E488E0001; Fri, 11 Jan 2019 06:06:04 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DE3F8E0011; Fri, 11 Jan 2019 06:06:04 -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 4AC128E0001 for ; Fri, 11 Jan 2019 06:06:04 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id u32so16327411qte.1 for ; Fri, 11 Jan 2019 03:06:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=BfUpppeyoWSvXTeJISDGH1+DjW33bSA1+i866QTVNEg=; b=mgzvgIN8EMle0K+MT/XjfZYrHnDmr/O0/oMzd9ruHJtAvy+1NmnA+tNYB3sSg0WAZ4 zVtujHf7hCCeJPYd+tDrqlCM4GB52ankdJVeXlYLxoW9x/QDB4ESuegPocXyt7O4xm9w kO+/hotv+X0CNyhRVqghiM97x0Th4O7sGEKcMoZe+6qMAysNp9AQ0WRStD9XXxoc8A02 xE8lUhs+Q9nBKX9TNqdhn9enV8oIuVwUbFSfMZx4FNZk0zl1ft73Kivqgv0E6Pil7NTY KPtGeeW3vs7J2Ux7Uzb1cg9DDNRL62wd/CIhrKFYyj0X8JzRwTn8oBVw4smmeu12NLTz 5UOA== 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: AJcUukdh0RsOyb8zyXK2YgIikOu38Bfur6EBvYTlvtfjPAjVzJVdC19A WhntNmsLSVwDKvykk/b4/8rIbzSmVCOo9qRX/b8WUml7eh5VZD7yCZ/mfJp7flKFozsL/bMTuWR 9huHtOr48DbHSMlDDxgBh0MOf48xuU7LZytqE3F9TX++jqYw1Nq0zqdj8PPhrcvnJdg== X-Received: by 2002:ac8:7094:: with SMTP id y20mr13161004qto.380.1547204764079; Fri, 11 Jan 2019 03:06:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN5xyAb5/jkdlUbYJFGyxEtrFxqAq33R5EgnX04aKkwPwMg4Eh4gWNeC8pkzy4K3zUGUIeod X-Received: by 2002:ac8:7094:: with SMTP id y20mr13160965qto.380.1547204763337; Fri, 11 Jan 2019 03:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204763; cv=none; d=google.com; s=arc-20160816; b=Okb11cw/rnMRXTnlh9pYcgCG/Ew3W4vTKdtOXqlqi/t0zyL01RfrW1s0pLYb4hvJeC WWpdFuFz7VWxeshCjw1y3HMJK/v3Dcu/Pzza0Fdv7ci0od3lQmfjteCW0hz1pCqthCkl vVD0HenXQGW971517+aWcbwVEXFqkMWZsoAMkJDJW4sMFQctYZoE3k6X2G18F1Eww4MX TPal83BMNULwQ9OXIxqFEmsipiHiV5JOJHQTMMXw33vI/LkCscByQfNngnIsA+eizKYJ Ij7jQLuPbxSHah7bFutRPHF/3O+K20ZFZBHsPPx0xwLHXiWa0TvPJLdD1m4IIkM/Da7V zClg== 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=BfUpppeyoWSvXTeJISDGH1+DjW33bSA1+i866QTVNEg=; b=hk1oonAeZ07Eu54+ZlhCjJoOLfrBxKCmhv9/hLF9GrzAAnRfGvhUQ/eA+jXYNvHmn5 oQOMC3nJs6ANMg4+BwxxuTUG1SOzG8Ec737sXQqH//nlJ6X1RtV66xgbwU5RFpxtfaSR 9HUKvqwPXAmFMAEyBCoWj3PdBN6EhNzLD5mTB+B/6ToCAAsDKcNC3xFTp/ALPN1PpMP3 4jOYYk5WN5AdWPkMy+iZV4dJoFAQAPgIXQVeShk5d6yhLbprvQDiiau7KlcSxCyT0Fb2 MG5vcWCGldUg/DTSInsl1m4EFuQC+V2ZjbxFTU00P8EWm1PC3xcUBtMNK5c2B008umiC D6Kg== 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 w5si4299760qvi.223.2019.01.11.03.06.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:06:03 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 D317FE3281; Fri, 11 Jan 2019 11:06:01 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 949DC60603; Fri, 11 Jan 2019 11:05:47 +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 V13 15/19] block: enable multipage bvecs Date: Fri, 11 Jan 2019 19:01:23 +0800 Message-Id: <20190111110127.21664-16-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-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.39]); Fri, 11 Jan 2019 11:06:02 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 c5231e5c7e85..1ece9f30294b 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -441,7 +441,7 @@ extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, unsigned int, unsigned int); bool __bio_try_merge_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int off); + unsigned int len, unsigned int off, bool same_page); void __bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int off); int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter); From patchwork Fri Jan 11 11:01:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757801 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 4AB5C14E5 for ; Fri, 11 Jan 2019 11:06:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BD4129C0E for ; Fri, 11 Jan 2019 11:06:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EA7529C15; Fri, 11 Jan 2019 11:06:09 +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 C4AA129C0E for ; Fri, 11 Jan 2019 11:06:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A53788E0012; Fri, 11 Jan 2019 06:06:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9D8FE8E0001; Fri, 11 Jan 2019 06:06:07 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A4988E0012; Fri, 11 Jan 2019 06:06:07 -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 5EF348E0001 for ; Fri, 11 Jan 2019 06:06:07 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id w18so15947089qts.8 for ; Fri, 11 Jan 2019 03:06:07 -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=ZTTEI184zjp8LLvTWvrd6TUN+5CgfMPjY9NTQhNyF9o=; b=rGAx54hwI6ZRyY122DvM08yyo4uOHGmk57cBfsEZaC6Z+yVblDwTsYpnLqBbhgLMZO jrskdpUfjqBor91kn5IQ6K5029rxxaQzrYZ67ixk+twLvSBcGcmVlpGoYjMABsyyX19a 0rP0rtj5+fLnndQWLDhvqHrZ0t1QR+vCXx3dvNI2yVOVx7mXo/GlPyAcBQuNGEinT/Y/ E8x0xFXYudCWr7XUlthgkW+hD24e/4wAu3srq13cKDIPZ7UPI/L0CHMm6BK6zk6Rsw7e /EEY8QL/3COPbyU5eDqYzBqKS5121lpyg+QG4bw9YL2kOSm0bINbAXxcFZgcNfyeP9Mz vfVg== 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: AJcUukd5XPlG/2cTiySv4MmuPfZL/sG4xudQw5H1FYFewPRia6ROlmf0 YFcPd8CVYvgA4pwxr7OpBHdBgFGb7OUBP3i5GU7Hu/BBJ41Lf+AzoK/7EG1CSexbKLik1ok+Dvi WmHOOURTJmIxJOSxTHS4q61MVNm1z41VGQQs9OA8Uw63KJFCaVmCAHVNbcLcQHU82Gg== X-Received: by 2002:a0c:e789:: with SMTP id x9mr12497332qvn.245.1547204767170; Fri, 11 Jan 2019 03:06:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN7sTwjMIPcvvMJCAV4qU2j60FelWm6Zf9+v67i3VPtyWRaNi3uW8g6rvXmZgdwED4tB4VvL X-Received: by 2002:a0c:e789:: with SMTP id x9mr12497301qvn.245.1547204766632; Fri, 11 Jan 2019 03:06:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204766; cv=none; d=google.com; s=arc-20160816; b=eUlFJWt1/r3/PwnDg+AM3qRbJfhuAR8AmZb/esTrEqzbktiZJvtaEgyb40gasUmHUx FJKpIkOjkG4O9GnTzfYU9W6SckJNSVRQlvcAoZBRlCNPPIBW17A80ao2kiRX7zSz8ROi wnQMRr4fQkA/YHoemeAoLEQ8KH8XTja6V3UdWPs5VU8CWa+XoBePR/AMlohef7Ho/2ru e2EI5cwOhnOU1WPlUey5YGic3kFuTVJ35rNdnLKAslIdiQK76HQnxd8EtSpCIXuDODV8 6WowgxNwInk6O7gFZm2RxvI0S0fq8glw7cIwqCSNNwSiwOZ1sW4C7uzN0ImTO4+pAJRk pITA== 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=ZTTEI184zjp8LLvTWvrd6TUN+5CgfMPjY9NTQhNyF9o=; b=T+C0VO1k/DteAMJZJHihfjIbryUqJb41YZUWkBRySj0dJN/MUu72jzgnI/q0B4q4pT be3Q8kfpkiSVBxxF08XcFM3E0ueIJ++qiZWJMg/SgP6hCfqptxwxdrP1kHuCqXWyHwyt PrdKI9rsTsCFGMgCus9LzsOuuVYIx08Z+pXWl35/TbT5PhAvuk2eWjqVnhBGcxX+10T6 5+zUScHwpXIpC+FpXavoarFT+6j7Qt/a1szwpA5s67Ct4nIbfwJMUavHweejAAWQrK77 0oM3ATHE/O4IyfoN3e1fWT/AKswQHOtHWEii2Pbn0nVF7HPL3TplrLRAxunvIbFjl0HG 3ghA== 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 h13si278132qtb.233.2019.01.11.03.06.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:06:06 -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 74A71C0C8CF2; Fri, 11 Jan 2019 11:06:05 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77C0827CB2; Fri, 11 Jan 2019 11:06:04 +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 V13 16/19] block: always define BIO_MAX_PAGES as 256 Date: Fri, 11 Jan 2019 19:01:24 +0800 Message-Id: <20190111110127.21664-17-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 11 Jan 2019 11:06: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 1ece9f30294b..54ef81f11f83 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -34,15 +34,7 @@ #define BIO_BUG_ON #endif -#ifdef CONFIG_THP_SWAP -#if HPAGE_PMD_NR > 256 -#define BIO_MAX_PAGES HPAGE_PMD_NR -#else #define BIO_MAX_PAGES 256 -#endif -#else -#define BIO_MAX_PAGES 256 -#endif #define bio_prio(bio) (bio)->bi_ioprio #define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio) From patchwork Fri Jan 11 11:01:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757807 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 B58A81515 for ; Fri, 11 Jan 2019 11:06:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A582429C0E for ; Fri, 11 Jan 2019 11:06:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 996F929C13; Fri, 11 Jan 2019 11:06:12 +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 357E329C24 for ; Fri, 11 Jan 2019 11:06:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C26128E0013; Fri, 11 Jan 2019 06:06:10 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD42D8E0001; Fri, 11 Jan 2019 06:06:10 -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 A77E78E0013; Fri, 11 Jan 2019 06:06:10 -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 77A908E0001 for ; Fri, 11 Jan 2019 06:06:10 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id d35so16263360qtd.20 for ; Fri, 11 Jan 2019 03:06:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=wNodGZU7EcFMVOxNqWEpjAbmpaD39TDM+4us0d0SSCc=; b=kmPLmLBpzv49dJ4t6parBdPm0iUk48weAnS0ZX7nAiy6iklsfEi8d0Ahy7U12q8mL5 t55lfagKnAmVaWEzbVWT7tMjW2cUgQLoAo3Zno+bvLqfXg4HZS49cAa1kkIcRLqJdqOl t2VSUBF0iaJPloeSZDdw4fnYrW3eGQxA8ZMSeoJv93SKmchqC1PkFI2LcvfWcBrwCQon ZRhM/FYJJCjKlXPHwl3+4A1SYamo6FmUMmqu4eY3XwsDfTefGb9VDuvtMHjmpLHJhxav 1i0YZexz98ArVcVJlCAnuO93MHlM9F76Rj/QVH/JnbRQEZGLevC5o3JZ/7IZzqwU6xGk xN/w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukejoYb5RKpFjNHUMnYpqWjliZMJDPVAH6p0qTLy2VaBKZ/rZy54 8J0HbNOwk20G9cqkSigHKW8CAMr7piE/pqnSs651c1YARiqabnc5seEyA5CCq8sH28PpdW9PLB3 A63Zts0vCHN6NARfXDyn8OteFa4qxjoWYgFaZPetYz4pW4x36zGyOvoPexoLe4cYwTQ== X-Received: by 2002:a05:6214:c7:: with SMTP id f7mr13762025qvs.44.1547204770207; Fri, 11 Jan 2019 03:06:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN533PyXtMit6qhzrEiQ/GrEYGL1nJsoxygr7cZjSoxZP8vua6lcM6LxzEkVqJjnWO5f8bp6 X-Received: by 2002:a05:6214:c7:: with SMTP id f7mr13761991qvs.44.1547204769644; Fri, 11 Jan 2019 03:06:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204769; cv=none; d=google.com; s=arc-20160816; b=YFv8W5zLFsfA7b90DYcEYHb1pCIktih8PLSiLvjHij/Q8uJFAtSGvcppcQxy7NqxLA cM/OYWYVaBcVytiGjQlBaFinIQ0rj39OLA+46nSWMUMy279TUghJr4rcw8dF2P588aws Wirel6R9fAoXKjuDPoup0GXUJL8O4cMKSbosyncAVSpL6T0p9RNsSwgkv0OF3h0hMZjS kOzNRnp8RsKA4foeEVviaCDWtN870OD92Iw7fAJtxAlg4bfv3JkArcqk98Zb3TfbuwaQ aiE7eZmAc6/feqczGP6FGbDzjaCLS98tCGQWdYQjGiuU3KAUboABe1GUF0YWKnkJhHqB dn0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=wNodGZU7EcFMVOxNqWEpjAbmpaD39TDM+4us0d0SSCc=; b=VBzPq7CQluKeIlmaqaZDYTBKLIQ+gnOFeZfxRSwGZ1LRYS0Yu3+mjVlXPc03b+dH9k DydwH+oAHS9a9QfbnEHjsrcndyEQXoezLj6wCbVJPxx5IU0umk2cKXDVpE12wqiFBxp6 jW1uZn9Ik97qVq17bU+CbEnrAkQWuZy0DnQWnAz6hoBs5tw/IKfAzcZ6AUEzCwLhlJVw o/RP9YgsqG/yHlH8Sen7Rkz0XHA8d/f3wcHgo0gF5wmgBv5iaSGXSQ7OP0r9UpvND0RU u9DY/TBk/RLeDO6XJeoiKI5fMXDOwxBTTqf4PkDkDJ3U5S081G0bFnUi1nr9PenIzpWR 4c3g== 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 o51si501121qtj.204.2019.01.11.03.06.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:06:09 -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 9E464144194; Fri, 11 Jan 2019 11:06:08 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id C618A6B460; Fri, 11 Jan 2019 11:06:07 +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 V13 17/19] block: document usage of bio iterator helpers Date: Fri, 11 Jan 2019 19:01:25 +0800 Message-Id: <20190111110127.21664-18-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 11 Jan 2019 11:06:08 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Now multi-page bvec is supported, some helpers may return page by page, meantime some may return segment by segment, this patch documents the usage. Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval Signed-off-by: Ming Lei --- Documentation/block/biovecs.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Documentation/block/biovecs.txt b/Documentation/block/biovecs.txt index 25689584e6e0..ce6eccaf5df7 100644 --- a/Documentation/block/biovecs.txt +++ b/Documentation/block/biovecs.txt @@ -117,3 +117,28 @@ Other implications: size limitations and the limitations of the underlying devices. Thus there's no need to define ->merge_bvec_fn() callbacks for individual block drivers. + +Usage of helpers: +================= + +* The following helpers whose names have the suffix of "_all" can only be used +on non-BIO_CLONED bio. They are usually used by filesystem code. Drivers +shouldn't use them because the bio may have been split before it reached the +driver. + + bio_for_each_segment_all() + bio_first_bvec_all() + bio_first_page_all() + bio_last_bvec_all() + +* The following helpers iterate over single-page segment. The passed 'struct +bio_vec' will contain a single-page IO vector during the iteration + + bio_for_each_segment() + bio_for_each_segment_all() + +* The following helpers iterate over multi-page bvec. The passed 'struct +bio_vec' will contain a multi-page IO vector during the iteration + + bio_for_each_bvec() + rq_for_each_bvec() From patchwork Fri Jan 11 11:01:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757813 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 843731515 for ; Fri, 11 Jan 2019 11:06:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7446B29C0E for ; Fri, 11 Jan 2019 11:06:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67DFC29C0F; Fri, 11 Jan 2019 11:06: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 CF8C729C13 for ; Fri, 11 Jan 2019 11:06:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9B5D8E0014; Fri, 11 Jan 2019 06:06:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C22478E0001; Fri, 11 Jan 2019 06:06:22 -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 AEB508E0014; Fri, 11 Jan 2019 06:06:22 -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 7FE808E0001 for ; Fri, 11 Jan 2019 06:06:22 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id 41so15977023qto.17 for ; Fri, 11 Jan 2019 03:06:22 -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=QTQMTnGihEOhnNJB9JQOzJ911TrP0SPKAaKiZ6eM96M=; b=LSGzajVUiJaB3T1t4qTE2r5AhbGGD779aHS2RLMSH59m9Mmy2fQC8lFIXm2jNAbDvJ 7KCAZFG6vhjWgT1+V2aHiDuaI7EfJ1/QY6w4GmnYe8KaPunRfVMDYpHcHN4tHlemBDF3 WNCVAb8JDJcItBkL+uEcnLhYCHF0aWHIRoL3b2ZTPLrnGggDaLZ/9mMltn2RCw4L5vVg gp2cfx/UKz9La+NFpTm5dkMqRUNaZ+jaO1u19fMru4ZaWekGZTE/2addKoyB5BDnZI88 63oPQjLfacvMhQ4iG+F7Q874lC59dVte+HDaDfZLxwe6EpAE8hNBcxRlZrWntkMiCsrx 2UrQ== 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: AJcUukcVt+Mvi/G5sF/Z5kHITSzsEA4hGd3gEbin4OcqXdNeCW576WpY GC8xZRkIngfVS3DGMciYj+5Ql1XHnDQjhkf8i6+S6u9Jz9TrM6mKgkIg3yquffPh31hcscKF6xO MfOHw0Dmhi2ZqezSHx4Xms00K7PxD35Qxb4tsBPy3wpOf9jilOxK3cVRtVnkRcpy7NA== X-Received: by 2002:a37:7645:: with SMTP id r66mr12301822qkc.14.1547204782254; Fri, 11 Jan 2019 03:06:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN78/4cQ9gDN1a993gIzPmKTueLuhTTVQ2gOdT9ho2IbIq5k7QLti5YcwK7GS7XkH91NbA+j X-Received: by 2002:a37:7645:: with SMTP id r66mr12301782qkc.14.1547204781558; Fri, 11 Jan 2019 03:06:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204781; cv=none; d=google.com; s=arc-20160816; b=WUCy2yItzO1YKL+uAd6EL6Fk/FpbS//cty9Kde2Nj5SfGPb4Q0tcz2gumfeC6W9BOJ VdVSWIBeGF7XSXVf+RxioSUcprEbGoPzfRTwLCDxQ4tly9B2B6bcSQGdzrlrnUE/lC8C dbd3mKhN9DvaqEg4P660WBHV/3EIit+rzE1WaI6F5iqIUtN9EApj4+K0bQDiYjoZGIzi N34gsUK90oHk/8HrLeh38DrRmGNs6PhAPRoxrne72oU+5J6FS+eax7LCMkUiLe7ODDGO PSQAa/JZ6jFh4xQA6Leq+UigMw9biU0ZMRMC5hwZTFBMy34xkm55qvBbz78gBe7eQFU8 S2Zg== 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=QTQMTnGihEOhnNJB9JQOzJ911TrP0SPKAaKiZ6eM96M=; b=gGY4NjH+gEuyLD+jWjS0OdoHSuhqE3GiWmDpPEevmasI/DWzgKhg3yReD070S7SF6l fJdM2EBz7t5CLhO6dqKhGRT3OeT2QoPSyYt1rsgVGjJ1BPu8VbhRlM5sP44yd8WgpC2r sy8fDiJ+/waB5Qg9cgegzVtdJC6bzTE2k7Nu39bSWQgJ79G2lIFsmEUIqi8AzTrFktya vnSgambklz+tnSaKwsA+gDHzU13FHIFvGalt+lOczH7x2HIoDSx2cTmVdvnfOYSel7Ca Afd1r+8XNtjuQ9knKV8s/tPz5fWaKYvVXeWTrweGx+WqgEADhDPCAsLvQv6TLGeNDtbn 1CmQ== 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 f57si4669558qtf.362.2019.01.11.03.06.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:06:21 -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 73E758E68E; Fri, 11 Jan 2019 11:06:20 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id F13055D9C8; Fri, 11 Jan 2019 11:06:10 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com, Ming Lei Subject: [PATCH V13 18/19] block: kill QUEUE_FLAG_NO_SG_MERGE Date: Fri, 11 Jan 2019 19:01:26 +0800 Message-Id: <20190111110127.21664-19-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 11 Jan 2019 11:06:20 +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 bf736d2b3710..dc4877eaf9f9 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -354,8 +354,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; @@ -381,13 +380,6 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, nr_phys_segs = 0; for_each_bio(bio) { bio_for_each_bvec(bv, bio, iter) { - /* - * If SG merging is disabled, each bio vector is - * a segment - */ - if (no_sg_merge) - goto new_segment; - if (prev) { if (seg_size + bv.bv_len > queue_max_segment_size(q)) @@ -417,27 +409,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 7f4ca073e2f3..61bb72f55fc3 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 Fri Jan 11 11:01:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10757819 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 D222614E5 for ; Fri, 11 Jan 2019 11:06:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C15A029C0E for ; Fri, 11 Jan 2019 11:06:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B51F629C13; Fri, 11 Jan 2019 11:06:36 +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 201FC29C0E for ; Fri, 11 Jan 2019 11:06:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 017F48E0015; Fri, 11 Jan 2019 06:06:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EE23F8E0001; Fri, 11 Jan 2019 06:06:34 -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 DAA4B8E0015; Fri, 11 Jan 2019 06:06:34 -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 AD2EA8E0001 for ; Fri, 11 Jan 2019 06:06:34 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id q33so15927364qte.23 for ; Fri, 11 Jan 2019 03:06:34 -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=4PMt2RxP7MoOPGehHZhpzIBmWUfF03HWn6by5orIN14=; b=enHTam+F3aSM9dybbkn1HRAkWL+ZiYTpJUtt7Trvx/kvYTyT4jmYqgiIh921fdG2nF /ja6OQ1FBPLY+LG3LyWgW/cr2lYdCPw7k5/zfW78DAbdt69vYWPqZpvtXstW9Au5tq/W 8Y660cHA197m4Uun9PN9l0psOwtNK/dL3GDNPsk1ezh/iUvUjHpnOkL1N5ARUo9RGfq3 RR4QImmjY5MKaOxE0Ztjb14NKiUaNIK7D7fanSl4EE1/zugirfx/gOaFLVxdsVHcgUm5 /ACFfhTQTAq18jD8SvKTQcNfAC+QP5X8+gJ5GkLui/sXY2QICRaPqWVkyHOKvoahly7q YgLQ== 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: AJcUukeq0/8/FNiHkkwq07q2GICqrfQSWbh5nbbZaqV41bgDuC0ALkkX BcSa7vNuTnPrAkqgvLIOrCAACTtL92pHA+D2yIUxip0p6VSRPXpg1+yv4YODROZXNKz57dG+pTk yi65/HDZj2u5ZuqemufHTOFfpx7f97k5Ae2nFHr9fJhytynzqUiDaNZILioXfe8hs2A== X-Received: by 2002:ac8:67da:: with SMTP id r26mr13332122qtp.350.1547204794474; Fri, 11 Jan 2019 03:06:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN7RAcYAmtlevKPguOI419wtIQYFVAXu8lyPEhS/QI/1FqGTGlA/oxjwt70oMkYkulWN041b X-Received: by 2002:ac8:67da:: with SMTP id r26mr13332081qtp.350.1547204793796; Fri, 11 Jan 2019 03:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547204793; cv=none; d=google.com; s=arc-20160816; b=oEPgbDfdeG7MGjmzZEezv3WKVUkwbQ8YtFI9k0yoCitdoKeIHMGJp2ymSssoPWkwRi scqUbhey1vU24/qkhBUJo9PiIl0uHokxywEfIU/HnE69CtXyxvTEDvEkTV/hkeAnnkmk 2aJ83ILW8xt/i4aZVJ2x2gr1r0viySEcUCCHyAGGl1M9ny3tup3tmNWiyOd2WetA30Vj Cpusz8y/apdxuwNzxlqr171LcX7+b/hEv1UpwPkpNgPTgGGKESk1m3Wm6Z9K//Lr3qtN Dl87o9e1XwrmUbc140D6w3dhvNx0oSVjdmk2gp7I1bP+ZUa0Ocab+Y2vvHjsro1Fo1+f KSxQ== 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=4PMt2RxP7MoOPGehHZhpzIBmWUfF03HWn6by5orIN14=; b=KG5ZEzOiz3cJ+6mvCxpInynUENg9pUPXehXBxIEpbFRuFSSpy+tln3mms3fQhq3bKF zbZT1xy2WukTPaR8SmkhpCTArciTzT71ZMTjpml95CQlUddfpXJHVRGbIB4DUVyiN/nb 8MIwf40HgBZYJtlp9xy1OEG+aF2zvv7fXT+Mf941DhkMNjarvTlKafsWnUiApyd9vqHh Kda/+T6iojxwHSBfRkH4MMwk8/L6fCJYoedx90ic6yQI1CIHd9lSDll/OmUjCgxPTH5y naS6MT3mPlf/aIz1ZgHIFHHkcRWtFZmbMEFAtspWd5LCqpK9P8FFEdwfUp93xIKaIaX3 TLDQ== 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 j24si2946239qvg.81.2019.01.11.03.06.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 03:06:33 -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 6FE632CD7FA; Fri, 11 Jan 2019 11:06:32 +0000 (UTC) Received: from localhost (ovpn-8-28.pek2.redhat.com [10.72.8.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBF055D6AA; Fri, 11 Jan 2019 11:06: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 V13 19/19] block: kill BLK_MQ_F_SG_MERGE Date: Fri, 11 Jan 2019 19:01:27 +0800 Message-Id: <20190111110127.21664-20-ming.lei@redhat.com> In-Reply-To: <20190111110127.21664-1-ming.lei@redhat.com> References: <20190111110127.21664-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 11 Jan 2019 11:06: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 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 28dd22c6f83f..e3b9212ec7a1 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1906,7 +1906,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 8e5140bbf241..3dfd300b5283 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 a10d5736d8f7..a7040f9a1b1b 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,