diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-10-29 20:17:49 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-24 01:33:55 -0500 |
commit | 1c3b13e64cf70d652fb04e32d13ae3e36810c2e4 (patch) | |
tree | ca3d3fd7d0c6d99fa2bc041ed51bac4aaa9a242a /fs/bio.c | |
parent | 5341a6278bc5d10dbbb2ab6031b41d95c8db7a35 (diff) |
dm: Refactor for new bio cloning/splitting
We need to convert the dm code to the new bvec_iter primitives which
respect bi_bvec_done; they also allow us to drastically simplify dm's
bio splitting code.
Also, it's no longer necessary to save/restore the bvec array anymore -
driver conversions for immutable bvecs are done, so drivers should never
be modifying it.
Also kill bio_sector_offset(), dm was the only user and it doesn't make
much sense anymore.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: dm-devel@redhat.com
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'fs/bio.c')
-rw-r--r-- | fs/bio.c | 72 |
1 files changed, 0 insertions, 72 deletions
@@ -515,40 +515,6 @@ inline int bio_phys_segments(struct request_queue *q, struct bio *bio) | |||
515 | EXPORT_SYMBOL(bio_phys_segments); | 515 | EXPORT_SYMBOL(bio_phys_segments); |
516 | 516 | ||
517 | /** | 517 | /** |
518 | * __bio_clone - clone a bio | ||
519 | * @bio: destination bio | ||
520 | * @bio_src: bio to clone | ||
521 | * | ||
522 | * Clone a &bio. Caller will own the returned bio, but not | ||
523 | * the actual data it points to. Reference count of returned | ||
524 | * bio will be one. | ||
525 | */ | ||
526 | void __bio_clone(struct bio *bio, struct bio *bio_src) | ||
527 | { | ||
528 | if (bio_is_rw(bio_src)) { | ||
529 | struct bio_vec bv; | ||
530 | struct bvec_iter iter; | ||
531 | |||
532 | bio_for_each_segment(bv, bio_src, iter) | ||
533 | bio->bi_io_vec[bio->bi_vcnt++] = bv; | ||
534 | } else if (bio_has_data(bio_src)) { | ||
535 | memcpy(bio->bi_io_vec, bio_src->bi_io_vec, | ||
536 | bio_src->bi_max_vecs * sizeof(struct bio_vec)); | ||
537 | bio->bi_vcnt = bio_src->bi_vcnt; | ||
538 | } | ||
539 | |||
540 | /* | ||
541 | * most users will be overriding ->bi_bdev with a new target, | ||
542 | * so we don't set nor calculate new physical/hw segment counts here | ||
543 | */ | ||
544 | bio->bi_bdev = bio_src->bi_bdev; | ||
545 | bio->bi_flags |= 1 << BIO_CLONED; | ||
546 | bio->bi_rw = bio_src->bi_rw; | ||
547 | bio->bi_iter = bio_src->bi_iter; | ||
548 | } | ||
549 | EXPORT_SYMBOL(__bio_clone); | ||
550 | |||
551 | /** | ||
552 | * __bio_clone_fast - clone a bio that shares the original bio's biovec | 518 | * __bio_clone_fast - clone a bio that shares the original bio's biovec |
553 | * @bio: destination bio | 519 | * @bio: destination bio |
554 | * @bio_src: bio to clone | 520 | * @bio_src: bio to clone |
@@ -1921,44 +1887,6 @@ void bio_trim(struct bio *bio, int offset, int size) | |||
1921 | } | 1887 | } |
1922 | EXPORT_SYMBOL_GPL(bio_trim); | 1888 | EXPORT_SYMBOL_GPL(bio_trim); |
1923 | 1889 | ||
1924 | /** | ||
1925 | * bio_sector_offset - Find hardware sector offset in bio | ||
1926 | * @bio: bio to inspect | ||
1927 | * @index: bio_vec index | ||
1928 | * @offset: offset in bv_page | ||
1929 | * | ||
1930 | * Return the number of hardware sectors between beginning of bio | ||
1931 | * and an end point indicated by a bio_vec index and an offset | ||
1932 | * within that vector's page. | ||
1933 | */ | ||
1934 | sector_t bio_sector_offset(struct bio *bio, unsigned short index, | ||
1935 | unsigned int offset) | ||
1936 | { | ||
1937 | unsigned int sector_sz; | ||
1938 | struct bio_vec *bv; | ||
1939 | sector_t sectors; | ||
1940 | int i; | ||
1941 | |||
1942 | sector_sz = queue_logical_block_size(bio->bi_bdev->bd_disk->queue); | ||
1943 | sectors = 0; | ||
1944 | |||
1945 | if (index >= bio->bi_iter.bi_idx) | ||
1946 | index = bio->bi_vcnt - 1; | ||
1947 | |||
1948 | bio_for_each_segment_all(bv, bio, i) { | ||
1949 | if (i == index) { | ||
1950 | if (offset > bv->bv_offset) | ||
1951 | sectors += (offset - bv->bv_offset) / sector_sz; | ||
1952 | break; | ||
1953 | } | ||
1954 | |||
1955 | sectors += bv->bv_len / sector_sz; | ||
1956 | } | ||
1957 | |||
1958 | return sectors; | ||
1959 | } | ||
1960 | EXPORT_SYMBOL(bio_sector_offset); | ||
1961 | |||
1962 | /* | 1890 | /* |
1963 | * create memory pools for biovec's in a bio_set. | 1891 | * create memory pools for biovec's in a bio_set. |
1964 | * use the global biovec slabs created for general use. | 1892 | * use the global biovec slabs created for general use. |