From patchwork Tue Feb 28 15:41:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9596069 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 E0CF7601D7 for ; Tue, 28 Feb 2017 15:43:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1E8628535 for ; Tue, 28 Feb 2017 15:43:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C698B2853A; Tue, 28 Feb 2017 15:43:06 +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 6A12D28535 for ; Tue, 28 Feb 2017 15:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752366AbdB1PnF (ORCPT ); Tue, 28 Feb 2017 10:43:05 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35236 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbdB1PmW (ORCPT ); Tue, 28 Feb 2017 10:42:22 -0500 Received: by mail-pg0-f67.google.com with SMTP id 1so1988008pgz.2; Tue, 28 Feb 2017 07:42:21 -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=sdpl+gOe8DjmBHCqXWuMStjbCBXf9du1IqmH+R/aeDI=; b=eYc+q+ElTTLXIgQU93nb4brmOpTRcxGCgJobkXwYdzxkFP55kuwEm/s+YpueHgN0IJ xwOIhiz2tb/tMbdYX4oH5rrvTZUFy+OMjZBy+uPaUbGtaYiA9IMknu/K4OgpJ8sreZgo G4M6dCVvGKCF2TYbxKQF2/hvwyrsYokX7ehMy4D4O/CNEL+/4IBrmWyy96qzi84s1ThU iyzKRPOwlLlPqgIbvCMHOH9Rg5jnOywqEfdOSNTQo1CbFXGkGxc58Nfbg5StB4UVxH8P m4Q5BA9i5m2JkNW1ZaZv2OLQd7ERVKC6Jfi+xsrXaDyGars9Qo8+jfHs67Y89+Ut2c6s gwVg== 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=sdpl+gOe8DjmBHCqXWuMStjbCBXf9du1IqmH+R/aeDI=; b=W4/c039V5KEjdX/6UpZ7NVa0xU0a7ohVV80m2Kse/dP2piQT7ZIHGcSJcnMDR0Ukne cPA/6A5llMkWZfAULdAsTw3h/9L6M9O1IBqVtdVA6Ij2pVN2Nueg+djyfPngbvon5DY5 QRAhsHXO9UC/E09j11abOnjp4Too+8XUo3mE/ISfRJ+kr1HBGiPzFfJdHTBA38xhKYr4 S9DCXwTiwI5aBY4ur5YGW3+R0hFAeQpUF3mZiRvAPL5WOoLOo4p2AtcAyMy3D4ngR53Y Z38uuRuk5dL76ibkTv+5LZCZVBnw0TCCN9O/dqtytvKDl3guLoI19252YD/Jj3ADPJsu YJeA== X-Gm-Message-State: AMke39kPRDB87iqgbbwsC7WB5ePg+wQ/KcfMSwkH4pg0C52QG1ciWkq39bZC1USUS63xaA== X-Received: by 10.84.197.131 with SMTP id n3mr3829335pld.43.1488296541382; Tue, 28 Feb 2017 07:42:21 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id r7sm5070469pfl.25.2017.02.28.07.42.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Feb 2017 07:42:20 -0800 (PST) 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 v2 05/13] md: raid1: simplify r1buf_pool_free() Date: Tue, 28 Feb 2017 23:41:35 +0800 Message-Id: <1488296503-4987-6-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488296503-4987-1-git-send-email-tom.leiming@gmail.com> References: <1488296503-4987-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 25c9172db639..c442b4657e2f 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]);