Commit 491221f8 authored by Guoqing Jiang's avatar Guoqing Jiang Committed by Jens Axboe

block: export bio_free_pages to other modules

bio_free_pages is introduced in commit 1dfa0f68
("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: default avatarGuoqing Jiang <gqjiang@suse.com>
Acked-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 1e3aeae4
...@@ -1068,7 +1068,7 @@ static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter) ...@@ -1068,7 +1068,7 @@ static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter)
return 0; return 0;
} }
static void bio_free_pages(struct bio *bio) void bio_free_pages(struct bio *bio)
{ {
struct bio_vec *bvec; struct bio_vec *bvec;
int i; int i;
...@@ -1076,6 +1076,7 @@ static void bio_free_pages(struct bio *bio) ...@@ -1076,6 +1076,7 @@ static void bio_free_pages(struct bio *bio)
bio_for_each_segment_all(bvec, bio, i) bio_for_each_segment_all(bvec, bio, i)
__free_page(bvec->bv_page); __free_page(bvec->bv_page);
} }
EXPORT_SYMBOL(bio_free_pages);
/** /**
* bio_uncopy_user - finish previously mapped bio * bio_uncopy_user - finish previously mapped bio
......
...@@ -361,12 +361,8 @@ static void __btree_node_write_done(struct closure *cl) ...@@ -361,12 +361,8 @@ static void __btree_node_write_done(struct closure *cl)
static void btree_node_write_done(struct closure *cl) static void btree_node_write_done(struct closure *cl)
{ {
struct btree *b = container_of(cl, struct btree, io); struct btree *b = container_of(cl, struct btree, io);
struct bio_vec *bv;
int n;
bio_for_each_segment_all(bv, b->bio, n)
__free_page(bv->bv_page);
bio_free_pages(b->bio);
__btree_node_write_done(cl); __btree_node_write_done(cl);
} }
......
...@@ -107,9 +107,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) ...@@ -107,9 +107,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
{ {
char name[BDEVNAME_SIZE]; char name[BDEVNAME_SIZE];
struct bio *check; struct bio *check;
struct bio_vec bv, *bv2; struct bio_vec bv;
struct bvec_iter iter; struct bvec_iter iter;
int i;
check = bio_clone(bio, GFP_NOIO); check = bio_clone(bio, GFP_NOIO);
if (!check) if (!check)
...@@ -136,8 +135,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) ...@@ -136,8 +135,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
kunmap_atomic(p1); kunmap_atomic(p1);
} }
bio_for_each_segment_all(bv2, check, i) bio_free_pages(check);
__free_page(bv2->bv_page);
out_put: out_put:
bio_put(check); bio_put(check);
} }
......
...@@ -44,11 +44,8 @@ static void write_moving_finish(struct closure *cl) ...@@ -44,11 +44,8 @@ static void write_moving_finish(struct closure *cl)
{ {
struct moving_io *io = container_of(cl, struct moving_io, cl); struct moving_io *io = container_of(cl, struct moving_io, cl);
struct bio *bio = &io->bio.bio; struct bio *bio = &io->bio.bio;
struct bio_vec *bv;
int i;
bio_for_each_segment_all(bv, bio, i) bio_free_pages(bio);
__free_page(bv->bv_page);
if (io->op.replace_collision) if (io->op.replace_collision)
trace_bcache_gc_copy_collision(&io->w->key); trace_bcache_gc_copy_collision(&io->w->key);
......
...@@ -694,13 +694,8 @@ static void cached_dev_cache_miss_done(struct closure *cl) ...@@ -694,13 +694,8 @@ static void cached_dev_cache_miss_done(struct closure *cl)
if (s->iop.replace_collision) if (s->iop.replace_collision)
bch_mark_cache_miss_collision(s->iop.c, s->d); bch_mark_cache_miss_collision(s->iop.c, s->d);
if (s->iop.bio) { if (s->iop.bio)
int i; bio_free_pages(s->iop.bio);
struct bio_vec *bv;
bio_for_each_segment_all(bv, s->iop.bio, i)
__free_page(bv->bv_page);
}
cached_dev_bio_complete(cl); cached_dev_bio_complete(cl);
} }
......
...@@ -128,11 +128,8 @@ static void write_dirty_finish(struct closure *cl) ...@@ -128,11 +128,8 @@ static void write_dirty_finish(struct closure *cl)
struct dirty_io *io = container_of(cl, struct dirty_io, cl); struct dirty_io *io = container_of(cl, struct dirty_io, cl);
struct keybuf_key *w = io->bio.bi_private; struct keybuf_key *w = io->bio.bi_private;
struct cached_dev *dc = io->dc; struct cached_dev *dc = io->dc;
struct bio_vec *bv;
int i;
bio_for_each_segment_all(bv, &io->bio, i) bio_free_pages(&io->bio);
__free_page(bv->bv_page);
/* This is kind of a dumb way of signalling errors. */ /* This is kind of a dumb way of signalling errors. */
if (KEY_DIRTY(&w->key)) { if (KEY_DIRTY(&w->key)) {
......
...@@ -149,8 +149,6 @@ static void put_io_block(struct log_writes_c *lc) ...@@ -149,8 +149,6 @@ static void put_io_block(struct log_writes_c *lc)
static void log_end_io(struct bio *bio) static void log_end_io(struct bio *bio)
{ {
struct log_writes_c *lc = bio->bi_private; struct log_writes_c *lc = bio->bi_private;
struct bio_vec *bvec;
int i;
if (bio->bi_error) { if (bio->bi_error) {
unsigned long flags; unsigned long flags;
...@@ -161,9 +159,7 @@ static void log_end_io(struct bio *bio) ...@@ -161,9 +159,7 @@ static void log_end_io(struct bio *bio)
spin_unlock_irqrestore(&lc->blocks_lock, flags); spin_unlock_irqrestore(&lc->blocks_lock, flags);
} }
bio_for_each_segment_all(bvec, bio, i) bio_free_pages(bio);
__free_page(bvec->bv_page);
put_io_block(lc); put_io_block(lc);
bio_put(bio); bio_put(bio);
} }
......
...@@ -145,12 +145,8 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) ...@@ -145,12 +145,8 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
return r1_bio; return r1_bio;
out_free_pages: out_free_pages:
while (--j >= 0) { while (--j >= 0)
struct bio_vec *bv; bio_free_pages(r1_bio->bios[j]);
bio_for_each_segment_all(bv, r1_bio->bios[j], i)
__free_page(bv->bv_page);
}
out_free_bio: out_free_bio:
while (++j < pi->raid_disks) while (++j < pi->raid_disks)
......
...@@ -459,6 +459,7 @@ static inline void bio_flush_dcache_pages(struct bio *bi) ...@@ -459,6 +459,7 @@ static inline void bio_flush_dcache_pages(struct bio *bi)
extern void bio_copy_data(struct bio *dst, struct bio *src); extern void bio_copy_data(struct bio *dst, struct bio *src);
extern int bio_alloc_pages(struct bio *bio, gfp_t gfp); extern int bio_alloc_pages(struct bio *bio, gfp_t gfp);
extern void bio_free_pages(struct bio *bio);
extern struct bio *bio_copy_user_iov(struct request_queue *, extern struct bio *bio_copy_user_iov(struct request_queue *,
struct rq_map_data *, struct rq_map_data *,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment