Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
blk-cgroup.c File Reference
#include <linux/ioprio.h>
#include <linux/kdev_t.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/blkdev.h>
#include <linux/slab.h>
#include <linux/genhd.h>
#include <linux/delay.h>
#include <linux/atomic.h>
#include "blk-cgroup.h"
#include "blk.h"

Go to the source code of this file.

Macros

#define MAX_KEY_LEN   100
 

Functions

 EXPORT_SYMBOL_GPL (blkcg_root)
 
struct blkcg_gqblkg_lookup (struct blkcg *blkcg, struct request_queue *q)
 
 EXPORT_SYMBOL_GPL (blkg_lookup)
 
struct blkcg_gqblkg_lookup_create (struct blkcg *blkcg, struct request_queue *q)
 
 EXPORT_SYMBOL_GPL (blkg_lookup_create)
 
void __blkg_release (struct blkcg_gq *blkg)
 
 EXPORT_SYMBOL_GPL (__blkg_release)
 
struct request_list * __blk_queue_next_rl (struct request_list *rl, struct request_queue *q)
 
void blkcg_print_blkgs (struct seq_file *sf, struct blkcg *blkcg, u64(*prfill)(struct seq_file *, struct blkg_policy_data *, int), const struct blkcg_policy *pol, int data, bool show_total)
 
 EXPORT_SYMBOL_GPL (blkcg_print_blkgs)
 
u64 __blkg_prfill_u64 (struct seq_file *sf, struct blkg_policy_data *pd, u64 v)
 
 EXPORT_SYMBOL_GPL (__blkg_prfill_u64)
 
u64 __blkg_prfill_rwstat (struct seq_file *sf, struct blkg_policy_data *pd, const struct blkg_rwstat *rwstat)
 
u64 blkg_prfill_stat (struct seq_file *sf, struct blkg_policy_data *pd, int off)
 
 EXPORT_SYMBOL_GPL (blkg_prfill_stat)
 
u64 blkg_prfill_rwstat (struct seq_file *sf, struct blkg_policy_data *pd, int off)
 
 EXPORT_SYMBOL_GPL (blkg_prfill_rwstat)
 
int blkg_conf_prep (struct blkcg *blkcg, const struct blkcg_policy *pol, const char *input, struct blkg_conf_ctx *ctx) __acquires(rcu) __acquires(disk-> queue->queue_lock)
 
 EXPORT_SYMBOL_GPL (blkg_conf_prep)
 
void blkg_conf_finish (struct blkg_conf_ctx *ctx) __releases(ctx-> disk->queue->queue_lock) __releases(rcu)
 
 EXPORT_SYMBOL_GPL (blkg_conf_finish)
 
int blkcg_init_queue (struct request_queue *q)
 
void blkcg_drain_queue (struct request_queue *q)
 
void blkcg_exit_queue (struct request_queue *q)
 
 EXPORT_SYMBOL_GPL (blkio_subsys)
 
int blkcg_activate_policy (struct request_queue *q, const struct blkcg_policy *pol)
 
 EXPORT_SYMBOL_GPL (blkcg_activate_policy)
 
void blkcg_deactivate_policy (struct request_queue *q, const struct blkcg_policy *pol)
 
 EXPORT_SYMBOL_GPL (blkcg_deactivate_policy)
 
int blkcg_policy_register (struct blkcg_policy *pol)
 
 EXPORT_SYMBOL_GPL (blkcg_policy_register)
 
void blkcg_policy_unregister (struct blkcg_policy *pol)
 
 EXPORT_SYMBOL_GPL (blkcg_policy_unregister)
 

Variables

struct blkcg blkcg_root = { .cfq_weight = 2 * CFQ_WEIGHT_DEFAULT }
 
struct cftype blkcg_files []
 
struct cgroup_subsys blkio_subsys
 

Macro Definition Documentation

#define MAX_KEY_LEN   100

Definition at line 25 of file blk-cgroup.c.

Function Documentation

struct request_list* __blk_queue_next_rl ( struct request_list *  rl,
struct request_queue q 
)
read

Definition at line 324 of file blk-cgroup.c.

