From patchwork Thu Feb 16 11:45:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9576933 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 D1496600C5 for ; Thu, 16 Feb 2017 11:48:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D21E328546 for ; Thu, 16 Feb 2017 11:48:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6BFE285B7; Thu, 16 Feb 2017 11:48:27 +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 7933C28546 for ; Thu, 16 Feb 2017 11:48:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932208AbdBPLrB (ORCPT ); Thu, 16 Feb 2017 06:47:01 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35316 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932096AbdBPLq5 (ORCPT ); Thu, 16 Feb 2017 06:46:57 -0500 Received: by mail-pg0-f68.google.com with SMTP id y6so725707pgy.2; Thu, 16 Feb 2017 03:46:52 -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=RhJg7p1GtJ2n+/dgr3DUioJnFyGFOE8r2i0WE/aplN0=; b=P+chuFPYVLWPyt0Uoy0k7Eq4i4jaZW9eKiPdAAkISZE8+Eok4szkgEsRLBc0CGjbPF iL1LG2xnsZotDO3CWhJ1puO+KTZrRHpehLG48feZ/XoqKIhk2uVqC2euLtahOTMQsTf+ e+ZglVYHlBrtmuTHceV+Lijd/oHELbxAGn2Q+dIgWesF2b0DGf3oc2avSiXIHIuipfzX RD1IZ9AD5zgV9Kndv5ODmEV2eI7xVYtoGaSQU1aCgZc5XwNFKRxoLMKSn1hNq4NolOy2 30++NrzPmcKkxoX8jtZenVPDHhUYd5Mz3FPEMCEtKujg6lmdVHO4SwfCnFVBnrgKzy38 snNA== 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=RhJg7p1GtJ2n+/dgr3DUioJnFyGFOE8r2i0WE/aplN0=; b=EZrWwepWmKTpc5LqHU9cLwYY/bChoPaWGhsbUm16rIyevWe4QS+sdXWnU9X0CHHz/C /I7tSIiLYucp2D9aP8S8VoW+IpNvjDYJQzIb2IGUFzT2VjO6GOGkctf88mos4yttWLBp FvNHKiAiMn/zdv1AOM9cICbxsFhFe9nPUHtFQGu1Ech1eQGHWEJ1CkAN68FGrW/+UyEr GNrzWsr1gIH62iRamsOr/8jzVYUM9P/QxNG5+yYF/+IT1xr8z0/ZSCTYpe+Dvay3aqlx nzNmiqti3PsijO7pO28anYs26/UFnVI72Imso5+fUFBeyCr/uZjwaYOflK4so08Tt0WW bh/A== X-Gm-Message-State: AMke39mJqgojUFrxSvas/udPv5XHNU1RPGp4KbWiW3d+ZE5A8iTSZuo3Oy6b7+glX23AYw== X-Received: by 10.84.217.215 with SMTP id d23mr1364660plj.33.1487245601780; Thu, 16 Feb 2017 03:46:41 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id p14sm13279893pfl.75.2017.02.16.03.46.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 03:46:41 -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 10/17] md: raid1: remove direct access to bvec table in fix_sync_read_error Date: Thu, 16 Feb 2017 19:45:40 +0800 Message-Id: <1487245547-24384-11-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 uses a stack variable to hold the pages in bio, so that we can remove direct access to bvec table in fix_sync_read_error(). This 16*8 stack variable is just fine for kernel thread context. Signed-off-by: Ming Lei --- drivers/md/raid1.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 1dd6b2760fba..02ee8542295d 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1874,6 +1874,16 @@ static int fix_sync_read_error(struct r1bio *r1_bio) int sectors = r1_bio->sectors; int idx = 0; struct md_rdev *rdev; + struct bio_vec *bvl; + int i; + struct page *pages[RESYNC_PAGES]; + + /* + * bio for read_disk is filled up, so we can use + * bio_for_each_segment_all() to retrieve all pages. + */ + bio_for_each_segment_all(bvl, bio, i) + pages[i] = bvl->bv_page; rdev = conf->mirrors[r1_bio->read_disk].rdev; if (test_bit(FailFast, &rdev->flags)) { @@ -1903,7 +1913,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio) */ rdev = conf->mirrors[d].rdev; if (sync_page_io(rdev, sect, s<<9, - bio->bi_io_vec[idx].bv_page, + pages[idx], REQ_OP_READ, 0, false)) { success = 1; break; @@ -1958,7 +1968,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio) continue; rdev = conf->mirrors[d].rdev; if (r1_sync_page_io(rdev, sect, s, - bio->bi_io_vec[idx].bv_page, + pages[idx], WRITE) == 0) { r1_bio->bios[d]->bi_end_io = NULL; rdev_dec_pending(rdev, mddev); @@ -1973,7 +1983,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio) continue; rdev = conf->mirrors[d].rdev; if (r1_sync_page_io(rdev, sect, s, - bio->bi_io_vec[idx].bv_page, + pages[idx], READ) != 0) atomic_add(s, &rdev->corrected_errors); }