From patchwork Mon Dec 18 12:22:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10119331 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 2687660327 for ; Mon, 18 Dec 2017 12:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18F3F28F70 for ; Mon, 18 Dec 2017 12:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DECA28FCB; Mon, 18 Dec 2017 12:36:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9D5C28F70 for ; Mon, 18 Dec 2017 12:36:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933776AbdLRMbB (ORCPT ); Mon, 18 Dec 2017 07:31:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45478 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933748AbdLRMa5 (ORCPT ); Mon, 18 Dec 2017 07:30:57 -0500 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 BFDEC37E7B; Mon, 18 Dec 2017 12:30:56 +0000 (UTC) Received: from localhost (ovpn-12-48.pek2.redhat.com [10.72.12.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 608BC60C5B; Mon, 18 Dec 2017 12:30:46 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Alexander Viro , Kent Overstreet Cc: 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 , Ming Lei Subject: [PATCH V4 32/45] md/dm/bcache: conver to bio_for_each_page_all2 and bio_for_each_segment Date: Mon, 18 Dec 2017 20:22:34 +0800 Message-Id: <20171218122247.3488-33-ming.lei@redhat.com> In-Reply-To: <20171218122247.3488-1-ming.lei@redhat.com> References: <20171218122247.3488-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Dec 2017 12:30:56 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In bch_bio_alloc_pages(), bio_for_each_segment() is fine because this helper can only be used on a freshly new bio. For other cases, we conver to bio_for_each_page_all2() since they needn't to update bvec table. bio_for_each_page_all() can't be used any more after multipage bvec is enabled, so we have to convert to bio_for_each_page_all2(). 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 a82100527495..ac7bac6e6a29 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_iter_all bia; - bio_for_each_page_all(bv, b->bio, j) + bio_for_each_page_all2(bv, b->bio, j, bia) 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 8f2d522822b1..a23cd6a14b74 100644 --- a/drivers/md/bcache/util.c +++ b/drivers/md/bcache/util.c @@ -298,7 +298,7 @@ int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) int i; struct bio_vec *bv; - bio_for_each_page_all(bv, bio, i) { + bio_for_each_segment_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 970a761de621..19dc1f6b523a 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1442,8 +1442,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 bia; - bio_for_each_page_all(bv, clone, i) { + bio_for_each_page_all2(bv, clone, i, bia) { 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 e64b49929b8d..da5d7ea5504b 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2083,13 +2083,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 bia; if (sbio->bi_end_io != end_sync_read) continue; /* Now we can 'fixup' the error value */ sbio->bi_status = 0; - bio_for_each_page_all(bi, sbio, j) + bio_for_each_page_all2(bi, sbio, j, bia) page_len[j] = bi->bv_len; if (!status) {