Skip to content

Commit

Permalink
blkcg: style cleanups for blk-cgroup.h
Browse files Browse the repository at this point in the history
* Update indentation on struct field declarations.

* Uniformly don't use "extern" on function declarations.

* Merge the two #ifdef CONFIG_BLK_CGROUP blocks.

All changes in this patch are cosmetic.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Vivek Goyal <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
htejun authored and axboe committed Apr 20, 2012
1 parent 54e7ed1 commit 36558c8
Showing 1 changed file with 52 additions and 56 deletions.
108 changes: 52 additions & 56 deletions block/blk-cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ enum blkg_rwstat_type {
};

struct blkio_cgroup {
struct cgroup_subsys_state css;
spinlock_t lock;
struct hlist_head blkg_list;
struct cgroup_subsys_state css;
spinlock_t lock;
struct hlist_head blkg_list;

/* for policies to test whether associated blkcg has changed */
uint64_t id;
uint64_t id;

/* TODO: per-policy storage in blkio_cgroup */
unsigned int cfq_weight; /* belongs to cfq */
unsigned int cfq_weight; /* belongs to cfq */
};

struct blkg_stat {
Expand All @@ -62,57 +62,67 @@ struct blkg_rwstat {
/* per-blkg per-policy data */
struct blkg_policy_data {
/* the blkg this per-policy data belongs to */
struct blkio_group *blkg;
struct blkio_group *blkg;

/* used during policy activation */
struct list_head alloc_node;
struct list_head alloc_node;

/* pol->pdata_size bytes of private data used by policy impl */
char pdata[] __aligned(__alignof__(unsigned long long));
char pdata[] __aligned(__alignof__(unsigned long long));
};

struct blkio_group {
/* Pointer to the associated request_queue */
struct request_queue *q;
struct list_head q_node;
struct hlist_node blkcg_node;
struct blkio_cgroup *blkcg;
struct request_queue *q;
struct list_head q_node;
struct hlist_node blkcg_node;
struct blkio_cgroup *blkcg;
/* reference count */
int refcnt;
int refcnt;

struct blkg_policy_data *pd[BLKCG_MAX_POLS];
struct blkg_policy_data *pd[BLKCG_MAX_POLS];

struct rcu_head rcu_head;
struct rcu_head rcu_head;
};

typedef void (blkio_init_group_fn)(struct blkio_group *blkg);
typedef void (blkio_exit_group_fn)(struct blkio_group *blkg);
typedef void (blkio_reset_group_stats_fn)(struct blkio_group *blkg);

struct blkio_policy_ops {
blkio_init_group_fn *blkio_init_group_fn;
blkio_exit_group_fn *blkio_exit_group_fn;
blkio_reset_group_stats_fn *blkio_reset_group_stats_fn;
blkio_init_group_fn *blkio_init_group_fn;
blkio_exit_group_fn *blkio_exit_group_fn;
blkio_reset_group_stats_fn *blkio_reset_group_stats_fn;
};

struct blkio_policy_type {
struct blkio_policy_ops ops;
int plid;
size_t pdata_size; /* policy specific private data size */
struct cftype *cftypes; /* cgroup files for the policy */
struct blkio_policy_ops ops;
int plid;
/* policy specific private data size */
size_t pdata_size;
/* cgroup files for the policy */
struct cftype *cftypes;
};

extern int blkcg_init_queue(struct request_queue *q);
extern void blkcg_drain_queue(struct request_queue *q);
extern void blkcg_exit_queue(struct request_queue *q);
extern struct blkio_cgroup blkio_root_cgroup;

struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio);
struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
struct request_queue *q);
struct blkio_group *blkg_lookup_create(struct blkio_cgroup *blkcg,
struct request_queue *q);
int blkcg_init_queue(struct request_queue *q);
void blkcg_drain_queue(struct request_queue *q);
void blkcg_exit_queue(struct request_queue *q);

/* Blkio controller policy registration */
extern int blkio_policy_register(struct blkio_policy_type *);
extern void blkio_policy_unregister(struct blkio_policy_type *);
extern int blkcg_activate_policy(struct request_queue *q,
const struct blkio_policy_type *pol);
extern void blkcg_deactivate_policy(struct request_queue *q,
const struct blkio_policy_type *pol);
int blkio_policy_register(struct blkio_policy_type *);
void blkio_policy_unregister(struct blkio_policy_type *);
int blkcg_activate_policy(struct request_queue *q,
const struct blkio_policy_type *pol);
void blkcg_deactivate_policy(struct request_queue *q,
const struct blkio_policy_type *pol);

void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
u64 (*prfill)(struct seq_file *, void *, int),
Expand All @@ -125,9 +135,9 @@ u64 blkg_prfill_stat(struct seq_file *sf, void *pdata, int off);
u64 blkg_prfill_rwstat(struct seq_file *sf, void *pdata, int off);

struct blkg_conf_ctx {
struct gendisk *disk;
struct blkio_group *blkg;
u64 v;
struct gendisk *disk;
struct blkio_group *blkg;
u64 v;
};

int blkg_conf_prep(struct blkio_cgroup *blkcg,
Expand Down Expand Up @@ -329,14 +339,19 @@ static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
memset(rwstat->cnt, 0, sizeof(rwstat->cnt));
}

#else
#else /* CONFIG_BLK_CGROUP */

struct cgroup;

struct blkio_group {
};

struct blkio_policy_type {
};

static inline struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
static inline struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio) { return NULL; }
static inline struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg, void *key) { return NULL; }
static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
static inline void blkcg_drain_queue(struct request_queue *q) { }
static inline void blkcg_exit_queue(struct request_queue *q) { }
Expand All @@ -355,24 +370,5 @@ static inline char *blkg_path(struct blkio_group *blkg) { return NULL; }
static inline void blkg_get(struct blkio_group *blkg) { }
static inline void blkg_put(struct blkio_group *blkg) { }

#endif

#ifdef CONFIG_BLK_CGROUP
extern struct blkio_cgroup blkio_root_cgroup;
extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
extern struct blkio_cgroup *bio_blkio_cgroup(struct bio *bio);
extern struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
struct request_queue *q);
struct blkio_group *blkg_lookup_create(struct blkio_cgroup *blkcg,
struct request_queue *q);
#else
struct cgroup;
static inline struct blkio_cgroup *
cgroup_to_blkio_cgroup(struct cgroup *cgroup) { return NULL; }
static inline struct blkio_cgroup *
bio_blkio_cgroup(struct bio *bio) { return NULL; }

static inline struct blkio_group *blkg_lookup(struct blkio_cgroup *blkcg,
void *key) { return NULL; }
#endif
#endif /* _BLK_CGROUP_H */
#endif /* CONFIG_BLK_CGROUP */
#endif /* _BLK_CGROUP_H */

0 comments on commit 36558c8

Please sign in to comment.