From patchwork Thu Feb 16 11:45:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9576939 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 83E30600C5 for ; Thu, 16 Feb 2017 11:48:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83FF428546 for ; Thu, 16 Feb 2017 11:48:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 751E7285BD; Thu, 16 Feb 2017 11:48: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 3119628546 for ; Thu, 16 Feb 2017 11:48:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932181AbdBPLq6 (ORCPT ); Thu, 16 Feb 2017 06:46:58 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36434 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932170AbdBPLq4 (ORCPT ); Thu, 16 Feb 2017 06:46:56 -0500 Received: by mail-pf0-f193.google.com with SMTP id 19so1479498pfo.3; Thu, 16 Feb 2017 03:46:55 -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=EkMi6Rz+Vz/bQMhD53+2I1RQlJznfFoy3pN6mtERqDs=; b=Y2af3/Fgqf1mV1stDRyRBoGVbDVuzrYn7sm+527s7y/9t3L4r/wj1nPOJv5+jR3L7l wIdWVpzKGHh+F41LHA257CAhSPzcqXlrzzvoqiS72nObHIjpAtjna83RZFiim43swEUl otcChcrsdpw/peH4U8TuDFRwtRXEXkfUNftirCzl9bZhr5SoIZX0nKiI4j6+t+o4IrLF K3sD3vvM9hDFrUdG21QaX57ErOmK6Cb7sXuBs0GE0e51tdQDeWVmsroJlVr+bv305RiX Q5wGIO/6MnUk4HC6gOTwlKzarT2b/Bw6u+K9+jtVg89yfgiBGojAqNgKuJ0ViZDaEjIK vzHQ== 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=EkMi6Rz+Vz/bQMhD53+2I1RQlJznfFoy3pN6mtERqDs=; b=XLSM2h3GEl/fWVHzu/KwraGgFuPYYWMX9K1rOH5HHThMbwVgkGUz8FQP97AEbs+2kK TlCvKcN1VwarMZkVrXxqyf9VaUXoov8UWVTgyeW1ifXa8+YwFYhpCvjKED6ENaYX7zCM /g1q9skiXbrPfy4WUei5y48wb8EeZPdOhDlEuMed6zvbo0sSaXLOeFtW0l3PETjh+WnN CK7YOGtbsV3VJVNj9KMkiz0exVTIAkrtekV6IwnklaF88xQZ9aMFEcS4YrqgP5CkrjOo KT97WBm89qt8wztXGYHfHobOCHt8evTV0uMG0a29obidrgj00cI9Yxd3AmQM6coaBFhp xvCA== X-Gm-Message-State: AMke39mmdQoW70VH4XMrqJ/lTIMzNt2R/acXIAb/6Dmw8xo0u+OzpQby0xCFHss8Gb7xLQ== X-Received: by 10.84.128.66 with SMTP id 60mr2686396pla.34.1487245615178; Thu, 16 Feb 2017 03:46:55 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id c2sm13298736pfl.61.2017.02.16.03.46.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 03:46:54 -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 14/17] md: raid10: avoid direct access to bvec table in sync_request_write() Date: Thu, 16 Feb 2017 19:45:44 +0800 Message-Id: <1487245547-24384-15-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 The cost is 256bytes(8*16*2) stack space, and just use the bio helper to retrieve pages from bio. Signed-off-by: Ming Lei --- drivers/md/raid10.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 5c698f3d3083..69fe2a3cef89 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2036,6 +2036,8 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) int i, first; struct bio *tbio, *fbio; int vcnt; + struct bio_vec *bvl; + struct page *fbio_pages[RESYNC_PAGES], *tbio_pages[RESYNC_PAGES]; atomic_set(&r10_bio->remaining, 1); @@ -2052,6 +2054,10 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) fbio->bi_iter.bi_size = r10_bio->sectors << 9; fbio->bi_iter.bi_idx = 0; + /* the bio has been filled up in raid10_sync_request */ + bio_for_each_segment_all(bvl, fbio, i) + fbio_pages[i] = bvl->bv_page; + vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9); /* now find blocks with errors */ for (i=0 ; i < conf->copies ; i++) { @@ -2072,12 +2078,17 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) * All vec entries are PAGE_SIZE; */ int sectors = r10_bio->sectors; + + /* the bio has been filled up in raid10_sync_request */ + bio_for_each_segment_all(bvl, tbio, j) + tbio_pages[j] = bvl->bv_page; + for (j = 0; j < vcnt; j++) { int len = PAGE_SIZE; if (sectors < (len / 512)) len = sectors * 512; - if (memcmp(page_address(fbio->bi_io_vec[j].bv_page), - page_address(tbio->bi_io_vec[j].bv_page), + if (memcmp(page_address(fbio_pages[j]), + page_address(tbio_pages[j]), len)) break; sectors -= len/512;