u64 __blkg_prfill_rwstat ( struct seq_file sf,
struct blkg_policy_data pd,
const struct blkg_rwstat *  rwstat 
)

__blkg_prfill_rwstat - prfill helper for a blkg_rwstat : seq_file to print to : policy private data of interest : rwstat to print

Print to for the device assocaited with .

Definition at line 460 of file blk-cgroup.c.

u64 __blkg_prfill_u64 ( struct seq_file sf,
struct blkg_policy_data pd,
u64  v 
)

__blkg_prfill_u64 - prfill helper for a single u64 value : seq_file to print to : policy private data of interest : value to print

Print to for the device assocaited with .

Definition at line 440 of file blk-cgroup.c.

void __blkg_release ( struct blkcg_gq blkg)

Definition at line 302 of file blk-cgroup.c.

int blkcg_activate_policy ( struct request_queue q,
const struct blkcg_policy pol 
)

blkcg_activate_policy - activate a blkcg policy on a request_queue : request_queue of interest : blkcg policy to activate

Activate on . Requires GFP_KERNEL context. goes through bypass mode to populate its blkgs with policy_data for .

Activation happens with bypassed, so nobody would be accessing blkgs from IO path. Update of each blkg is protected by both queue and blkcg locks so that holding either lock and testing blkcg_policy_enabled() is always enough for dereferencing policy data.

The caller is responsible for synchronizing [de]activations and policy [un]registerations. Returns 0 on success, -errno on failure.

Definition at line 777 of file blk-cgroup.c.

void blkcg_deactivate_policy ( struct request_queue q,
const struct blkcg_policy pol 
)

blkcg_deactivate_policy - deactivate a blkcg policy on a request_queue : request_queue of interest : blkcg policy to deactivate

Deactivate on . Follows the same synchronization rules as blkcg_activate_policy().

Definition at line 875 of file blk-cgroup.c.

void blkcg_drain_queue ( struct request_queue q)

blkcg_drain_queue - drain blkcg part of request_queue : request_queue to drain

Called from blk_drain_queue(). Responsible for draining blkcg part.

Definition at line 694 of file blk-cgroup.c.

void blkcg_exit_queue ( struct request_queue q)

blkcg_exit_queue - exit and release blkcg part of request_queue : request_queue being released

Called from blk_release_queue(). Responsible for exiting blkcg part.

Definition at line 707 of file blk-cgroup.c.

int blkcg_init_queue ( struct request_queue q)

blkcg_init_queue - initialize blkcg part of request queue : request_queue to initialize

Called from blk_alloc_queue_node(). Responsible for initializing blkcg part of new request_queue .

RETURNS: 0 on success, -errno on failure.

Definition at line 681 of file blk-cgroup.c.

int blkcg_policy_register ( struct blkcg_policy pol)

blkcg_policy_register - register a blkcg policy : blkcg policy to register

Register with blkcg core. Might sleep and may be modified on successful registration. Returns 0 on success and -errno on failure.

Definition at line 917 of file blk-cgroup.c.

void blkcg_policy_unregister ( struct blkcg_policy pol)

blkcg_policy_unregister - unregister a blkcg policy : blkcg policy to unregister

Undo blkcg_policy_register(). Might sleep.

Definition at line 954 of file blk-cgroup.c.

void blkcg_print_blkgs ( struct seq_file sf,
struct blkcg *  blkcg,
u64(*)(struct seq_file *, struct blkg_policy_data *, int prfill,
const struct blkcg_policy pol,
int  data,
bool  show_total 
)

blkcg_print_blkgs - helper for printing per-blkg data : seq_file to print to : blkcg of interest : fill function to print out a blkg : policy in question : data to be passed to : to print out sum of prfill return values or not

This function invokes on each blkg of if pd for the policy specified by exists. is invoked with , the policy data and . If is true, the sum of the return values from is printed with "Total" label at the end.

This is to be used to construct print functions for cftype->read_seq_string method.

Definition at line 411 of file blk-cgroup.c.

void blkg_conf_finish ( struct blkg_conf_ctx *  ctx) -> disk->queue->queue_lock) __releases(rcu)

