mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
dec223c92a
There is no real need to expose the blkcg structure to the whole kernel. Move it to the private header an expose a helper to let the writeback code access the cgwb_list member. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20220420042723.1010598-8-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
134 lines
3.4 KiB
C
134 lines
3.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _BLK_CGROUP_H
|
|
#define _BLK_CGROUP_H
|
|
/*
|
|
* Common Block IO controller cgroup interface
|
|
*
|
|
* Based on ideas and code from CFQ, CFS and BFQ:
|
|
* Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
|
|
*
|
|
* Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
|
|
* Paolo Valente <paolo.valente@unimore.it>
|
|
*
|
|
* Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
|
|
* Nauman Rafique <nauman@google.com>
|
|
*/
|
|
|
|
#include <linux/cgroup.h>
|
|
#include <linux/percpu.h>
|
|
#include <linux/percpu_counter.h>
|
|
#include <linux/u64_stats_sync.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/radix-tree.h>
|
|
#include <linux/blkdev.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/kthread.h>
|
|
#include <linux/fs.h>
|
|
|
|
#define FC_APPID_LEN 129
|
|
|
|
#ifdef CONFIG_BLK_CGROUP
|
|
|
|
enum blkg_iostat_type {
|
|
BLKG_IOSTAT_READ,
|
|
BLKG_IOSTAT_WRITE,
|
|
BLKG_IOSTAT_DISCARD,
|
|
|
|
BLKG_IOSTAT_NR,
|
|
};
|
|
|
|
struct blkg_iostat {
|
|
u64 bytes[BLKG_IOSTAT_NR];
|
|
u64 ios[BLKG_IOSTAT_NR];
|
|
};
|
|
|
|
struct blkg_iostat_set {
|
|
struct u64_stats_sync sync;
|
|
struct blkg_iostat cur;
|
|
struct blkg_iostat last;
|
|
};
|
|
|
|
/* association between a blk cgroup and a request queue */
|
|
struct blkcg_gq {
|
|
/* Pointer to the associated request_queue */
|
|
struct request_queue *q;
|
|
struct list_head q_node;
|
|
struct hlist_node blkcg_node;
|
|
struct blkcg *blkcg;
|
|
|
|
/* all non-root blkcg_gq's are guaranteed to have access to parent */
|
|
struct blkcg_gq *parent;
|
|
|
|
/* reference count */
|
|
struct percpu_ref refcnt;
|
|
|
|
/* is this blkg online? protected by both blkcg and q locks */
|
|
bool online;
|
|
|
|
struct blkg_iostat_set __percpu *iostat_cpu;
|
|
struct blkg_iostat_set iostat;
|
|
|
|
struct blkg_policy_data *pd[BLKCG_MAX_POLS];
|
|
|
|
spinlock_t async_bio_lock;
|
|
struct bio_list async_bios;
|
|
union {
|
|
struct work_struct async_bio_work;
|
|
struct work_struct free_work;
|
|
};
|
|
|
|
atomic_t use_delay;
|
|
atomic64_t delay_nsec;
|
|
atomic64_t delay_start;
|
|
u64 last_delay;
|
|
int last_use;
|
|
|
|
struct rcu_head rcu_head;
|
|
};
|
|
|
|
extern struct cgroup_subsys_state * const blkcg_root_css;
|
|
|
|
void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay);
|
|
void blkcg_maybe_throttle_current(void);
|
|
|
|
/**
|
|
* bio_blkcg - grab the blkcg associated with a bio
|
|
* @bio: target bio
|
|
*
|
|
* This returns the blkcg associated with a bio, %NULL if not associated.
|
|
* Callers are expected to either handle %NULL or know association has been
|
|
* done prior to calling this.
|
|
*/
|
|
static inline struct blkcg *bio_blkcg(struct bio *bio)
|
|
{
|
|
if (bio && bio->bi_blkg)
|
|
return bio->bi_blkg->blkcg;
|
|
return NULL;
|
|
}
|
|
|
|
bool blk_cgroup_congested(void);
|
|
void blkcg_pin_online(struct cgroup_subsys_state *blkcg_css);
|
|
void blkcg_unpin_online(struct cgroup_subsys_state *blkcg_css);
|
|
struct list_head *blkcg_get_cgwb_list(struct cgroup_subsys_state *css);
|
|
|
|
#else /* CONFIG_BLK_CGROUP */
|
|
|
|
struct blkcg_gq {
|
|
};
|
|
|
|
#define blkcg_root_css ((struct cgroup_subsys_state *)ERR_PTR(-EINVAL))
|
|
|
|
static inline void blkcg_maybe_throttle_current(void) { }
|
|
static inline bool blk_cgroup_congested(void) { return false; }
|
|
|
|
#ifdef CONFIG_BLOCK
|
|
static inline void blkcg_schedule_throttle(struct request_queue *q, bool use_memdelay) { }
|
|
static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; }
|
|
#endif /* CONFIG_BLOCK */
|
|
|
|
#endif /* CONFIG_BLK_CGROUP */
|
|
|
|
int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len);
|
|
char *blkcg_get_fc_appid(struct bio *bio);
|
|
|
|
#endif /* _BLK_CGROUP_H */
|