blk-merge.c (b7e56edba4b02f2079042c326a8cd72a44635817) blk-merge.c (8a78362c4eefc1deddbefe2c7f38aabbc2429d6b)
1/*
2 * Functions related to segment and merge handling
3 */
4#include <linux/kernel.h>
5#include <linux/module.h>
6#include <linux/bio.h>
7#include <linux/blkdev.h>
8#include <linux/scatterlist.h>

--- 192 unchanged lines hidden (view full) ---

201EXPORT_SYMBOL(blk_rq_map_sg);
202
203static inline int ll_new_hw_segment(struct request_queue *q,
204 struct request *req,
205 struct bio *bio)
206{
207 int nr_phys_segs = bio_phys_segments(q, bio);
208
1/*
2 * Functions related to segment and merge handling
3 */
4#include <linux/kernel.h>
5#include <linux/module.h>
6#include <linux/bio.h>
7#include <linux/blkdev.h>
8#include <linux/scatterlist.h>

--- 192 unchanged lines hidden (view full) ---

201EXPORT_SYMBOL(blk_rq_map_sg);
202
203static inline int ll_new_hw_segment(struct request_queue *q,
204 struct request *req,
205 struct bio *bio)
206{
207 int nr_phys_segs = bio_phys_segments(q, bio);
208
209 if (req->nr_phys_segments + nr_phys_segs > queue_max_hw_segments(q) ||
210 req->nr_phys_segments + nr_phys_segs > queue_max_phys_segments(q)) {
209 if (req->nr_phys_segments + nr_phys_segs > queue_max_segments(q)) {
211 req->cmd_flags |= REQ_NOMERGE;
212 if (req == q->last_merge)
213 q->last_merge = NULL;
214 return 0;
215 }
216
217 /*
218 * This will form the start of a new hw segment. Bump both

--- 76 unchanged lines hidden (view full) ---

295 if (blk_phys_contig_segment(q, req->biotail, next->bio)) {
296 if (req->nr_phys_segments == 1)
297 req->bio->bi_seg_front_size = seg_size;
298 if (next->nr_phys_segments == 1)
299 next->biotail->bi_seg_back_size = seg_size;
300 total_phys_segments--;
301 }
302
210 req->cmd_flags |= REQ_NOMERGE;
211 if (req == q->last_merge)
212 q->last_merge = NULL;
213 return 0;
214 }
215
216 /*
217 * This will form the start of a new hw segment. Bump both

--- 76 unchanged lines hidden (view full) ---

294 if (blk_phys_contig_segment(q, req->biotail, next->bio)) {
295 if (req->nr_phys_segments == 1)
296 req->bio->bi_seg_front_size = seg_size;
297 if (next->nr_phys_segments == 1)
298 next->biotail->bi_seg_back_size = seg_size;
299 total_phys_segments--;
300 }
301
303 if (total_phys_segments > queue_max_phys_segments(q))
302 if (total_phys_segments > queue_max_segments(q))
304 return 0;
305
303 return 0;
304
306 if (total_phys_segments > queue_max_hw_segments(q))
307 return 0;
308
309 /* Merge is OK... */
310 req->nr_phys_segments = total_phys_segments;
311 return 1;
312}
313
314/**
315 * blk_rq_set_mixed_merge - mark a request as mixed merge
316 * @rq: request to mark as mixed merge

--- 138 unchanged lines hidden ---
305 /* Merge is OK... */
306 req->nr_phys_segments = total_phys_segments;
307 return 1;
308}
309
310/**
311 * blk_rq_set_mixed_merge - mark a request as mixed merge
312 * @rq: request to mark as mixed merge

--- 138 unchanged lines hidden ---