From patchwork Thu Mar 16 16:12:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9628857 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 8D63D60244 for ; Thu, 16 Mar 2017 16:15:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E2C9283F9 for ; Thu, 16 Mar 2017 16:15:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7308F2841E; Thu, 16 Mar 2017 16:15:29 +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 106A0283F9 for ; Thu, 16 Mar 2017 16:15:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755100AbdCPQPZ (ORCPT ); Thu, 16 Mar 2017 12:15:25 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34397 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755117AbdCPQOh (ORCPT ); Thu, 16 Mar 2017 12:14:37 -0400 Received: by mail-pf0-f196.google.com with SMTP id o126so6268394pfb.1; Thu, 16 Mar 2017 09:14:36 -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=d7+BKx/3VTBqHwghOAYB8O7l+ZR3rh6XRH/cS7X2Yqg=; b=Fbvj+Kfc4Kd5vfGW5jyInI5gDpcsRcrNDED0CSbCJ+9ZjSGuyP1WiXEbA3/fkUA3za SmQ3v7OBmARl1TwfEkA6MHv9MNNCtQL/zMcyghNVhCQ1qJ+5dtICqEADmlvA+IacFIz6 L4onnb37oohU5AiUHsoVICftlohAA6LWjFGxBK5NiJJKnfZnFsMlj60UuSGvyMxYAZjg 5FKWfyCoVM6QCUSgrEi7SzCV3tG5R+ptwYOkWF+zxbWMO9e+I2p2IWEqOch2WD451TwA L49GTryZGJpK9+JPCOIbJeWDLPDlLvzObr//etDUk4y9jAybhy+BRGYrKaR1uX0UDhq5 khAw== 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=d7+BKx/3VTBqHwghOAYB8O7l+ZR3rh6XRH/cS7X2Yqg=; b=XnI0Ix2b+aETOxchPqJhTMVE00Vp4CER6h7E5VpbEfglvvdho3cLH1rxLHLLAUirH7 99WqtNnac83zJuAuLn/vmB0Y0N3oLIhDxkAXufiDH0dBu2jEZkTVVPar2dWsWr8oIeV2 DfQKNhiL3U/r6MWoSBhDwn+GbsWMn4Fiv+/svi9SKsjNNdd18a5vXggum07I9PUvSf8g Iz8zN2qh0gtLZ/o0XhXbzi71elr2XE0j3IyL+Fb0ONoh5ZZDigIUiLRX0nazqTuP9VLV AOjjShopOKtHTdsCs8iUMZg8W/4m//ddY1uZd0OT70FnDre0jnqp4jZP7aUgEiCkV6E9 r/Gg== X-Gm-Message-State: AFeK/H0DXEjAdzFX31SSTdoWjj0A+ghdBR8D0f4U9GdcPL7V587H8ShpCe/ja0JP+xKa6w== X-Received: by 10.84.231.207 with SMTP id g15mr13609912pln.2.1489680875810; Thu, 16 Mar 2017 09:14:35 -0700 (PDT) Received: from localhost ([103.192.224.52]) by smtp.gmail.com with ESMTPSA id y67sm11488590pfa.96.2017.03.16.09.14.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Mar 2017 09:14:35 -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 09/14] md: raid1: move 'offset' out of loop Date: Fri, 17 Mar 2017 00:12:30 +0800 Message-Id: <20170316161235.27110-10-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 The 'offset' local variable can't be changed inside the loop, so move it out. Signed-off-by: Ming Lei --- drivers/md/raid1.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 4034a2963da8..2f3622c695ce 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1317,6 +1317,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio) int first_clone; int sectors_handled; int max_sectors; + sector_t offset; /* * Register the new request and wait if the reconstruction @@ -1481,13 +1482,13 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio) atomic_set(&r1_bio->behind_remaining, 0); first_clone = 1; + + offset = r1_bio->sector - bio->bi_iter.bi_sector; for (i = 0; i < disks; i++) { struct bio *mbio = NULL; - sector_t offset; if (!r1_bio->bios[i]) continue; - offset = r1_bio->sector - bio->bi_iter.bi_sector; if (first_clone) { /* do behind I/O ?