From patchwork Mon Oct 15 20:08:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1596351 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork2.kernel.org (Postfix) with ESMTP id 2CFEDDFB34 for ; Mon, 15 Oct 2012 20:19:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FKHN12007739; Mon, 15 Oct 2012 16:17:23 -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 q9FKHN3C028034 for ; Mon, 15 Oct 2012 16:17:23 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9FKHH10005336 for ; Mon, 15 Oct 2012 16:17:17 -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 q9FKHGrD024015 for ; Mon, 15 Oct 2012 16:17:16 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so5290710pbb.33 for ; Mon, 15 Oct 2012 13:17:16 -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=gjR7/RJ05a+01Q6FErN3AikLssxgMdwCsRm2kzOLSd383e18Oc9c5KkuDxNLws4h1X syi6S3/W1ylMXuK4LxPU+IvyhAFuHgUZSYR7pcseVZL0DAoFi7l5xiik3lBMoCkiawH9 9Ud/MHtmBWU1iWe5mkQzjT8MWCBT2OdmEPP5OU/GWJQ5nSHMm+1uXIzFDc0PQTrCSR1P cDPBJjC1VwaAQRukMmSpQquvrwc1+l5gY3r8WoajJlBhtljI+KqHVOgXLriKnloew81Q /sEp9Uu5xuJTUbB6p+rvQ9YY6ujfZYHsMbTV7dU/pfsiVueNS6ktLDkf9UAOCefi9rgc ujGw== 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=Sz4cvTALvuHXODx/PJuYCJBYJksO0A+mkrescyCacIGdu/9AcKb9HnZkSoD8IfwiKD WSX0LO/TSv+m1kFU8VjvLl32C1vzZT5ujNro4e69jGeCltPW/EjA+HusVioSU9dFQjnG u9Up+fX+nXmAsPc7oE8Ll9F3BvZBFFnbN7lLaexjFwQOJNCERWC8vlUiW2jJqZKaKxkP 63Al29d3Gej0VXRo7Kpz+CLYqPhNbJquzW5de4rk7h2inIU8l8DhxXbUTNsomEfCSQYD 1aTtsDLh6caGTR+qPsGjrRKWbj5BB8aFWEJTHH0KFnSMj0eHlNVZNOsdZiczW/Mo3rJK GRAg== Received: by 10.66.86.42 with SMTP id m10mr36101816paz.3.1350331803872; Mon, 15 Oct 2012 13:10:03 -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 k9sm3021703paz.22.2012.10.15.13.10.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 13:10:03 -0700 (PDT) From: Kent Overstreet To: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com Date: Mon, 15 Oct 2012 13:08:47 -0700 Message-Id: <1350331769-14856-14-git-send-email-koverstreet@google.com> In-Reply-To: <1350331769-14856-1-git-send-email-koverstreet@google.com> References: <1350331769-14856-1-git-send-email-koverstreet@google.com> X-Gm-Message-State: ALoCoQn7gN73dfIquKkw/z4/l6MGkh3lThdBFPqBrVQZeZK5lnJDTqkulknlRoJ0jmv2TBlln32ic+tfcSfhpvOTmXhymE3nFhgrFIjoyP3Ysgo0fs1sw8+89rVtvz78BIIiBXTbWxWn8/i3fCLPN4Q4pYGgjp1xO6vr4XRZS8Il3LrgiCvJTvyTk2sYVTPwZ2dASHMHqbWP X-RedHat-Spam-Score: -3.072 (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.20 X-loop: dm-devel@redhat.com Cc: tj@kernel.org, axboe@kernel.dk, Kent Overstreet , vgoyal@redhat.com Subject: [dm-devel] [PATCH v4 13/24] 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;