aboutsummaryrefslogtreecommitdiffstats
path: root/block/bounce.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/bounce.c')
-rw-r--r--block/bounce.c31
1 files changed, 4 insertions, 27 deletions
diff --git a/block/bounce.c b/block/bounce.c
index 2c310ea007ee..0611aea1cfe9 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -177,26 +177,8 @@ static void bounce_end_io_read_isa(struct bio *bio)
177 __bounce_end_io_read(bio, isa_page_pool); 177 __bounce_end_io_read(bio, isa_page_pool);
178} 178}
179 179
180#ifdef CONFIG_NEED_BOUNCE_POOL
181static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio)
182{
183 if (bio_data_dir(bio) != WRITE)
184 return 0;
185
186 if (!bdi_cap_stable_pages_required(&q->backing_dev_info))
187 return 0;
188
189 return bio_flagged(bio, BIO_SNAP_STABLE);
190}
191#else
192static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio)
193{
194 return 0;
195}
196#endif /* CONFIG_NEED_BOUNCE_POOL */
197
198static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, 180static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
199 mempool_t *pool, int force) 181 mempool_t *pool)
200{ 182{
201 struct bio *bio; 183 struct bio *bio;
202 int rw = bio_data_dir(*bio_orig); 184 int rw = bio_data_dir(*bio_orig);
@@ -204,8 +186,6 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
204 struct bvec_iter iter; 186 struct bvec_iter iter;
205 unsigned i; 187 unsigned i;
206 188
207 if (force)
208 goto bounce;
209 bio_for_each_segment(from, *bio_orig, iter) 189 bio_for_each_segment(from, *bio_orig, iter)
210 if (page_to_pfn(from.bv_page) > queue_bounce_pfn(q)) 190 if (page_to_pfn(from.bv_page) > queue_bounce_pfn(q))
211 goto bounce; 191 goto bounce;
@@ -217,7 +197,7 @@ bounce:
217 bio_for_each_segment_all(to, bio, i) { 197 bio_for_each_segment_all(to, bio, i) {
218 struct page *page = to->bv_page; 198 struct page *page = to->bv_page;
219 199
220 if (page_to_pfn(page) <= queue_bounce_pfn(q) && !force) 200 if (page_to_pfn(page) <= queue_bounce_pfn(q))
221 continue; 201 continue;
222 202
223 to->bv_page = mempool_alloc(pool, q->bounce_gfp); 203 to->bv_page = mempool_alloc(pool, q->bounce_gfp);
@@ -255,7 +235,6 @@ bounce:
255 235
256void blk_queue_bounce(struct request_queue *q, struct bio **bio_orig) 236void blk_queue_bounce(struct request_queue *q, struct bio **bio_orig)
257{ 237{
258 int must_bounce;
259 mempool_t *pool; 238 mempool_t *pool;
260 239
261 /* 240 /*
@@ -264,15 +243,13 @@ void blk_queue_bounce(struct request_queue *q, struct bio **bio_orig)
264 if (!bio_has_data(*bio_orig)) 243 if (!bio_has_data(*bio_orig))
265 return; 244 return;
266 245
267 must_bounce = must_snapshot_stable_pages(q, *bio_orig);
268
269 /* 246 /*
270 * for non-isa bounce case, just check if the bounce pfn is equal 247 * for non-isa bounce case, just check if the bounce pfn is equal
271 * to or bigger than the highest pfn in the system -- in that case, 248 * to or bigger than the highest pfn in the system -- in that case,
272 * don't waste time iterating over bio segments 249 * don't waste time iterating over bio segments
273 */ 250 */
274 if (!(q->bounce_gfp & GFP_DMA)) { 251 if (!(q->bounce_gfp & GFP_DMA)) {
275 if (queue_bounce_pfn(q) >= blk_max_pfn && !must_bounce) 252 if (queue_bounce_pfn(q) >= blk_max_pfn)
276 return; 253 return;
277 pool = page_pool; 254 pool = page_pool;
278 } else { 255 } else {
@@ -283,7 +260,7 @@ void blk_queue_bounce(struct request_queue *q, struct bio **bio_orig)
283 /* 260 /*
284 * slow path 261 * slow path
285 */ 262 */
286 __blk_queue_bounce(q, bio_orig, pool, must_bounce); 263 __blk_queue_bounce(q, bio_orig, pool);
287} 264}
288 265
289EXPORT_SYMBOL(blk_queue_bounce); 266EXPORT_SYMBOL(blk_queue_bounce);