From patchwork Thu Mar 16 16:12:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9628859 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 C9F2760244 for ; Thu, 16 Mar 2017 16:15:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBA6A283F9 for ; Thu, 16 Mar 2017 16:15:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B033D2841E; Thu, 16 Mar 2017 16:15:34 +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 570AB283F9 for ; Thu, 16 Mar 2017 16:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755098AbdCPQPb (ORCPT ); Thu, 16 Mar 2017 12:15:31 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36745 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755129AbdCPQOg (ORCPT ); Thu, 16 Mar 2017 12:14:36 -0400 Received: by mail-pf0-f195.google.com with SMTP id r137so2440540pfr.3; Thu, 16 Mar 2017 09:14:30 -0700 (PDT) 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=FEIm2nDlFTnVhzopvcNuPOEr55/Z7boRLByNVexVpEo=; b=mPhCgJ8lHjO4S62exMeD4Nq4dxOZkpdApyZ0m99TBR4iICzCIShYFuZvqi+L2rayeH QwTRCANr7Xzn/1/ywxnWakcEtagUV8KCRss67wzCnvV+Tg+qkmgmwkJZHzYTwRj0UFPf 3ehxx3/VDYQYwQwRDu60JDm2mA5cu04pJwOzLwSoCUtM+fRRuikAOwHT98HUXnouQuQ0 95Gu6uIL2GvofcH2BoZE3hXypf/sAPdhTCWvkX6bpsv5PxBLyYf5gOoPRNvUOlIP1w8x ELfVKf6AYWVKMl7gfijZDyC9+z/4PpkYlTOexNGDJ1Txsd/iUy2CT4b4lBaweSyfx13n kyuw== 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=FEIm2nDlFTnVhzopvcNuPOEr55/Z7boRLByNVexVpEo=; b=h5yqhs7FLB5Lq3ETo0IQW9IqxMm5YCWp05ZiyB2zec1/TyV3PqAFcAkKWf5f1/cAM3 jUhDKbBoBNa6OVD+bdIQ1GwKNWbE6cfZswKj4NmmcIhHUqgrA5AbS8ia4LjRDKlGbux4 /5KJCQjObR2umolEcxyRcwbAQwVG9WXaLMQFCRFnwU2S+BckH6Whw+YFs0dIRoMEkgrj fh893p02j94yEshHkOAbMBL080o1xE7GycZn2S9QVAfoblVrM++MqUZTREasTOA2rLiq O6qKx85XEtdXPR5fIthTKvL7W2ZTD89B5JjeFKp8UwZSQrGzWSFq+ZAiZBiTMc6i/tz8 aNAw== X-Gm-Message-State: AFeK/H2Kg8xM6SPifrBLgu4qFe9a+NXfLEdNJ2XfH8Sf1AAc3k5z3Q3EfFsCBppmVsf1Yg== X-Received: by 10.99.163.72 with SMTP id v8mr407689pgn.115.1489680870105; Thu, 16 Mar 2017 09:14:30 -0700 (PDT) Received: from localhost ([103.192.224.52]) by smtp.gmail.com with ESMTPSA id s21sm11578414pgg.65.2017.03.16.09.14.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Mar 2017 09:14:29 -0700 (PDT) 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 v3 07/14] md: raid1: use bio helper in process_checks() Date: Fri, 17 Mar 2017 00:12:28 +0800 Message-Id: <20170316161235.27110-8-tom.leiming@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170316161235.27110-1-tom.leiming@gmail.com> References: <20170316161235.27110-1-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 b1345aa4efd8..4034a2963da8 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2130,6 +2130,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) @@ -2148,9 +2149,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; @@ -2174,17 +2173,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