block/blk-throttle.h

Source file repositories/reference/linux-study-clean/block/blk-throttle.h

File Facts

System
Linux kernel
Corpus path
block/blk-throttle.h
Extension
.h
Size
6597 bytes
Lines
210
Domain
Representative Device Path
Bucket
PCIe NVMe Storage Path
Inferred role
Representative Device Path: implementation source
Status
source implementation candidate

Why This File Exists

Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.

Dependency Surface

Detected Declarations

Annotated Snippet

struct throtl_qnode {
	struct list_head	node;		/* service_queue->queued[] */
	struct bio_list		bios_bps;	/* queued bios for bps limit */
	struct bio_list		bios_iops;	/* queued bios for iops limit */
	struct throtl_grp	*tg;		/* tg this qnode belongs to */
};

struct throtl_service_queue {
	struct throtl_service_queue *parent_sq;	/* the parent service_queue */

	/*
	 * Bios queued directly to this service_queue or dispatched from
	 * children throtl_grp's.
	 */
	struct list_head	queued[2];	/* throtl_qnode [READ/WRITE] */
	unsigned int		nr_queued_bps[2];	/* number of queued bps bios */
	unsigned int		nr_queued_iops[2];	/* number of queued iops bios */

	/*
	 * RB tree of active children throtl_grp's, which are sorted by
	 * their ->disptime.
	 */
	struct rb_root_cached	pending_tree;	/* RB tree of active tgs */
	unsigned int		nr_pending;	/* # queued in the tree */
	unsigned long		first_pending_disptime;	/* disptime of the first tg */
	struct timer_list	pending_timer;	/* fires on first_pending_disptime */
};

enum tg_state_flags {
	THROTL_TG_PENDING		= 1 << 0,	/* on parent's pending tree */
	THROTL_TG_WAS_EMPTY		= 1 << 1,	/* bio_lists[] became non-empty */
	/*
	 * The sq's iops queue is empty, and a bio is about to be enqueued
	 * to the first qnode's bios_iops list.
	 */
	THROTL_TG_IOPS_WAS_EMPTY	= 1 << 2,
	THROTL_TG_CANCELING		= 1 << 3,	/* starts to cancel bio */
};

struct throtl_grp {
	/* must be the first member */
	struct blkg_policy_data pd;

	/* active throtl group service_queue member */
	struct rb_node rb_node;

	/* throtl_data this group belongs to */
	struct throtl_data *td;

	/* this group's service queue */
	struct throtl_service_queue service_queue;

	/*
	 * qnode_on_self is used when bios are directly queued to this
	 * throtl_grp so that local bios compete fairly with bios
	 * dispatched from children.  qnode_on_parent is used when bios are
	 * dispatched from this throtl_grp into its parent and will compete
	 * with the sibling qnode_on_parents and the parent's
	 * qnode_on_self.
	 */
	struct throtl_qnode qnode_on_self[2];
	struct throtl_qnode qnode_on_parent[2];

	/*
	 * Dispatch time in jiffies. This is the estimated time when group
	 * will unthrottle and is ready to dispatch more bio. It is used as
	 * key to sort active groups in service tree.
	 */
	unsigned long disptime;

	unsigned int flags;

	/* are there any throtl rules between this group and td? */
	bool has_rules_bps[2];
	bool has_rules_iops[2];

	/* bytes per second rate limits */
	uint64_t bps[2];

	/* IOPS limits */
	unsigned int iops[2];

	/*
	 * Number of bytes/bio's dispatched in current slice.
	 * When new configuration is submitted while some bios are still throttled,
	 * first calculate the carryover: the amount of bytes/IOs already waited
	 * under the previous configuration. Then, [bytes/io]_disp are represented
	 * as the negative of the carryover, and they will be used to calculate the
	 * wait time under the new configuration.
	 */

Annotation

Implementation Notes