From patchwork Mon Sep 24 22:34:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1500781 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork2.kernel.org (Postfix) with ESMTP id A297DDF280 for ; Mon, 24 Sep 2012 22:39:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8OMbCWg030593; Mon, 24 Sep 2012 18:37:12 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8OMZruD009234 for ; Mon, 24 Sep 2012 18:35:53 -0400 Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8OMZmQn028472 for ; Mon, 24 Sep 2012 18:35:48 -0400 Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8OMZdAX027130 for ; Mon, 24 Sep 2012 18:35:48 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so7786879pbb.33 for ; Mon, 24 Sep 2012 15:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=TAYRxGCtgO0STk+QKK7sIfUALdx+r48amSdoAMDgW6A=; b=ozQyIn/jB3Z6/7fEQRHoupuVvaGzGE0nCggcHuRmvGGVz97+FmXM3jyhC34hxCZ0nR xob1cDIWPTAr0eTm/2O01uLWHkta6xL98hslzbUHjzFm2xt4MTXkaW04tj3Dt7/2faBm TlDtL+ADOx9HLCIXlVZdaeu0cu71Ebh2tuL6GH/OqcNJ7y2ThK/63LuEz2vQYwWQRmSr DRrkLGb4bwXRkU5l3ATMtjwkROcRk5M8xL4ycXE1gwd0a85fX0ekQiM1Anb4JrDCikb0 gDqKsdeExCrNEgX88l3vG0PB6dBIgt8bKbYp+D37+TrzEble0SQHh+noWqucpYiIa+XC P+rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=TAYRxGCtgO0STk+QKK7sIfUALdx+r48amSdoAMDgW6A=; b=jfZ3zPRoHr/fjRyFHSbB46K3X7ODhtH8oGIcf/FBWSHV8q2q9HQcym3Npdj7+AhoGM 1SbS6hanxZOFrvLtimDOLAmGzbAmJhZhZ9WVyCBsH7goMaIjYxOgXSL83mnZ/YBJZf5B Jtu0dK7plS/w++uFsL4Epc6+SqFFAQvMIOuSpuo3Oc3hXeMk9GpfOwZHA8g9RZYtHOok JtBJc3tO3yXFjaRM2Pb96ZdlL2jKUWK1AKJUrlpM1CVJrrTaRgpzKSzZNVyuoAHCfuq/ lZgbv3XXLkLfuoTUuU0AKQSMGJMsgm9avsfzB4cz2FTL+kxcqrBGF0o17bw8Vve+ra4x 0kjw== Received: by 10.66.77.7 with SMTP id o7mr35946825paw.37.1348526147951; Mon, 24 Sep 2012 15:35:47 -0700 (PDT) Received: by 10.66.77.7 with SMTP id o7mr35946783paw.37.1348526147688; Mon, 24 Sep 2012 15:35:47 -0700 (PDT) Received: from formenos.mtv.corp.google.com (formenos.mtv.corp.google.com [172.18.110.66]) by mx.google.com with ESMTPS id nu8sm133316pbc.45.2012.09.24.15.35.46 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 15:35:47 -0700 (PDT) From: Kent Overstreet To: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com Date: Mon, 24 Sep 2012 15:34:55 -0700 Message-Id: <1348526106-17074-16-git-send-email-koverstreet@google.com> In-Reply-To: <1348526106-17074-1-git-send-email-koverstreet@google.com> References: <1348526106-17074-1-git-send-email-koverstreet@google.com> X-Gm-Message-State: ALoCoQm+l0V2b9M4Q9iCNpFYDsMvK4EcVe1CwMUHzHWKf+g9DoSl6HdOrCrqI0TJFipfWvA2yB7Sh6ncDe97dul4PPGSigFiJtniW06uiygZZiXDRRhFCEudjQnTvKzbR6E2inKKwwFvi0cFcGbz5oyl0pX3yKVAzsi9ny4BV/XIlyyFlO1FS7UEp4K7U1mBupN2M8Otanfh X-RedHat-Spam-Score: -3.512 (BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.18 X-loop: dm-devel@redhat.com Cc: tj@kernel.org, axboe@kernel.dk, Kent Overstreet , vgoyal@redhat.com Subject: [dm-devel] [PATCH v3 15/26] raid1: Refactor narrow_write_error() to not use bi_idx X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com More bi_idx removal. This code was just open coding bio_clone(). This could probably be further improved by using bio_advance() instead of skipping over null pages, but that'd be a larger rework. Signed-off-by: Kent Overstreet CC: Jens Axboe CC: NeilBrown --- drivers/md/raid1.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 4614b9e..af39f74 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2052,8 +2052,6 @@ static int narrow_write_error(struct r1bio *r1_bio, int i) struct mddev *mddev = r1_bio->mddev; struct r1conf *conf = mddev->private; struct md_rdev *rdev = conf->mirrors[i].rdev; - int vcnt, idx; - struct bio_vec *vec; /* bio has the data to be written to device 'i' where * we just recently had a write error. @@ -2081,30 +2079,32 @@ static int narrow_write_error(struct r1bio *r1_bio, int i) & ~(sector_t)(block_sectors - 1)) - sector; - if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { - vcnt = r1_bio->behind_page_count; - vec = r1_bio->behind_bvecs; - idx = 0; - while (vec[idx].bv_page == NULL) - idx++; - } else { - vcnt = r1_bio->master_bio->bi_vcnt; - vec = r1_bio->master_bio->bi_io_vec; - idx = r1_bio->master_bio->bi_idx; - } while (sect_to_write) { struct bio *wbio; if (sectors > sect_to_write) sectors = sect_to_write; /* Write at 'sector' for 'sectors'*/ - wbio = bio_alloc_mddev(GFP_NOIO, vcnt, mddev); - memcpy(wbio->bi_io_vec, vec, vcnt * sizeof(struct bio_vec)); - wbio->bi_sector = r1_bio->sector; + if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { + unsigned vcnt = r1_bio->behind_page_count; + struct bio_vec *vec = r1_bio->behind_bvecs; + + while (!vec->bv_page) { + vec++; + vcnt--; + } + + wbio = bio_alloc_mddev(GFP_NOIO, vcnt, mddev); + memcpy(wbio->bi_io_vec, vec, vcnt * sizeof(struct bio_vec)); + + wbio->bi_vcnt = vcnt; + } else { + wbio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev); + } + wbio->bi_rw = WRITE; - wbio->bi_vcnt = vcnt; + wbio->bi_sector = r1_bio->sector; wbio->bi_size = r1_bio->sectors << 9; - wbio->bi_idx = idx; md_trim_bio(wbio, sector - r1_bio->sector, sectors); wbio->bi_sector += rdev->data_offset;