diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2010-09-15 17:06:35 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-09-16 02:42:52 -0400 |
commit | e43473b7f223ec866f7db273697e76c337c390f9 (patch) | |
tree | e90b52dbe4ec4ae37263a00e2bd9eaf5367cf72f /include | |
parent | 4c9eefa16c6f124ffcc736cb719b24ea27f85017 (diff) |
blkio: Core implementation of throttle policy
o Actual implementation of throttling policy in block layer. Currently it
implements READ and WRITE bytes per second throttling logic. IOPS throttling
comes in later patches.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/blk_types.h | 3 | ||||
-rw-r--r-- | include/linux/blkdev.h | 24 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index ca83a97c9715..10a0c291b55a 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h | |||
@@ -130,6 +130,8 @@ enum rq_flag_bits { | |||
130 | /* bio only flags */ | 130 | /* bio only flags */ |
131 | __REQ_UNPLUG, /* unplug the immediately after submission */ | 131 | __REQ_UNPLUG, /* unplug the immediately after submission */ |
132 | __REQ_RAHEAD, /* read ahead, can fail anytime */ | 132 | __REQ_RAHEAD, /* read ahead, can fail anytime */ |
133 | __REQ_THROTTLED, /* This bio has already been subjected to | ||
134 | * throttling rules. Don't do it again. */ | ||
133 | 135 | ||
134 | /* request only flags */ | 136 | /* request only flags */ |
135 | __REQ_SORTED, /* elevator knows about this request */ | 137 | __REQ_SORTED, /* elevator knows about this request */ |
@@ -172,6 +174,7 @@ enum rq_flag_bits { | |||
172 | 174 | ||
173 | #define REQ_UNPLUG (1 << __REQ_UNPLUG) | 175 | #define REQ_UNPLUG (1 << __REQ_UNPLUG) |
174 | #define REQ_RAHEAD (1 << __REQ_RAHEAD) | 176 | #define REQ_RAHEAD (1 << __REQ_RAHEAD) |
177 | #define REQ_THROTTLED (1 << __REQ_THROTTLED) | ||
175 | 178 | ||
176 | #define REQ_SORTED (1 << __REQ_SORTED) | 179 | #define REQ_SORTED (1 << __REQ_SORTED) |
177 | #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) | 180 | #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 780824edac16..1341df5806df 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -371,6 +371,11 @@ struct request_queue | |||
371 | #if defined(CONFIG_BLK_DEV_BSG) | 371 | #if defined(CONFIG_BLK_DEV_BSG) |
372 | struct bsg_class_device bsg_dev; | 372 | struct bsg_class_device bsg_dev; |
373 | #endif | 373 | #endif |
374 | |||
375 | #ifdef CONFIG_BLK_DEV_THROTTLING | ||
376 | /* Throttle data */ | ||
377 | struct throtl_data *td; | ||
378 | #endif | ||
374 | }; | 379 | }; |
375 | 380 | ||
376 | #define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ | 381 | #define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ |
@@ -1131,6 +1136,7 @@ static inline void put_dev_sector(Sector p) | |||
1131 | 1136 | ||
1132 | struct work_struct; | 1137 | struct work_struct; |
1133 | int kblockd_schedule_work(struct request_queue *q, struct work_struct *work); | 1138 | int kblockd_schedule_work(struct request_queue *q, struct work_struct *work); |
1139 | int kblockd_schedule_delayed_work(struct request_queue *q, struct delayed_work *dwork, unsigned long delay); | ||
1134 | 1140 | ||
1135 | #ifdef CONFIG_BLK_CGROUP | 1141 | #ifdef CONFIG_BLK_CGROUP |
1136 | /* | 1142 | /* |
@@ -1174,6 +1180,24 @@ static inline uint64_t rq_io_start_time_ns(struct request *req) | |||
1174 | } | 1180 | } |
1175 | #endif | 1181 | #endif |
1176 | 1182 | ||
1183 | #ifdef CONFIG_BLK_DEV_THROTTLING | ||
1184 | extern int blk_throtl_init(struct request_queue *q); | ||
1185 | extern void blk_throtl_exit(struct request_queue *q); | ||
1186 | extern int blk_throtl_bio(struct request_queue *q, struct bio **bio); | ||
1187 | extern void throtl_schedule_delayed_work(struct request_queue *q, unsigned long delay); | ||
1188 | extern void throtl_shutdown_timer_wq(struct request_queue *q); | ||
1189 | #else /* CONFIG_BLK_DEV_THROTTLING */ | ||
1190 | static inline int blk_throtl_bio(struct request_queue *q, struct bio **bio) | ||
1191 | { | ||
1192 | return 0; | ||
1193 | } | ||
1194 | |||
1195 | static inline int blk_throtl_init(struct request_queue *q) { return 0; } | ||
1196 | static inline int blk_throtl_exit(struct request_queue *q) { return 0; } | ||
1197 | static inline void throtl_schedule_delayed_work(struct request_queue *q, unsigned long delay) {} | ||
1198 | static inline void throtl_shutdown_timer_wq(struct request_queue *q) {} | ||
1199 | #endif /* CONFIG_BLK_DEV_THROTTLING */ | ||
1200 | |||
1177 | #define MODULE_ALIAS_BLOCKDEV(major,minor) \ | 1201 | #define MODULE_ALIAS_BLOCKDEV(major,minor) \ |
1178 | MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor)) | 1202 | MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor)) |
1179 | #define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \ | 1203 | #define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \ |