From patchwork Mon Nov 26 02:17:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697269 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 EA05917FE for ; Mon, 26 Nov 2018 02:18:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D146E2933F for ; Mon, 26 Nov 2018 02:18:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3F7729618; Mon, 26 Nov 2018 02:18:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=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 2CDB12933F for ; Mon, 26 Nov 2018 02:17:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43FF46B3F64; Sun, 25 Nov 2018 21:17:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 416A66B3F65; Sun, 25 Nov 2018 21:17:57 -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 2E0826B3F66; Sun, 25 Nov 2018 21:17:57 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 072986B3F64 for ; Sun, 25 Nov 2018 21:17:57 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id y83so17868822qka.7 for ; Sun, 25 Nov 2018 18:17:57 -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=85jswBOr7hJzhNcCIFA7nUTq4yrigFMCRFNfS8KyoFY=; b=XBbWy2PGVaVgcQT4+3qNSWoiopOG1IsWRh+iNeCp+8T5Nm4OXx10yzPLolQW0xPBRQ 7dwCUCxntcJvQmVUdqlg5fez6cCKhYhK0Tw9v671SG+XRl+ycHmtvh+3GXd9w+xb1BRP 4b5xsaBx43tcv8OnEKOJaPg2q12xwXiCtt7BTDzUk9sXGHVGwhjIBVJ0AYOwkfKXKOCH pE03bIQ57kakfRRZGSbGMMqavto/nUQTaPlf+sSKDtfi5yrX8fY0YE3E88DD+zcCaef/ WR+LlCOpMi7lI2aj9vb0oPdlNYRHzvz5zaCAt9qMlOB4GMzPQBtgaV5DvMDd4c5rAxPq v0Nw== 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: AA+aEWbXbsGUOq9djqm+PHWs7riybEikQLqRKru35CjSd/walE6SzjOj EcrOGLyX2k9JS8J5ngRLAJSOI8m6ilY1AZJN2MUC4SxlBBo+2mLQYHF9/Jg9DCuvV8irvNBNOdh QdZB03V1hrX9n28H8IlHt5vJnqeXKkM9kpdeDj2L2QPQ4UIuf9TjKp88SXm45JieeBA== X-Received: by 2002:a0c:e84f:: with SMTP id l15mr23632290qvo.124.1543198676709; Sun, 25 Nov 2018 18:17:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/Un4wS/b6PBk8vTkkWiOH4n5toIQ1ITS+czfsPK6HUjsKDe+VHU6GFT2uciZv8YNa6PgrDB X-Received: by 2002:a0c:e84f:: with SMTP id l15mr23632221qvo.124.1543198675076; Sun, 25 Nov 2018 18:17:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198675; cv=none; d=google.com; s=arc-20160816; b=KK9yadWauirenA5jAzvbNyeqnm28qYdPFBoeOV/aJGmEhgqsLMSQIfz5EUWOOI408F /vkoWU5pzRbmX+ZaBfDQSLnveob/5vKSkBBRZHL7M2hQe8cQGjJhoGUsRbs0nzV8e7pc 1oaG+Cd42EkY2yXNKNd5xkNWQgF5979252Sg+86spNL5FGEKmDJYY/tA1RKyoTV9zYJ2 LJ6i/RkK4PuyiQydVuh/zuYk2nFNmcdRjxNSYV84A3+GcNxHrXFYjq+l6GW0rjf3k3cQ kWsRlO4btp+u/bUL6r/4kwZWnrApYn0PMuWeM34xOtKSmBfMLPojxYzd5DYMZw399iLi pTsw== 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=85jswBOr7hJzhNcCIFA7nUTq4yrigFMCRFNfS8KyoFY=; b=KerbT1uhVNibOjC8w81MVfuuzMBbpWEzEBhbj/U9ltyKiR4OJ0Px+b4rFZYPhh2N+k hcBec7oI/eQNRAqMRsehgGlgVDLLaGG/2gWe8cGXXpG2/wM6HBoBnFiSgm7QFNrQhRcC 75lLQL97Albp6SEvBsr/mn1dxJ9jFsTy6QcVJPl6ee6i91lAW3tKQbyOuRHp0DvnvX88 yKFyT7HMjsSRULZXW9TdCWy2NmcOX69ncehwDhTnUY2uy5axlUTMRPjwlk8G0jEYNgqt /2W4u2PIo6YuFSY55jtjUTGi6YBa07NUIUniYAONdaesAERamnRTm9dzNOHoaP+10KNo cutw== 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 46si6267702qtx.375.2018.11.25.18.17.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:17:55 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB255308AA13; Mon, 26 Nov 2018 02:17:53 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD7C32D179; Mon, 26 Nov 2018 02:17:44 +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, Shaohua Li , 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 V12 01/20] btrfs: remove various bio_offset arguments Date: Mon, 26 Nov 2018 10:17:01 +0800 Message-Id: <20181126021720.19471-2-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.41]); Mon, 26 Nov 2018 02:17:54 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Christoph Hellwig The btrfs write path passes a bio_offset argument through some deep callchains including async offloading. In the end this is easily calculatable using page_offset plus the bvec offset for the first page in the bio, and only actually used by by a single function. Just move the calculation of the offset there. Reviewed-by: David Sterba Signed-off-by: Christoph Hellwig --- fs/btrfs/disk-io.c | 21 +++++---------------- fs/btrfs/disk-io.h | 2 +- fs/btrfs/extent_io.c | 9 ++------- fs/btrfs/extent_io.h | 5 ++--- fs/btrfs/inode.c | 17 ++++++++--------- 5 files changed, 18 insertions(+), 36 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 3f0b6d1936e8..169839487ac9 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -108,11 +108,6 @@ struct async_submit_bio { struct bio *bio; extent_submit_bio_start_t *submit_bio_start; int mirror_num; - /* - * bio_offset is optional, can be used if the pages in the bio - * can't tell us where in the file the bio should go - */ - u64 bio_offset; struct btrfs_work work; blk_status_t status; }; @@ -754,8 +749,7 @@ static void run_one_async_start(struct btrfs_work *work) blk_status_t ret; async = container_of(work, struct async_submit_bio, work); - ret = async->submit_bio_start(async->private_data, async->bio, - async->bio_offset); + ret = async->submit_bio_start(async->private_data, async->bio); if (ret) async->status = ret; } @@ -786,7 +780,7 @@ static void run_one_async_free(struct btrfs_work *work) blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror_num, unsigned long bio_flags, - u64 bio_offset, void *private_data, + void *private_data, extent_submit_bio_start_t *submit_bio_start) { struct async_submit_bio *async; @@ -803,8 +797,6 @@ blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, btrfs_init_work(&async->work, btrfs_worker_helper, run_one_async_start, run_one_async_done, run_one_async_free); - async->bio_offset = bio_offset; - async->status = 0; if (op_is_sync(bio->bi_opf)) @@ -831,8 +823,7 @@ static blk_status_t btree_csum_one_bio(struct bio *bio) return errno_to_blk_status(ret); } -static blk_status_t btree_submit_bio_start(void *private_data, struct bio *bio, - u64 bio_offset) +static blk_status_t btree_submit_bio_start(void *private_data, struct bio *bio) { /* * when we're called for a write, we're already in the async @@ -853,8 +844,7 @@ static int check_async_write(struct btrfs_inode *bi) } static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio, - int mirror_num, unsigned long bio_flags, - u64 bio_offset) + int mirror_num, unsigned long bio_flags) { struct inode *inode = private_data; struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); @@ -882,8 +872,7 @@ static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio, * checksumming can happen in parallel across all CPUs */ ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, 0, - bio_offset, private_data, - btree_submit_bio_start); + private_data, btree_submit_bio_start); } if (ret) diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 4cccba22640f..b48b3ec353fc 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -119,7 +119,7 @@ blk_status_t btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, enum btrfs_wq_endio_type metadata); blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror_num, unsigned long bio_flags, - u64 bio_offset, void *private_data, + void *private_data, extent_submit_bio_start_t *submit_bio_start); blk_status_t btrfs_submit_bio_done(void *private_data, struct bio *bio, int mirror_num); diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d228f706ff3e..15fd46582bb2 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2397,7 +2397,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, read_mode, failrec->this_mirror, failrec->in_validation); status = tree->ops->submit_bio_hook(tree->private_data, bio, failrec->this_mirror, - failrec->bio_flags, 0); + failrec->bio_flags); if (status) { free_io_failure(failure_tree, tree, failrec); bio_put(bio); @@ -2719,18 +2719,13 @@ static int __must_check submit_one_bio(struct bio *bio, int mirror_num, unsigned long bio_flags) { blk_status_t ret = 0; - struct bio_vec *bvec = bio_last_bvec_all(bio); - struct page *page = bvec->bv_page; struct extent_io_tree *tree = bio->bi_private; - u64 start; - - start = page_offset(page) + bvec->bv_offset; bio->bi_private = NULL; if (tree->ops) ret = tree->ops->submit_bio_hook(tree->private_data, bio, - mirror_num, bio_flags, start); + mirror_num, bio_flags); else btrfsic_submit_bio(bio); diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 369daa5d4f73..ea3e1a2206dc 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -86,11 +86,10 @@ struct btrfs_io_bio; struct io_failure_record; typedef blk_status_t (extent_submit_bio_hook_t)(void *private_data, struct bio *bio, - int mirror_num, unsigned long bio_flags, - u64 bio_offset); + int mirror_num, unsigned long bio_flags); typedef blk_status_t (extent_submit_bio_start_t)(void *private_data, - struct bio *bio, u64 bio_offset); + struct bio *bio); struct extent_io_ops { /* diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9ea4c6f0352f..c576b3fcaea7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1920,8 +1920,7 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset, * At IO completion time the cums attached on the ordered extent record * are inserted into the btree */ -static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio, - u64 bio_offset) +static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio) { struct inode *inode = private_data; blk_status_t ret = 0; @@ -1973,8 +1972,7 @@ blk_status_t btrfs_submit_bio_done(void *private_data, struct bio *bio, * c-3) otherwise: async submit */ static blk_status_t btrfs_submit_bio_hook(void *private_data, struct bio *bio, - int mirror_num, unsigned long bio_flags, - u64 bio_offset) + int mirror_num, unsigned long bio_flags) { struct inode *inode = private_data; struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); @@ -2011,8 +2009,7 @@ static blk_status_t btrfs_submit_bio_hook(void *private_data, struct bio *bio, goto mapit; /* we're doing a write, do the async checksumming */ ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, bio_flags, - bio_offset, inode, - btrfs_submit_bio_start); + inode, btrfs_submit_bio_start); goto out; } else if (!skip_sum) { ret = btrfs_csum_one_bio(inode, bio, 0, 0); @@ -8123,10 +8120,13 @@ static void btrfs_endio_direct_write(struct bio *bio) } static blk_status_t btrfs_submit_bio_start_direct_io(void *private_data, - struct bio *bio, u64 offset) + struct bio *bio) { struct inode *inode = private_data; + struct bio_vec *bvec = bio_first_bvec_all(bio); + u64 offset = page_offset(bvec->bv_page) + bvec->bv_offset; blk_status_t ret; + ret = btrfs_csum_one_bio(inode, bio, offset, 1); BUG_ON(ret); /* -ENOMEM */ return 0; @@ -8225,8 +8225,7 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio, goto map; if (write && async_submit) { - ret = btrfs_wq_submit_bio(fs_info, bio, 0, 0, - file_offset, inode, + ret = btrfs_wq_submit_bio(fs_info, bio, 0, 0, inode, btrfs_submit_bio_start_direct_io); goto err; } else if (write) { From patchwork Mon Nov 26 02:17:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697275 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 C177516B1 for ; Mon, 26 Nov 2018 02:18:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF5222933F for ; Mon, 26 Nov 2018 02:18:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A231229618; Mon, 26 Nov 2018 02:18:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C63D2933F for ; Mon, 26 Nov 2018 02:18:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 663FC6B3F66; Sun, 25 Nov 2018 21:18:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 638DF6B3F67; Sun, 25 Nov 2018 21:18:05 -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 502CF6B3F68; Sun, 25 Nov 2018 21:18:05 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 1F9C06B3F66 for ; Sun, 25 Nov 2018 21:18:05 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id 98so17818932qkp.22 for ; Sun, 25 Nov 2018 18:18:05 -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=J28GifHhq0vbZn3piUaltnQEoZPZaE4eSIHOBz8uDr0=; b=Q2gSTRF3tIJfvYWgTZXKu90Bq0RpNmg6ZryzcA9QzFZHyZiFO99+3JTt2zBXiy7RVS RGSnqIijRggmBhEEee+KjisYsnyfMvkuOiGHSi7mqpNkhDRjDA4gErQDKHaV8rDZrP4C l7uP2+yPcpFDyMiCqpxZcZwfwd3VPj7635PB4pzPpn/LyPP00grBkC2VJkKMnqdNPDAS SgRSNMbN0YcnHdYV7qxPQlfC3AzYkbBgkfVX2KpHD4KzUqVfJN6F2ZAFK1YxiYVwJ1aD 0GJP1qnTPZ7Yp8t9F+9MdJDkWuVKu5c1KDcbkMM58zQndNBPOlWcjkIHR3tVe+RTGVL+ Jjeg== 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: AA+aEWY0E0hvY1VX9h5VmDedq14q26yDs5VvtvSgYg5MxHFLtZBZ+n8U Rgy/X/4r+JZmWt4Vf44dI0LifL4Bueuaj+lx3eatMA98O5UhlZuBBa1xLg4t9ZHHa65yxN52Wj2 GdCswUPRFMYcDI/yPGaC9ys6w7Of+SMSorPreggAxlh8cC24eeYhNvO2+i6T2kUK/NQ== X-Received: by 2002:a37:d1c5:: with SMTP id o66mr23547246qkl.293.1543198684894; Sun, 25 Nov 2018 18:18:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/VmkZQRYIZYpV7SHpgkEELiJqqmlD0CUlSJ1f5gKIfejVZBiKupNFYlphCPA0+DJWqfBDTF X-Received: by 2002:a37:d1c5:: with SMTP id o66mr23547229qkl.293.1543198684338; Sun, 25 Nov 2018 18:18:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198684; cv=none; d=google.com; s=arc-20160816; b=Zun4SG3o7rfmEUXQ25PPWcK3E/dTDypyKzGWRP6SNfsZz8Ut3yYB6XmAGyB1o8NX3L ZclOfdhXPTsA2r38aLH7l7Tqwy4bKsU2SBwh+smH1ThDv4kUN7pCXvncQbPiV+fpQQHc 5RXBqkuisJwwL5Qy+VbdLBsycG007snii2jknWBhJLDYpJr0cTKjm95mhchQ1sUeHbyM I2/JyuTtihcv0i6ieL6lfk1xCDzqoGps5O9CBsbg5l+j1F9MlMrAEQ+qG2Bvwoz4FRPF iM56GXrVr5MYhuK23N+4pK86T+VKjFGtnqqil3SrWd+AjMUD7ZaRRs0nyp9tudEbOAbT Oc4g== 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=J28GifHhq0vbZn3piUaltnQEoZPZaE4eSIHOBz8uDr0=; b=Qb2iHAIetvScdYbKMqyynjp01oBt65mzunQ+x9ooU9rDhdsAUVbgy2LOyrI9FFlOk4 pUAIs7CcvHbpsbTR9f0/yt23t2y+M8D61y1+udOWDdCecwsBRAaWwPQmXgKlNO0PNh6g iiy1vGd8C2FZ4gSCkIYQQ8yEk8coGsgkUviZR8x7U+OOLK77vrMAZPdx1BPS4WOxs5Ze aMS/oll3uRq2CuUhbTTkBQ+9Cd2CRf/5RrwiJsGQ0Sdy0IWq1nyNBx5J4WefH5Sv4gKM Z9erHMY3IthbDGxT2S3W3G6U8ZhaPz+/Rif1uT71J0WlCmS9pDdF9ltGh0McNgndkpm2 qyzQ== 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 s16si5789310qtk.382.2018.11.25.18.18.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:18:04 -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 06E193084035; Mon, 26 Nov 2018 02:18:03 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 077FA6A6B4; Mon, 26 Nov 2018 02:17:55 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , 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 V12 02/20] btrfs: look at bi_size for repair decisions Date: Mon, 26 Nov 2018 10:17:02 +0800 Message-Id: <20181126021720.19471-3-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.40]); Mon, 26 Nov 2018 02:18:03 +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: David Sterba Signed-off-by: Christoph Hellwig Reviewed-by: Omar Sandoval --- 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 15fd46582bb2..40751e86a2a9 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2368,7 +2368,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 056fb627edb3..6f6bc331a5d1 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -263,12 +263,6 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) bv->bv_len = iter.bi_bvec_done; } -static inline unsigned bio_pages_all(struct bio *bio) -{ - WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); - return bio->bi_vcnt; -} - static inline struct bio_vec *bio_first_bvec_all(struct bio *bio) { WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); From patchwork Mon Nov 26 02:17:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697289 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 B56B317FE for ; Mon, 26 Nov 2018 02:18:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1E0E293BD for ; Mon, 26 Nov 2018 02:18:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95E2029927; Mon, 26 Nov 2018 02:18:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F38F229618 for ; Mon, 26 Nov 2018 02:18:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3D8C6B3F67; Sun, 25 Nov 2018 21:18:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F13206B3F68; Sun, 25 Nov 2018 21:18:16 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDC136B3F69; Sun, 25 Nov 2018 21:18:16 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id B12B16B3F67 for ; Sun, 25 Nov 2018 21:18:16 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id z126so18029306qka.10 for ; Sun, 25 Nov 2018 18:18:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=J89zl5kQ3BTex+7oYI2+/tHtb1DQsIxa4S9PEfUlIUk=; b=j1Z+N/9gHX++bJP2HRbyyOO2EEPCUUqBSCtZaHzJfT06x5CoexEWLFCgw+BUBMD8ua TRJoAuKvilaCG/57TAAssHq124ucDMp9uLlXcAiegZnL075MU2vCHFjCmYv8uf4IvDSU 6kkl5KaxV8jipbujSvLTIr1iX6BiQR3bCZF0vuN2ILSx352vP8f13E77+Exz02gyZvhi oRVzQj9sbptBelEXGx19IL14a7QJ0sGB2UjM9Hd5JWDyir9cK6d4MRYRxBb1MFlmq/w9 NI0uCl9qWkbHqJnKUSZrSA5+U+dNyp58vOa8e2Tgwl9Ywl8F8yn0fpxTrXp5gRg7BAF1 E09w== 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: AGRZ1gINEhCVk/LV7VmRAh8/CDnObg6DV109524HfEzYIUgZG5WLOa6W GC99dtCPZj7NvcSscufXHw1bEQYWbxiA215GPtJ3L7K58xZQc7IN5Wk25/7TZOkfJTESxCIlSI3 wlzxww1waLEgWRv9IMPJUh6/E/OBLNlfExPs6jsedpWUuwFSeYOAignCSqcszUvs2vw== X-Received: by 2002:ac8:4359:: with SMTP id a25mr24291483qtn.361.1543198696443; Sun, 25 Nov 2018 18:18:16 -0800 (PST) X-Google-Smtp-Source: AJdET5fE8C9GEwugsrgW72tfgmJ38zTSyHdu3F0W1H74cH6PsshSyypj7czV+uqAmFpGu0EHAXxK X-Received: by 2002:ac8:4359:: with SMTP id a25mr24291455qtn.361.1543198695634; Sun, 25 Nov 2018 18:18:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198695; cv=none; d=google.com; s=arc-20160816; b=SS1jY9N7+EfRQqhoelnJS7mDDQwOgSIvtG04E3/x9QEW4UMu7lWMOBUwumcmRQcIkU 5uqWbzhSQ+ehJyWtfexsTu8uVKfl3KnwTCqWTlVsWl3i1kk76Cl+F/6vcsP623EecjJk 6riDeDpatGGlKpgD0ZYoXti6JJxQYTzxhxjl1YQbD25gHLdX5UOjIlK3rqk7yWuCVgpy 6u91OcgtuEE72fCDQbUx1HI3Wg4aJJUNuTSMtp4gUjH+TTFleS3/RP1x22NGLeWYr9rD YsSVpGVIft+DXyeCgIWDjTuxMQ32oXkRk4VXl4YFGylfSxR7QIKtdTuyX1L9ml+CJ1fI uDRg== 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=J89zl5kQ3BTex+7oYI2+/tHtb1DQsIxa4S9PEfUlIUk=; b=haFAuW+N9UAzsuQeO+GdirbBeFZQKNLsp3QeHWaPLd0UA93sOfGaEy+k0bb6Wnm9AL 3u/D6CeZ9vLXFOHjbmMiWgJ5G+PgTGuOe8F4/bNPsuA0PyIv539xrl83Q8o3pZgJx9aG 7rz+C4PeGk0IyVPKpy/hkY31M0/knZyB0nZ9lhOi0150WU1mCUTgqRsQfLc/Yoc8PIVV ppCWR+qYkPKyt+D3kftcoiPoCcfZtkHzqs3bswWRet4riGjcErch3Pemg3+MEFPF5Vs+ lMsqhKed93V90v1N6ZeRWT6sZ5HozfyBmlTLTtmDC5dbpYoIYmyVD8Qwl3izPCBwxQnu CsVw== 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 i66si542736qkc.207.2018.11.25.18.18.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:18:15 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 6A69C300B914; Mon, 26 Nov 2018 02:18:14 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F0DD2D17B; Mon, 26 Nov 2018 02:18: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, Shaohua Li , 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 V12 03/20] block: remove the "cluster" flag Date: Mon, 26 Nov 2018 10:17:03 +0800 Message-Id: <20181126021720.19471-4-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.43]); Mon, 26 Nov 2018 02:18:14 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Christoph Hellwig The cluster flag implements some very old SCSI behavior. As far as I can tell the original intent was to enable or disable any kind of segment merging. But the actually visible effect to the LLDD is that it limits each segments to be inside a single page, which we can also affect by setting the maximum segment size and the segment boundary. Signed-off-by: Christoph Hellwig Replace virt boundary with segment boundary limit. Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- block/blk-merge.c | 20 ++++++++------------ block/blk-settings.c | 3 --- block/blk-sysfs.c | 5 +---- drivers/scsi/scsi_lib.c | 20 ++++++++++++++++---- include/linux/blkdev.h | 6 ------ 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 6be04ef8da5b..e69d8f8ba819 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -195,7 +195,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, goto split; } - if (bvprvp && blk_queue_cluster(q)) { + if (bvprvp) { if (seg_size + bv.bv_len > queue_max_segment_size(q)) goto new_segment; if (!biovec_phys_mergeable(q, bvprvp, &bv)) @@ -295,10 +295,10 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, bool no_sg_merge) { struct bio_vec bv, bvprv = { NULL }; - int cluster, prev = 0; unsigned int seg_size, nr_phys_segs; struct bio *fbio, *bbio; struct bvec_iter iter; + bool prev = false; if (!bio) return 0; @@ -313,7 +313,6 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, } fbio = bio; - cluster = blk_queue_cluster(q); seg_size = 0; nr_phys_segs = 0; for_each_bio(bio) { @@ -325,7 +324,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, if (no_sg_merge) goto new_segment; - if (prev && cluster) { + if (prev) { if (seg_size + bv.bv_len > queue_max_segment_size(q)) goto new_segment; @@ -343,7 +342,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, nr_phys_segs++; bvprv = bv; - prev = 1; + prev = true; seg_size = bv.bv_len; } bbio = bio; @@ -396,9 +395,6 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, { struct bio_vec end_bv = { NULL }, nxt_bv; - if (!blk_queue_cluster(q)) - return 0; - if (bio->bi_seg_back_size + nxt->bi_seg_front_size > queue_max_segment_size(q)) return 0; @@ -415,12 +411,12 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, static inline void __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec, struct scatterlist *sglist, struct bio_vec *bvprv, - struct scatterlist **sg, int *nsegs, int *cluster) + struct scatterlist **sg, int *nsegs) { int nbytes = bvec->bv_len; - if (*sg && *cluster) { + if (*sg) { if ((*sg)->length + nbytes > queue_max_segment_size(q)) goto new_segment; if (!biovec_phys_mergeable(q, bvprv, bvec)) @@ -466,12 +462,12 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, { struct bio_vec bvec, bvprv = { NULL }; struct bvec_iter iter; - int cluster = blk_queue_cluster(q), nsegs = 0; + int nsegs = 0; for_each_bio(bio) bio_for_each_segment(bvec, bio, iter) __blk_segment_map_sg(q, &bvec, sglist, &bvprv, sg, - &nsegs, &cluster); + &nsegs); return nsegs; } diff --git a/block/blk-settings.c b/block/blk-settings.c index 3abe831e92c8..3e7038e475ee 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -56,7 +56,6 @@ void blk_set_default_limits(struct queue_limits *lim) lim->alignment_offset = 0; lim->io_opt = 0; lim->misaligned = 0; - lim->cluster = 1; lim->zoned = BLK_ZONED_NONE; } EXPORT_SYMBOL(blk_set_default_limits); @@ -547,8 +546,6 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->io_min = max(t->io_min, b->io_min); t->io_opt = lcm_not_zero(t->io_opt, b->io_opt); - t->cluster &= b->cluster; - /* Physical block size a multiple of the logical block size? */ if (t->physical_block_size & (t->logical_block_size - 1)) { t->physical_block_size = t->logical_block_size; diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 80eef48fddc8..ef7b844a3e00 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -132,10 +132,7 @@ static ssize_t queue_max_integrity_segments_show(struct request_queue *q, char * static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page) { - if (blk_queue_cluster(q)) - return queue_var_show(queue_max_segment_size(q), (page)); - - return queue_var_show(PAGE_SIZE, (page)); + return queue_var_show(queue_max_segment_size(q), page); } static ssize_t queue_logical_block_size_show(struct request_queue *q, char *page) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 0df15cb738d2..78d6d05992b0 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1810,6 +1810,8 @@ static int scsi_map_queues(struct blk_mq_tag_set *set) void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) { struct device *dev = shost->dma_dev; + unsigned max_segment_size = dma_get_max_seg_size(dev); + unsigned long segment_boundary = shost->dma_boundary; /* * this limit is imposed by hardware restrictions @@ -1828,13 +1830,23 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) blk_queue_max_hw_sectors(q, shost->max_sectors); if (shost->unchecked_isa_dma) blk_queue_bounce_limit(q, BLK_BOUNCE_ISA); - blk_queue_segment_boundary(q, shost->dma_boundary); dma_set_seg_boundary(dev, shost->dma_boundary); - blk_queue_max_segment_size(q, dma_get_max_seg_size(dev)); + /* + * Clustering is a really old concept from the stone age of Linux + * SCSI support. But the basic idea is that we never give the + * driver a segment that spans multiple pages. For that we need + * to limit the segment size, and set the segment boundary so that + * we never merge a second segment which is no page aligned. + */ + if (!shost->use_clustering) { + max_segment_size = min_t(unsigned, max_segment_size, PAGE_SIZE); + segment_boundary = min_t(unsigned, segment_boundary, + PAGE_SIZE - 1); + } - if (!shost->use_clustering) - q->limits.cluster = 0; + blk_queue_max_segment_size(q, max_segment_size); + blk_queue_segment_boundary(q, segment_boundary); /* * Set a reasonable default alignment: The larger of 32-byte (dword), diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 9b53db06ad08..399a7a415609 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -341,7 +341,6 @@ struct queue_limits { unsigned char misaligned; unsigned char discard_misaligned; - unsigned char cluster; unsigned char raid_partial_stripes_expensive; enum blk_zoned_model zoned; }; @@ -660,11 +659,6 @@ static inline bool queue_is_mq(struct request_queue *q) return q->mq_ops; } -static inline unsigned int blk_queue_cluster(struct request_queue *q) -{ - return q->limits.cluster; -} - static inline enum blk_zoned_model blk_queue_zoned_model(struct request_queue *q) { From patchwork Mon Nov 26 02:17:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697293 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 10B801750 for ; Mon, 26 Nov 2018 02:18:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F32D429927 for ; Mon, 26 Nov 2018 02:18:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E603429A13; Mon, 26 Nov 2018 02:18:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7526029A11 for ; Mon, 26 Nov 2018 02:18:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0B066B3F69; Sun, 25 Nov 2018 21:18:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D180D6B3F6A; Sun, 25 Nov 2018 21:18:18 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C07426B3F6B; Sun, 25 Nov 2018 21:18:18 -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 8B06B6B3F69 for ; Sun, 25 Nov 2018 21:18:18 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id b16so15140255qtc.22 for ; Sun, 25 Nov 2018 18:18:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=i2RSDXiiLv4eqGo5PQxpOUk/2wBp+PkxCNDt1NMuxnk=; b=NxS45HiAmyUs8kR26iVF+xDlUjPbUPD5+J+H/+5QL4NNojAA40vWm0XfMfPb8nzn07 knn2VRcCZUNC5BBHTOKDTcnm7vvV4u+SViFCrYEo+JYaK7MhlnPLSAIiFLFa/pp8Qxqh 5x7iOTL3e25oW74n0KdDprGoXbzFQ18Zca7joHtsHLpkEU5zMXQqGj4UT/mdvSpNMDp3 HJTRmbDjdbMFPzBTMPmZ6cxzbp5h0e5VLpgKUVOCTOcJHfSLcSI+F49u2aZeT2Hnt26V C75Yj9hj9oDdYnGwEGXtwCf0WfKAq7v+OzWnUbYeWfl9UjJYg7BmfjsfHaD9n4HaZOS+ CieA== 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: AGRZ1gLACC5++1PJAhouA9FEia9h7x74wB1q7h7548PxyxtDexIhOtMW ZOTdfivZo1sDLqbpEVmlb328qZIiwKrI70+JT+F6HCVrHXwsC+5Il8e+98hczvOV7fgqE+xClzm VnDLoIzw+GRfaFsrs1/Y1QUxHbdttxu2orlw5G7eMZ4ifnrTaWkEzFgRpOyqX6DZ4bA== X-Received: by 2002:aed:2e63:: with SMTP id j90mr24264383qtd.35.1543198698332; Sun, 25 Nov 2018 18:18:18 -0800 (PST) X-Google-Smtp-Source: AJdET5c8JoiHesoTLg8mTD6HwHTOSIqtb1Lln0VDtbTKsjbkGOjCWT+g9OxWn/mMJLoIUi0srQTG X-Received: by 2002:aed:2e63:: with SMTP id j90mr24264358qtd.35.1543198697796; Sun, 25 Nov 2018 18:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198697; cv=none; d=google.com; s=arc-20160816; b=ryHnu1GtcyrwUS6B4IRRFYyordJVt8Jd25L5VEQ2k/o+/G9RHLSs45QYQdVN5jvMvP A97tGaZtmhTifYkZk0EorD8BIA2mIHlCjy6mQHTeL6el3JmPJAoA14OUtthTlOUUJxuc hD0ZPJLlrqEPMHSDsoPbaMImsIxEAB3IcWpkvbNMHiHCJtfquxtqKvsOEa1H1gAJAlf4 1a4mcZw1Gl3b4ufkOfR5VSmAW7pXqiLkLi1QesT+l5wbOlhRcTnAf0z1m3AnEP5qd3Kb Ii8WiF406hRG+/fFNL03/CUB2LMuYx/PIMPaxF7F7vWio6NAxrIg5+kQSZnzZ0MeETX4 oSHA== 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=i2RSDXiiLv4eqGo5PQxpOUk/2wBp+PkxCNDt1NMuxnk=; b=G3sGxur7LB2dhjxOjGq7N14lfbWsQHpIJcR/FQrByk2hsaI7TtO46GT2KJkHNJOOwD 1n0ThSeIcMbeE817136/XBXNSKuDsY27ZDmebUXSNlcFCKye6+RWc0ZRH60Gfoo5Ho01 FDAlVuGAydJz01Ek4wU85uiJaRtzoM11tMGX6CNBj8FFsYBqI4oUM9LpmbjvJir6s2Ps /SBLUiMKp87fmrVnMKW60wCElKYWWUsc94Hwbe1JNNnLHLLHazZmLFElDjhaTgIuvypj NuFcetjG6KyHAUf2ifJmaNn7NBh6jxKfKwFbaiqro5NaajZT1dfeEc5PdfSgBQwgs1ol itcA== 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 c10si1577172qvi.210.2018.11.25.18.18.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:18:17 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 B9DF4C0578FA; Mon, 26 Nov 2018 02:18:16 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC0292CD5B; Mon, 26 Nov 2018 02:18:15 +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, Shaohua Li , 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 V12 04/20] block: don't use bio->bi_vcnt to figure out segment number Date: Mon, 26 Nov 2018 10:17:04 +0800 Message-Id: <20181126021720.19471-5-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.31]); Mon, 26 Nov 2018 02:18:17 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It is wrong to use bio->bi_vcnt to figure out how many segments there are in the bio even though CLONED flag isn't set on this bio, because this bio may be splitted or advanced. So always use bio_segments() in blk_recount_segments(), and it shouldn't cause any performance loss now because the physical segment number is figured out in blk_queue_split() and BIO_SEG_VALID is set meantime since bdced438acd83ad83a6c ("block: setup bi_phys_segments after splitting"). Reviewed-by: Christoph Hellwig Fixes: 76d8137a3113 ("blk-merge: recaculate segment if it isn't less than max segments") Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- 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 e69d8f8ba819..51ec6ca56a0a 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -367,13 +367,7 @@ void blk_recalc_rq_segments(struct request *rq) void blk_recount_segments(struct request_queue *q, struct bio *bio) { - unsigned short seg_cnt; - - /* estimate segment number by bi_vcnt for non-cloned bio */ - if (bio_flagged(bio, BIO_CLONED)) - seg_cnt = bio_segments(bio); - else - seg_cnt = bio->bi_vcnt; + unsigned short seg_cnt = bio_segments(bio); if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) && (seg_cnt < queue_max_segments(q))) From patchwork Mon Nov 26 02:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697315 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 C5DF81750 for ; Mon, 26 Nov 2018 02:18:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B46D129889 for ; Mon, 26 Nov 2018 02:18:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6D692995C; Mon, 26 Nov 2018 02:18:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=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 98DFE29889 for ; Mon, 26 Nov 2018 02:18:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2F346B3F6C; Sun, 25 Nov 2018 21:18:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C055A6B3F6D; Sun, 25 Nov 2018 21:18: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 ACCEF6B3F6E; Sun, 25 Nov 2018 21:18:38 -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 8028E6B3F6C for ; Sun, 25 Nov 2018 21:18:38 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id z6so15254709qtj.21 for ; Sun, 25 Nov 2018 18:18: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=ppLexaBx3GlwO/Rrt5sG9akfv80BsODE54PFkogFcPM=; b=f/XzIQzMC47qXvasMOH2x7lep6xLbL7Ieq2fA98avCT/g0GDKpEFiNA4VMYofWPX8f 61d5k+tUov+8386KDO9mkMT/OlAr/WUmnL/ryuAYSpYKtOCxbSPRtcnOaDyn5IQw+0j/ 30Lc6FAOGm3Nyv1V10lM+t0pxCfrb1bDH11qaRKaruVKBqJogFM5d5yTWK9i/lV9gsXZ 15AwGIesHLPlocenB3qrvF6ysPnbDfv+nza+j7gAcG+UNCFbUdsMvqjqzkBCIwcFK791 Nc3gH9SSWvGMM6AZ2exRLYnJemuV6h5AEOiiBhfq6u7ZhYG2MpnxPfu95LRLMj0lsdx8 CS8Q== 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: AA+aEWb/e5MA+APDyirg23LENgi2kwMoXPJpiI70b8/92lO0dBqpHzz0 ZjzPAEOy67GwvtwCzsHZZT7D/zoTzuy52W8a4nlyjmcFhVI+9PmZ+IC/lvw5bGGFNXxVBqmvkXU lHxfXKpr/MCFVz0+lMaxXSy6IqVgJ5AATlm4SUCMj2g/ltYZi5u3OAHaOr5O6xtmsgg== X-Received: by 2002:ac8:7451:: with SMTP id h17mr20391766qtr.319.1543198718308; Sun, 25 Nov 2018 18:18:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1CS0DoJ8IT1MvsFltpz6YDW1Ug7miRU8X0oecRQtpsM7gR1s7LKtEkav+JbIr68tjCqd+ X-Received: by 2002:ac8:7451:: with SMTP id h17mr20391741qtr.319.1543198717589; Sun, 25 Nov 2018 18:18:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198717; cv=none; d=google.com; s=arc-20160816; b=YeV5gBb+yxf1Yqb6AIMLEsTLDy63pDKFBhVIGh7mturOyHOJvH/0pE7Nm0Liy9yJUZ m1s/u8h6o8CHkYiK9T9eXJP+Wom8dB1T3IrsrTNqofgSgZzeQhXDLutD9417wMmxDPc/ hkezY412VTKcMtAQ6IIAQA0H4rf56TispXtz5BARpdB4TQdJv5TBk30sju3vQioiX/zt 9JOtoKSsMPBcfvaLx5BQNRT26COQQpk4VxKmyzOeVOel5G6cyhAUohA90PRTsTjwbdVz IfACkWqJJsrtBeLfcZpStpTjT3es5ZJ1nS115RI1Dl4Li8iOh76KJVMH7zV1W8s+PvZ6 lxYw== 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=ppLexaBx3GlwO/Rrt5sG9akfv80BsODE54PFkogFcPM=; b=ylDCSrGfV4JUj4G8MTJhuajeXuAeQ1P2buNGm8xVCCnWiqydLnlkGKv7K+/NL2wKXH HTQn31ApSQ0ugAYcOylNsiG5oQUgXWHwG1Qe0GkMR4cCUwOeDR6WxFbTNQpquCD4VX79 8YAb24iu2f02hQoDdhCHhzx2jiEaOk8P8qxJeqjvmShZJ5w16NAE5+B3FygCiYG2V12z aP86odsbZUUscpLCN7BiHakhCMjJDjRCCGokq2UCsUGhdPH+KV0SaHXOihnpUrZyCskU WLTzkmJhMxX0fwR76OJbCG4JO4W3dIjXv5e3vZe/CM/2eGmwd9mK8AstWoG04QA43LN8 VmNA== 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 q31si13155705qtj.66.2018.11.25.18.18.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:18: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-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 982B789AC5; Mon, 26 Nov 2018 02:18:36 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA9725C1B2; Mon, 26 Nov 2018 02:18:18 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , 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 V12 05/20] block: remove bvec_iter_rewind() Date: Mon, 26 Nov 2018 10:17:05 +0800 Message-Id: <20181126021720.19471-6-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 26 Nov 2018 02:18: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 Commit 7759eb23fd980 ("block: remove bio_rewind_iter()") removes bio_rewind_iter(), then no one uses bvec_iter_rewind() any more, so remove it. Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval --- include/linux/bvec.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 02c73c6aa805..ba0ae40e77c9 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -92,30 +92,6 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv, return true; } -static inline bool bvec_iter_rewind(const struct bio_vec *bv, - struct bvec_iter *iter, - unsigned int bytes) -{ - while (bytes) { - unsigned len = min(bytes, iter->bi_bvec_done); - - if (iter->bi_bvec_done == 0) { - if (WARN_ONCE(iter->bi_idx == 0, - "Attempted to rewind iter beyond " - "bvec's boundaries\n")) { - return false; - } - iter->bi_idx--; - iter->bi_bvec_done = __bvec_iter_bvec(bv, *iter)->bv_len; - continue; - } - bytes -= len; - iter->bi_size += len; - iter->bi_bvec_done -= len; - } - return true; -} - #define for_each_bvec(bvl, bio_vec, iter, start) \ for (iter = (start); \ (iter).bi_size && \ From patchwork Mon Nov 26 02:17:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697325 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 0BD9C16B1 for ; Mon, 26 Nov 2018 02:18:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED93E29975 for ; Mon, 26 Nov 2018 02:18:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0F2B29988; Mon, 26 Nov 2018 02:18:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=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 0DFB729975 for ; Mon, 26 Nov 2018 02:18:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10BBD6B3F70; Sun, 25 Nov 2018 21:18:51 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E2896B3F71; Sun, 25 Nov 2018 21:18:51 -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 EEC306B3F72; Sun, 25 Nov 2018 21:18:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id BF6BD6B3F70 for ; Sun, 25 Nov 2018 21:18:50 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id z68so18196692qkb.14 for ; Sun, 25 Nov 2018 18:18:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=3SZHY3vLa9rG6mdwBXekiArQmYZtvFkdEYqjv8ekeG4=; b=YvshTbPPAhuK9LsTa4sewRX8WMtEq0PP4l8paoDSKzsovJf8pFFF4oCQtiNKaK8nyN a54JC8p4w+3x4yKvr8N97/wZF9zycILnHdgiyBLAhCRcsiDtuv06+XH68RMvCAi3jN91 2FyuTV/BidMlLUROoz2/VgxGuGc/k127zOlYd/AQzMX/kljj70b9W0M7SpLr87PtGSAM Kf96jZZJUczW7jMwNVqUr8QZ6o1aNgHaYhb6m6pPk1VV+xzXqnFdawuuhXYNWWFTUvrH 7ImRAc93+eJNW0ESozpN6wKssEE0SXJmj00bHKc2nTTRveDf2JHeBvIsxjLzTsw/Gepr Z2fA== 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: AA+aEWYLbG1P0AAVY7qO+ndMfxKdOI5bK4aStckgjb+NJZyANDTRPNs/ 4F4uuYlJSaw3n/kNQSzsq3epxmzGSu+Hf2koFELtZIht3ujeWTGuxJZ1MCMxcfZHGcjgk18dgv9 33eE6Gbdv+UVhuVtagy+xofi0nmfGobui6Zg5Zp69HW9LAQaHrkSK3M3QTy+eW8F1lA== X-Received: by 2002:a37:6801:: with SMTP id d1mr22869257qkc.217.1543198730503; Sun, 25 Nov 2018 18:18:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/VsSBhgR3YqB90vZTiqqTvBNvGZjkAM7evJ358hT+kiBtiZ6eBCyMzou+rnxkPStq/bXPzy X-Received: by 2002:a37:6801:: with SMTP id d1mr22869224qkc.217.1543198729548; Sun, 25 Nov 2018 18:18:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198729; cv=none; d=google.com; s=arc-20160816; b=A67iuqZCYpY+Faz9c4S7e6yG1Bie3XV93/AytgW72E9OW1MBadPzYUM2Zge978abna L9DNHKoHhxnRWmA/cqmVrprGD8APXJ080w4fLG4woeNWuTftfhcLZnt78D58Sw3sKHnw GRrGM3kweuBBTVWAscHFI2EqTrd2KGnq7i1WOkOpmeb1KlSsBz2zk0dGMV0enEFWOvwi 7GOGmpJ/AjInO5KEgiG/qwFjBAqFtMmuUFNIORcqH5R1n8BgJ4SbTsTNxyhc0apun6+x T5CbETiTh7QuwrspRFrmh8rWhviE5cEQEYZzkRx5/uGWQWMyWk1wc+HOFZDwedv0Ailj 3QNw== 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=3SZHY3vLa9rG6mdwBXekiArQmYZtvFkdEYqjv8ekeG4=; b=cwDRzTgigS+/DpVrhBHQEh0pnbjiscuvRj/fErrgEFNM1xChxphRvSMXg/aatCPnG6 r8lbPWtnjxYQLOSmlWBnIzFPpNlh7vtO06YYGDuA7zl4hX17+Ev759K30RglePdiDWif G74UM6BdKO7ODcgyMi8OpIq9s824e0ij+Ej400iUxOov2x0HN0K+HGtY+qmKXMTDaJKG n7kGtx2LE8zU2RrSzzL0jKBa9FswQCsz9cDHiI8HFGmuXojw/ssqDlMdC67eqkH9lhAl qqlpAq7nsBhEge/aaJoDk5HTwD9cNQKBUuZxH5HFgaRnBPe0Ed8o9Y6fcRMWGXVVo1wm ut1g== 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 x24si7048434qtp.214.2018.11.25.18.18.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:18:49 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 6F5D6461F8; Mon, 26 Nov 2018 02:18:48 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC7D719753; Mon, 26 Nov 2018 02:18: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, Shaohua Li , 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 V12 06/20] block: rename bvec helpers Date: Mon, 26 Nov 2018 10:17:06 +0800 Message-Id: <20181126021720.19471-7-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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]); Mon, 26 Nov 2018 02:18:48 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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. Suggested-by: Christoph Hellwig Signed-off-by: Ming Lei Acked-by: Miguel Ojeda Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval --- .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 bb3096bf2cc6..bb037ed2b4eb 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 6f6bc331a5d1..6a0ff02f4d1c 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) @@ -733,7 +733,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 7ebccb5c1637..e34eef12740f 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -65,7 +65,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 57fcc6b4bf6e..c543426ace9f 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -889,17 +889,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; @@ -912,7 +912,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); @@ -925,9 +925,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 Mon Nov 26 02:17:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697337 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 C7E1417FE for ; Mon, 26 Nov 2018 02:19:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B65F929A29 for ; Mon, 26 Nov 2018 02:19:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A941A29A2C; Mon, 26 Nov 2018 02:19:05 +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 3359F29A2A for ; Mon, 26 Nov 2018 02:19:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 503296B3F73; Sun, 25 Nov 2018 21:19:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4D8D36B3F74; Sun, 25 Nov 2018 21:19: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 3A0EE6B3F75; Sun, 25 Nov 2018 21:19:04 -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 0DFC16B3F73 for ; Sun, 25 Nov 2018 21:19:04 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id z6so15255363qtj.21 for ; Sun, 25 Nov 2018 18:19: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=lloQNHzy519wn2iu+Z2myWbbZPs4FDGIkPv0Pi+d1Ys=; b=lCV5GKFnUixDG22hRP91SB+xnqmX/yATbU+vLmQAgNlThZSFBSspuZksp9jXyMsBiA drQQBhqVQSxxliFUYZBoAQPkqyfkZ6R/bvOxzCmpNx36XdfF+sLUM/VLNqeeQp7vO5rL //fMJNwSZX5suaiLrOxIEe0nRux/COubZYJ/tJ8ArpxIMdUMRBU61FBqjulLlpMhh267 ZvTJF+4tRiurQoeEQ/nDWfjLwa80Dd3jS4pLLWev06flpDOC6Fs3kegrF4ACL0kCibAt Ww+CxNUzDyV6Mju+wWUo/jh+caqhxqoC39RMd4/rQvaW/Bh3Ro0cJDYtTFGWaQeXpH1q VU4Q== 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: AGRZ1gKBc9YPogXlnMueefpEdPPDX4aIcg3GIRuCfseYf6IlhQ4fOTEA +n/8if7tOFKyXl0Fk5YlaLJlogNyHOy7UzidK8hZ27ctkqbw4qmnjVhCKyWtUiXES2/bll76fuu tkyKXgG4qhMLgeR6JtuLdK6ZBgpbsVdM5uu4MNEgfGTMgi1fkx9hqP5IZamDL0+6tiw== X-Received: by 2002:aed:31c5:: with SMTP id 63mr23794122qth.385.1543198743813; Sun, 25 Nov 2018 18:19:03 -0800 (PST) X-Google-Smtp-Source: AJdET5ezlVBRusFfxFUK/KyMc52+1xwd4zybQP1XIZl+Zgq8ZMl8U5n6kc/ZUSuz8Hx1xUEQ2Gxs X-Received: by 2002:aed:31c5:: with SMTP id 63mr23794107qth.385.1543198743016; Sun, 25 Nov 2018 18:19:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198742; cv=none; d=google.com; s=arc-20160816; b=v6tdvC48U2zvs37pExJd3QE9myKfvGghGNrEOm5cQzdT/jUjWilEcU3FOW5jKhd0PY fVW8995PTmcZN9GtHb5ioRuOJsp0D3n9p5jeW2ONRB1TzAqxAAW1ZqPcWuqSVJoLtK/X 0YkM8HTG6+SKPi8dWfn2D5XGaRVC/J61x/FXhIRExUZxuBuhwv2fZ/W4aLuQkPfZu4/h nQ5a3ZFFMnDpkL8zI0KGEUNn+fo6t+CCYvntk/gUM5DobOZA+xCP03R7EEwASrO4UrKz GvTG+YeSR4cwbZtUPbRo59XoWJhRpqaWPpNKcqAHshKZ9Z5B4KcM7Gmr4qGO1suf3bZ1 f+Ww== 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=lloQNHzy519wn2iu+Z2myWbbZPs4FDGIkPv0Pi+d1Ys=; b=UAMP9om3q0TdKgfoteP5H9ndygiqdMoOJIh5UefaiMFT+DM/TRzyXAM2MHUdF8vUgE fOIi2v/25487jfOdmL5oY3SbZnRlcgLp4zvF2JDWuYcbBfgR29HBuycrckl/M6BYcLHo Ibi6hW7G/qLKFyb9ZGaZKYfRJ2MUianXr4Lel4OlYpxw3M4n+v63qFJQgw4ycb4sC6U8 HbNKcOYrnVZr1kmbu9dJukj9wClkGzzh5cYL8oIul4SKOVCDqAFZ3CCUuUyENyil9RSe 9VLykodwdli9sCPlx0xBCWzJcNgeL+M2ZoK7j++YBWslfDHFr1c+Ahv4whS895RPnIRz p/fA== 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 j80si7842494qkh.96.2018.11.25.18.19.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:19:02 -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 D235A8535D; Mon, 26 Nov 2018 02:19:01 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AEF82D1E3; Mon, 26 Nov 2018 02:18:50 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , 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 V12 07/20] block: introduce multi-page bvec helpers Date: Mon, 26 Nov 2018 10:17:07 +0800 Message-Id: <20181126021720.19471-8-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 26 Nov 2018 02:19: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 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: Omar Sandoval Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig --- 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 Mon Nov 26 02:17:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697349 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 7396C17FE for ; Mon, 26 Nov 2018 02:19:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62513298A1 for ; Mon, 26 Nov 2018 02:19:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5639629A2C; Mon, 26 Nov 2018 02:19:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=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 ED92E298A1 for ; Mon, 26 Nov 2018 02:19:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26B406B3F74; Sun, 25 Nov 2018 21:19:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 241466B3F76; Sun, 25 Nov 2018 21:19: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 10B586B3F77; Sun, 25 Nov 2018 21:19:21 -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 D86F96B3F74 for ; Sun, 25 Nov 2018 21:19:20 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id u32so15455076qte.1 for ; Sun, 25 Nov 2018 18:19:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=JmcaCNMSWSxCE7cr5FHQOO01hm2NHoIVxTuAFK08snc=; b=DtsWVcpRG5DzFZjR9jvVrUaqoSDGiTuzYC22Gci9p6INWU7hg6ulJy77vsYtZzgfl6 i/GSMG7WsIq84bvQ8SmWe5JF4AlABU+6aB8Pbcy+/ox22rCUBlX0OjtOGRC3GCt3QVaH LDUHogizH8v56ZL8TsKO1pjraT8I0mMBaaveYnv8yT4ic4rCF57PRvd3+/VF6oof74C4 HfpNc1cMJFk0A7+ZJZ4jwqGe39h1KLTzlL8CCQpsDCfUSTH/JoInlYfk3BL6aYXZm56b 2aeQKCYjssLJk/lYU+BIQPgEdpRI2DD+U71ObolYWApEg1cSPuPm/lVodju5oHb7hhJp rRfw== 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: AGRZ1gJCIKbC+cxFwqKjlHKWXftyS0u15Pyro2etYcNSQGtmha8k6nSq sEeeR21XWyqnXCcIJCFGucFPRdq20uuLzPNvOJVR58y4cgO44+uuwutbThaoU/mTxdyVyDTRNeh ifOrg5nuswaZt09JPsxQZGlf7sYBMClRIGPryf+68zBWnIt0sfblSrxg9W5r+Xf/qxw== X-Received: by 2002:aed:2391:: with SMTP id j17mr23448851qtc.205.1543198760651; Sun, 25 Nov 2018 18:19:20 -0800 (PST) X-Google-Smtp-Source: AJdET5cB4Rvw1xKFgrUnULbJYfltVJ8BA2Y2wqF7hYga+NIFK3/fQgc+ayrVAYzmqJf6WLdPiare X-Received: by 2002:aed:2391:: with SMTP id j17mr23448830qtc.205.1543198760064; Sun, 25 Nov 2018 18:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198760; cv=none; d=google.com; s=arc-20160816; b=ylty6Jaj64NRSXER9PbtBzTTap7XlKEMSLAGXO0zj3TPsf7+R+Nq8C3m13hdftfjsW pJV/wRSFAZWMbXi58dX0iGNiPwsvLvo/gAXSmGYzarnkmNvqqznuRCW6LqYPastmVns8 LnOl6YcPYgQgfJWm7Wt4ybulPQk2USE1/G3JIFEBp+pT5GOIQ09aF7U8HI10SxT4dCV1 fvAocW3XgTLIknXWgeXckO3Sd49Nzh+gM5STNBo6WSQiNtQ2Y6/UZeTIndKlwsZ5ZRXS a4COvOCUwDcEpG9vV3lvJ6pj+aA5stV3x8FpoFGpEzvB+SYZlzU/8QLPUvaOkxW9iJ/I 6Xpg== 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=JmcaCNMSWSxCE7cr5FHQOO01hm2NHoIVxTuAFK08snc=; b=U9cG/Og/WZJiC8N2HSffIyqNXGD16PnvfPL4LP08E4yXcNlrm3epKJYupgWHuwCXYJ kvQ9Z5LiN/ukkEHWXPlUJhu3Oa8I3R/uXThUyOKyvvG2Ln5LluVdofDM8HH5K4SUUkxj Hnki8xD2xYdLgCNx4E8YvyW6bjkkZW/FnO+NKSoQQWqbFo+8c3nqrLW4Lfm+atw1D5FI rIcmHV4MR0XnlSnpskTPX08MxdIJlH4JKgarKpPRV0TnVR3Podn0wz7/xpQA4cCV3WOZ rT5cjTABSDmbCfRp59rB1cc4fy6sHnJCrhvFcLouH7+9tpZKtDsCqh3h9rg7+weDX+Zg 1IGA== 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 g14si5517qti.392.2018.11.25.18.19.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:19: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-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 EDB3130832D3; Mon, 26 Nov 2018 02:19:18 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E4EC5458D; Mon, 26 Nov 2018 02:19:03 +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, Shaohua Li , 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 V12 08/20] block: introduce bio_for_each_bvec() and rq_for_each_bvec() Date: Mon, 26 Nov 2018 10:17:08 +0800 Message-Id: <20181126021720.19471-9-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.44]); Mon, 26 Nov 2018 02:19:19 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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: Omar Sandoval Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig --- 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 6a0ff02f4d1c..46fd0e03233b 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 399a7a415609..fa263de3f1d1 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -799,6 +799,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 Mon Nov 26 02:17:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697361 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 66A0A1750 for ; Mon, 26 Nov 2018 02:19:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5469B29A30 for ; Mon, 26 Nov 2018 02:19:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4661D29A32; Mon, 26 Nov 2018 02:19: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=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 B483429A30 for ; Mon, 26 Nov 2018 02:19:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF1456B3F76; Sun, 25 Nov 2018 21:19:32 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CC7C46B3F78; Sun, 25 Nov 2018 21:19:32 -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 B91F46B3F79; Sun, 25 Nov 2018 21:19:32 -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 88CA06B3F76 for ; Sun, 25 Nov 2018 21:19:32 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id p24so15405031qtl.2 for ; Sun, 25 Nov 2018 18:19:32 -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=LvI5Ds5bnvZaqKCMcY3iOwKbE8ds7I7FAm6kP7ysdT8=; b=Lx4g3GbkkLHY6AnbrCn7SygPii8NmTu5HVin87BpGTUZ0ljMGbwJ9qMyxRzOC6G3AI WymUOjwE6nQ6/rA+2STO3VgadmQdtRTEu9Csrke8xAOtT+hjGCfpxYLGeqndiktaKJAO lXOhoJOYnMntyobiJ/YhzBRTTEwpu3pOwOAswALZqniKNYBMAvNbqHTEy3iq7n7P9s0l Wew37iCDZvtUaXF+ZQynif9t/9+I9D0K8VRkPLQsXR4v4I8BshUrgIYrclMGV2F60euN diW19us8hmuNY38MtpW5y+8sojPfrJa47RzjJmIudL8WEDvQ43F6DKmbzrczIMhASeCx +fLg== 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: AGRZ1gJDwtQKPfT/MDJBjH+K6fYYsS/b/rxA4Dspaqtld/DJG5OWTr4l +qaM02HmG75p4DH6iPH6Huttlsv/CQIkAVoYQTSa7J7Zr0CSStnJ+207dWkWzWju6HmthYZqSEn AyoAJM8WOAXuVwsXtrWKcYwbo/wro0OpHfDYud0/fFV6f/AYGqPuR/iDgd9jE06vcjA== X-Received: by 2002:ac8:3fc9:: with SMTP id v9mr23614888qtk.108.1543198772313; Sun, 25 Nov 2018 18:19:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/VP1LDmmDtRHLBCtJHw0KyJVcjpfbd5x6LJ6T2aNWcoHd0kWUWqSMwWEQ6FHeNlctoTl1yu X-Received: by 2002:ac8:3fc9:: with SMTP id v9mr23614869qtk.108.1543198771512; Sun, 25 Nov 2018 18:19:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198771; cv=none; d=google.com; s=arc-20160816; b=NtBc7EQdJ76KpSNZ+AWCQ2stmssl24coEZlnDaPUb0lWyi6dQd6nsTENi3u5Nz1igT VnmeT8kVmJmLa/27lWonUEI/DOt1y9K924k/cBwMT1yjjvgTAE4am2UZRbLkLtISbMez Z8KXZ2x4nprOwixMB7feIm9HIpBSzuVWUuQsZxUoUZBwrRCyQcpOONaAaa3Xxk7wLKFt uxfWX6Uc9dCEfGFpK+5MsujuDAK8Ez7cguU15MNsoAD7BCtsh/g5d6cXXPcFcqByHjr6 QVDHZqxcMyGwPsKzomGVRESaj3rp3wsMbNFYdosnIAxQ1Xg8cIonj1BI0AVVOntR+kve xM9w== 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=LvI5Ds5bnvZaqKCMcY3iOwKbE8ds7I7FAm6kP7ysdT8=; b=KEDIUWjCFx3V1F62CHxKmqHZa2AG0yFoWqb3FVdj6bcsz9tn69L1Moid4NdG6WA3a6 q+rDsVetCep1Kqjx/Mkb90laqxVkYJsnDq3sx2HqlU2Zry6LjWKWICMIzClNH8hWfsob YwW0hrAwU5hst/vDLLb55ivqUvqM0B/e2QOUyAkaG8OkE4Ym7MSF93QTZfIkelboguz5 clei8UVnI/wel7t78gbhUyLRggU6o8mMpkUIeLF7Cd6eY3z4HbM2eYAkRCOl1wDbeess JGAN6vnOuyBu8sRhzjO/4/YzC/k+rl58WwkoUcZQO/91td5wl6Ip6E7MmA8YzI+Y52my Pkow== 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 h12si5457532qti.361.2018.11.25.18.19.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:19:31 -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 648E899C4B; Mon, 26 Nov 2018 02:19:30 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FBBD194A7; Mon, 26 Nov 2018 02:19:20 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , 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 V12 09/20] block: use bio_for_each_bvec() to compute multi-page bvec count Date: Mon, 26 Nov 2018 10:17:09 +0800 Message-Id: <20181126021720.19471-10-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.38]); Mon, 26 Nov 2018 02:19:30 +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. Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval --- block/blk-merge.c | 100 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 20 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 51ec6ca56a0a..2d8f388d43de 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -161,6 +161,70 @@ 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; + + /* + * Multipage 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 +238,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 +253,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 +280,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 +299,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; @@ -296,6 +360,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, { struct bio_vec bv, bvprv = { NULL }; unsigned int seg_size, nr_phys_segs; + unsigned front_seg_size = bio->bi_seg_front_size; struct bio *fbio, *bbio; struct bvec_iter iter; bool prev = false; @@ -316,7 +381,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 +401,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 = true; - seg_size = bv.bv_len; + bvec_split_segs(q, &bv, &nr_phys_segs, &seg_size, + &front_seg_size, NULL); } bbio = bio; } - if (nr_phys_segs == 1 && seg_size > fbio->bi_seg_front_size) - fbio->bi_seg_front_size = seg_size; + fbio->bi_seg_front_size = front_seg_size; if (seg_size > bbio->bi_seg_back_size) bbio->bi_seg_back_size = seg_size; From patchwork Mon Nov 26 02:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697375 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 604EE1750 for ; Mon, 26 Nov 2018 02:19:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 500FE29A36 for ; Mon, 26 Nov 2018 02:19:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4321029A35; Mon, 26 Nov 2018 02:19:47 +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 D85EE29A33 for ; Mon, 26 Nov 2018 02:19:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 021AE6B3F78; Sun, 25 Nov 2018 21:19:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F384B6B3F7A; Sun, 25 Nov 2018 21:19:45 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E297A6B3F7B; Sun, 25 Nov 2018 21:19:45 -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 B8B416B3F78 for ; Sun, 25 Nov 2018 21:19:45 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id b16so15142343qtc.22 for ; Sun, 25 Nov 2018 18:19:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=5dXOAXvdCY1pHWNmtmr9I2FodyP1Hp94z8fKZgHrHiU=; b=SG1SUqAyXCxR77/hm9Sn9PMOMfPVIr6JMOmXICNUQLKboIhhHvonUp8oTvTbQ/gD1B t8cfYhM2Id61RWW1Ztz+EhPuod3DHTOBpun5roK82dQ2zgVCwfuaR6NUUyM80OoTRhZe Y0VC2c4XDpDjLzfvFu+aceIchYAT0KfHtyZyKY1j1EvnsvJTWt8oV/k+PHllTD+nIoPj Evvm08qB04XpWuyIIkViWA5Pz84S7ahgYnR8zG9hncSQfGID3UdpBAf/aGdzPnQK2p6g dJY+YqgRQYrzvW3KIgN7PPi6Sg2PE4uuFb3ZEO/5MAZhZFxNm9XMkt/NG0QrgUS5pEqK 75MA== 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: AA+aEWandBxDBLsLgU/zCZKiXIFfDDXcoG4thSMdKRqKBAgSDaIgRiCr ik92JH+DibvirafGRdN+z66qvYGjVJUllockoZk5kpFc7GZ4vWaQXOB+mqufOJ1CQhQ91YR8R4I Cq6FwamQc6d5o6E0zyQgHiB1GX6puqJKYe+lJ6OjXN4m9jNAmK3VTLjnD1v2bOyLINQ== X-Received: by 2002:a0c:e091:: with SMTP id l17mr23805314qvk.144.1543198785494; Sun, 25 Nov 2018 18:19:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/WsybKY4peN1vpgs3SoSHVMVslyYlzyd5Wr2Qgf7c83s1H9WwCBJhnIA8i3fStu1RxeFaTL X-Received: by 2002:a0c:e091:: with SMTP id l17mr23805295qvk.144.1543198784779; Sun, 25 Nov 2018 18:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198784; cv=none; d=google.com; s=arc-20160816; b=vgt82ppEVAWsTKJ5z8zsKZ8y91aZ7YrxVqYuHRRVI/feRIsN8VJnHU1AAaj8xWi+3g JmPQiO3lx+MaXjwN5F0K/FdGAmQAPgZEs4kN9wf8Vd0P9k117cFzlwMfCbXiLmcljipW q+V521hGKmmzYMPJSgdwzDsj+i7ss4wuUalh4ZhOMVL2w9qOl4vDoZB3peMA2xdg3GZe olXm+oHoxn/RN77Tq1yWreAjimjRNbh2q/X4t0jlDPYFRseBDZpHuvrEtUb2lfuzFvoh 5oHYpcJuLp1r+2NVdzeJbL4OJjcu56MKwyIQSa/h3+E8/sep1PxcoKWleGIltJ1+pbOs zPoA== 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=5dXOAXvdCY1pHWNmtmr9I2FodyP1Hp94z8fKZgHrHiU=; b=BNmOXvttipsIzPTkZHgLRoI5CUARz0tSGv2iwadhJ5ONslQsAspxOW+RDQm7ST4GAS 7bChWl4T+enQZy624KNfdxt3+3R0QDvks+iB7PfKtuGdzrdJJV/cmG/VWR2FYaqXIvHj 08MpY7kD/4xXpIaX0uBab/RqgVLVbzpux2KbRtjz1npRdd7nXvqOKAOYZEItdahRiDMd bOY6Qfl8WK2a1c7APzzZy7okVKuaHtkTNiXbwzoXDMsqfkeVUygv1rWMpGoCrFjXbpHe 3h+j0E0KuElGWYGPc/xOLI/DhgbBsdTzl+IuUAduzHKLzANBtwfwf2Vu5rCkzF//LBWB iqaA== 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 y27si5895264qtk.149.2018.11.25.18.19.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:19:44 -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 B13B188304; Mon, 26 Nov 2018 02:19:43 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CC843781; Mon, 26 Nov 2018 02:19:32 +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, Shaohua Li , 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 V12 10/20] block: use bio_for_each_bvec() to map sg Date: Mon, 26 Nov 2018 10:17:10 +0800 Message-Id: <20181126021720.19471-11-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.28]); Mon, 26 Nov 2018 02:19:44 +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 Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig --- 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 2d8f388d43de..20b5b0c3e182 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -462,6 +462,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, @@ -479,25 +527,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; } @@ -519,7 +549,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 Mon Nov 26 02:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697383 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 0F62E1750 for ; Mon, 26 Nov 2018 02:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F057C29A3D for ; Mon, 26 Nov 2018 02:20:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E417329A3F; Mon, 26 Nov 2018 02:20:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 838F829A3D for ; Mon, 26 Nov 2018 02:20:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A33526B3F7A; Sun, 25 Nov 2018 21:19:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A08236B3F7C; Sun, 25 Nov 2018 21:19:59 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F9A86B3F7D; Sun, 25 Nov 2018 21:19:59 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 5EF476B3F7A for ; Sun, 25 Nov 2018 21:19:59 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id 67so17782202qkj.18 for ; Sun, 25 Nov 2018 18:19:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=NqRnUsjWXdLCn3+BBd1E+TE68uZNAdSmdjd3DOkgrrI=; b=Sm/PZQ7/MPkpjchmRfOT1pmWr9MShyIDbypGfsRuKgTuLCZvcpeAFpoF4jf/q9jo18 1m+EODQR2HD/NrYswQ5iQLQmWyOUUOeBFoK5qtno5/dnqMCfBmxHNtvv/vNu30/TnZgs 4gXwzhXG7tiolyO4widmX6Vpa0D2YhZjAmAn4d9iVR2OgPcnYr0zTrAc5845dDh7a9S2 v/eOzUvK4Vx5YP15juOSZZv/JaFVrH9ifS0LltNENSzcKnpyBnKAfPDpGRcWLJOpKhAe AZHTHDcmPnDr3QGRLgueIrVrJ99Q/dBkoVHp2hfV17FLS0BU85Mk/LC1w3L8qifPzUPL 3OOA== 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: AA+aEWbpYCeuvtezuiq6L9X5SBs9Ot9dvKKKuPdJY+Sdnbx/hWeTbUWO 2lG+0/YRCIqscr+kvj9BQBC4h0FMJaC/40wsE7Vqs3CW1IA32tyvTOy/k9WFq3DmfBGjEY2GuvU RbJf7Q3fSBgO6bNAqdClh4vVaUp8XX6V+psthdBc0p+hIkheEojyjf7hy3EDTWqliSg== X-Received: by 2002:ac8:1414:: with SMTP id k20mr24084106qtj.298.1543198799150; Sun, 25 Nov 2018 18:19:59 -0800 (PST) X-Google-Smtp-Source: AJdET5erCyFJ3ZKoH5q1OJzy+PYOrBUJLURUCY+MnfvGgNVXWhM7tjNxry7zVyx6bXx+RTcgxU2V X-Received: by 2002:ac8:1414:: with SMTP id k20mr24084093qtj.298.1543198798611; Sun, 25 Nov 2018 18:19:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198798; cv=none; d=google.com; s=arc-20160816; b=C/oKQTYdrWRRsvdiypanJ51h/92Jbn71HYHMfwNZw09VtH7w1J91ktCNkhZMUZ/ZuA jBOtZAk8uJeLWNpamajaJ4AnsmIsGg1a8RTkzwwrm7ijtWlheppfguRGgz3ApWRAYH9B 8YQurLFwuvpGgsKANydMFMzOkxCtk4yW5Ze/YUnB1B/gZ9kgBokMMeSAobFl/OKzkM4J J3sbLPeD6y6ty6EBHSTKfSKdEuR5mwNz3bUlPEUovvKs4PkpULibnbtrBrEmnNc/2YyN ZUCMdLOnF20JT1mUaZDOihuqU0VBydxJszliH24N0wPptMY/4pagXoMu9Uyom1ICKlHR kpqw== 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=SDULwPghibqWlWohBoFA7xFpoebZIrNiXykrt52h7idsX1IXkJyQ8YZe/mIKzZ289f +lIWGF4vAfJA1RQsDvm5PAyzY0PCFWuh7oNQJ158L7juTdQXJ80/6+kxXKIiXzyGTkU8 OWtlLjuIgu3+OkyH022Sv5TTpQs4fkZDyBDBbEiNsiEHCwOcZJp5aEQ1u60zD+wGyym4 WaDaaLHcz99PR38cDTiBV/KFy8jRIn1tXLNjBLu6OjYM1psKMASgvwagz5VB7eEsnTbj p/lk1CTaXiVi6xsMvRN8y/+snPoclAECF06eQiYEqhMXnoLopGUSPX9RqgqWzxEKdQVn vkQg== 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 g11si7617480qth.320.2018.11.25.18.19.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:19:58 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 9B82E3001E46; Mon, 26 Nov 2018 02:19:57 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD4101001947; Mon, 26 Nov 2018 02:19:45 +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, Shaohua Li , 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 V12 11/20] block: introduce bvec_last_segment() Date: Mon, 26 Nov 2018 10:17:11 +0800 Message-Id: <20181126021720.19471-12-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.47]); Mon, 26 Nov 2018 02:19:57 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 Mon Nov 26 02:17:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697389 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 6CDB117FE for ; Mon, 26 Nov 2018 02:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5897229A7A for ; Mon, 26 Nov 2018 02:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F21729A79; Mon, 26 Nov 2018 02:20:32 +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 4A48329A43 for ; Mon, 26 Nov 2018 02:20:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 501F16B3F7E; Sun, 25 Nov 2018 21:20:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4D8546B3F7F; Sun, 25 Nov 2018 21:20:15 -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 3A0E56B3F80; Sun, 25 Nov 2018 21:20:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 0E0FB6B3F7E for ; Sun, 25 Nov 2018 21:20:15 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id k66so18280268qkf.1 for ; Sun, 25 Nov 2018 18:20:15 -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=c2SF5KIPKkkjYa6soG59vjMHK08LElFkLaPhpIbMqOY=; b=Bvtr5HIvwRVqdA1h6m9EO54KGoABGc/UfGV9+nhgu506apjZIEvZTBjotwzYUU3oTa Oop1g19jRAMt0u58Gt3A9JFg55GZ+H3FRa6D+91vCmy8mbT3uuSMkEj1SUUzl+z+RlKz fHDk1qusGexVslKi90mkyvlS1OAtHFxy58Q57ujMzjiHdsbX2duyETxp4rM2wmQv9Sf4 ftAH2n6/frxZ251u9bN60pyySqs2ZfNH1gWsl7dlQjMNc7iEVQPK707+uwCAaX+f2pip Hk+yWGOdkC/VhJuI1TivEV2lMATgxwPczIgC2Y4ia+S+TWUChsc3/JH1jTkNEnS1ndVj VGrw== 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: AA+aEWaQ+EdntUvPilSfpvQHh+nASAmRD6v2e4m4/dMOFJVU3Mc476pS ti4Yi3ba/lIm9rSu5Urodezl014bT0VcQ/2HoHwOhR/hM1Uu8u37BhVrwkQINzfxcPA97/3C4DV o9AQpRJNwinJ/W8nCYAkKbbe57p/lexZbsJ7vncQ8LO8ACBUiO0IyFVQ5nuVE/VDIXQ== X-Received: by 2002:a37:1fc6:: with SMTP id n67mr23505659qkh.180.1543198814836; Sun, 25 Nov 2018 18:20:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/WN8QAiXEU8t4udM2NtgVLKkRXqx02gmdgA3GYbiBDWlDT9CCAt9VUNR9I0syAgXI3E5F4U X-Received: by 2002:a37:1fc6:: with SMTP id n67mr23505644qkh.180.1543198814316; Sun, 25 Nov 2018 18:20:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198814; cv=none; d=google.com; s=arc-20160816; b=ouG1bmLoG68YVrVYcJHZbTIGpJEATXdWSHdpiaQYt4lri1vje6L3KHGU8S6OVTV1dN CnFTUCpH6ueh3WwwqGeT8+nzQ8SZoliid9DsKSi9Y5n81QDSgboSWMntTNK9bttqmDj4 Auo8jcDYbdgnyRvEoJBkbMV0gbF6c90I3El+SuH7TWiohP+lfrZs4WMhHT43oD5eZo/a paB5mnjfu1QpjQ9ZCMUDjqu5/zGBX/TEZXfTbIEka9NyBjwjTNJbPsINgAcrBUHhIuDT Wpce67IUMSqDo09n4Q8Sf92JVJSoiTWe+YLfyg5mZamemZK7optCqGTUlDs5bUMD0BUC 3hqQ== 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=c2SF5KIPKkkjYa6soG59vjMHK08LElFkLaPhpIbMqOY=; b=MjAutrBpcbfWg+w1f0MmP8Qhr8IPLYWIT1MtHLxEpBnDOXozPSpBOqwPf7zItPZxby IP3E6ImQhYtD1WVkBAwvJPcp63/CqyOa7IdB6T8bY5YEpTZnQkqYYBi+isyM4v9NlxX9 djttafyt8wwceNe6JwsSEMsk5nTDjwHZpaDxWkTOsmQ1tuF0eJ1zGAprUtQVCW86e0bl xLIoNpgeUC20qG4MhXNRcbi6T3474BmFtVll5eAJb1rTZgQcRvBJOl8Wljq6VXD9AIrX 0EivSwJKmanvx9tEmtXeyr5hy0CyAeBRhyk2JEncf+4qBEwyN0eOb3W4kJvjLnSXN8cg 6e6A== 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 b48si5800396qtk.45.2018.11.25.18.20.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:20:14 -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 4191888308; Mon, 26 Nov 2018 02:20:13 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id A53F65DD64; Mon, 26 Nov 2018 02:19: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, Shaohua Li , 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 V12 12/20] fs/buffer.c: use bvec iterator to truncate the bio Date: Mon, 26 Nov 2018 10:17:12 +0800 Message-Id: <20181126021720.19471-13-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.28]); Mon, 26 Nov 2018 02:20:13 +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 1286c2b95498..fa37ad52e962 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3032,7 +3032,10 @@ void guard_bio_eod(int op, struct bio *bio) /* ..and clear the end of the buffer for reads */ if (op == REQ_OP_READ) { - zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len, + struct bio_vec bv; + + bvec_last_segment(bvec, &bv); + zero_user(bv.bv_page, bv.bv_offset + bv.bv_len, truncated_bytes); } } From patchwork Mon Nov 26 02:17:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697395 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 B3F2469BA for ; Mon, 26 Nov 2018 02:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D56829A6F for ; Mon, 26 Nov 2018 02:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9147D29A89; Mon, 26 Nov 2018 02:20:32 +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 915C429A52 for ; Mon, 26 Nov 2018 02:20:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52A5E6B3F7F; Sun, 25 Nov 2018 21:20:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4FF9B6B3F81; Sun, 25 Nov 2018 21:20:18 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C72F6B3F82; Sun, 25 Nov 2018 21:20:18 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 117066B3F7F for ; Sun, 25 Nov 2018 21:20:18 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id y83so17872648qka.7 for ; Sun, 25 Nov 2018 18:20:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=iiHAK/QyTWLI6+6lI1iCedqrSnHhk/ms7RdzNo36y3M=; b=gOP9Y1fqZvNKozg9PrvhugmAAEtWV+helysvxeyWQ52SLLAeDdyBlfd5+GLV7a4fKX qwgR34n+jygGFzM4WuBV88IxGhJF76N04AyP/a2En7uVqm4FQKlQqFJqVSpnXa6cLqJf gpTKQbnnuiI4NHQedaO/4JpLbq1DbgILEaybI4+w97IxIaNs87SPJPWlY7j+bJhyY2MO vwTxaI/LL/GpfaSSGTdwFGMm9vSO5c2GVrDv9/dTzhjRlhSfhAcjwblD/zHtB/88PkuR WYQj930V64PAeao+t+28vIWg8mTz7Zuhl9B/GCCIPguZ9GSzUhRm9ajRqSpY6jwEzTgD ggKg== 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: AA+aEWYOOJVDN8Vwl6EMr8jZc0cT4fkV6lPQjwSdA48sNNpuwrHqWAqb iVZi7hTAiwYsS4k7aJ/meMXj5BDOfcj6yF9dZaMzU7UXWYKMdgavzV8J9s/zvDyQk0uA6MBbhkz HpLVHcVRbxMk7h/LOghxHp3CF3YUKcAzlevJZRCnrMVweCgvm0E+XcupuzrS+ZeQkZg== X-Received: by 2002:ac8:2281:: with SMTP id f1mr23767422qta.197.1543198817786; Sun, 25 Nov 2018 18:20:17 -0800 (PST) X-Google-Smtp-Source: AJdET5eD41vzK8Kt5vOHcbZy/pNXYLBhvEvy5wJbX29VYyaIUT50jy2rB7QCsinIpX1Npemvi6Zs X-Received: by 2002:ac8:2281:: with SMTP id f1mr23767395qta.197.1543198817191; Sun, 25 Nov 2018 18:20:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198817; cv=none; d=google.com; s=arc-20160816; b=CV2Fb47KC/dix2cvRdnlDTEnXaIhPNOCqpGQdiRbklEP+ujz3wnBBg9TvOWvx9zVC3 iTmavJz9VBVc0aPnGbA1LcmduVhw7Q4yD2u5VWiQtTPLxgZ9JK5O0twbQ5qpVyciYaDw zDTldIqrIN7zaJ7Cf8ead9sY7Hlc5c2zag7jiEarT9nYSMgIdO7q8dCGyxcP1wCckY7q 4AFE2536T6FVvU6QECpSMGgUT+x/wS+Pv01VQy8RfOKQIyv/yk2oGThRbX2N3jmGVHEQ x0/ZoeGCCwOw/GkQi+5U+R4+lKhBCmX1W+ZgkrD5/+PTXM2yqhxe9ByaxrTBYmJRHdbJ b5ZQ== 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=iiHAK/QyTWLI6+6lI1iCedqrSnHhk/ms7RdzNo36y3M=; b=wp+V8mN+alzEOfCFayQv7uaSk7LHpGcsQG3iUVAEBF2p0pQRYr3lxMTeq6rXrSriYB +xbPAu6hL3c7jEPoVeQk84ksf1sLOS9nnCQdAUnOc9BoET0Ajhw0Tw4eeD0e+okrEA2f nB1Ey/ezXRxLfIm9Lfw7XD7DThObpKE6m/ehqxwVP6BaLcLFcTNJjvOsxaTffEhyvGqI /g/CZU/I0FcrwFv4WbX4efpXiLlqNy6d8Bh3FuHIyePO5PAssctZ5UiExZAELUjMJRwA iyMXrjgtjjL1JByUWqfGX+4vF56JCjWwf/XH+pCrpOMEMjg3kP3UrdCqEZv2ubj0VIJ2 M36A== 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 h12si7732908qvb.79.2018.11.25.18.20.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:20:17 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 1AFAE307EA9E; Mon, 26 Nov 2018 02:20:16 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F06A5DE8D; Mon, 26 Nov 2018 02:20:15 +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, Shaohua Li , 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 V12 13/20] block: loop: pass multi-page bvec to iov_iter Date: Mon, 26 Nov 2018 10:17:13 +0800 Message-Id: <20181126021720.19471-14-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.44]); Mon, 26 Nov 2018 02:20:16 +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 Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- 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 176ab1f28eca..e3683211f12d 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -510,21 +510,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; @@ -533,10 +534,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++; } @@ -550,11 +551,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, */ offset = bio->bi_iter.bi_bvec_done; bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); - segments = bio_segments(bio); } atomic_set(&cmd->ref, 2); - iov_iter_bvec(&iter, rw, bvec, segments, blk_rq_bytes(rq)); + iov_iter_bvec(&iter, rw, bvec, nr_bvec, blk_rq_bytes(rq)); iter.iov_offset = offset; cmd->iocb.ki_pos = pos; From patchwork Mon Nov 26 02:17:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697401 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 12C4D16B1 for ; Mon, 26 Nov 2018 02:20:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1D0729A49 for ; Mon, 26 Nov 2018 02:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5C1F29A90; Mon, 26 Nov 2018 02:20:32 +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 7FD9129A4E for ; Mon, 26 Nov 2018 02:20:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 948D06B3F81; Sun, 25 Nov 2018 21:20:31 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 91D606B3F83; Sun, 25 Nov 2018 21:20: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 80DA06B3F84; Sun, 25 Nov 2018 21:20:31 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 563446B3F81 for ; Sun, 25 Nov 2018 21:20:31 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id c7so18000925qkg.16 for ; Sun, 25 Nov 2018 18:20: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=J+Wkn7ss71nFXVcnKcca2rbr8+sm4+oaNEhSOc+cM7w=; b=MgDEefXIZzLAQekUec3M4rl3iV4j2e+YaQZgRHUN82SmSxM7gTNbzFQUGYOgkiEMvA +S/Gy7tlzGN4gHvzBQhSpmR/tF81O1XausVCBgJ1NOrI4bxiVPdKZkQ/jWgUF8DOnqBo oLPTCn+uE2Lf7ukLn53U1Ci8kh5dN8unDJQWTmiqJdVBTgxy2ia1ssI88QHx2wOx+hzY VYyifS7WvX3Ila/g4H+FZTz6HiUOiSXagFKV8PL3r+Ml7enz4iw/MSrQCfhEkDGs2h+l +WzOsB0kCRX72itoo2wBh++wdxuiWUZkkntteyTkjg3jfYg3KsQCFo+vliaND9deT60m Zqmg== 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: AGRZ1gLFfMroN7TnOH9j7XS8iMVa7n4tKn0GK7PMKSBo/pc+15P2B8Ok ZrnpaprdFUaoymxwhK4C51bOy+H9EDZQMfxLUpYRYn7TQUv2vJdOhhgdQ4fvuNaRXELmETUSHFb QRqa9tnGE/RQzqssALgrVqz4nlp1XsM2+N+eUuDq89kp2CQbfTacycfeKCIQmQslitQ== X-Received: by 2002:ac8:3437:: with SMTP id u52mr23058092qtb.237.1543198831131; Sun, 25 Nov 2018 18:20:31 -0800 (PST) X-Google-Smtp-Source: AJdET5c70t84IZHEgVnyK9p+ppo4yTEzBQ/pBwTo0QePoqp6wSp/MiXn9ryvr5VB25UABH0aJxnn X-Received: by 2002:ac8:3437:: with SMTP id u52mr23058068qtb.237.1543198830497; Sun, 25 Nov 2018 18:20:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198830; cv=none; d=google.com; s=arc-20160816; b=hhAuY3lR0uiAaNJKZL7UtANyY20YooHPuCrerzDLMbIg4VQKwmYhotXOT59UiGisuX 9IHUYZf5sGFyF8StgxF2cbwa83NF+uhnO5F0c1bWn2a4gMyfv61Wx7sl/VbjaRhi08Kq vF6W9eNacDBpC18W0qJJ5pmu3IkGoR6HFqzwmfAnpSYW4m8LkYnNI8SSt/uDF+rDSNkD c1c3NdJQKP9HNcUTwsYSfZpDHCZT0P6OSgbD+6d+hKK4FlmPyYYdIOGyXYx+5wkMP5jr dHWNgxAgOkGJpfcOsTPcbrCKRfDfw48ZlTQ56/VQ2XoZU4yBgEWrg7KBprxke06hKwPx UjBA== 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=J+Wkn7ss71nFXVcnKcca2rbr8+sm4+oaNEhSOc+cM7w=; b=IDG9113YSmvAN5ZAzpaCIgrQkkwRftSKP93BA53gOzPkZfeDtt1NOjh+AYc2+A5/hI tU5exEORvFRYFW4DRpOOkIzGh+P9w++ZGb+EphpQAOc7VfzUmIDqiyKRUzK5Aew7etuN cNTejsz8hXFyZMA3IZvHCVOXm90o/V51pPy2OVQ04D6nRfQirzfj2fHI+XFk8f0p6PcV OazH4IetuSHpPuXi0pQLzlwZEeNUJi5dCRmK+AkXtZpUpY9IjCLHIFpV1N7eKWaiaGpG 66XOGHC9nJwh7KnZcBvWGNEJyt7a13J+IKu+jRkOFc5uBLWHrKbdUmeSRZKgG0oAF2OX 2mhw== 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 z8si209012qto.268.2018.11.25.18.20.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:20: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-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 7159030A3143; Mon, 26 Nov 2018 02:20:29 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A0321054FBA; Mon, 26 Nov 2018 02:20:17 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , 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 V12 14/20] bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages() Date: Mon, 26 Nov 2018 10:17:14 +0800 Message-Id: <20181126021720.19471-15-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.43]); Mon, 26 Nov 2018 02:20: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 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: Christoph Hellwig Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- drivers/md/bcache/util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index 20eddeac1531..62fb917f7a4f 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -270,7 +270,11 @@ int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) int i; struct bio_vec *bv; - bio_for_each_segment_all(bv, bio, i) { + /* + * This is called on freshly new bio, so it is safe to access the + * bvec table directly. + */ + for (i = 0, bv = bio->bi_io_vec; i < bio->bi_vcnt; bv++, i++) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { while (--bv >= bio->bi_io_vec) From patchwork Mon Nov 26 02:17:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697433 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 6A79516B1 for ; Mon, 26 Nov 2018 02:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5776129A57 for ; Mon, 26 Nov 2018 02:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AEE429A88; Mon, 26 Nov 2018 02:20:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=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 B05EB29A57 for ; Mon, 26 Nov 2018 02:20:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D31D6B3F83; Sun, 25 Nov 2018 21:20:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8A8CF6B3F85; Sun, 25 Nov 2018 21:20:49 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 770AF6B3F86; Sun, 25 Nov 2018 21:20:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 413AE6B3F83 for ; Sun, 25 Nov 2018 21:20:49 -0500 (EST) Received: by mail-qk1-f198.google.com with SMTP id c7so18001436qkg.16 for ; Sun, 25 Nov 2018 18:20:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=jckkpvu1yejjtjdBqjc1NQMisPNgtnHZRX2N6Heb1DQ=; b=a6hxZvC4xcs7Rp1aicYHRV5hM7wgSocY8OACOBmePduEDRKouQ5cH2NTxNWbXuwR6O ycVOVdxq8pZZEfseTVZlo8m2PDj5+3pVt56vI5bK222NzUbU3Qrl6tmNkngPY2UVHpIh VNH35PiIjucRk1LxzossH2LqOps1MSeGFuwtXHzVJo0NL0zouuf9rIb6LAKQ5RyEZpRL reJvPkXlndkokL+7ZM5C1nz0sSeZ5RMyNloVXDg1e97REweDgDpgnQbsC6z2Ty8lleEX X0oIhbjVI+pqojm5kvTUII7Iob025l9J/O0wHzuvVFN7v1NuzzwCA8v2ltVgS/vxQ3RX DiXA== 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: AA+aEWYO6egNuIEJ89QQe0F7AEbet7E1g2uQGYtMBewu34hlOWYWHGqs a8UUVPzPDXDyNh9YFDKNR4I+z6xud3rX43Zv6SA5tT8/1vbC8tiF7DNPs/US3fVOv892y70Tvru djSAEf63X4tnpiUpA+CkafLzn8grtXQGo4NSd/wiXeW0ZUoijpBCu+IeWOubvlutiRw== X-Received: by 2002:a37:4b44:: with SMTP id y65mr22187801qka.316.1543198848956; Sun, 25 Nov 2018 18:20:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/WVkX+bPZOXK6nqMfwZh4kQJqaCOjEsimFahKkfHuK8ZZAnJy5b5nighO+irPXbCQRl5jxv X-Received: by 2002:a37:4b44:: with SMTP id y65mr22187737qka.316.1543198847137; Sun, 25 Nov 2018 18:20:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198847; cv=none; d=google.com; s=arc-20160816; b=YzCwrcXQjIVYfjsvVD49k8EltjMavS3/2jiuOh5hB+vbQv9kyaKePurFDCMQL8hDKZ 9Po651Py4bgWNvBU1aaPBIyuN49phPin3c/+ow3pSKpp+4Az6r4r0BG+L35KeFy6t2Ec U77jzfZAiHWCof2hRFKngSblIbErukryxi97kkscoKhjnILaYEq/cHKLWrmmlt/PmlSz 2yM0rR3iisHtCAju32Hg4UvjMtcFauh2QjU1gqzrNQ78x5imlhqe0Rh4X1cuINzejFWn i24PoY7Rqg0taUs1HFC5jregYnP+M1aLHlxHLIprodefuCQjrSbhEb2ayTPo2yR7jflb pTtw== 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=jckkpvu1yejjtjdBqjc1NQMisPNgtnHZRX2N6Heb1DQ=; b=rSBH6lWNjoNrKbNlFj7jzsUJVpZXl8WD8wWh0LOsAeV007wcO2AJ3G2/GjbjpOTS6l n6bi5EgC9uftvkjapPgDVrBWbCzkpuX6qzNSY6lr5qY9HlRVWz6gsZykw90vCFpij4He /0KgLPVRSgSdICMSwHaPiMyASuE7R8dd2zF/XveslMhwzDBENx4OfzR6dF8JaSRF/08V q+T6um7VgVSGqIUUu8JHHMF+eON86KDpv2iMocffr7jevTnXQfmQrQLFwy3oFW+D6l5l oXo/MirIj7j0FN93AD1v3QigHmgPhp2RjT1bxPjdIqP6GCEfqb0Ghjvvo4VJWgRpZpuo G+GA== 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 y36si416961qtd.218.2018.11.25.18.20.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:20:47 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 083F69AE9D; Mon, 26 Nov 2018 02:20:46 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FE8D5C22D; Mon, 26 Nov 2018 02:20: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, Shaohua Li , 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 V12 15/20] block: allow bio_for_each_segment_all() to iterate over multi-page bvec Date: Mon, 26 Nov 2018 10:17:15 +0800 Message-Id: <20181126021720.19471-16-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 26 Nov 2018 02:20:46 +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: Christoph Hellwig Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- 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 03895cc0d74a..75fde30af51f 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1073,8 +1073,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, @@ -1104,8 +1105,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, @@ -1127,8 +1129,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); } @@ -1597,8 +1604,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); } @@ -1645,8 +1653,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 559c55bda040..7338041e3042 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); @@ -293,6 +294,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) @@ -312,7 +314,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 3f4211b5cd33..6242ae4e2127 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -427,8 +427,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 b8eec515a003..a0dcf28c01b5 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 6384f73e5418..96240ceca02a 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 79d3ba62b298..41a8a9399863 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -731,11 +731,12 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) const blk_status_t err = bio->bi_status; unsigned int i; struct bio_vec *bvec; + struct bvec_iter_all iter_all; #ifdef EROFS_FS_HAS_MANAGED_CACHE struct address_space *mngda = NULL; #endif - 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 64ba27b8b754..f8dbfa0b4225 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)) @@ -248,7 +249,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); @@ -316,8 +317,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 2955a4ea2fa8..602a74c645c3 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 169839487ac9..559ab016a33c 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -811,9 +811,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 40751e86a2a9..87907aba2a25 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2445,9 +2445,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); @@ -2516,9 +2517,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); @@ -3664,9 +3666,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 c576b3fcaea7..47c4013f4d06 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7819,6 +7819,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; @@ -7830,7 +7831,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); @@ -7909,6 +7910,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; @@ -7922,7 +7924,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 df41d7049936..e33a99871d60 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 ea07d5a34317..5904fc2e180c 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 db7590178dfc..0644b4e7d6d4 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 f461d75ac049..b0d9537bc797 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 b293cb3e27a2..d28f482a0d52 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 4c7069b8f3c1..f2f165620161 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -168,7 +168,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; @@ -207,6 +208,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", @@ -214,7 +216,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 c5df035ace6f..1f648d098a3b 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -262,8 +262,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); } @@ -1541,8 +1542,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 46fd0e03233b..c35997dd02c2 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 Mon Nov 26 02:17:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697437 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 35DAF1750 for ; Mon, 26 Nov 2018 02:20:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24C1529A90 for ; Mon, 26 Nov 2018 02:20:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 176EC29A7B; Mon, 26 Nov 2018 02:20:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82C0429A71 for ; Mon, 26 Nov 2018 02:20:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1570F6B3F85; Sun, 25 Nov 2018 21:20:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 130FD6B3F87; Sun, 25 Nov 2018 21:20: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 F3A0C6B3F88; Sun, 25 Nov 2018 21:20:51 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id C10556B3F85 for ; Sun, 25 Nov 2018 21:20:51 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id c7so18001541qkg.16 for ; Sun, 25 Nov 2018 18:20: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=D52GbWcm3ObobeXQn+eeWC9SUYpUrUbaKa2PFe/zFbo=; b=UBdbfN9ZkIzLtBZ3B0qEP3l5SEufR97QxBU/AUh5ot/mt+6PW1WAUMYFrozuOiumUd 7ym3ijvzygnS8uriFAknN0rSpmON8AEWqBVnpKbPRCpXPHu+h5D888T5App8VsdrWGPD 2Qf6SSoRKJokV2CJkyvaXGV4+r1qjG+sj+83iOabjdoDjz7AGVM4oGp/3E44i1Xat2nn pASVLippwrzb6C66/G5sU8NKqMjS5b82EPXTHlqNlfPOM+r6mzNlIW8AhBTDrJG7YkGQ QAXFHWjl0Qt3+c0Mxxjd0biBDT6bvnkwAUd3rjbZAQSg+rScHkHtsPhWLEMZbD4tTRWw 6N/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: AA+aEWY7CD+72rN55Hz+SV6c6+kDSvwuwMDE3wHOFMJsAcW+ZMDh/q4l kMu+5LZJmERQ6hkrwdXAQxMLw6pmRbV6VquKQ9dLLn/F0z1izp2T8F4D6vqjIxUFshZq6IfZecG UbxxSQbv5ek+kklupw6SEBpYacRTaL9f7qpT94C/CipSI9gNPsfxoW6KiXwvfuF/mTQ== X-Received: by 2002:a0c:d2f7:: with SMTP id x52mr23935766qvh.35.1543198851535; Sun, 25 Nov 2018 18:20:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/VWmUqzSG5wRHKD5p4XyIFBMEG9sLmDTywiAcwd0bDxMyEtljHGfh/ewPdfqibm5C0enwqP X-Received: by 2002:a0c:d2f7:: with SMTP id x52mr23935717qvh.35.1543198850333; Sun, 25 Nov 2018 18:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198850; cv=none; d=google.com; s=arc-20160816; b=cbGKapQRIeKZC732t6l/TYsQC8vZjVbfUoSyM4drwNfwLxsCMvEgiTvhAyyE+nu1vN XQFohYThJa8UvxqcAHj0IVbS2kUSuymyZIOKUi3AEWCCi382WROhJQhNYECfuyP8Z1MA /3OwX9iONMDj9DfkHeXTPaG/GdN5JFkCE3OmttT4G2Z7tRYpxV7W4X9rGt6tYIyTLoBh qKQl4Fgwjit1qN+F7eaIOHhWqFH0O+f+VwKqYXMHAtakbAakjdD9xkX2vkHRfAQolJWR at6qbFMBQaXjoY2arEwIDm42nT3b1bGIrCMlYkBEVSJ6iGttTiuxnAa27TMuy7i/ecCC tvWQ== 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=D52GbWcm3ObobeXQn+eeWC9SUYpUrUbaKa2PFe/zFbo=; b=t4GTX1bBJEEB+D7Mpm07H7dGxdY/QSBpA6h0M9ELGJH6Yq+nqNIDhLf3/x0OM3eV9x VoFghLruaJ7PdJ/gi/sTnQvqcPDSRVVUGJCj+RqrrIJQ2fVYHgZ0Y6ZuNXVw4R3gexsw f1gVSczhPA92AsK57pn2cCqE2P8mbhITufdP/2/gKLhGA10RDHYww+Zgp5ccXTurAGDy 2tQU5bfyMeGAMan80x0xQC6QtCiqlsFumT0piboxdYz3XzYoCxM9DGByERW78ahBP7Xt s1NpcsQH5bXYnIOfr9ILjCvUcmwzhc6v6mY1EfvHCEMDa8q76FoDp32pHhmDqIBTS+go JXpA== 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 u56si533642qvc.4.2018.11.25.18.20.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:20:50 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44AF3811D3; Mon, 26 Nov 2018 02:20:49 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58ADA5C22D; Mon, 26 Nov 2018 02:20:48 +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, Shaohua Li , 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 V12 16/20] block: enable multipage bvecs Date: Mon, 26 Nov 2018 10:17:16 +0800 Message-Id: <20181126021720.19471-17-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 26 Nov 2018 02:20:49 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This patch pulls the trigger for multi-page bvecs. Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- 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 75fde30af51f..8bf9338d4783 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; + 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 != page_addr + off) + return false; + if (same_page && ((vec_end_addr - 1) & 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 1f648d098a3b..ec5527b0fba4 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -313,7 +313,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; } @@ -344,7 +344,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 c35997dd02c2..5505f74aef8b 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -441,7 +441,7 @@ extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, unsigned int, unsigned int); bool __bio_try_merge_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int off); + unsigned int len, unsigned int off, bool same_page); void __bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int off); int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter); From patchwork Mon Nov 26 02:17:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697453 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 0A0491591 for ; Mon, 26 Nov 2018 02:21:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB98329A6A for ; Mon, 26 Nov 2018 02:21:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF6E029A8E; Mon, 26 Nov 2018 02:21:07 +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 7F5D129A8A for ; Mon, 26 Nov 2018 02:21:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F8696B3F89; Sun, 25 Nov 2018 21:21:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8CE936B3F8A; Sun, 25 Nov 2018 21:21: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 7BEBA6B3F8B; Sun, 25 Nov 2018 21:21:06 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 51B706B3F89 for ; Sun, 25 Nov 2018 21:21:06 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id s19so18146768qke.20 for ; Sun, 25 Nov 2018 18:21: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=eKGJRdA+xrnSQcEt1FKMjp3+puyEwgRgYmeQMjJwbXA=; b=RaMJZgiDfh+H6MAUHWbrVK2b7jYYKKDk9JINbEJBsmbGT1rfZJ15uD6Xk4+BwDDZj5 RfVd1iyc0MOHXm6xAGERJC+saMGiWjhq1NkM6EIlOtnEXDts8omU9GzDSVMm/hb2iLz5 1pGnT7Ihi2kWGV0MCbrqtdBmfEDEOgvuwbA5rRV6YEqfP+ktJoKMlU/gVrQg1SEQjG0E b5kS+1PRNkWv+2WMl4GRxL9yTf9I0V0lWKh95nTEGRYEsGq0gT/MjNwEOcP0hKLRB4hD 3pt+tYADesT3xjTee9vQtKLEN3PpQQbs51/Uy/myqk1cKNnDq1cPskdz0MBBWsP4iJI/ MRnw== 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: AA+aEWYF95vVAMcK8Pqt5aWxB55UShJUMsrRkQC/IkyMQomD04NyLIf3 YBPn5jvI9ucY6BFsOk9KrW3J+pr97a4OxzYquHqqv7Wv1ukSCYQBYnG5mkv5zO5X9wChxS/iaVC APcknmR2zH+mTg6lYTbx/jQ/gwc3xvKm3Gqdr95yJvvddh97H7hr/doUUzR0rOUr9IA== X-Received: by 2002:a0c:9d81:: with SMTP id s1mr24015204qvd.82.1543198866119; Sun, 25 Nov 2018 18:21:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/UkgwF/yMxuTznVAEurwz4fcDfrkm2c5Gy6l4ay6pkUjsUYQcFlRrj4rZAjlUp3nsSaBvgB X-Received: by 2002:a0c:9d81:: with SMTP id s1mr24015186qvd.82.1543198865568; Sun, 25 Nov 2018 18:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198865; cv=none; d=google.com; s=arc-20160816; b=O/ckevLzRu5ArMEBLGtJerGvstcrENpnNifMPE+AJXg/zDs0uY4b0h4OpUf/RJZu2H sYy6yeG668P3Y5yEt4g3UCQ63kVdBhdJ60jFd1I6gcGb81aCKlrCedKP72owKKtYPNZL m4mUjnqS1dqmQqfcpluN8BfC8eYxMPUtwCbOVaiTozNFTwWvO7tIe41F3ka8vFAZ5vhW yjv01X6zF3hSt35e7/r85nghhwNYdSSVVyiCsaNkMwn+r8kyBel+9PMz9H2slC/5iuLe VDYCVhwicZgcdqrdLMAUXL2h8DqAsEcwCmEwBDCqBpB416KsZ/IbbzWzg6d63m7as8vg TAdQ== 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=eKGJRdA+xrnSQcEt1FKMjp3+puyEwgRgYmeQMjJwbXA=; b=YCnpIZcCRP2MYgH6UbhnDfT6rNxI84mXF5c1hyMAEw2lUTckOAxDplDyMLJCgd3veq V8Mm15WQXmvQ28Uj48vv00UXnf08fi9+jvSJEHqscqwA1lWgKpdHrN1+kKW2z/+b5ZoJ pRPXNnV8zsdMVlrEQUSImKePA8Svp2QHF3VuBAIjOMz4pE2gSJk6+1r3Ap6SdQyXAyrM c3TrnRwlVvMQz7XPddUimsoj3x6V0zR0WOoYbCIip2sam0bRBuXquzVaqh6ZB17Bt+v7 XFqVX+E31uWZMbN2U+1zhogp5uWNgGHgq6+IZ1VQoofYdasV/HcztF7ba8sT8jPpvajt NpKA== 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 x83si1143550qka.105.2018.11.25.18.21.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:21:05 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 584B1309B6D4; Mon, 26 Nov 2018 02:21:04 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EC0218A5E; Mon, 26 Nov 2018 02:20:51 +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, Shaohua Li , 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 V12 17/20] block: always define BIO_MAX_PAGES as 256 Date: Mon, 26 Nov 2018 10:17:17 +0800 Message-Id: <20181126021720.19471-18-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.47]); Mon, 26 Nov 2018 02:21:04 +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: Christoph Hellwig Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- include/linux/bio.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 5505f74aef8b..7be48c55b14a 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -34,15 +34,7 @@ #define BIO_BUG_ON #endif -#ifdef CONFIG_THP_SWAP -#if HPAGE_PMD_NR > 256 -#define BIO_MAX_PAGES HPAGE_PMD_NR -#else #define BIO_MAX_PAGES 256 -#endif -#else -#define BIO_MAX_PAGES 256 -#endif #define bio_prio(bio) (bio)->bi_ioprio #define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio) From patchwork Mon Nov 26 02:17:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697467 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 52B1417FE for ; Mon, 26 Nov 2018 02:21:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 416AA29A8A for ; Mon, 26 Nov 2018 02:21:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3500429A9B; Mon, 26 Nov 2018 02:21:19 +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 CAB2129AA1 for ; Mon, 26 Nov 2018 02:21:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2D3A6B3F8A; Sun, 25 Nov 2018 21:21:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C030E6B3F8C; Sun, 25 Nov 2018 21:21:17 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF3196B3F8D; Sun, 25 Nov 2018 21:21:17 -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 8464D6B3F8A for ; Sun, 25 Nov 2018 21:21:17 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id h17so15415726qto.4 for ; Sun, 25 Nov 2018 18:21:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=yYLS3f8bnPqwUYt8Xj5ITdNjPiFcqq/9bs4atK52tz8=; b=p6y8jcd5IIaQOmoqCddSNbR4DgfQFVmK720cx4556AnUC8VHujVhRGhRsdQ6NWvX5G Y57d0GUU/2jPqVGW/auXnj1vd90y6f8DFQRG3ClA3QXO2bdOwNyhy/G4DqjPoeTRygBV pNj9HUuPTXbllFrws4fj9vxzdVUv9e139yD0miS2jxOlFCDHdV1KdRRDrhQ3LCu6iuOY Th6LZbYyu75+qo6W9abYQ61oFCLPXjyTRfvJaFEV+hfHGH5+TKe6wqr/g6Wdc6/8EZTX fvHH0XTR7C6fwln0Wum18C5BE3R1najH1OO6c8Ln+pELSwXW099AYAHOzKK/YOAxNQ2S z6oQ== 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: AA+aEWb6G1doz3RP9ivHtNVuUdt7XWTkcY2s+cuW+/0lgqVniVDlZbR3 3XDuAQazMlB8TuApqpIhZm8X6XOwEEu+D4tOaJfTxymW/bFL15Gd5kUhDhTr8cdidWt0zpVj5xh vgEU6XoL234eCYGRVwh9OsPOm+w9YqdV2Pal/1jsf/3LIHo/dtOxXb1nOiP+gU1mPAA== X-Received: by 2002:ae9:dd42:: with SMTP id r63mr22380423qkf.264.1543198877305; Sun, 25 Nov 2018 18:21:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/WZczoHigoNPV28q8GJSqewJxXatCLL8+zCkLctP2Dm46kUkLeFWyOUNgPa4bgMvA+2ETCd X-Received: by 2002:ae9:dd42:: with SMTP id r63mr22380402qkf.264.1543198876714; Sun, 25 Nov 2018 18:21:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198876; cv=none; d=google.com; s=arc-20160816; b=zLjXuZKMCw0XSnZFaV+ONe4i2yyYXKQD6+/eZ7caq+M/pypxQp8f3VeDfZ5u+DTUd6 qTpG6Vvww+aYTIsmquJu6hlLU96/sGrXJ8e50cdkatUf9Qgu+Wv5u06wpjJPsNuXBv5V Iv565hLT2oH2z5TYQaSJ4A0XPOJylEDcvBj+9d1AJG0CnhN/rdqU45QS0jwoAkGY6GW3 VjruJ7P4A3OsbwPbv77HqAtdRFWTSA023ixbMrKgpWUXhWoXYoOF8djsZ0Qa79yiXzQ4 oSyvp6Sq/++WFMB1uTjwx/sG56XKdVy8e9jV4cxQX5yYI7Wqj0MyJ9tubyp3A6hOeC4e kC1A== 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=yYLS3f8bnPqwUYt8Xj5ITdNjPiFcqq/9bs4atK52tz8=; b=dpbdUnfAGxud8GZgmncZgVBCbpX/ODAOA26PmYCQr2WKCGeii6K9RM8MV5N1suL2+P kCD6SU4r8M9Vz+5xJjOboV7J+YqRnVTDVycXIRg82nkHqneUxAODvTpenaR2scwlR9B3 k2p5bY9Iwmf2jMdJrVwuTNaCxdM2Mfxuf11gTf44tV9a2XWxRt+bh3SfWfRB7u5M97Ra 6On6V9tGUEcmHa6Q3IJpUugb456pPBCu0fTEaKNwH1ClD1ZOvkQ2uIfORTDzZQHaNNXB wDL0JYM0tAJN7b13tAJyL3BE4MxG0PeyO+7sJaAcftfjxXYKW/OFPF5RO5TTOYGUmiKI t59w== 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 25si728655qkz.65.2018.11.25.18.21.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:21:16 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-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 84CADC049D7A; Mon, 26 Nov 2018 02:21:15 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E58419744; Mon, 26 Nov 2018 02:21: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, Shaohua Li , 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 V12 18/20] block: document usage of bio iterator helpers Date: Mon, 26 Nov 2018 10:17:18 +0800 Message-Id: <20181126021720.19471-19-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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]); Mon, 26 Nov 2018 02:21:16 +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. Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig Reviewed-by: Omar Sandoval --- 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 Mon Nov 26 02:17:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697481 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 42D5C16B1 for ; Mon, 26 Nov 2018 02:21:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3228529AA1 for ; Mon, 26 Nov 2018 02:21:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2583829AA9; Mon, 26 Nov 2018 02:21:32 +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 7CBC129AC2 for ; Mon, 26 Nov 2018 02:21:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8111E6B3F8C; Sun, 25 Nov 2018 21:21:30 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7E61D6B3F8E; Sun, 25 Nov 2018 21:21:30 -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 6AD1A6B3F8F; Sun, 25 Nov 2018 21:21:30 -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 3F48A6B3F8C for ; Sun, 25 Nov 2018 21:21:30 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id d35so15447061qtd.20 for ; Sun, 25 Nov 2018 18:21:30 -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=JAk4rIma+Ea807AEnkgWW9rrDJRA56i1/EIDUeqJu1Y=; b=dIq6glPtIZY/GhCcZv8uHsHFRPlrNYrq2zW66s3S+udHVpuBSSEh4cKdUdTB5mI9Np ebj1whGfnaYxYRNdp/1Ggt8/8pt9RJcdxuCXpQ24eKjuLaPRZKOj3tk04/HQSNnw+hBx JnrcLTqLIMxUZvEm3JH/ONzvUzfbZtYPPOR9INwdMSRf7wYvN+Q7f4TjROAmSHOGppjJ /DtnNsIbCG+1MRTFBTwCXbX3fH1vQhWjD/Ruakt43HKLe6Hnl3nkslKUetfSg0/p9qdX Ij1CciXtVrZgU5Qpask2vmHIW71htUGkKj98eKkhlm4AHCzRYkVFYVNulqQ/D1mm65g8 m41g== 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: AA+aEWb+yHolYayIn3DwbbFHWORwmvU9RQNuvD3a8GHot7rhVA8j49BG 1YAHVhUG4kHISVeyGHxt7cwMBWr5qLurIt+thEjLytR59dfDfU0qAjsOgdAT2ARnMYju5HWsKFj VNbS6sAdn/aYRmebRVK6W4iMtsqjX1KUODs3JuQra3/ibc5e6RY/SvgaM+1Zh+1aOCg== X-Received: by 2002:a0c:df12:: with SMTP id g18mr23537188qvl.208.1543198890010; Sun, 25 Nov 2018 18:21:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/XyduFlWqQdjDtR0U9NU3xyjufIaol+TeakFMJ72UxDUkkI7LRF7Ei+Lfmjpbw02s2ZEZyi X-Received: by 2002:a0c:df12:: with SMTP id g18mr23537159qvl.208.1543198889242; Sun, 25 Nov 2018 18:21:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198889; cv=none; d=google.com; s=arc-20160816; b=rdwdk6bFuaCxkOTeeJ8D3GprKqVC40/RJznNZSwBtTwBXuBono6n9oAEPmO8M8okKv 1rMB3eUbUeLQM4Z+XGKsf54zoNbiOLzz16pLxx3/O21PD0qwgB1L+cpPRpfUNAJDs/mm u9XGOj+W0PWfQoCdqIxXDU9AAYZkSeVQdPuIn9LRBqy4x+FC66oVAnVoYEqaVnSxzBpE 5srhHmSQ+t63fzmnply1xyalmzUvSLmZvSbFAq+wU0mJsbuMqm9o8kR30ULZ7KJGal1j gSQ3NHSVqK3G2Ajh5oiFm8Fmh1Izt3nm0Jyu461qa67gXHVxF9RPXc9skdV0nG2ilHKS UEvA== 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=JAk4rIma+Ea807AEnkgWW9rrDJRA56i1/EIDUeqJu1Y=; b=a20bZNlsVhVeuUW7RhsFAH3qSmtbAsHikMnvZauuNerdJLg3uzFAiYEGhgn59AlOEP txtIAYhOIXQerWI7ox3WKpjORNKQsPEtZHgn4S2Fo57S/cYPaAHAgQ3foFj8yBFOKv8A D/vYvpQFuhzTmT77z/M4QmAZJwoDsZApGeJTtKu8NP5WuYUvKjGWH2D4qd/8lbEgEoPn aTKsYQOyPozVddLyjMygRSpGmaNFHPJN/sN0ys0Qxjmh7nrAXEr5BRdSrI60+mCh5tGW kplXr/+wBcQpZKBLjLWTLll3QeTwfBWM7QWdZpCjp73Y4DRRy7//PcWcmGwh+8gmrReY hBRA== 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 x4si585536qtj.211.2018.11.25.18.21.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:21:29 -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 18C27356F5; Mon, 26 Nov 2018 02:21:28 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7B115C2E4; Mon, 26 Nov 2018 02:21:17 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , 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 V12 19/20] block: kill QUEUE_FLAG_NO_SG_MERGE Date: Mon, 26 Nov 2018 10:17:19 +0800 Message-Id: <20181126021720.19471-20-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.30]); Mon, 26 Nov 2018 02:21:28 +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 20b5b0c3e182..9a7fd8b1f90a 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -355,8 +355,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 }; unsigned int seg_size, nr_phys_segs; @@ -382,13 +381,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)) @@ -418,27 +410,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 a32bb79d6c95..d752fe4461af 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -127,7 +127,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 b16204df65d1..7b17191d755b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2780,9 +2780,6 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT; - 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 844f7d0f2ef8..a41832cf0c98 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 fa263de3f1d1..9c1ae3a62ed3 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -589,7 +589,6 @@ struct request_queue { #define QUEUE_FLAG_SAME_FORCE 15 /* force complete on same CPU */ #define QUEUE_FLAG_DEAD 16 /* queue tear-down finished */ #define QUEUE_FLAG_INIT_DONE 17 /* queue is initialized */ -#define QUEUE_FLAG_NO_SG_MERGE 18 /* don't attempt to merge SG segments*/ #define QUEUE_FLAG_POLL 19 /* IO polling enabled if set */ #define QUEUE_FLAG_WC 20 /* Write back caching */ #define QUEUE_FLAG_FUA 21 /* device supports FUA writes */ From patchwork Mon Nov 26 02:17:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10697495 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 ADA301591 for ; Mon, 26 Nov 2018 02:21:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D65F29A52 for ; Mon, 26 Nov 2018 02:21:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 912E929ADF; Mon, 26 Nov 2018 02:21:45 +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 F140F29A6C for ; Mon, 26 Nov 2018 02:21:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9D9D6B3F8E; Sun, 25 Nov 2018 21:21:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E4BFF6B3F90; Sun, 25 Nov 2018 21:21:43 -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 D26C46B3F91; Sun, 25 Nov 2018 21:21:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id A67226B3F8E for ; Sun, 25 Nov 2018 21:21:43 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id k66so18282774qkf.1 for ; Sun, 25 Nov 2018 18:21:43 -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=xqdsngi9UFiD1zPCGalYjn/mFcMyxtnRdlxJv3ax4I8=; b=HZ1cZhbgsCfqYPxVrFe0sk8jf/t7EniirtNm0Ysxdt9ZdJXvbo/BDHc0nx9itoe9Gv XGKI1OxFV36Pd5MTNSAEXjONj6dlx1C0NIdczA7joNfJww6jIl5XgjqaX91TxNbAQd0q cMRV2gnyoaCX9nfiPDusEL7O9NJ2yEmi2jw01al2gb9Uz7w9GPSNE6e/0buNAQYyAiLx Haz8y2E+O5iDdzRYcnDdoI6+UxjNyLvkFMXT6LktlEZBghyu5DjNfGAkwBLBRMcs8U89 AnansSEwZ3nVBAAM7fP8L6FT+ldu1laheeZSgM2CwwWOXk2TvI3cF2pS6piFQ+gfXzLT ZolA== 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: AA+aEWb/1LkBE2J20j9jFvJ1NUjgplN1TyLa/ZTPgu6KA3z+3AcGh2Nj naBdJCBOmrdXh+yxmrLu3WsxMGeWIsMJnmkIOIJn1w8R4HUwOnuIu86dpSqAQU+F1l2fKrXaHrX qokEc7+YHwy6qTCFtx0N09oYQSwwNgJj7hUBVWieAEChxMyfh8Vr+nRPY2/sMaL7qGA== X-Received: by 2002:a37:c304:: with SMTP id a4mr23154933qkj.269.1543198903384; Sun, 25 Nov 2018 18:21:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/WOACLGDJT9Iwasestj4QhCvBkmHuRkkxVL6BFwNBpnPw9ib0flRaB+HyROL0FKVfinpKmw X-Received: by 2002:a37:c304:: with SMTP id a4mr23154889qkj.269.1543198902122; Sun, 25 Nov 2018 18:21:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198902; cv=none; d=google.com; s=arc-20160816; b=L1BWLFwO5Bqe7lZ5EyZBBCAOLJFI+8fR0Ds3NWUqZstz3SudB1DUBwzKULOEGcPt5Z NI8OJy0Yg7697vb8mopGu9UAirXPohRmljhlemeGP33l/vISWgweQkezm6Ja+Hc08PCU C6nWOOJgaQOeAe+2aHeIytvQK8xJs3j/KWjg1EGCL6bMkJ/UN9NMdG17UTtR3iSBAQQD uDhTFWkhw/PagDMwxOuIDDFbfYCGiprOkoufpxUtxY0thZ3OOzZ4X7dnjJJGBbbu7tDa iZVemuMj81YKj9elr+rk4KU1Pn2UNmT78myV+is89kubVrxlGu2Rotbj+34ujZ0akOnt SyrQ== 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=xqdsngi9UFiD1zPCGalYjn/mFcMyxtnRdlxJv3ax4I8=; b=uTywCBe/xMD7yrxFqtonNbWhZtZ2eWBfUJ55dmI8CvfphO6GnUwnMdzmFoIflKzfBj olK5wgjw22e1g37HQMEn5gFqxDeD4CMbvRFgAIiLabCMQWLhrgj+JjfzamMcQNMv5P8s 8DtC4UJDKI+hzqEaoWVCG4Sty2zur13qGpUZv7AMyx9IVFEr7Fsfc5HPxJDYfm99pC9T QxupMM+uZ+eeN2ZQ7T0Dft2qj+6iNrUOXjEfEJyXzcfjQl2l5M8oxz0FwKz7uI0rpbR9 R+eYnNuRS0F35OCrh5/Y79M82Cw63yarRMVCHw/Vi7ouPZnMgf0wJAaUP8JHmTqp0wIn OWLw== 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 10si1065707qto.215.2018.11.25.18.21.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 18:21:42 -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 04C4930841DE; Mon, 26 Nov 2018 02:21:41 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45B8F1054FBA; Mon, 26 Nov 2018 02:21:29 +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, Shaohua Li , 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 V12 20/20] block: kill BLK_MQ_F_SG_MERGE Date: Mon, 26 Nov 2018 10:17:20 +0800 Message-Id: <20181126021720.19471-21-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-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.40]); Mon, 26 Nov 2018 02:21:41 +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 d752fe4461af..a6ec055b54fa 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -249,7 +249,6 @@ static const char *const alloc_policy_name[] = { static const char *const hctx_flag_name[] = { HCTX_FLAG_NAME(SHOULD_MERGE), HCTX_FLAG_NAME(TAG_SHARED), - HCTX_FLAG_NAME(SG_MERGE), HCTX_FLAG_NAME(BLOCKING), HCTX_FLAG_NAME(NO_SCHED), }; diff --git a/drivers/block/loop.c b/drivers/block/loop.c index e3683211f12d..4cf5486689de 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 1f1fe9a618ea..afbac62a02a2 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -536,7 +536,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 78d6d05992b0..f5ffb97352f7 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1902,7 +1902,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 929e8abc5535..ca7389d7e04f 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -211,7 +211,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,