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
596596 bio->bi_bdev = bio_src->bi_bdev;
597597 bio_set_flag(bio, BIO_CLONED);
598598 bio->bi_opf = bio_src->bi_opf;
599+ bio->bi_write_hint = bio_src->bi_write_hint;
599600 bio->bi_iter = bio_src->bi_iter;
600601 bio->bi_io_vec = bio_src->bi_io_vec;
601602
@@ -679,6 +680,7 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, · 77 unmodified lines
679680 return NULL;
680681 bio->bi_bdev = bio_src->bi_bdev;
681682 bio->bi_opf = bio_src->bi_opf;
683+ bio->bi_write_hint = bio_src->bi_write_hint;
682684 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector;
683685 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size;
684686
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
17651765 req->ioprio = ioc->ioprio;
17661766 else
17671767 req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
1768+ req->write_hint = bio->bi_write_hint;
17681769 blk_rq_bio_prep(req->q, req, bio);
17691770 }
17701771 EXPORT_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
672672 !blk_write_same_mergeable(req->bio, next->bio))
673673 return NULL;
674674
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+
675682 /*
676683 * If we are allowed to merge, then append bio list
677684 * 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
791798 !blk_write_same_mergeable(rq->bio, bio))
792799 return false;
793800
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+
794808 return true;
795809 }
796810
include/linux/blk_types.h+1−0
@@ -56,6 +56,7 @@ struct bio { · 55 unmodified lines
5656 */
5757 unsigned short bi_flags; /* status, etc and bvec pool number */
5858 unsigned short bi_ioprio;
59+ unsigned short bi_write_hint;
5960
6061 struct bvec_iter bi_iter;
6162
include/linux/blkdev.h+2−0
@@ -225,6 +225,8 @@ struct request { · 224 unmodified lines
225225
226226 unsigned int extra_len; /* length of alignment and padding */
227227
228+ unsigned short write_hint;
229+
228230 unsigned long deadline;
229231 struct list_head timeout_list;
230232

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