From patchwork Thu Mar 16 16:12:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9628863 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 6581460244 for ; Thu, 16 Mar 2017 16:15:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5714C283F9 for ; Thu, 16 Mar 2017 16:15:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BFBA2841E; Thu, 16 Mar 2017 16:15:38 +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 09DBB283F9 for ; Thu, 16 Mar 2017 16:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754745AbdCPQOf (ORCPT ); Thu, 16 Mar 2017 12:14:35 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34954 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755068AbdCPQO2 (ORCPT ); Thu, 16 Mar 2017 12:14:28 -0400 Received: by mail-pf0-f196.google.com with SMTP id x63so6154588pfx.2; Thu, 16 Mar 2017 09:14:26 -0700 (PDT) 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=g0qHtmL2l5xagIyZnSIM5mVRYJ+E7JAdbO9gWlpmaMM=; b=YK1nfwpWRS/jZifBXPkZAP0GqUCyLy7kuvSaZRr5Em92G/mdDOrK88AQDMEWOl+trv R7D+eftH04e0E1ldnnUCzlb0X+PWBt8oXcZ5Mrmbi4//Iz19Qc9Pg5kePADNieGFdJNS DLN6plFlv6k7A1S4LiqEg01VRe0PVJjs37KXO2HSDDFjrMED/oLWgggPI4CJ94zQfl4C YmLjs4/OLWuHAILsVLH1brrzteduc2kTJlQYV06JM/dEpkK126mO3C8drcC+1fThbktS eEkLMqzCykpIh4aowSYLkie9IZs+5cne0Okn/KfAPFWtyIho6PphFwRIAlJINXiSilo3 0zcg== 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=g0qHtmL2l5xagIyZnSIM5mVRYJ+E7JAdbO9gWlpmaMM=; b=fnLyEYyWyBCSOnxVEJJ6Ez1rmL8vnXabT0mtIS/1dhp7bXySuYN19bbfWFVtaXrSL4 VgAEcM5aPxJgRf4+ks72St9SezI7O8hCWRLqgNjxLlyFuJfuV8jS3XEbhCmQzjqcnr3X Vz/hFpW8DEghqPHAJY1XDNZN0wp443h+UF962ZbxsAufMw33AxiJErAUl+6GNYu25NK9 Q/V02cx/kpyb0ysCzjqrIfdIXhCGJg1eZQeLPU1QLyO/fW2PKAGZNrWLtlgt824RpBkY HPPXpTfivXQoKqEW8S6798RDd2aWmzQLSGrZsIQm6Fq/ijRIW4cFR6vFb+54CA+/liTC BbHw== X-Gm-Message-State: AFeK/H3r/PsugZ5hFIhoqOs+EWaOx9Qj9DFcLQqRkc4ei1CEtK8HGNSmJAiKfuGcj/3F+g== X-Received: by 10.98.54.196 with SMTP id d187mr11353628pfa.33.1489680861284; Thu, 16 Mar 2017 09:14:21 -0700 (PDT) Received: from localhost ([103.192.224.52]) by smtp.gmail.com with ESMTPSA id e13sm11591524pgn.38.2017.03.16.09.14.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Mar 2017 09:14:20 -0700 (PDT) From: Ming Lei To: Shaohua Li , Jens Axboe , linux-raid@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig Cc: Ming Lei Subject: [PATCH v3 04/14] md: raid1: simplify r1buf_pool_free() Date: Fri, 17 Mar 2017 00:12:25 +0800 Message-Id: <20170316161235.27110-5-tom.leiming@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170316161235.27110-1-tom.leiming@gmail.com> References: <20170316161235.27110-1-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 This patch gets each page's reference of each bio for resync, then r1buf_pool_free() gets simplified a lot. The same policy has been taken in raid10's buf pool allocation/free too. Signed-off-by: Ming Lei --- drivers/md/raid1.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 908e2caeb704..e30d89690109 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -142,9 +142,12 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) /* If not user-requests, copy the page pointers to all bios */ if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) { for (i=0; iraid_disks; j++) - r1_bio->bios[j]->bi_io_vec[i].bv_page = + for (j=1; jraid_disks; j++) { + struct page *page = r1_bio->bios[0]->bi_io_vec[i].bv_page; + get_page(page); + r1_bio->bios[j]->bi_io_vec[i].bv_page = page; + } } r1_bio->master_bio = NULL; @@ -169,12 +172,8 @@ static void r1buf_pool_free(void *__r1_bio, void *data) struct r1bio *r1bio = __r1_bio; for (i = 0; i < RESYNC_PAGES; i++) - for (j = pi->raid_disks; j-- ;) { - if (j == 0 || - r1bio->bios[j]->bi_io_vec[i].bv_page != - r1bio->bios[0]->bi_io_vec[i].bv_page) - safe_put_page(r1bio->bios[j]->bi_io_vec[i].bv_page); - } + for (j = pi->raid_disks; j-- ;) + safe_put_page(r1bio->bios[j]->bi_io_vec[i].bv_page); for (i=0 ; i < pi->raid_disks; i++) bio_put(r1bio->bios[i]);