]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/linux/iocontext.h
block, cfq: misc updates to cfq_io_context
[mirror_ubuntu-eoan-kernel.git] / include / linux / iocontext.h
CommitLineData
fd0928df
JA
1#ifndef IOCONTEXT_H
2#define IOCONTEXT_H
3
4ac845a2 4#include <linux/radix-tree.h>
34e6bbf2 5#include <linux/rcupdate.h>
4ac845a2 6
fd0928df 7struct cfq_queue;
383cd721
SL
8struct cfq_ttime {
9 unsigned long last_end_request;
10
11 unsigned long ttime_total;
12 unsigned long ttime_samples;
13 unsigned long ttime_mean;
14};
15
fd0928df 16struct cfq_io_context {
fd0928df 17 void *key;
283287a5 18 struct request_queue *q;
fd0928df
JA
19
20 struct cfq_queue *cfqq[2];
21
22 struct io_context *ioc;
23
383cd721 24 struct cfq_ttime ttime;
fd0928df 25
fd0928df 26 struct list_head queue_list;
ffc4e759 27 struct hlist_node cic_list;
fd0928df
JA
28
29 void (*dtor)(struct io_context *); /* destructor */
30 void (*exit)(struct io_context *); /* called on task exit */
34e6bbf2
FC
31
32 struct rcu_head rcu_head;
fd0928df
JA
33};
34
35/*
d38ecf93
JA
36 * I/O subsystem state of the associated processes. It is refcounted
37 * and kmalloc'ed. These could be shared between processes.
fd0928df
JA
38 */
39struct io_context {
d9c7d394 40 atomic_long_t refcount;
d38ecf93
JA
41 atomic_t nr_tasks;
42
43 /* all the fields below are protected by this lock */
44 spinlock_t lock;
fd0928df
JA
45
46 unsigned short ioprio;
47 unsigned short ioprio_changed;
48
67523c48 49#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
31e4c28d
VG
50 unsigned short cgroup_changed;
51#endif
52
fd0928df
JA
53 /*
54 * For request batching
55 */
fd0928df 56 int nr_batch_requests; /* Number of requests left in the batch */
58c24a61 57 unsigned long last_waited; /* Time last woken after wait for request */
fd0928df 58
4ac845a2 59 struct radix_tree_root radix_root;
ffc4e759 60 struct hlist_head cic_list;
4d2deb40 61 void __rcu *ioc_data;
fd0928df
JA
62};
63
d38ecf93
JA
64static inline struct io_context *ioc_task_link(struct io_context *ioc)
65{
66 /*
67 * if ref count is zero, don't allow sharing (ioc is going away, it's
68 * a race).
69 */
d9c7d394 70 if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
cbb4f264 71 atomic_inc(&ioc->nr_tasks);
d38ecf93 72 return ioc;
d237e5c7 73 }
d38ecf93
JA
74
75 return NULL;
76}
77
b69f2292 78struct task_struct;
da9cbc87 79#ifdef CONFIG_BLOCK
42ec57a8 80void put_io_context(struct io_context *ioc);
b69f2292 81void exit_io_context(struct task_struct *task);
6e736be7
TH
82struct io_context *get_task_io_context(struct task_struct *task,
83 gfp_t gfp_flags, int node);
da9cbc87 84#else
da9cbc87 85struct io_context;
42ec57a8
TH
86static inline void put_io_context(struct io_context *ioc) { }
87static inline void exit_io_context(struct task_struct *task) { }
da9cbc87
JA
88#endif
89
fd0928df 90#endif