Blame view

include/linux/iocontext.h 2.01 KB
fd0928df9   Jens Axboe   ioprio: move io p...
1
2
  #ifndef IOCONTEXT_H
  #define IOCONTEXT_H
4ac845a2e   Jens Axboe   block: cfq: make ...
3
  #include <linux/radix-tree.h>
34e6bbf23   Fabio Checconi   cfq-iosched: fix ...
4
  #include <linux/rcupdate.h>
4ac845a2e   Jens Axboe   block: cfq: make ...
5

fd0928df9   Jens Axboe   ioprio: move io p...
6
  struct cfq_queue;
383cd7213   Shaohua Li   CFQ: move think t...
7
8
9
10
11
12
13
  struct cfq_ttime {
  	unsigned long last_end_request;
  
  	unsigned long ttime_total;
  	unsigned long ttime_samples;
  	unsigned long ttime_mean;
  };
dc86900e0   Tejun Heo   block, cfq: move ...
14
15
16
17
  enum {
  	CIC_IOPRIO_CHANGED,
  	CIC_CGROUP_CHANGED,
  };
fd0928df9   Jens Axboe   ioprio: move io p...
18
  struct cfq_io_context {
fd0928df9   Jens Axboe   ioprio: move io p...
19
  	void *key;
283287a52   Tejun Heo   block, cfq: misc ...
20
  	struct request_queue *q;
fd0928df9   Jens Axboe   ioprio: move io p...
21
22
23
24
  
  	struct cfq_queue *cfqq[2];
  
  	struct io_context *ioc;
383cd7213   Shaohua Li   CFQ: move think t...
25
  	struct cfq_ttime ttime;
fd0928df9   Jens Axboe   ioprio: move io p...
26

fd0928df9   Jens Axboe   ioprio: move io p...
27
  	struct list_head queue_list;
ffc4e7595   Jens Axboe   cfq-iosched: add ...
28
  	struct hlist_node cic_list;
fd0928df9   Jens Axboe   ioprio: move io p...
29

dc86900e0   Tejun Heo   block, cfq: move ...
30
  	unsigned long changed;
fd0928df9   Jens Axboe   ioprio: move io p...
31
32
  	void (*dtor)(struct io_context *); /* destructor */
  	void (*exit)(struct io_context *); /* called on task exit */
34e6bbf23   Fabio Checconi   cfq-iosched: fix ...
33
34
  
  	struct rcu_head rcu_head;
fd0928df9   Jens Axboe   ioprio: move io p...
35
36
37
  };
  
  /*
d38ecf935   Jens Axboe   io context sharin...
38
39
   * I/O subsystem state of the associated processes.  It is refcounted
   * and kmalloc'ed. These could be shared between processes.
fd0928df9   Jens Axboe   ioprio: move io p...
40
41
   */
  struct io_context {
d9c7d394a   Nikanth Karthikesan   block: prevent po...
42
  	atomic_long_t refcount;
d38ecf935   Jens Axboe   io context sharin...
43
44
45
46
  	atomic_t nr_tasks;
  
  	/* all the fields below are protected by this lock */
  	spinlock_t lock;
fd0928df9   Jens Axboe   ioprio: move io p...
47
48
  
  	unsigned short ioprio;
31e4c28d9   Vivek Goyal   blkio: Introduce ...
49

fd0928df9   Jens Axboe   ioprio: move io p...
50
51
52
  	/*
  	 * For request batching
  	 */
fd0928df9   Jens Axboe   ioprio: move io p...
53
  	int nr_batch_requests;     /* Number of requests left in the batch */
58c24a616   Richard Kennedy   block: remove pad...
54
  	unsigned long last_waited; /* Time last woken after wait for request */
fd0928df9   Jens Axboe   ioprio: move io p...
55

4ac845a2e   Jens Axboe   block: cfq: make ...
56
  	struct radix_tree_root radix_root;
ffc4e7595   Jens Axboe   cfq-iosched: add ...
57
  	struct hlist_head cic_list;
4d2deb40b   Arnd Bergmann   kernel: __rcu ann...
58
  	void __rcu *ioc_data;
fd0928df9   Jens Axboe   ioprio: move io p...
59
  };
d38ecf935   Jens Axboe   io context sharin...
60
61
62
63
64
65
  static inline struct io_context *ioc_task_link(struct io_context *ioc)
  {
  	/*
  	 * if ref count is zero, don't allow sharing (ioc is going away, it's
  	 * a race).
  	 */
d9c7d394a   Nikanth Karthikesan   block: prevent po...
66
  	if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
cbb4f2646   Li Zefan   io context: fix r...
67
  		atomic_inc(&ioc->nr_tasks);
d38ecf935   Jens Axboe   io context sharin...
68
  		return ioc;
d237e5c7c   Jens Axboe   io context: incre...
69
  	}
d38ecf935   Jens Axboe   io context sharin...
70
71
72
  
  	return NULL;
  }
b69f22920   Louis Rilling   block: Fix io_con...
73
  struct task_struct;
da9cbc873   Jens Axboe   block: blkdev.h c...
74
  #ifdef CONFIG_BLOCK
42ec57a8f   Tejun Heo   block: misc ioc c...
75
  void put_io_context(struct io_context *ioc);
b69f22920   Louis Rilling   block: Fix io_con...
76
  void exit_io_context(struct task_struct *task);
6e736be7f   Tejun Heo   block: make ioc g...
77
78
  struct io_context *get_task_io_context(struct task_struct *task,
  				       gfp_t gfp_flags, int node);
dc86900e0   Tejun Heo   block, cfq: move ...
79
80
  void ioc_ioprio_changed(struct io_context *ioc, int ioprio);
  void ioc_cgroup_changed(struct io_context *ioc);
da9cbc873   Jens Axboe   block: blkdev.h c...
81
  #else
da9cbc873   Jens Axboe   block: blkdev.h c...
82
  struct io_context;
42ec57a8f   Tejun Heo   block: misc ioc c...
83
84
  static inline void put_io_context(struct io_context *ioc) { }
  static inline void exit_io_context(struct task_struct *task) { }
da9cbc873   Jens Axboe   block: blkdev.h c...
85
  #endif
fd0928df9   Jens Axboe   ioprio: move io p...
86
  #endif