From patchwork Tue Feb 28 15:41:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9596053 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 C8FC3601D7 for ; Tue, 28 Feb 2017 15:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B62912853D for ; Tue, 28 Feb 2017 15:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5F8A2853F; Tue, 28 Feb 2017 15:42: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=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 4B55D28538 for ; Tue, 28 Feb 2017 15:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752466AbdB1Pmh (ORCPT ); Tue, 28 Feb 2017 10:42:37 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36524 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752366AbdB1Pme (ORCPT ); Tue, 28 Feb 2017 10:42:34 -0500 Received: by mail-pg0-f67.google.com with SMTP id 25so1984789pgy.3; Tue, 28 Feb 2017 07:42:33 -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=nXdo4djnmzO/mEsKYkTub/WjqPP1EVskbYVN+c6WsQ0=; b=gb1gHvrBvnUNJnAhDhbwJiQWPFqb87xcVl40oDKlXpHD7YB6OjvPxk40bdzPzH/5BJ W638tkfsQY6g5CA2O3ZRHwTEzb6E3dZPvots77HNlc8y8s+Cp8f75XqeGWF4bxdOM6e8 LqzQvbRorr2w/wUubSzsEkaha+3R/zTnfDBRQ6GPlTBrnVQfS83rKSAwUoboYFy1uDze n2p0mKuUahYOUNHOo8AhwHAghv4/jHcc1gBe96mHJ2N7rvwod0BgXDdmjfKrpFmNewl2 5reh4IpJTw37f2/gnekquFNJCLwF12YAM6fnvtbzHQq+4zHELUJAsiZ8BD70KmbiPTj4 pZ7Q== 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=nXdo4djnmzO/mEsKYkTub/WjqPP1EVskbYVN+c6WsQ0=; b=KaYgxmRQGP35PN1l7KX3xvc0p0iE8uv4xyzJP31R07fCFRgy91ESjXcjWrEZu1tuAr GEawXmVTKX/NfFWo6Xibg/A86YN7odsSkmtPj5/CnMpLX9X2aFIaEmf+gjotlWoJGZsa Q632MbzzlOzjumJOMlHOQfH5scNnOP5FnpJYcpVDzKPhN5izLfxiOlGown/frqZo/NSq Noh76TRmr7Z9uHrOLHXNk6fKrOLqLE5O4/Y+kc6Z7nBlUci89IqXA2Vn2iD2o8Psz+ds RTTvUgpq9xaCyTNaeEKn6igHbbkHWuxYQVb5wACUcvP17R2Dj6a+lheg8KnN/y6uMB2k i37A== X-Gm-Message-State: AMke39leFcMmyjte8wFiryLiTbCmRGhlbaZlaHO9qEbGF/SBF2M9QCwEmXXkfeB9CEE/Qw== X-Received: by 10.84.238.195 with SMTP id l3mr3877385pln.180.1488296553444; Tue, 28 Feb 2017 07:42:33 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id f62sm5075749pfg.48.2017.02.28.07.42.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Feb 2017 07:42:32 -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 08/13] md: raid1: use bio helper in process_checks() Date: Tue, 28 Feb 2017 23:41:38 +0800 Message-Id: <1488296503-4987-9-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 Avoid to direct access to bvec table. Signed-off-by: Ming Lei --- drivers/md/raid1.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index d0cb5c026506..316bd6dd6cc1 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2108,6 +2108,7 @@ 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]; struct resync_pages *rp = get_resync_pages(b); if (b->bi_end_io != end_sync_read) @@ -2126,9 +2127,7 @@ static void process_checks(struct r1bio *r1_bio) b->bi_private = rp; size = b->bi_iter.bi_size; - for (j = 0; j < vcnt ; j++) { - struct bio_vec *bi; - bi = &b->bi_io_vec[j]; + bio_for_each_segment_all(bi, b, j) { bi->bv_offset = 0; if (size > PAGE_SIZE) bi->bv_len = PAGE_SIZE; @@ -2152,17 +2151,22 @@ static void process_checks(struct r1bio *r1_bio) int error = sbio->bi_error; struct page **ppages = get_resync_pages(pbio)->pages; struct page **spages = get_resync_pages(sbio)->pages; + struct bio_vec *bi; + int page_len[RESYNC_PAGES]; if (sbio->bi_end_io != end_sync_read) continue; /* Now we can 'fixup' the error value */ sbio->bi_error = 0; + bio_for_each_segment_all(bi, sbio, j) + page_len[j] = bi->bv_len; + if (!error) { for (j = vcnt; j-- ; ) { if (memcmp(page_address(ppages[j]), page_address(spages[j]), - sbio->bi_io_vec[j].bv_len)) + page_len[j])) break; } } else