From patchwork Mon Oct 15 20:08:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1595731 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 B68443FD86 for ; Mon, 15 Oct 2012 20:13:59 +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 q9FKAw4w010196; Mon, 15 Oct 2012 16:10:58 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FK9whZ026907 for ; Mon, 15 Oct 2012 16:09:58 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9FK9rx9026534 for ; Mon, 15 Oct 2012 16:09:53 -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 q9FK9l1J021824 for ; Mon, 15 Oct 2012 16:09:51 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so5284665pbb.33 for ; Mon, 15 Oct 2012 13:09:51 -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=0/JT0vfmaFcVF8Vj/qvH8pAUOmGl9byV9nxgr5cxB8c=; b=Ng5QzJ3DNX0vKwn2+s01KRNLusXkzn5qe5YyxpB06aa2f9f8mGN24AEL/58L7jRLU7 D/MuArklafUFkLSnvQ20YjlxIZxRc+WQ346iyB+5b1yHhV8Vyuom8yQAtOixWuaMIgd4 SEU3lBabIeDRqKvRyVfIWXn7rgY9BfYnEwyZzJ0I0inT+ymdVJ8oC1hKfAedxqSVQdj7 /7KMQvvFp0rTkmDZdvSG94wb7gAitkk/RJSP5Wh/gLOmctrQ2qNJp06sQLerLbpYrGPa Kha/kAovIZQNDf1PqNt/UpVMwuiLcolA8xLehr3OxyWYY7vc3/OiI9nLQcwvQLj2dKXi Ixqw== 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=0/JT0vfmaFcVF8Vj/qvH8pAUOmGl9byV9nxgr5cxB8c=; b=pncuSShcsDpSZWyHYeKP8G440VNCEiwyCDkXh9LHhqj0WGOiimWkIy9shvM97Wks4F kN3qk32/KcCyI056bHgYUc2oUcvt14yoV6McaB6pxyd9CB5309KcefU87jK0iedXG4nl CpcR+Lh4ye90r1AFm8jAqf8Autqm9CeRx+BQ+d/jroHsz27VOc8a2dT5HlgAkT8T+IGG 6ESc2f1JCCTqXt1smsJmvkIW13KszlwmLe92vk0zwzlRo+atjWo40AbRiaq9Uqvm3FSM edAbnYOUamnyl39mjj7vAx5ZBtpQ3/Pw+H2YQDMxi0MF8UeOGXuCpECzuv4phEIBOV9Y 2LSg== Received: by 10.68.130.71 with SMTP id oc7mr40932609pbb.116.1350331791255; Mon, 15 Oct 2012 13:09:51 -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.09.50 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 13:09:50 -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:40 -0700 Message-Id: <1350331769-14856-7-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: ALoCoQlQ2wtMki/uYP2CG6rUVlnT4b57Q2zrVA4CYaqa8ZWnZvpEtlx2riAlqL9wFp4KCnUJCse+YFPVGDljRL5CtOmygQUxlS9EMu0Xgcl76/Fpps4fM0ts6VEpqfkuYU6HkdfNi+u2HUZ6UR++wkzA4CixFkMbPjPcyzeux2AqPA1vACNL6aaq9+hYWEKkSzHJj64/fIfD 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.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Cc: axboe@kernel.dk, "Martin K. Petersen" , Kent Overstreet , tj@kernel.org, vgoyal@redhat.com, Lars Ellenberg Subject: [dm-devel] [PATCH v4 06/24] block: Change bio_split() to respect the current value of 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 In the current code bio_split() won't be seeing partially completed bios so this doesn't change any behaviour, but this makes the code a bit clearer as to what bio_split() actually requires. The immediate purpose of the patch is removing unnecessary bi_idx references, but the end goal is to allow partial completed bios to be submitted, which along with immutable biovecs enables effecient bio splitting. Some of the callers were (double) checking that bios could be split, so update their checks too. Signed-off-by: Kent Overstreet CC: Jens Axboe CC: Lars Ellenberg CC: Neil Brown CC: Martin K. Petersen --- drivers/block/drbd/drbd_req.c | 6 +++--- drivers/md/raid0.c | 3 +-- drivers/md/raid10.c | 3 +-- fs/bio-integrity.c | 4 ++-- fs/bio.c | 7 +++---- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index 47f55db..382ada7 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -1155,11 +1155,11 @@ void drbd_make_request(struct request_queue *q, struct bio *bio) /* can this bio be split generically? * Maybe add our own split-arbitrary-bios function. */ - if (bio->bi_vcnt != 1 || bio->bi_idx != 0 || bio->bi_size > DRBD_MAX_BIO_SIZE) { + if (bio_segments(bio) != 1 || bio->bi_size > DRBD_MAX_BIO_SIZE) { /* rather error out here than BUG in bio_split */ dev_err(DEV, "bio would need to, but cannot, be split: " - "(vcnt=%u,idx=%u,size=%u,sector=%llu)\n", - bio->bi_vcnt, bio->bi_idx, bio->bi_size, + "(segments=%u,size=%u,sector=%llu)\n", + bio_segments(bio), bio->bi_size, (unsigned long long)bio->bi_sector); bio_endio(bio, -EINVAL); } else { diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 89016cb..769b3cb 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -510,8 +510,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio) sector_t sector = bio->bi_sector; struct bio_pair *bp; /* Sanity check -- queue functions should prevent this happening */ - if (bio->bi_vcnt != 1 || - bio->bi_idx != 0) + if (bio_segments(bio) != 1) goto bad_map; /* This is a one page bio that upper layers * refuse to split for us, so we need to split it. diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 9715aaf..bbd08f5 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1081,8 +1081,7 @@ static void make_request(struct mddev *mddev, struct bio * bio) || conf->prev.near_copies < conf->prev.raid_disks))) { struct bio_pair *bp; /* Sanity check -- queue functions should prevent this happening */ - if (bio->bi_vcnt != 1 || - bio->bi_idx != 0) + if (bio_segments(bio) != 1) goto bad_map; /* This is a one page bio that upper layers * refuse to split for us, so we need to split it. diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c index 8c4c604..ca7b02d 100644 --- a/fs/bio-integrity.c +++ b/fs/bio-integrity.c @@ -661,8 +661,8 @@ void bio_integrity_split(struct bio *bio, struct bio_pair *bp, int sectors) bp->bio1.bi_integrity = &bp->bip1; bp->bio2.bi_integrity = &bp->bip2; - bp->iv1 = bip->bip_vec[0]; - bp->iv2 = bip->bip_vec[0]; + bp->iv1 = bip->bip_vec[bip->bip_idx]; + bp->iv2 = bip->bip_vec[bip->bip_idx]; bp->bip1.bip_vec = &bp->iv1; bp->bip2.bip_vec = &bp->iv2; diff --git a/fs/bio.c b/fs/bio.c index dc3452e..4ae3382 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -1616,8 +1616,7 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors) trace_block_split(bdev_get_queue(bi->bi_bdev), bi, bi->bi_sector + first_sectors); - BUG_ON(bi->bi_vcnt != 1 && bi->bi_vcnt != 0); - BUG_ON(bi->bi_idx != 0); + BUG_ON(bio_segments(bi) > 1); atomic_set(&bp->cnt, 3); bp->error = 0; bp->bio1 = *bi; @@ -1627,8 +1626,8 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors) bp->bio1.bi_size = first_sectors << 9; if (bi->bi_vcnt != 0) { - bp->bv1 = bi->bi_io_vec[0]; - bp->bv2 = bi->bi_io_vec[0]; + bp->bv1 = *bio_iovec(bi); + bp->bv2 = *bio_iovec(bi); if (bio_is_rw(bi)) { bp->bv2.bv_offset += first_sectors << 9;