History

block: add support for write hints in a bio

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.

Jens Axboe committed 9 years ago

Commit cb6934f1 parent c75b1d95 files · +20 −0Browse files

Unified · Split

5 files
  1. block/bio.c +2 −0
  2. block/blk-core.c +1 −0
  3. block/blk-merge.c +14 −0
  4. include/linux/blk_types.h +1 −0
  5. include/linux/blkdev.h +2 −0
block/bio.c+2−0
@@ -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
block/blk-core.c+1−0
@@ -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 else1766 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}
1770EXPORT_SYMBOL_GPL(blk_init_request_from_bio);1771EXPORT_SYMBOL_GPL(blk_init_request_from_bio);
block/blk-merge.c+14−0
@@ -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 list683 * If we are allowed to merge, then append bio list
677 * from next to rq and release next. merge_requests_fn684 * 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
include/linux/blk_types.h+1−0
@@ -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
include/linux/blkdev.h+2−0
@@ -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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t