blkg_conf_finish - finish up per-blkg config update : blkg_conf_ctx intiailized by blkg_conf_prep()

Finish up after per-blkg config update. This function must be paired with blkg_conf_prep().

Definition at line 585 of file blk-cgroup.c.

int blkg_conf_prep ( struct blkcg *  blkcg,
const struct blkcg_policy pol,
const char input,
struct blkg_conf_ctx *  ctx 
) -> queue->queue_lock)

blkg_conf_prep - parse and prepare for per-blkg config update : target block cgroup : target policy : input string : blkg_conf_ctx to be filled

Parse per-blkg config update from and initialize with the result. ->blkg points to the blkg to be updated and ->v the new value. This function returns with RCU read lock and queue lock held and must be paired with blkg_conf_finish().

Definition at line 528 of file blk-cgroup.c.

struct blkcg_gq* blkg_lookup ( struct blkcg *  blkcg,
struct request_queue q 
)
read

blkg_lookup - lookup blkg for the specified blkcg - q pair : blkcg of interest : request_queue of interest

Lookup blkg for the - pair. This function should be called under RCU read lock and is guaranteed to return NULL if is bypassing

Definition at line 159 of file blk-cgroup.c.

struct blkcg_gq* blkg_lookup_create ( struct blkcg *  blkcg,
struct request_queue q 
)
read

Definition at line 226 of file blk-cgroup.c.

u64 blkg_prfill_rwstat ( struct seq_file sf,
struct blkg_policy_data pd,
int  off 
)

blkg_prfill_rwstat - prfill callback for blkg_rwstat : seq_file to print to : policy private data of interest : offset to the blkg_rwstat in

prfill callback for printing a blkg_rwstat.

Definition at line 507 of file blk-cgroup.c.

u64 blkg_prfill_stat ( struct seq_file sf,
struct blkg_policy_data pd,
int  off 
)

blkg_prfill_stat - prfill callback for blkg_stat : seq_file to print to : policy private data of interest : offset to the blkg_stat in

prfill callback for printing a blkg_stat.

Definition at line 493 of file blk-cgroup.c.

EXPORT_SYMBOL_GPL ( blkcg_root  )
EXPORT_SYMBOL_GPL ( blkg_lookup  )
EXPORT_SYMBOL_GPL ( blkg_lookup_create  )
EXPORT_SYMBOL_GPL ( __blkg_release  )
EXPORT_SYMBOL_GPL ( blkcg_print_blkgs  )
EXPORT_SYMBOL_GPL ( __blkg_prfill_u64  )
EXPORT_SYMBOL_GPL ( blkg_prfill_stat  )
EXPORT_SYMBOL_GPL ( blkg_prfill_rwstat  )
EXPORT_SYMBOL_GPL ( blkg_conf_prep  )
EXPORT_SYMBOL_GPL ( blkg_conf_finish  )
EXPORT_SYMBOL_GPL ( blkio_subsys  )
EXPORT_SYMBOL_GPL ( blkcg_activate_policy  )
EXPORT_SYMBOL_GPL ( blkcg_deactivate_policy  )
EXPORT_SYMBOL_GPL ( blkcg_policy_register  )
EXPORT_SYMBOL_GPL ( blkcg_policy_unregister  )

Variable Documentation

struct cftype blkcg_files[]
Initial value:
= {
{
.name = "reset_stats",
.write_u64 = blkcg_reset_stats,
},
{ }
}

Definition at line 594 of file blk-cgroup.c.

struct blkcg blkcg_root = { .cfq_weight = 2 * CFQ_WEIGHT_DEFAULT }

Definition at line 29 of file blk-cgroup.c.

struct cgroup_subsys blkio_subsys
Initial value:
= {
.name = "blkio",
.create = blkcg_create,
.can_attach = blkcg_can_attach,
.pre_destroy = blkcg_pre_destroy,
.destroy = blkcg_destroy,
.subsys_id = blkio_subsys_id,
.base_cftypes = blkcg_files,
.module = THIS_MODULE,
.broken_hierarchy = true,
}

Definition at line 741 of file blk-cgroup.c.