No functional changes in this patch, we just use up some holes in the bio and request structures to define a write hint that we psas down the stack. Ensure that we don't merge requests that have different life time hints assigned to them, and that we inherit the write hint when cloning a bio.
Unified · Split
| @@ -596,6 +596,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src) · 595 unmodified lines | |||
| 596 | bio->bi_bdev = bio_src->bi_bdev; | 596 | bio->bi_bdev = bio_src->bi_bdev; |
| 597 | bio_set_flag(bio, BIO_CLONED); | 597 | bio_set_flag(bio, BIO_CLONED); |
| 598 | bio->bi_opf = bio_src->bi_opf; | 598 | bio->bi_opf = bio_src->bi_opf; |
| 599 | bio->bi_write_hint = bio_src->bi_write_hint; | ||
| 599 | bio->bi_iter = bio_src->bi_iter; | 600 | bio->bi_iter = bio_src->bi_iter; |
| 600 | bio->bi_io_vec = bio_src->bi_io_vec; | 601 | bio->bi_io_vec = bio_src->bi_io_vec; |
| 601 | 602 | ||
| @@ -679,6 +680,7 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, · 77 unmodified lines | |||
| 679 | return NULL; | 680 | return NULL; |
| 680 | bio->bi_bdev = bio_src->bi_bdev; | 681 | bio->bi_bdev = bio_src->bi_bdev; |
| 681 | bio->bi_opf = bio_src->bi_opf; | 682 | bio->bi_opf = bio_src->bi_opf; |
| 683 | bio->bi_write_hint = bio_src->bi_write_hint; | ||
| 682 | bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; | 684 | bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; |
| 683 | bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; | 685 | bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; |
| 684 | 686 | ||
| @@ -1765,6 +1765,7 @@ void blk_init_request_from_bio(struct request *req, struct bio *bio) · 1764 unmodified lines | |||
| 1765 | req->ioprio = ioc->ioprio; | 1765 | req->ioprio = ioc->ioprio; |
| 1766 | else | 1766 | else |
| 1767 | req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0); | 1767 | req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0); |
| 1768 | req->write_hint = bio->bi_write_hint; | ||
| 1768 | blk_rq_bio_prep(req->q, req, bio); | 1769 | blk_rq_bio_prep(req->q, req, bio); |
| 1769 | } | 1770 | } |
| 1770 | EXPORT_SYMBOL_GPL(blk_init_request_from_bio); | 1771 | EXPORT_SYMBOL_GPL(blk_init_request_from_bio); |
| @@ -672,6 +672,13 @@ static struct request *attempt_merge(struct request_queue *q, · 671 unmodified lines | |||
| 672 | !blk_write_same_mergeable(req->bio, next->bio)) | 672 | !blk_write_same_mergeable(req->bio, next->bio)) |
| 673 | return NULL; | 673 | return NULL; |
| 674 | 674 | ||
| 675 | /* | ||
| 676 | * Don't allow merge of different write hints, or for a hint with | ||
| 677 | * non-hint IO. | ||
| 678 | */ | ||
| 679 | if (req->write_hint != next->write_hint) | ||
| 680 | return NULL; | ||
| 681 | |||
| 675 | /* | 682 | /* |
| 676 | * If we are allowed to merge, then append bio list | 683 | * If we are allowed to merge, then append bio list |
| 677 | * from next to rq and release next. merge_requests_fn | 684 | * from next to rq and release next. merge_requests_fn |
| @@ -791,6 +798,13 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) · 113 unmodified lines | |||
| 791 | !blk_write_same_mergeable(rq->bio, bio)) | 798 | !blk_write_same_mergeable(rq->bio, bio)) |
| 792 | return false; | 799 | return false; |
| 793 | 800 | ||
| 801 | /* | ||
| 802 | * Don't allow merge of different write hints, or for a hint with | ||
| 803 | * non-hint IO. | ||
| 804 | */ | ||
| 805 | if (rq->write_hint != bio->bi_write_hint) | ||
| 806 | return false; | ||
| 807 | |||
| 794 | return true; | 808 | return true; |
| 795 | } | 809 | } |
| 796 | 810 | ||
| @@ -56,6 +56,7 @@ struct bio { · 55 unmodified lines | |||
| 56 | */ | 56 | */ |
| 57 | unsigned short bi_flags; /* status, etc and bvec pool number */ | 57 | unsigned short bi_flags; /* status, etc and bvec pool number */ |
| 58 | unsigned short bi_ioprio; | 58 | unsigned short bi_ioprio; |
| 59 | unsigned short bi_write_hint; | ||
| 59 | 60 | ||
| 60 | struct bvec_iter bi_iter; | 61 | struct bvec_iter bi_iter; |
| 61 | 62 | ||
| @@ -225,6 +225,8 @@ struct request { · 224 unmodified lines | |||
| 225 | 225 | ||
| 226 | unsigned int extra_len; /* length of alignment and padding */ | 226 | unsigned int extra_len; /* length of alignment and padding */ |
| 227 | 227 | ||
| 228 | unsigned short write_hint; | ||
| 229 | |||
| 228 | unsigned long deadline; | 230 | unsigned long deadline; |
| 229 | struct list_head timeout_list; | 231 | struct list_head timeout_list; |
| 230 | 232 | ||