diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 17e18897342841887ec25b45585cfe49478bf77a..74a567afb83069f1d666409c645107a2d78e516d 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) * bi_sector for remaps as it sees fit. So the values of these fields * should NOT be depended on after the call to generic_make_request. */ -void generic_make_request(struct bio *bio) +static inline void __generic_make_request(struct bio *bio) { request_queue_t *q; sector_t maxsector; @@ -3215,6 +3215,57 @@ void generic_make_request(struct bio *bio) } while (ret); } +/* + * We only want one ->make_request_fn to be active at a time, + * else stack usage with stacked devices could be a problem. + * So use current->bio_{list,tail} to keep a list of requests + * submited by a make_request_fn function. + * current->bio_tail is also used as a flag to say if + * generic_make_request is currently active in this task or not. + * If it is NULL, then no make_request is active. If it is non-NULL, + * then a make_request is active, and new requests should be added + * at the tail + */ +void generic_make_request(struct bio *bio) +{ + if (current->bio_tail) { + /* make_request is active */ + *(current->bio_tail) = bio; + bio->bi_next = NULL; + current->bio_tail = &bio->bi_next; + return; + } + /* following loop may be a bit non-obvious, and so deserves some + * explanation. + * Before entering the loop, bio->bi_next is NULL (as all callers + * ensure that) so we have a list with a single bio. + * We pretend that we have just taken it off a longer list, so + * we assign bio_list to the next (which is NULL) and bio_tail + * to &bio_list, thus initialising the bio_list of new bios to be + * added. __generic_make_request may indeed add some more bios + * through a recursive call to generic_make_request. If it + * did, we find a non-NULL value in bio_list and re-enter the loop + * from the top. In this case we really did just take the bio + * of the top of the list (no pretending) and so fixup bio_list and + * bio_tail or bi_next, and call into __generic_make_request again. + * + * The loop was structured like this to make only one call to + * __generic_make_request (which is important as it is large and + * inlined) and to keep the structure simple. + */ + BUG_ON(bio->bi_next); + do { + current->bio_list = bio->bi_next; + if (bio->bi_next == NULL) + current->bio_tail = ¤t->bio_list; + else + bio->bi_next = NULL; + __generic_make_request(bio); + bio = current->bio_list; + } while (bio); + current->bio_tail = NULL; /* deactivate */ +} + EXPORT_SYMBOL(generic_make_request); /** diff --git a/include/linux/genhd.h b/include/linux/genhd.h index f589559cf0709586d1f126f92ebbbbca9cefa53b..4c03ee353e78684f64fd230101c7eab150860d79 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -434,6 +434,10 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index) #endif -#endif +#else /* CONFIG_BLOCK */ + +static inline void printk_all_partitions(void) { } + +#endif /* CONFIG_BLOCK */ #endif diff --git a/include/linux/sched.h b/include/linux/sched.h index 97c0c7da58efe896e519ef3a5a338da716c2b052..a81897e2a244a7cb0a9f84dd03adc7ba27e46253 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -88,6 +88,7 @@ struct sched_param { struct exec_domain; struct futex_pi_state; +struct bio; /* * List of flags we want to share for kernel threads, @@ -1016,6 +1017,9 @@ struct task_struct { /* journalling filesystem info */ void *journal_info; +/* stacked block device info */ + struct bio *bio_list, **bio_tail; + /* VM state */ struct reclaim_state *reclaim_state;