diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2016-09-22 03:10:01 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-09-22 09:48:03 -0400 |
commit | 491221f88d00651e449c9caf7415b6453c8a77b7 (patch) | |
tree | 8021285e1ee5eaff42fa4a5a00929ad36dad7633 | |
parent | 1e3aeae4ea710023dda2a6b780183ee371d1a796 (diff) |
block: export bio_free_pages to other modules
bio_free_pages is introduced in commit 1dfa0f68c040
("block: add a helper to free bio bounce buffer pages"),
we can reuse the func in other modules after it was
imported.
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Shaohua Li <shli@fb.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Acked-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | block/bio.c | 3 | ||||
-rw-r--r-- | drivers/md/bcache/btree.c | 6 | ||||
-rw-r--r-- | drivers/md/bcache/debug.c | 6 | ||||
-rw-r--r-- | drivers/md/bcache/movinggc.c | 5 | ||||
-rw-r--r-- | drivers/md/bcache/request.c | 9 | ||||
-rw-r--r-- | drivers/md/bcache/writeback.c | 5 | ||||
-rw-r--r-- | drivers/md/dm-log-writes.c | 6 | ||||
-rw-r--r-- | drivers/md/raid1.c | 8 | ||||
-rw-r--r-- | include/linux/bio.h | 1 |
9 files changed, 13 insertions, 36 deletions
diff --git a/block/bio.c b/block/bio.c index a6d279e1ea9e..db85c5753a76 100644 --- a/block/bio.c +++ b/block/bio.c | |||
@@ -1068,7 +1068,7 @@ static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter) | |||
1068 | return 0; | 1068 | return 0; |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | static void bio_free_pages(struct bio *bio) | 1071 | void bio_free_pages(struct bio *bio) |
1072 | { | 1072 | { |
1073 | struct bio_vec *bvec; | 1073 | struct bio_vec *bvec; |
1074 | int i; | 1074 | int i; |
@@ -1076,6 +1076,7 @@ static void bio_free_pages(struct bio *bio) | |||
1076 | bio_for_each_segment_all(bvec, bio, i) | 1076 | bio_for_each_segment_all(bvec, bio, i) |
1077 | __free_page(bvec->bv_page); | 1077 | __free_page(bvec->bv_page); |
1078 | } | 1078 | } |
1079 | EXPORT_SYMBOL(bio_free_pages); | ||
1079 | 1080 | ||
1080 | /** | 1081 | /** |
1081 | * bio_uncopy_user - finish previously mapped bio | 1082 | * bio_uncopy_user - finish previously mapped bio |
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 76f7534d1dd1..81d3db40cd7b 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c | |||
@@ -361,12 +361,8 @@ static void __btree_node_write_done(struct closure *cl) | |||
361 | static void btree_node_write_done(struct closure *cl) | 361 | static void btree_node_write_done(struct closure *cl) |
362 | { | 362 | { |
363 | struct btree *b = container_of(cl, struct btree, io); | 363 | struct btree *b = container_of(cl, struct btree, io); |
364 | struct bio_vec *bv; | ||
365 | int n; | ||
366 | |||
367 | bio_for_each_segment_all(bv, b->bio, n) | ||
368 | __free_page(bv->bv_page); | ||
369 | 364 | ||
365 | bio_free_pages(b->bio); | ||
370 | __btree_node_write_done(cl); | 366 | __btree_node_write_done(cl); |
371 | } | 367 | } |
372 | 368 | ||
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index c28df164701e..333a1e5f6ae6 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c | |||
@@ -107,9 +107,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) | |||
107 | { | 107 | { |
108 | char name[BDEVNAME_SIZE]; | 108 | char name[BDEVNAME_SIZE]; |
109 | struct bio *check; | 109 | struct bio *check; |
110 | struct bio_vec bv, *bv2; | 110 | struct bio_vec bv; |
111 | struct bvec_iter iter; | 111 | struct bvec_iter iter; |
112 | int i; | ||
113 | 112 | ||
114 | check = bio_clone(bio, GFP_NOIO); | 113 | check = bio_clone(bio, GFP_NOIO); |
115 | if (!check) | 114 | if (!check) |
@@ -136,8 +135,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) | |||
136 | kunmap_atomic(p1); | 135 | kunmap_atomic(p1); |
137 | } | 136 | } |
138 | 137 | ||
139 | bio_for_each_segment_all(bv2, check, i) | 138 | bio_free_pages(check); |
140 | __free_page(bv2->bv_page); | ||
141 | out_put: | 139 | out_put: |
142 | bio_put(check); | 140 | bio_put(check); |
143 | } | 141 | } |
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index 1881319f2298..5c4bddecfaf0 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c | |||
@@ -44,11 +44,8 @@ static void write_moving_finish(struct closure *cl) | |||
44 | { | 44 | { |
45 | struct moving_io *io = container_of(cl, struct moving_io, cl); | 45 | struct moving_io *io = container_of(cl, struct moving_io, cl); |
46 | struct bio *bio = &io->bio.bio; | 46 | struct bio *bio = &io->bio.bio; |
47 | struct bio_vec *bv; | ||
48 | int i; | ||
49 | 47 | ||
50 | bio_for_each_segment_all(bv, bio, i) | 48 | bio_free_pages(bio); |
51 | __free_page(bv->bv_page); | ||
52 | 49 | ||
53 | if (io->op.replace_collision) | 50 | if (io->op.replace_collision) |
54 | trace_bcache_gc_copy_collision(&io->w->key); | 51 | trace_bcache_gc_copy_collision(&io->w->key); |
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 4b177fe11ebb..40ffe5e424b3 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c | |||
@@ -694,13 +694,8 @@ static void cached_dev_cache_miss_done(struct closure *cl) | |||
694 | if (s->iop.replace_collision) | 694 | if (s->iop.replace_collision) |
695 | bch_mark_cache_miss_collision(s->iop.c, s->d); | 695 | bch_mark_cache_miss_collision(s->iop.c, s->d); |
696 | 696 | ||
697 | if (s->iop.bio) { | 697 | if (s->iop.bio) |
698 | int i; | 698 | bio_free_pages(s->iop.bio); |
699 | struct bio_vec *bv; | ||
700 | |||
701 | bio_for_each_segment_all(bv, s->iop.bio, i) | ||
702 | __free_page(bv->bv_page); | ||
703 | } | ||
704 | 699 | ||
705 | cached_dev_bio_complete(cl); | 700 | cached_dev_bio_complete(cl); |
706 | } | 701 | } |
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index d9fd2a62e5f6..e51644e503a5 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c | |||
@@ -128,11 +128,8 @@ static void write_dirty_finish(struct closure *cl) | |||
128 | struct dirty_io *io = container_of(cl, struct dirty_io, cl); | 128 | struct dirty_io *io = container_of(cl, struct dirty_io, cl); |
129 | struct keybuf_key *w = io->bio.bi_private; | 129 | struct keybuf_key *w = io->bio.bi_private; |
130 | struct cached_dev *dc = io->dc; | 130 | struct cached_dev *dc = io->dc; |
131 | struct bio_vec *bv; | ||
132 | int i; | ||
133 | 131 | ||
134 | bio_for_each_segment_all(bv, &io->bio, i) | 132 | bio_free_pages(&io->bio); |
135 | __free_page(bv->bv_page); | ||
136 | 133 | ||
137 | /* This is kind of a dumb way of signalling errors. */ | 134 | /* This is kind of a dumb way of signalling errors. */ |
138 | if (KEY_DIRTY(&w->key)) { | 135 | if (KEY_DIRTY(&w->key)) { |
diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index 4ab68033f9d1..b52404159ccf 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c | |||
@@ -149,8 +149,6 @@ static void put_io_block(struct log_writes_c *lc) | |||
149 | static void log_end_io(struct bio *bio) | 149 | static void log_end_io(struct bio *bio) |
150 | { | 150 | { |
151 | struct log_writes_c *lc = bio->bi_private; | 151 | struct log_writes_c *lc = bio->bi_private; |
152 | struct bio_vec *bvec; | ||
153 | int i; | ||
154 | 152 | ||
155 | if (bio->bi_error) { | 153 | if (bio->bi_error) { |
156 | unsigned long flags; | 154 | unsigned long flags; |
@@ -161,9 +159,7 @@ static void log_end_io(struct bio *bio) | |||
161 | spin_unlock_irqrestore(&lc->blocks_lock, flags); | 159 | spin_unlock_irqrestore(&lc->blocks_lock, flags); |
162 | } | 160 | } |
163 | 161 | ||
164 | bio_for_each_segment_all(bvec, bio, i) | 162 | bio_free_pages(bio); |
165 | __free_page(bvec->bv_page); | ||
166 | |||
167 | put_io_block(lc); | 163 | put_io_block(lc); |
168 | bio_put(bio); | 164 | bio_put(bio); |
169 | } | 165 | } |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 21dc00eb1989..1961d827dbd1 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -145,12 +145,8 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) | |||
145 | return r1_bio; | 145 | return r1_bio; |
146 | 146 | ||
147 | out_free_pages: | 147 | out_free_pages: |
148 | while (--j >= 0) { | 148 | while (--j >= 0) |
149 | struct bio_vec *bv; | 149 | bio_free_pages(r1_bio->bios[j]); |
150 | |||
151 | bio_for_each_segment_all(bv, r1_bio->bios[j], i) | ||
152 | __free_page(bv->bv_page); | ||
153 | } | ||
154 | 150 | ||
155 | out_free_bio: | 151 | out_free_bio: |
156 | while (++j < pi->raid_disks) | 152 | while (++j < pi->raid_disks) |
diff --git a/include/linux/bio.h b/include/linux/bio.h index e00721a2dce1..97cb48f03dc7 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -459,6 +459,7 @@ static inline void bio_flush_dcache_pages(struct bio *bi) | |||
459 | 459 | ||
460 | extern void bio_copy_data(struct bio *dst, struct bio *src); | 460 | extern void bio_copy_data(struct bio *dst, struct bio *src); |
461 | extern int bio_alloc_pages(struct bio *bio, gfp_t gfp); | 461 | extern int bio_alloc_pages(struct bio *bio, gfp_t gfp); |
462 | extern void bio_free_pages(struct bio *bio); | ||
462 | 463 | ||
463 | extern struct bio *bio_copy_user_iov(struct request_queue *, | 464 | extern struct bio *bio_copy_user_iov(struct request_queue *, |
464 | struct rq_map_data *, | 465 | struct rq_map_data *, |