From patchwork Thu Feb 16 11:45:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9576945 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 81DDF600C5 for ; Thu, 16 Feb 2017 11:49:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84FD32855B for ; Thu, 16 Feb 2017 11:49:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78C88285B9; Thu, 16 Feb 2017 11:49:53 +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 31E882855B for ; Thu, 16 Feb 2017 11:49:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753524AbdBPLtM (ORCPT ); Thu, 16 Feb 2017 06:49:12 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34026 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932152AbdBPLqy (ORCPT ); Thu, 16 Feb 2017 06:46:54 -0500 Received: by mail-pf0-f195.google.com with SMTP id o64so1485329pfb.1; Thu, 16 Feb 2017 03:46:53 -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=qA+KxZUjnzCtcvymb+px24ZaptLe+rwDrbup8cHal54=; b=S3MFbull4unM1P9bST+Jz7Z2xt05cr7ZuSbTlKIB4Nk6mQ3VgP1tbap/nxWM3u0u+T WjE3l18tQo7j+57aH+isFWNNY710RT1asUeCzd20FJQjaGeCRv6hzXsDj8s13pDUnOw/ KGrrpZ4m7yp1m+k7PS9WbzLWJejYRmOGiLEGSjlOR/bz6G1v3xtrFX4+KlqT2WNKuvla hBXXKvuq2FRny6SjgPad/OjPPhVxvKUIxdu6mOygnV4bRia9o96v9aMcMU39XAxf2tmV hrdwE81UFrucLFSBRBeA/RIip2cMZ5Kaliyip00GdZe0vh7hjQlv5EOTuT4prmQAmqPe 26mQ== 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=qA+KxZUjnzCtcvymb+px24ZaptLe+rwDrbup8cHal54=; b=NlNKu15GEJCYm2OD1cUk7aSpacYC7pBVuNIr5QzESOa5rCIR/BV5xFk1L9/QBBob9x lz05Mr8o7fghAu54K1Imp04BwGlffcDLBq6cdNC/ydy2K++QDIfn5LUuyXWiy0ZqdWcr /x5MjQsgAzmLP/2X8IxIs3/OAU57bBFQ0jF5XnVcakkLEBYgGH4sx8lvM9zs2JQmniwk 5RH05laLW8x/WQ2Gf5/9t5XJMSO6qjlcJC7A0NsJrKRtS2C1puVIrfdEMJ4XYdlZt6JK 4zIGB9wGWf6cx17L8clP6wAdDIK6MBlDxA6SBtkco5LiE1866Y0k/5IUCNqyspYHlwwJ 9ybQ== X-Gm-Message-State: AMke39lb0s0YnA1wkLhWni6OofUHAghyO6euEDl+cuuUSnVZnZUyCcAibzeiiVR4PwrgCg== X-Received: by 10.99.142.65 with SMTP id k62mr2205950pge.157.1487245608370; Thu, 16 Feb 2017 03:46:48 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id 75sm13219264pfw.103.2017.02.16.03.46.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 03:46:47 -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 12/17] md: raid1: avoid direct access to bvec table in process_checks() Date: Thu, 16 Feb 2017 19:45:42 +0800 Message-Id: <1487245547-24384-13-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 Given process_checks is only called in resync path, it should be ok to allocate three stack variable(total 320byteds) to store pages from bios. Signed-off-by: Ming Lei --- drivers/md/raid1.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 4400fbe7ce8c..54ec32be3277 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2010,6 +2010,9 @@ static void process_checks(struct r1bio *r1_bio) int primary; int i; int vcnt; + struct bio_vec *bi; + int page_len[RESYNC_PAGES]; + struct page *pbio_pages[RESYNC_PAGES], *sbio_pages[RESYNC_PAGES]; /* Fix variable parts of all bios */ vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9); @@ -2017,7 +2020,6 @@ static void process_checks(struct r1bio *r1_bio) int j; int size; int error; - struct bio_vec *bi; struct bio *b = r1_bio->bios[i]; if (b->bi_end_io != end_sync_read) continue; @@ -2051,6 +2053,11 @@ static void process_checks(struct r1bio *r1_bio) break; } r1_bio->read_disk = primary; + + /* .bi_vcnt has been set for all read bios */ + bio_for_each_segment_all(bi, r1_bio->bios[primary], i) + pbio_pages[i] = bi->bv_page; + for (i = 0; i < conf->raid_disks * 2; i++) { int j; struct bio *pbio = r1_bio->bios[primary]; @@ -2062,14 +2069,19 @@ static void process_checks(struct r1bio *r1_bio) /* Now we can 'fixup' the error value */ sbio->bi_error = 0; + bio_for_each_segment_all(bi, sbio, j) { + sbio_pages[j] = bi->bv_page; + page_len[j] = bi->bv_len; + } + if (!error) { for (j = vcnt; j-- ; ) { struct page *p, *s; - p = pbio->bi_io_vec[j].bv_page; - s = sbio->bi_io_vec[j].bv_page; + p = pbio_pages[j]; + s = sbio_pages[j]; if (memcmp(page_address(p), page_address(s), - sbio->bi_io_vec[j].bv_len)) + page_len[j])) break; } } else