From patchwork Mon Oct 15 20:09:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1596091 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork1.kernel.org (Postfix) with ESMTP id CBB953FD86 for ; Mon, 15 Oct 2012 20:15:32 +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 q9FKBanP010526; Mon, 15 Oct 2012 16:11:36 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FKArSD027270 for ; Mon, 15 Oct 2012 16:10:53 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9FKAmfp024041 for ; Mon, 15 Oct 2012 16:10: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 q9FKAQZC021993 for ; Mon, 15 Oct 2012 16:10:47 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so5285168pbb.33 for ; Mon, 15 Oct 2012 13:10: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=6Nx5wEUa+WEyoc8DaSU3w9pn96T8Kf5tBPD8q4Ep3b4=; b=Q1EgMZNJQ6f+e3hBu1RYNBhJeGiP/2/JALE1sFfrmQALswNx8ZxzMUPAOnasqLgWL0 Du6MxOR/rcrfo+Mmm4CBNUKz+0QEXIqT+xS/6j/g5wXGVzzOq9eZ2hybt3aBi7aum2Qg DstChEY4m35vuQWTbEWdQBm7PojgExO1UsjmMpoj4jCiHwZ4Ush0UYgUtWsh3BblRLIZ sLdbspd2oXw4c3hMfnI76JDr91Kp9ItqRb2SrRY/NFOeX6sE2ZYw4RYl9XXBK9/LD8pV w9o5fWESde9JiZZqBYlkKX6f/l4PTIflsUMMFdKYAgRG3zPX0EyseP/hmeCYPt8bbqmn IbNQ== 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=6Nx5wEUa+WEyoc8DaSU3w9pn96T8Kf5tBPD8q4Ep3b4=; b=TYtzu2CasKn/wMcDqvpiW+em9uy8VZCQ15ZVo7pUlKtRruxVjfY5wbCO2UACfaU5pb dwRxzmd+HKWgn2GIa7eMaOMHYhjKn1kdfkNl/IyjL65i49NVkLpG6MIWAfef276RO4dK WoYHjQwTnxzWmTiR+U91DAslY8XSzkvKZj4iw3cSwoAa0EbFn0O21qJ2bhysv6ZWiI3K XYI1ftrA+mPYvA8+iqG3iVtQ2rNQeV2ixd6tlw9ZWpUpLURAqX+RV4jiNFVPwwGvofnV O+h/IDpwYigDU6iLtT+R5S9k45+Ao7D57+e4qoZhgwto5Um5+D17PbH0WFTxffV07uM5 zMoA== Received: by 10.68.189.5 with SMTP id ge5mr40529485pbc.1.1350331847139; Mon, 15 Oct 2012 13:10: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 k9sm3021703paz.22.2012.10.15.13.10.45 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 13:10:46 -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:09:17 -0700 Message-Id: <1350331769-14856-44-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: ALoCoQmPm7zzvtLpmoikRTHoEII3xiYmNGP3fx7QlOKApYD+SaFlnE69FlVnUPl25A2nmphzu3bAq0I2D1t/Q/nR7UE8rP4UslBLhw8YI3g1Zuf8raWQRsxG06DrXcZzXaMKJlPnHqF+Mqo8bN8Jm7KaARl0PakfG8KmFlZ6Hupo48o+pGk2Pnge7ueb2RMNfn78DP4vYbme 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.24 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 Subject: [dm-devel] [PATCH v2 14/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 bd3e3b9..b1072da 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;