From patchwork Fri Feb 24 15:42: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: 9590611 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 C03836020A for ; Fri, 24 Feb 2017 15:48:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4E6122BF1 for ; Fri, 24 Feb 2017 15:48:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A953D286CC; Fri, 24 Feb 2017 15:48:43 +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 64F8122BF1 for ; Fri, 24 Feb 2017 15:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751541AbdBXPoM (ORCPT ); Fri, 24 Feb 2017 10:44:12 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34549 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751294AbdBXPnd (ORCPT ); Fri, 24 Feb 2017 10:43:33 -0500 Received: by mail-pf0-f195.google.com with SMTP id o64so1168020pfb.1; Fri, 24 Feb 2017 07:43:32 -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=VljgvUYW3oc4AV1FlLOC3DlgzBLLe1n7vEZYPklapi8=; b=OUmmMDw+OUV8pb0v4xiAQROG0tNXJxWcVnIj28j4WBs0Xe/3aCG78oebYe4CoXfKn6 1TY5K3JZwscEp2ISZ+Sb4yKTgR3ys2UAbjrKcEw457zj+thBmsRDV7+0wW+FFNk615W+ 4mNKtkUJDJ7D1ODAUhN086YY9yUEjf05urSfObbou7Q+1Iyph43bLMonRqYhicItO/It AvX4hay3E1gdbpjhddLAiVBLygjdxCV5QzHHwFjUCivWQl9SjhBcgYpuFpbAj4irzRH5 35KAas7ZTf0Sy/OcE90w6aLfOQudPT5dZT018Au8xhJivWEoPcRWNJB72cYE7eRE+5Z6 QjBw== 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=VljgvUYW3oc4AV1FlLOC3DlgzBLLe1n7vEZYPklapi8=; b=q4Up8X7Es1ABU3OUftCuncrS9V7B0ITRLefl+Ic4oHuyQQBJY4g16rfT+9gDfTpqls Q9oPXt4Ec11gJ6Rd4PUDZXSJDs93WsYaxVyUkCULxPHBHQUARrXzWFXWPnBIvASI/VP1 gJuLOvgZfLADfmdy5S+Wti6+wS3blRvVP1QlMkZi/lq03hgjtr3l/9x6b693bXcMql4X 4XR1lJmmeZlgFevKlBa3eJx7s06ElWYf6zptPUMDv42KAmr+XRiUuFNANCtKoRaWITFC SnuOz6F7yFSveJ3hBaow7tqsTexBFgBJxEo8MUDoLQtsS3YXAeb5XDp6rPgwIzvWY7V1 cnXw== X-Gm-Message-State: AMke39mSkotB7otbK+YEw57zYiwjS1zU1hjQLzHSqtq1JYDo9oJ45xLeoMeSsUMye4zFlQ== X-Received: by 10.84.129.2 with SMTP id 2mr4783215plb.108.1487951012356; Fri, 24 Feb 2017 07:43:32 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id o189sm15950509pga.12.2017.02.24.07.43.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 07:43:31 -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 Cc: Ming Lei Subject: [PATCH v1 06/14] md: raid1: simplify r1buf_pool_free() Date: Fri, 24 Feb 2017 23:42:43 +0800 Message-Id: <1487950971-1131-7-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487950971-1131-1-git-send-email-tom.leiming@gmail.com> References: <1487950971-1131-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 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 2013e5870761..2de0bd69d8da 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -139,9 +139,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; @@ -166,12 +169,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]);