diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/ll_rw_blk.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 17e188973428..74a567afb830 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c | |||
@@ -3116,7 +3116,7 @@ static inline int should_fail_request(struct bio *bio) | |||
3116 | * bi_sector for remaps as it sees fit. So the values of these fields | 3116 | * bi_sector for remaps as it sees fit. So the values of these fields |
3117 | * should NOT be depended on after the call to generic_make_request. | 3117 | * should NOT be depended on after the call to generic_make_request. |
3118 | */ | 3118 | */ |
3119 | void generic_make_request(struct bio *bio) | 3119 | static inline void __generic_make_request(struct bio *bio) |
3120 | { | 3120 | { |
3121 | request_queue_t *q; | 3121 | request_queue_t *q; |
3122 | sector_t maxsector; | 3122 | sector_t maxsector; |
@@ -3215,6 +3215,57 @@ end_io: | |||
3215 | } while (ret); | 3215 | } while (ret); |
3216 | } | 3216 | } |
3217 | 3217 | ||
3218 | /* | ||
3219 | * We only want one ->make_request_fn to be active at a time, | ||
3220 | * else stack usage with stacked devices could be a problem. | ||
3221 | * So use current->bio_{list,tail} to keep a list of requests | ||
3222 | * submited by a make_request_fn function. | ||
3223 | * current->bio_tail is also used as a flag to say if | ||
3224 | * generic_make_request is currently active in this task or not. | ||
3225 | * If it is NULL, then no make_request is active. If it is non-NULL, | ||
3226 | * then a make_request is active, and new requests should be added | ||
3227 | * at the tail | ||
3228 | */ | ||
3229 | void generic_make_request(struct bio *bio) | ||
3230 | { | ||
3231 | if (current->bio_tail) { | ||
3232 | /* make_request is active */ | ||
3233 | *(current->bio_tail) = bio; | ||
3234 | bio->bi_next = NULL; | ||
3235 | current->bio_tail = &bio->bi_next; | ||
3236 | return; | ||
3237 | } | ||
3238 | /* following loop may be a bit non-obvious, and so deserves some | ||
3239 | * explanation. | ||
3240 | * Before entering the loop, bio->bi_next is NULL (as all callers | ||
3241 | * ensure that) so we have a list with a single bio. | ||
3242 | * We pretend that we have just taken it off a longer list, so | ||
3243 | * we assign bio_list to the next (which is NULL) and bio_tail | ||
3244 | * to &bio_list, thus initialising the bio_list of new bios to be | ||
3245 | * added. __generic_make_request may indeed add some more bios | ||
3246 | * through a recursive call to generic_make_request. If it | ||
3247 | * did, we find a non-NULL value in bio_list and re-enter the loop | ||
3248 | * from the top. In this case we really did just take the bio | ||
3249 | * of the top of the list (no pretending) and so fixup bio_list and | ||
3250 | * bio_tail or bi_next, and call into __generic_make_request again. | ||
3251 | * | ||
3252 | * The loop was structured like this to make only one call to | ||
3253 | * __generic_make_request (which is important as it is large and | ||
3254 | * inlined) and to keep the structure simple. | ||
3255 | */ | ||
3256 | BUG_ON(bio->bi_next); | ||
3257 | do { | ||
3258 | current->bio_list = bio->bi_next; | ||
3259 | if (bio->bi_next == NULL) | ||
3260 | current->bio_tail = ¤t->bio_list; | ||
3261 | else | ||
3262 | bio->bi_next = NULL; | ||
3263 | __generic_make_request(bio); | ||
3264 | bio = current->bio_list; | ||
3265 | } while (bio); | ||
3266 | current->bio_tail = NULL; /* deactivate */ | ||
3267 | } | ||
3268 | |||
3218 | EXPORT_SYMBOL(generic_make_request); | 3269 | EXPORT_SYMBOL(generic_make_request); |
3219 | 3270 | ||
3220 | /** | 3271 | /** |