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/md/bcache/request.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/md/bcache/request.c')
-rw-r--r-- | drivers/md/bcache/request.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 78bab4154e97..47a9bbc75124 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c | |||
@@ -261,7 +261,7 @@ static void bch_data_invalidate(struct closure *cl) | |||
261 | struct bio *bio = op->bio; | 261 | struct bio *bio = op->bio; |
262 | 262 | ||
263 | pr_debug("invalidating %i sectors from %llu", | 263 | pr_debug("invalidating %i sectors from %llu", |
264 | bio_sectors(bio), (uint64_t) bio->bi_sector); | 264 | bio_sectors(bio), (uint64_t) bio->bi_iter.bi_sector); |
265 | 265 | ||
266 | while (bio_sectors(bio)) { | 266 | while (bio_sectors(bio)) { |
267 | unsigned sectors = min(bio_sectors(bio), | 267 | unsigned sectors = min(bio_sectors(bio), |
@@ -270,11 +270,11 @@ static void bch_data_invalidate(struct closure *cl) | |||
270 | if (bch_keylist_realloc(&op->insert_keys, 0, op->c)) | 270 | if (bch_keylist_realloc(&op->insert_keys, 0, op->c)) |
271 | goto out; | 271 | goto out; |
272 | 272 | ||
273 | bio->bi_sector += sectors; | 273 | bio->bi_iter.bi_sector += sectors; |
274 | bio->bi_size -= sectors << 9; | 274 | bio->bi_iter.bi_size -= sectors << 9; |
275 | 275 | ||
276 | bch_keylist_add(&op->insert_keys, | 276 | bch_keylist_add(&op->insert_keys, |
277 | &KEY(op->inode, bio->bi_sector, sectors)); | 277 | &KEY(op->inode, bio->bi_iter.bi_sector, sectors)); |
278 | } | 278 | } |
279 | 279 | ||
280 | op->insert_data_done = true; | 280 | op->insert_data_done = true; |
@@ -364,7 +364,7 @@ static void bch_data_insert_start(struct closure *cl) | |||
364 | k = op->insert_keys.top; | 364 | k = op->insert_keys.top; |
365 | bkey_init(k); | 365 | bkey_init(k); |
366 | SET_KEY_INODE(k, op->inode); | 366 | SET_KEY_INODE(k, op->inode); |
367 | SET_KEY_OFFSET(k, bio->bi_sector); | 367 | SET_KEY_OFFSET(k, bio->bi_iter.bi_sector); |
368 | 368 | ||
369 | if (!bch_alloc_sectors(op->c, k, bio_sectors(bio), | 369 | if (!bch_alloc_sectors(op->c, k, bio_sectors(bio), |
370 | op->write_point, op->write_prio, | 370 | op->write_point, op->write_prio, |
@@ -522,7 +522,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) | |||
522 | (bio->bi_rw & REQ_WRITE))) | 522 | (bio->bi_rw & REQ_WRITE))) |
523 | goto skip; | 523 | goto skip; |
524 | 524 | ||
525 | if (bio->bi_sector & (c->sb.block_size - 1) || | 525 | if (bio->bi_iter.bi_sector & (c->sb.block_size - 1) || |
526 | bio_sectors(bio) & (c->sb.block_size - 1)) { | 526 | bio_sectors(bio) & (c->sb.block_size - 1)) { |
527 | pr_debug("skipping unaligned io"); | 527 | pr_debug("skipping unaligned io"); |
528 | goto skip; | 528 | goto skip; |
@@ -546,8 +546,8 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) | |||
546 | 546 | ||
547 | spin_lock(&dc->io_lock); | 547 | spin_lock(&dc->io_lock); |
548 | 548 | ||
549 | hlist_for_each_entry(i, iohash(dc, bio->bi_sector), hash) | 549 | hlist_for_each_entry(i, iohash(dc, bio->bi_iter.bi_sector), hash) |
550 | if (i->last == bio->bi_sector && | 550 | if (i->last == bio->bi_iter.bi_sector && |
551 | time_before(jiffies, i->jiffies)) | 551 | time_before(jiffies, i->jiffies)) |
552 | goto found; | 552 | goto found; |
553 | 553 | ||
@@ -556,8 +556,8 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) | |||
556 | add_sequential(task); | 556 | add_sequential(task); |
557 | i->sequential = 0; | 557 | i->sequential = 0; |
558 | found: | 558 | found: |
559 | if (i->sequential + bio->bi_size > i->sequential) | 559 | if (i->sequential + bio->bi_iter.bi_size > i->sequential) |
560 | i->sequential += bio->bi_size; | 560 | i->sequential += bio->bi_iter.bi_size; |
561 | 561 | ||
562 | i->last = bio_end_sector(bio); | 562 | i->last = bio_end_sector(bio); |
563 | i->jiffies = jiffies + msecs_to_jiffies(5000); | 563 | i->jiffies = jiffies + msecs_to_jiffies(5000); |
@@ -650,15 +650,15 @@ static int cache_lookup_fn(struct btree_op *op, struct btree *b, struct bkey *k) | |||
650 | struct bkey *bio_key; | 650 | struct bkey *bio_key; |
651 | unsigned ptr; | 651 | unsigned ptr; |
652 | 652 | ||
653 | if (bkey_cmp(k, &KEY(s->iop.inode, bio->bi_sector, 0)) <= 0) | 653 | if (bkey_cmp(k, &KEY(s->iop.inode, bio->bi_iter.bi_sector, 0)) <= 0) |
654 | return MAP_CONTINUE; | 654 | return MAP_CONTINUE; |
655 | 655 | ||
656 | if (KEY_INODE(k) != s->iop.inode || | 656 | if (KEY_INODE(k) != s->iop.inode || |
657 | KEY_START(k) > bio->bi_sector) { | 657 | KEY_START(k) > bio->bi_iter.bi_sector) { |
658 | unsigned bio_sectors = bio_sectors(bio); | 658 | unsigned bio_sectors = bio_sectors(bio); |
659 | unsigned sectors = KEY_INODE(k) == s->iop.inode | 659 | unsigned sectors = KEY_INODE(k) == s->iop.inode |
660 | ? min_t(uint64_t, INT_MAX, | 660 | ? min_t(uint64_t, INT_MAX, |
661 | KEY_START(k) - bio->bi_sector) | 661 | KEY_START(k) - bio->bi_iter.bi_sector) |
662 | : INT_MAX; | 662 | : INT_MAX; |
663 | 663 | ||
664 | int ret = s->d->cache_miss(b, s, bio, sectors); | 664 | int ret = s->d->cache_miss(b, s, bio, sectors); |
@@ -681,13 +681,13 @@ static int cache_lookup_fn(struct btree_op *op, struct btree *b, struct bkey *k) | |||
681 | s->read_dirty_data = true; | 681 | s->read_dirty_data = true; |
682 | 682 | ||
683 | n = bch_bio_split(bio, min_t(uint64_t, INT_MAX, | 683 | n = bch_bio_split(bio, min_t(uint64_t, INT_MAX, |
684 | KEY_OFFSET(k) - bio->bi_sector), | 684 | KEY_OFFSET(k) - bio->bi_iter.bi_sector), |
685 | GFP_NOIO, s->d->bio_split); | 685 | GFP_NOIO, s->d->bio_split); |
686 | 686 | ||
687 | bio_key = &container_of(n, struct bbio, bio)->key; | 687 | bio_key = &container_of(n, struct bbio, bio)->key; |
688 | bch_bkey_copy_single_ptr(bio_key, k, ptr); | 688 | bch_bkey_copy_single_ptr(bio_key, k, ptr); |
689 | 689 | ||
690 | bch_cut_front(&KEY(s->iop.inode, n->bi_sector, 0), bio_key); | 690 | bch_cut_front(&KEY(s->iop.inode, n->bi_iter.bi_sector, 0), bio_key); |
691 | bch_cut_back(&KEY(s->iop.inode, bio_end_sector(n), 0), bio_key); | 691 | bch_cut_back(&KEY(s->iop.inode, bio_end_sector(n), 0), bio_key); |
692 | 692 | ||
693 | n->bi_end_io = bch_cache_read_endio; | 693 | n->bi_end_io = bch_cache_read_endio; |
@@ -714,7 +714,7 @@ static void cache_lookup(struct closure *cl) | |||
714 | struct bio *bio = &s->bio.bio; | 714 | struct bio *bio = &s->bio.bio; |
715 | 715 | ||
716 | int ret = bch_btree_map_keys(&s->op, s->iop.c, | 716 | int ret = bch_btree_map_keys(&s->op, s->iop.c, |
717 | &KEY(s->iop.inode, bio->bi_sector, 0), | 717 | &KEY(s->iop.inode, bio->bi_iter.bi_sector, 0), |
718 | cache_lookup_fn, MAP_END_KEY); | 718 | cache_lookup_fn, MAP_END_KEY); |
719 | if (ret == -EAGAIN) | 719 | if (ret == -EAGAIN) |
720 | continue_at(cl, cache_lookup, bcache_wq); | 720 | continue_at(cl, cache_lookup, bcache_wq); |
@@ -872,9 +872,9 @@ static void cached_dev_read_done(struct closure *cl) | |||
872 | 872 | ||
873 | if (s->iop.bio) { | 873 | if (s->iop.bio) { |
874 | bio_reset(s->iop.bio); | 874 | bio_reset(s->iop.bio); |
875 | s->iop.bio->bi_sector = s->cache_miss->bi_sector; | 875 | s->iop.bio->bi_iter.bi_sector = s->cache_miss->bi_iter.bi_sector; |
876 | s->iop.bio->bi_bdev = s->cache_miss->bi_bdev; | 876 | s->iop.bio->bi_bdev = s->cache_miss->bi_bdev; |
877 | s->iop.bio->bi_size = s->insert_bio_sectors << 9; | 877 | s->iop.bio->bi_iter.bi_size = s->insert_bio_sectors << 9; |
878 | bch_bio_map(s->iop.bio, NULL); | 878 | bch_bio_map(s->iop.bio, NULL); |
879 | 879 | ||
880 | bio_copy_data(s->cache_miss, s->iop.bio); | 880 | bio_copy_data(s->cache_miss, s->iop.bio); |
@@ -937,7 +937,7 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s, | |||
937 | s->insert_bio_sectors = min(sectors, bio_sectors(bio) + reada); | 937 | s->insert_bio_sectors = min(sectors, bio_sectors(bio) + reada); |
938 | 938 | ||
939 | s->iop.replace_key = KEY(s->iop.inode, | 939 | s->iop.replace_key = KEY(s->iop.inode, |
940 | bio->bi_sector + s->insert_bio_sectors, | 940 | bio->bi_iter.bi_sector + s->insert_bio_sectors, |
941 | s->insert_bio_sectors); | 941 | s->insert_bio_sectors); |
942 | 942 | ||
943 | ret = bch_btree_insert_check_key(b, &s->op, &s->iop.replace_key); | 943 | ret = bch_btree_insert_check_key(b, &s->op, &s->iop.replace_key); |
@@ -957,9 +957,9 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s, | |||
957 | if (!cache_bio) | 957 | if (!cache_bio) |
958 | goto out_submit; | 958 | goto out_submit; |
959 | 959 | ||
960 | cache_bio->bi_sector = miss->bi_sector; | 960 | cache_bio->bi_iter.bi_sector = miss->bi_iter.bi_sector; |
961 | cache_bio->bi_bdev = miss->bi_bdev; | 961 | cache_bio->bi_bdev = miss->bi_bdev; |
962 | cache_bio->bi_size = s->insert_bio_sectors << 9; | 962 | cache_bio->bi_iter.bi_size = s->insert_bio_sectors << 9; |
963 | 963 | ||
964 | cache_bio->bi_end_io = request_endio; | 964 | cache_bio->bi_end_io = request_endio; |
965 | cache_bio->bi_private = &s->cl; | 965 | cache_bio->bi_private = &s->cl; |
@@ -1009,7 +1009,7 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s) | |||
1009 | { | 1009 | { |
1010 | struct closure *cl = &s->cl; | 1010 | struct closure *cl = &s->cl; |
1011 | struct bio *bio = &s->bio.bio; | 1011 | struct bio *bio = &s->bio.bio; |
1012 | struct bkey start = KEY(dc->disk.id, bio->bi_sector, 0); | 1012 | struct bkey start = KEY(dc->disk.id, bio->bi_iter.bi_sector, 0); |
1013 | struct bkey end = KEY(dc->disk.id, bio_end_sector(bio), 0); | 1013 | struct bkey end = KEY(dc->disk.id, bio_end_sector(bio), 0); |
1014 | 1014 | ||
1015 | bch_keybuf_check_overlapping(&s->iop.c->moving_gc_keys, &start, &end); | 1015 | bch_keybuf_check_overlapping(&s->iop.c->moving_gc_keys, &start, &end); |
@@ -1104,13 +1104,13 @@ static void cached_dev_make_request(struct request_queue *q, struct bio *bio) | |||
1104 | part_stat_unlock(); | 1104 | part_stat_unlock(); |
1105 | 1105 | ||
1106 | bio->bi_bdev = dc->bdev; | 1106 | bio->bi_bdev = dc->bdev; |
1107 | bio->bi_sector += dc->sb.data_offset; | 1107 | bio->bi_iter.bi_sector += dc->sb.data_offset; |
1108 | 1108 | ||
1109 | if (cached_dev_get(dc)) { | 1109 | if (cached_dev_get(dc)) { |
1110 | s = search_alloc(bio, d); | 1110 | s = search_alloc(bio, d); |
1111 | trace_bcache_request_start(s->d, bio); | 1111 | trace_bcache_request_start(s->d, bio); |
1112 | 1112 | ||
1113 | if (!bio->bi_size) { | 1113 | if (!bio->bi_iter.bi_size) { |
1114 | /* | 1114 | /* |
1115 | * can't call bch_journal_meta from under | 1115 | * can't call bch_journal_meta from under |
1116 | * generic_make_request | 1116 | * generic_make_request |
@@ -1197,9 +1197,9 @@ static int flash_dev_cache_miss(struct btree *b, struct search *s, | |||
1197 | sectors -= j; | 1197 | sectors -= j; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | bio_advance(bio, min(sectors << 9, bio->bi_size)); | 1200 | bio_advance(bio, min(sectors << 9, bio->bi_iter.bi_size)); |
1201 | 1201 | ||
1202 | if (!bio->bi_size) | 1202 | if (!bio->bi_iter.bi_size) |
1203 | return MAP_DONE; | 1203 | return MAP_DONE; |
1204 | 1204 | ||
1205 | return MAP_CONTINUE; | 1205 | return MAP_CONTINUE; |
@@ -1233,7 +1233,7 @@ static void flash_dev_make_request(struct request_queue *q, struct bio *bio) | |||
1233 | 1233 | ||
1234 | trace_bcache_request_start(s->d, bio); | 1234 | trace_bcache_request_start(s->d, bio); |
1235 | 1235 | ||
1236 | if (!bio->bi_size) { | 1236 | if (!bio->bi_iter.bi_size) { |
1237 | /* | 1237 | /* |
1238 | * can't call bch_journal_meta from under | 1238 | * can't call bch_journal_meta from under |
1239 | * generic_make_request | 1239 | * generic_make_request |
@@ -1243,7 +1243,7 @@ static void flash_dev_make_request(struct request_queue *q, struct bio *bio) | |||
1243 | bcache_wq); | 1243 | bcache_wq); |
1244 | } else if (rw) { | 1244 | } else if (rw) { |
1245 | bch_keybuf_check_overlapping(&s->iop.c->moving_gc_keys, | 1245 | bch_keybuf_check_overlapping(&s->iop.c->moving_gc_keys, |
1246 | &KEY(d->id, bio->bi_sector, 0), | 1246 | &KEY(d->id, bio->bi_iter.bi_sector, 0), |
1247 | &KEY(d->id, bio_end_sector(bio), 0)); | 1247 | &KEY(d->id, bio_end_sector(bio), 0)); |
1248 | 1248 | ||
1249 | s->iop.bypass = (bio->bi_rw & REQ_DISCARD) != 0; | 1249 | s->iop.bypass = (bio->bi_rw & REQ_DISCARD) != 0; |