Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e43473b7 authored by Vivek Goyal's avatar Vivek Goyal Committed by Jens Axboe
Browse files

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: default avatarVivek Goyal <vgoyal@redhat.com>
Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
parent 4c9eefa1
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -77,6 +77,18 @@ config BLK_DEV_INTEGRITY
	T10/SCSI Data Integrity Field or the T13/ATA External Path
	Protection.  If in doubt, say N.

config BLK_DEV_THROTTLING
	bool "Block layer bio throttling support"
	depends on BLK_CGROUP=y && EXPERIMENTAL
	default n
	---help---
	Block layer bio throttling support. It can be used to limit
	the IO rate to a device. IO rate policies are per cgroup and
	one needs to mount and use blkio cgroup controller for creating
	cgroups and specifying per device IO rate policies.

	See Documentation/cgroups/blkio-controller.txt for more information.

endif # BLOCK

config BLOCK_COMPAT
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ obj-$(CONFIG_BLOCK) := elevator.o blk-core.o blk-tag.o blk-sysfs.o \

obj-$(CONFIG_BLK_DEV_BSG)	+= bsg.o
obj-$(CONFIG_BLK_CGROUP)	+= blk-cgroup.o
obj-$(CONFIG_BLK_DEV_THROTTLING)	+= blk-throttle.o
obj-$(CONFIG_IOSCHED_NOOP)	+= noop-iosched.o
obj-$(CONFIG_IOSCHED_DEADLINE)	+= deadline-iosched.o
obj-$(CONFIG_IOSCHED_CFQ)	+= cfq-iosched.o
+24 −0
Original line number Diff line number Diff line
@@ -382,6 +382,7 @@ void blk_sync_queue(struct request_queue *q)
	del_timer_sync(&q->unplug_timer);
	del_timer_sync(&q->timeout);
	cancel_work_sync(&q->unplug_work);
	throtl_shutdown_timer_wq(q);
}
EXPORT_SYMBOL(blk_sync_queue);

@@ -459,6 +460,8 @@ void blk_cleanup_queue(struct request_queue *q)
	if (q->elevator)
		elevator_exit(q->elevator);

	blk_throtl_exit(q);

	blk_put_queue(q);
}
EXPORT_SYMBOL(blk_cleanup_queue);
@@ -515,6 +518,11 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
		return NULL;
	}

	if (blk_throtl_init(q)) {
		kmem_cache_free(blk_requestq_cachep, q);
		return NULL;
	}

	setup_timer(&q->backing_dev_info.laptop_mode_wb_timer,
		    laptop_mode_timer_fn, (unsigned long) q);
	init_timer(&q->unplug_timer);
@@ -1522,6 +1530,15 @@ static inline void __generic_make_request(struct bio *bio)
			goto end_io;
		}

		blk_throtl_bio(q, &bio);

		/*
		 * If bio = NULL, bio has been throttled and will be submitted
		 * later.
		 */
		if (!bio)
			break;

		trace_block_bio_queue(q, bio);

		ret = q->make_request_fn(q, bio);
@@ -2580,6 +2597,13 @@ int kblockd_schedule_work(struct request_queue *q, struct work_struct *work)
}
EXPORT_SYMBOL(kblockd_schedule_work);

int kblockd_schedule_delayed_work(struct request_queue *q,
			struct delayed_work *dwork, unsigned long delay)
{
	return queue_delayed_work(kblockd_workqueue, dwork, delay);
}
EXPORT_SYMBOL(kblockd_schedule_delayed_work);

int __init blk_dev_init(void)
{
	BUILD_BUG_ON(__REQ_NR_BITS > 8 *

block/blk-throttle.c

0 → 100644
+909 −0

File added.

Preview size limit exceeded, changes collapsed.

+3 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading