From patchwork Fri Feb 24 15:42:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9590619 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 07D6B6020A for ; Fri, 24 Feb 2017 15:49:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0E02286CC for ; Fri, 24 Feb 2017 15:49:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E582F287AF; Fri, 24 Feb 2017 15:49:00 +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 A29DC286CC for ; Fri, 24 Feb 2017 15:49:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751495AbdBXPoK (ORCPT ); Fri, 24 Feb 2017 10:44:10 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33111 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751318AbdBXPnn (ORCPT ); Fri, 24 Feb 2017 10:43:43 -0500 Received: by mail-pg0-f66.google.com with SMTP id 5so3466589pgj.0; Fri, 24 Feb 2017 07:43:43 -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=8ZabSHUrQkn59rJh60HudJhGPH+ITSxZap2JssXnv8g=; b=uYFfEjRC/vvsLOQns4xlmRs21HSz0ENE4apD0YywCDsI/N4tf4kd1KkLgG+8iO8Zrp 078n16na7aUDAY3r8Lzp/ZNGk89OUn/YfLwg0AmzK3ZDhYdQRi0r/2VPmr58k2IH34wj 3ztz2/twstIxhR7S5EyriqYdOOSvPY/b9vfB0Q8q3YInTzY4QFgabUDzhqiFZ7RFzCMr x5YJegOb8mkYeMbZW4dekteHxi6QDQxGznRudSdRFyZsJk3QM9WYcMZdnJXNEV5ofhvj 9XfO4SJ3jllbv4D37XGiWFE6ryRPrJ1G4pFiz+oAvmcL3ueyzJQm9T/e/ZjSVGb/Fh19 Nhhg== 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=8ZabSHUrQkn59rJh60HudJhGPH+ITSxZap2JssXnv8g=; b=JBZE0HUSoOCa3yJ1Nk6SApkb8RuKb1ntYlLpB8fmgfCPwIK/JjoUl31OOb8lwtETCn OD/JPrg0sQ0So3W4S3tCG8qldHUBx4J7xeCbX33MkwfXLqXarFLULncsd5PaACt/lcLB LLEw6ZA5lVxhXk/fxN1fFd8d4ugsHLT6R8wClnLWDw0Ceu2GXaV4DZQ14r3JtkdfSTKC lhT0tgdw+14ZNsa2IBaj+OudgVn0hyWfyR33Jq+vqgFvwt+aF+iKdRG5MVYHzA9hLveQ ImWy60n56tE/cVSvfp6FQRmYbZxFYaQ5gp7BJHHmG+hLJSl70ZYRGU8qHLTNNfNq778c /odw== X-Gm-Message-State: AMke39mipRbNzWvjmUUuLH2SanRXQyqotlMriO8hBZNPiSR/SyfxHjFc2VfZVhUPt+LQVQ== X-Received: by 10.84.224.7 with SMTP id r7mr4704876plj.179.1487951022934; Fri, 24 Feb 2017 07:43:42 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id j62sm15906832pgc.54.2017.02.24.07.43.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 07:43:42 -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 Cc: Ming Lei Subject: [PATCH v1 09/14] md: raid1: use bio helper in process_checks() Date: Fri, 24 Feb 2017 23:42:46 +0800 Message-Id: <1487950971-1131-10-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487950971-1131-1-git-send-email-tom.leiming@gmail.com> References: <1487950971-1131-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 9371caace379..7363bf56f3b4 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