From patchwork Thu Feb 16 11:45:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9576949 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 E1DA3600C5 for ; Thu, 16 Feb 2017 11:50:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF1182855B for ; Thu, 16 Feb 2017 11:50:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4130285B7; Thu, 16 Feb 2017 11:50: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=-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=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 97A2B2855B for ; Thu, 16 Feb 2017 11:50:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932103AbdBPLqm (ORCPT ); Thu, 16 Feb 2017 06:46:42 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33504 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932096AbdBPLqk (ORCPT ); Thu, 16 Feb 2017 06:46:40 -0500 Received: by mail-pg0-f68.google.com with SMTP id 5so1825680pgj.0; Thu, 16 Feb 2017 03:46:40 -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=DRFbDH9UlhkDAi3aDEGk8m7+t9V9LkGQa/FsRJV9GZs=; b=eY7AdUtVo3z3lsfSRVXv0CqAg7kvJGA92/fmtBNPgFnvMx/7STvnljaUuNRgGN969s 2408Mrn1LJmuF0DDQYArvuRJ4cMX8R0t/JT0V0L3xYsuD+ckHdPRsV4y/u4s/uypHsD5 NXlx27TOMRkTTwyxxpP981pYfUNmKm/bZCEjP6Umfnd1Q5qH02j6VCBofRNEdv0V4bWA XEEGi2rRJsz0VxelLWRvGT9qYhCTyFhLwu8wbigQziqpvXY5441DAoS6MUN0GNsJKM4q gsEzDTYvg2xT9iGug5sSTidvvg+3Js4Q/xuIBH+LlcF/2YsVkym2MAMu8zSXM6K1NNVO rqMg== 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=DRFbDH9UlhkDAi3aDEGk8m7+t9V9LkGQa/FsRJV9GZs=; b=o5Ta0Bt8B8e4TzXp8suqOB1LMsg/0ebBU5cUI8t19CUQAOUDFtHg7pZ+VQhkfBK58B ZelZ0AtUyjRqNDbPKfzbsRQAn7SJ0BUU1RNudKFnRy3y1ted8YLCStKbPBYuMosN1KkD 4d6+LVKhpDI1GorzYxwsRlhQCeKCfuv7UqEU64cY9Eq/FzoMnd5ToC3+On/zoG35hWOx vV5wl/2r62SW3iVNDe2kZ+0O0L+TlhoInfB7Ixys9M+yx4PwRYfoPdcJ7eD1MWcr521x krgpPMGJEU6WVBn3nGM9GBitR+soVyyeXCWWJ5Tj47PGAtqRxTbKj6HDjsDUA09BrUea RXKQ== X-Gm-Message-State: AMke39kz+EhK61/7SwXqSlrjUphfLMOowNvxqnnVK24AK6ZklZd+bWYoMerNlia4DtG4jA== X-Received: by 10.84.241.76 with SMTP id u12mr2593034plm.107.1487245594904; Thu, 16 Feb 2017 03:46:34 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id l12sm13326484pfj.37.2017.02.16.03.46.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 03:46:34 -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 08/17] md: raid1: simplify r1buf_pool_free() Date: Thu, 16 Feb 2017 19:45:38 +0800 Message-Id: <1487245547-24384-9-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 This patch gets each page's reference of each bio for resync, then r1buf_pool_free() gets simplified. 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 23a3a678a9ed..ebea8615344a 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -143,9 +143,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; @@ -170,12 +173,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]);