From patchwork Sat Jun 9 12:30: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: 10455603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2FA2A60467 for ; Sat, 9 Jun 2018 12:34:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 224671FF83 for ; Sat, 9 Jun 2018 12:34:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16B8B223A6; Sat, 9 Jun 2018 12:34:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FA0C1FF83 for ; Sat, 9 Jun 2018 12:34:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E5A36B0286; Sat, 9 Jun 2018 08:34:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 994A96B0288; Sat, 9 Jun 2018 08:34:21 -0400 (EDT) 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 8AA1B6B0289; Sat, 9 Jun 2018 08:34:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by kanga.kvack.org (Postfix) with ESMTP id 5CA9C6B0286 for ; Sat, 9 Jun 2018 08:34:21 -0400 (EDT) Received: by mail-qt0-f197.google.com with SMTP id c1-v6so378540qtj.6 for ; Sat, 09 Jun 2018 05:34:21 -0700 (PDT) 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=YpwG844zOvcaPXq0NSfxGyErI8UTcOJTpbTtZhiX/Ug=; b=TTZzRSnyQyzTxk9hB3yWm9h70h8b4E1YJtMXCiWm5EH8IUC/aE67rY0TMSLRUjDyQU EZXV35wXf9/3irBwPgTLJO5JGAvyn/zPA8GVUTYMjFMvPR4V3AsLvCzzGdUvOQsys08q 35loot/4TWZ0+xVLNU+mFk7Onoy8PmYzsSKtaquLBenqBxHPX8C6P3rwdCQ2rPEvnsf9 tx0LP9dHx5Z5P05yhdhQizQfnQtCslKYYEELa7f/K1fVsUHp5yDJpegGlNMQyc7Kq98w TZZwZf9eswQpapHxB6WnFCwM/tM62RMgAoLv0S2G+iohduki3NCvwEmyXfqrIdjEbDMd JnEw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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: APt69E3vd1r7q7zomTaYc0KXfpgmhgOo15/fLTQQhtK+2WteMCD9yRv9 0ZGxR5ytWUW7+mE4+mrySoJ0k6MZs2WfF/4/MfvYuYe8iTFuj4t3fGLKEIHHM4qg3MTpcCO+1LX TtqfpoeEf+GZdY/YJPbWlbFYeqq2OSrl8/KjzjHkpOjbI05Llpl2QJBm/Rji+dwi/iw== X-Received: by 2002:ac8:2439:: with SMTP id c54-v6mr9638835qtc.21.1528547661135; Sat, 09 Jun 2018 05:34:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIbNv89T4x7wMj+7eqPchFR/NoHPHKzpI4P/j5n9MqJCqwe9KUx5TGIkPPCzqnbWbvdQgu9 X-Received: by 2002:ac8:2439:: with SMTP id c54-v6mr9638810qtc.21.1528547660559; Sat, 09 Jun 2018 05:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528547660; cv=none; d=google.com; s=arc-20160816; b=jnNqgS9IHkY6P4nuPNm3/OYio58Ift0R9zFqnjX7EfJ+qZdINHHUrkjjG1Elt43FOy 8jGOaJbojKvgDiAHiZ+XWtS1xP2rC+X1vMzK0XrVXrtnfYckmUdSsbdFkSh8CnOxn7mn wYDXpgv3PP3L3K7zAPxCsNToLjjWz8idZ5QlWph0jEM1ZCk9+GM50hLaEiPtiJDhm4KE fj6Y3SNbtRhUcvNn7AFUMdaCEc26PQUUETARyPNPGhPmkntm5vlZry5ZtfTql7uRd7XX nR0d/U9bMzxalwj38hRcJgZL8R6y1+qRhSXTpS4hYDjRStLQAYBsVmEhrTwSe1ZFkOCy Qafw== 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 :arc-authentication-results; bh=YpwG844zOvcaPXq0NSfxGyErI8UTcOJTpbTtZhiX/Ug=; b=jQwAEslOVmVAQJAlhkC/D+avwXvenAa4TpX918fX2otToKRcSlyktmEryqUPnt/Cpp IOxFVhIOKdRlHt65HMACPXZpQ12ndygSjj+KRBgHnYcR5D+0aeMvTTIZ5qQDwq2IEBYH +WxWbt6wGQO5FuIm8TNwv7hdVT9xd0VUO5bl4zSVVqr+WOFcYIyqnfOucERrkcBPsi7t ZD7ghy8ALGtf201r4Iu4v1tputQR8xw0A57YBjgGNYmMOCdsfCz0wwJQZvfdeqSjAhdO zXxLgQ9LbAEpdYePn1YdEt9bD2ICnZHdEUh8GWBiOrZSlr/uwJ8DVVRLGMHC5ohuNR+Q S8nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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 (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id q87-v6si7619460qkh.219.2018.06.09.05.34.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 05:34:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 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.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24E3D818BAF7; Sat, 9 Jun 2018 12:34:20 +0000 (UTC) Received: from localhost (ovpn-12-40.pek2.redhat.com [10.72.12.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id A708B2166BB2; Sat, 9 Jun 2018 12:34:14 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Alexander Viro , Kent Overstreet Cc: David Sterba , Huang Ying , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , "Darrick J . Wong" , Coly Li , Filipe Manana , Randy Dunlap , Ming Lei Subject: [PATCH V6 19/30] md/dm/bcache: conver to bio_for_each_chunk_segment_all and bio_for_each_chunk_all Date: Sat, 9 Jun 2018 20:30:03 +0800 Message-Id: <20180609123014.8861-20-ming.lei@redhat.com> In-Reply-To: <20180609123014.8861-1-ming.lei@redhat.com> References: <20180609123014.8861-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Sat, 09 Jun 2018 12:34:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Sat, 09 Jun 2018 12:34:20 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' 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 In bch_bio_alloc_pages(), bio_for_each_chunk_all() is fine because this helper can only be used on a freshly new bio. For other cases, we conver to bio_for_each_chunk_segment_all() since they needn't to update bvec table. bio_for_each_segment_all() can't be used any more after multipage bvec is enabled, so we have to convert to bio_for_each_chunk_segment_all(). Signed-off-by: Ming Lei --- drivers/md/bcache/btree.c | 3 ++- drivers/md/bcache/util.c | 2 +- drivers/md/dm-crypt.c | 3 ++- drivers/md/raid1.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 2a0968c04e21..dc0747c37bdf 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -423,8 +423,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_chunk_iter citer; - bio_for_each_segment_all(bv, b->bio, j) + bio_for_each_chunk_segment_all(bv, b->bio, j, citer) memcpy(page_address(bv->bv_page), base + j * PAGE_SIZE, PAGE_SIZE); diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c index fc479b026d6d..2f05199f7edb 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -268,7 +268,7 @@ 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) { + bio_for_each_chunk_all(bv, bio, i) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { while (--bv >= bio->bi_io_vec) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index da02f4d8e4b9..637ef1b1dc43 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1450,8 +1450,9 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) { unsigned int i; struct bio_vec *bv; + struct bvec_chunk_iter citer; - bio_for_each_segment_all(bv, clone, i) { + bio_for_each_chunk_segment_all(bv, clone, i, citer) { 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 bad28520719b..2a4f1037c680 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2116,13 +2116,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_chunk_iter citer; 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_chunk_segment_all(bi, sbio, j, citer) page_len[j] = bi->bv_len; if (!status) {