From patchwork Mon Oct 15 20:09:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1596171 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 E8AB3DFB34 for ; Mon, 15 Oct 2012 20:16:26 +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 q9FKBNs7006923; Mon, 15 Oct 2012 16:11:23 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FKAj4b027208 for ; Mon, 15 Oct 2012 16:10:45 -0400 Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9FKAeKc004906 for ; Mon, 15 Oct 2012 16:10:40 -0400 Received: from mail-da0-f46.google.com (mail-da0-f46.google.com [209.85.210.46]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9FK9m2s007506 for ; Mon, 15 Oct 2012 16:10:37 -0400 Received: by mail-da0-f46.google.com with SMTP id n41so2761040dak.33 for ; Mon, 15 Oct 2012 13:10:37 -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=ztI1UPfgxy4PWvVIbaR2bSqSIZrnZZEdOYg6Mx2HlFY=; b=POY9iS8vqBcj6niv7UwSK5hZTPM0vjn6ur5BOx3kyfIlzEwK5YHQ38bw8poTnhxprp RW9/WVr4s8Uuzl1cOpqHg38yU85710s72DUmng8msgK+T82JB0Bl8z6wBDHp36bvDyf1 ovmxZTtV+mDRU8oZWc/Uf0L7dYHAYo0lUg8HEyGEuzBgs3/MC8kV343m+OPGVrviUtJb 5y6N40ctZ8tbUwDON1U6YudBNnphBPtPrTssQzj8UCiad1NchiNjVYdwpbLJ5R8lTG2z n+qjXqFuSA6ljYxgvIZ4+6XJTHr+50hZjCKSkecG2dd29GapiBGvhCT0XK7NwscfEuR7 LDNA== 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=ztI1UPfgxy4PWvVIbaR2bSqSIZrnZZEdOYg6Mx2HlFY=; b=g9WYk8C3bayWgx0zWLAOAXtTyMaCmMvfgnEJ2uWGZGw2LgkWhMbv07w7+itl8FD8iQ bqMr/DD6qnTXMh2SFc9QgzEYbwgYU4LT6gbdAtIUla+IWJig7eJozw0mU2IlOgr51wSX KA4Q4FO3miBZYXXp6o6vPvIT+/qMwkS37nPBjTiUwZVuj94ddW1aJ2OjBYDD3A2FNK4t 9ElCtjZ8I7DhL/VQtfCqQw9a2f7znd1ZToyVWiiBln8lXHgQ1pwLzS+hQ+Lpoh84q0Bz RhJe/1KXN+evRf+iU06WELB2VEmE2E3Xdkh4QUjAMwutv1LhvZlIwJ1AAWI1rb35XA/x Rv0w== Received: by 10.68.234.71 with SMTP id uc7mr40211896pbc.72.1350331837668; Mon, 15 Oct 2012 13:10:37 -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.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 13:10:37 -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:10 -0700 Message-Id: <1350331769-14856-37-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: ALoCoQkyao3nOfvl5SkKCbd10y35S4Irys4+bdifnlY7i5Wrz5duaWW1XLDKjR+9gIh5S6c1+cJFQd/uFISwVdmQz2kFPjv0MKo9mdLi4uGPviYksA0LxE/AU0KnDxl4j3gDU2HoFSx+dVhPX7eBdsDY/lIgA7P5kPkz2IJRXl0NgfxRObcuSxr/auvhXBvU7QzqFKGeGSrI 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.22 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 Subject: [dm-devel] [PATCH v2 07/26] block: Don't use bi_idx in bio_split() or require it to be 0 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 Prep work for immutable bio_vecs/efficient bio splitting: they require auditing and removing most uses of bi_idx. So here we convert bio_split() to respect the current value of bi_idx and use the bio_iovec() macro, instead of assuming bi_idx will be 0. Signed-off-by: Kent Overstreet CC: Jens Axboe --- 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 af69a96..57eb253 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 387cb89..0587450 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -509,8 +509,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 1d64f7f..e8555a5 100644 --- a/fs/bio-integrity.c +++ b/fs/bio-integrity.c @@ -657,8 +657,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 07587c0..addeac2 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); - BUG_ON(bi->bi_idx != 0); + BUG_ON(bio_segments(bi) != 1); atomic_set(&bp->cnt, 3); bp->error = 0; bp->bio1 = *bi; @@ -1626,8 +1625,8 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors) bp->bio2.bi_size -= first_sectors << 9; bp->bio1.bi_size = first_sectors << 9; - bp->bv1 = bi->bi_io_vec[0]; - bp->bv2 = bi->bi_io_vec[0]; + bp->bv1 = *bio_iovec(bi); + bp->bv2 = *bio_iovec(bi); bp->bv2.bv_offset += first_sectors << 9; bp->bv2.bv_len -= first_sectors << 9; bp->bv1.bv_len = first_sectors << 9;