From patchwork Thu Feb 16 11:45:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9576915 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 BFF3560586 for ; Thu, 16 Feb 2017 11:47:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD1EF28546 for ; Thu, 16 Feb 2017 11:47:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2002285B7; Thu, 16 Feb 2017 11:47: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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 6EE422855B for ; Thu, 16 Feb 2017 11:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932161AbdBPLqy (ORCPT ); Thu, 16 Feb 2017 06:46:54 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35352 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932096AbdBPLqw (ORCPT ); Thu, 16 Feb 2017 06:46:52 -0500 Received: by mail-pg0-f66.google.com with SMTP id y6so726016pgy.2; Thu, 16 Feb 2017 03:46:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xc4jert9HyHxa0HeWeG9RwG9orYdbUX3lIytGE6/L/o=; b=Ps0neWwFxJhbp9iZ3cSGmeiisZyOWpWwMmCZI5sfEyX45ghrSKxJQXBgYesipvQrMB WotipCU2b+cRAnVUTTmPjLYmPzvHtEEJ2gqvVosn5NCP6TjDq0PWbI4c/HiiUvsZoaAo Qv4UqsCZsjSe/scGvvorcfjpuaHpRnIp8AaYqabN/+p0SC/T91DHHsO9WJUAos0Lql0J t2djOE5PF7Fpm35G2ELLSp1QX7llgd4VrEt6jB/Ik3+3NSz91u3hiKJY64okeqa4u5Y5 5WCRXvd9p4NhXhb9Htq8GXcL0N8B3pzMKWEcMrVk21Ng2TLKfpdU/RQFuwxAU4ruI0kl 6Rrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Xc4jert9HyHxa0HeWeG9RwG9orYdbUX3lIytGE6/L/o=; b=alQJD61mqWH9bW74GOUqD7BJL+8LeChaxWtjASxkJiupPCxJOJpHg3o+skmPrbgTQc W3hh5reNijZzACdDQGcJk7SEcifDiuiHOxpPtMtBN8Sq9pvylDSA97Yvu31XnuHOCC85 1aJPrFM/F1yCqltB6JSn8MEi+L9tROKVMFRX+J4UJmBtBQ76FHsGNSy0lZYRSE07HoM8 /RuprKSLBuzetxdJzOvscz3nOl/6lYRhWAUALIgco+wZwqRny1S2ajxNCXmCHKxHs1tK DAAAeip/g96TX3Cu54UM6mYyGNAV287pKczaSuWXswvbw4d7Ic139w3ZxQaDI7je01Mj YagQ== X-Gm-Message-State: AMke39lpJK7O5baurix3I+RRPiknsRFs3hiN+7EVMu+ao5X6tNpywMtNoGogLHxzifWSvA== X-Received: by 10.98.35.207 with SMTP id q76mr2126273pfj.112.1487245612020; Thu, 16 Feb 2017 03:46:52 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id p25sm13371266pfd.0.2017.02.16.03.46.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 03:46:51 -0800 (PST) From: Ming Lei To: Shaohua Li , Jens Axboe , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig , NeilBrown Cc: Ming Lei Subject: [PATCH 13/17] md: raid1: use bio_segments_all() Date: Thu, 16 Feb 2017 19:45:43 +0800 Message-Id: <1487245547-24384-14-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487245547-24384-1-git-send-email-tom.leiming@gmail.com> References: <1487245547-24384-1-git-send-email-tom.leiming@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use this helper, instead of direct access to .bi_vcnt. Signed-off-by: Ming Lei --- drivers/md/raid1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 54ec32be3277..02cfece74981 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -998,7 +998,8 @@ static void alloc_behind_pages(struct bio *bio, struct r1bio *r1_bio) { int i; struct bio_vec *bvec; - struct bio_vec *bvecs = kzalloc(bio->bi_vcnt * sizeof(struct bio_vec), + unsigned vcnt = bio_segments_all(bio); + struct bio_vec *bvecs = kzalloc(vcnt * sizeof(struct bio_vec), GFP_NOIO); if (unlikely(!bvecs)) return; @@ -1014,12 +1015,12 @@ static void alloc_behind_pages(struct bio *bio, struct r1bio *r1_bio) kunmap(bvec->bv_page); } r1_bio->behind_bvecs = bvecs; - r1_bio->behind_page_count = bio->bi_vcnt; + r1_bio->behind_page_count = vcnt; set_bit(R1BIO_BehindIO, &r1_bio->state); return; do_sync_io: - for (i = 0; i < bio->bi_vcnt; i++) + for (i = 0; i < vcnt; i++) if (bvecs[i].bv_page) put_page(bvecs[i].bv_page); kfree(bvecs);