diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-10-11 18:44:27 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-24 01:33:47 -0500 |
commit | 4f024f3797c43cb4b73cd2c50cec728842d0e49e (patch) | |
tree | 3aedcab02d2ad723a189d01934d1e94fec7a54e1 /drivers/block/nvme-core.c | |
parent | ed9c47bebeeea4a468b07cfd745c690190f8014c (diff) |
block: Abstract out bvec iterator
Immutable biovecs are going to require an explicit iterator. To
implement immutable bvecs, a later patch is going to add a bi_bvec_done
member to this struct; for now, this patch effectively just renames
things.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "Ed L. Cashin" <ecashin@coraid.com>
Cc: Nick Piggin <npiggin@kernel.dk>
Cc: Lars Ellenberg <drbd-dev@lists.linbit.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Matthew Wilcox <willy@linux.intel.com>
Cc: Geoff Levand <geoff@infradead.org>
Cc: Yehuda Sadeh <yehuda@inktank.com>
Cc: Sage Weil <sage@inktank.com>
Cc: Alex Elder <elder@inktank.com>
Cc: ceph-devel@vger.kernel.org
Cc: Joshua Morris <josh.h.morris@us.ibm.com>
Cc: Philip Kelleher <pjk1939@linux.vnet.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Neil Brown <neilb@suse.de>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: dm-devel@redhat.com
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: Boaz Harrosh <bharrosh@panasas.com>
Cc: Benny Halevy <bhalevy@tonian.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Chris Mason <chris.mason@fusionio.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Dave Kleikamp <shaggy@kernel.org>
Cc: Joern Engel <joern@logfs.org>
Cc: Prasad Joshi <prasadjoshi.linux@gmail.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: KONISHI Ryusuke <konishi.ryusuke@lab.ntt.co.jp>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Ben Myers <bpm@sgi.com>
Cc: xfs@oss.sgi.com
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Guo Chao <yan@linux.vnet.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Asai Thambi S P <asamymuthupa@micron.com>
Cc: Selvan Mani <smani@micron.com>
Cc: Sam Bradshaw <sbradshaw@micron.com>
Cc: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Jiang Liu <jiang.liu@huawei.com>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Jerome Marchand <jmarchand@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Peng Tao <tao.peng@emc.com>
Cc: Andy Adamson <andros@netapp.com>
Cc: fanchaoting <fanchaoting@cn.fujitsu.com>
Cc: Jie Liu <jeff.liu@oracle.com>
Cc: Sunil Mushran <sunil.mushran@gmail.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Namjae Jeon <namjae.jeon@samsung.com>
Cc: Pankaj Kumar <pankaj.km@samsung.com>
Cc: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: Mel Gorman <mgorman@suse.de>6
Diffstat (limited to 'drivers/block/nvme-core.c')
-rw-r--r-- | drivers/block/nvme-core.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 26d03fa0bf26..53d217381873 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c | |||
@@ -468,7 +468,7 @@ static struct nvme_bio_pair *nvme_bio_split(struct bio *bio, int idx, | |||
468 | { | 468 | { |
469 | struct nvme_bio_pair *bp; | 469 | struct nvme_bio_pair *bp; |
470 | 470 | ||
471 | BUG_ON(len > bio->bi_size); | 471 | BUG_ON(len > bio->bi_iter.bi_size); |
472 | BUG_ON(idx > bio->bi_vcnt); | 472 | BUG_ON(idx > bio->bi_vcnt); |
473 | 473 | ||
474 | bp = kmalloc(sizeof(*bp), GFP_ATOMIC); | 474 | bp = kmalloc(sizeof(*bp), GFP_ATOMIC); |
@@ -479,11 +479,11 @@ static struct nvme_bio_pair *nvme_bio_split(struct bio *bio, int idx, | |||
479 | bp->b1 = *bio; | 479 | bp->b1 = *bio; |
480 | bp->b2 = *bio; | 480 | bp->b2 = *bio; |
481 | 481 | ||
482 | bp->b1.bi_size = len; | 482 | bp->b1.bi_iter.bi_size = len; |
483 | bp->b2.bi_size -= len; | 483 | bp->b2.bi_iter.bi_size -= len; |
484 | bp->b1.bi_vcnt = idx; | 484 | bp->b1.bi_vcnt = idx; |
485 | bp->b2.bi_idx = idx; | 485 | bp->b2.bi_iter.bi_idx = idx; |
486 | bp->b2.bi_sector += len >> 9; | 486 | bp->b2.bi_iter.bi_sector += len >> 9; |
487 | 487 | ||
488 | if (offset) { | 488 | if (offset) { |
489 | bp->bv1 = kmalloc(bio->bi_max_vecs * sizeof(struct bio_vec), | 489 | bp->bv1 = kmalloc(bio->bi_max_vecs * sizeof(struct bio_vec), |
@@ -552,11 +552,12 @@ static int nvme_map_bio(struct nvme_queue *nvmeq, struct nvme_iod *iod, | |||
552 | { | 552 | { |
553 | struct bio_vec *bvec, *bvprv = NULL; | 553 | struct bio_vec *bvec, *bvprv = NULL; |
554 | struct scatterlist *sg = NULL; | 554 | struct scatterlist *sg = NULL; |
555 | int i, length = 0, nsegs = 0, split_len = bio->bi_size; | 555 | int i, length = 0, nsegs = 0, split_len = bio->bi_iter.bi_size; |
556 | 556 | ||
557 | if (nvmeq->dev->stripe_size) | 557 | if (nvmeq->dev->stripe_size) |
558 | split_len = nvmeq->dev->stripe_size - | 558 | split_len = nvmeq->dev->stripe_size - |
559 | ((bio->bi_sector << 9) & (nvmeq->dev->stripe_size - 1)); | 559 | ((bio->bi_iter.bi_sector << 9) & |
560 | (nvmeq->dev->stripe_size - 1)); | ||
560 | 561 | ||
561 | sg_init_table(iod->sg, psegs); | 562 | sg_init_table(iod->sg, psegs); |
562 | bio_for_each_segment(bvec, bio, i) { | 563 | bio_for_each_segment(bvec, bio, i) { |
@@ -584,7 +585,7 @@ static int nvme_map_bio(struct nvme_queue *nvmeq, struct nvme_iod *iod, | |||
584 | if (dma_map_sg(nvmeq->q_dmadev, iod->sg, iod->nents, dma_dir) == 0) | 585 | if (dma_map_sg(nvmeq->q_dmadev, iod->sg, iod->nents, dma_dir) == 0) |
585 | return -ENOMEM; | 586 | return -ENOMEM; |
586 | 587 | ||
587 | BUG_ON(length != bio->bi_size); | 588 | BUG_ON(length != bio->bi_iter.bi_size); |
588 | return length; | 589 | return length; |
589 | } | 590 | } |
590 | 591 | ||
@@ -608,8 +609,8 @@ static int nvme_submit_discard(struct nvme_queue *nvmeq, struct nvme_ns *ns, | |||
608 | iod->npages = 0; | 609 | iod->npages = 0; |
609 | 610 | ||
610 | range->cattr = cpu_to_le32(0); | 611 | range->cattr = cpu_to_le32(0); |
611 | range->nlb = cpu_to_le32(bio->bi_size >> ns->lba_shift); | 612 | range->nlb = cpu_to_le32(bio->bi_iter.bi_size >> ns->lba_shift); |
612 | range->slba = cpu_to_le64(nvme_block_nr(ns, bio->bi_sector)); | 613 | range->slba = cpu_to_le64(nvme_block_nr(ns, bio->bi_iter.bi_sector)); |
613 | 614 | ||
614 | memset(cmnd, 0, sizeof(*cmnd)); | 615 | memset(cmnd, 0, sizeof(*cmnd)); |
615 | cmnd->dsm.opcode = nvme_cmd_dsm; | 616 | cmnd->dsm.opcode = nvme_cmd_dsm; |
@@ -674,7 +675,7 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns, | |||
674 | } | 675 | } |
675 | 676 | ||
676 | result = -ENOMEM; | 677 | result = -ENOMEM; |
677 | iod = nvme_alloc_iod(psegs, bio->bi_size, GFP_ATOMIC); | 678 | iod = nvme_alloc_iod(psegs, bio->bi_iter.bi_size, GFP_ATOMIC); |
678 | if (!iod) | 679 | if (!iod) |
679 | goto nomem; | 680 | goto nomem; |
680 | iod->private = bio; | 681 | iod->private = bio; |
@@ -723,7 +724,7 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns, | |||
723 | cmnd->rw.nsid = cpu_to_le32(ns->ns_id); | 724 | cmnd->rw.nsid = cpu_to_le32(ns->ns_id); |
724 | length = nvme_setup_prps(nvmeq->dev, &cmnd->common, iod, length, | 725 | length = nvme_setup_prps(nvmeq->dev, &cmnd->common, iod, length, |
725 | GFP_ATOMIC); | 726 | GFP_ATOMIC); |
726 | cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, bio->bi_sector)); | 727 | cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, bio->bi_iter.bi_sector)); |
727 | cmnd->rw.length = cpu_to_le16((length >> ns->lba_shift) - 1); | 728 | cmnd->rw.length = cpu_to_le16((length >> ns->lba_shift) - 1); |
728 | cmnd->rw.control = cpu_to_le16(control); | 729 | cmnd->rw.control = cpu_to_le16(control); |
729 | cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt); | 730 | cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt); |