1/****************************************************************************
2 ****************************************************************************
3 ***
4 ***   This header was automatically generated from a Linux kernel header
5 ***   of the same name, to make information necessary for userspace to
6 ***   call into the kernel available to libc.  It contains only constants,
7 ***   structures, and macros generated from the original header, and thus,
8 ***   contains no copyrightable information.
9 ***
10 ****************************************************************************
11 ****************************************************************************/
12#ifndef _LINUX_BLKDEV_H
13#define _LINUX_BLKDEV_H
14
15#include <linux/major.h>
16#include <linux/genhd.h>
17#include <linux/list.h>
18#include <linux/timer.h>
19#include <linux/workqueue.h>
20#include <linux/pagemap.h>
21#include <linux/backing-dev.h>
22#include <linux/wait.h>
23#include <linux/mempool.h>
24#include <linux/bio.h>
25#include <linux/module.h>
26#include <linux/stringify.h>
27
28#include <asm/scatterlist.h>
29
30struct scsi_ioctl_command;
31
32struct request_queue;
33typedef struct request_queue request_queue_t;
34struct elevator_queue;
35typedef struct elevator_queue elevator_t;
36struct request_pm_state;
37struct blk_trace;
38
39#define BLKDEV_MIN_RQ 4
40#define BLKDEV_MAX_RQ 128
41
42struct as_io_context {
43 spinlock_t lock;
44
45 void (*dtor)(struct as_io_context *aic);
46 void (*exit)(struct as_io_context *aic);
47
48 unsigned long state;
49 atomic_t nr_queued;
50 atomic_t nr_dispatched;
51
52 unsigned long last_end_request;
53 unsigned long ttime_total;
54 unsigned long ttime_samples;
55 unsigned long ttime_mean;
56
57 unsigned int seek_samples;
58 sector_t last_request_pos;
59 u64 seek_total;
60 sector_t seek_mean;
61};
62
63struct cfq_queue;
64struct cfq_io_context {
65 struct rb_node rb_node;
66 void *key;
67
68 struct cfq_queue *cfqq[2];
69
70 struct io_context *ioc;
71
72 unsigned long last_end_request;
73 sector_t last_request_pos;
74 unsigned long last_queue;
75
76 unsigned long ttime_total;
77 unsigned long ttime_samples;
78 unsigned long ttime_mean;
79
80 unsigned int seek_samples;
81 u64 seek_total;
82 sector_t seek_mean;
83
84 struct list_head queue_list;
85
86 void (*dtor)(struct io_context *);
87 void (*exit)(struct io_context *);
88};
89
90struct io_context {
91 atomic_t refcount;
92 struct task_struct *task;
93
94 int (*set_ioprio)(struct io_context *, unsigned int);
95
96 unsigned long last_waited;
97 int nr_batch_requests;
98
99 struct as_io_context *aic;
100 struct rb_root cic_root;
101};
102
103struct io_context *current_io_context(gfp_t gfp_flags);
104struct io_context *get_io_context(gfp_t gfp_flags);
105
106struct request;
107typedef void (rq_end_io_fn)(struct request *, int);
108
109struct request_list {
110 int count[2];
111 int starved[2];
112 int elvpriv;
113 mempool_t *rq_pool;
114 wait_queue_head_t wait[2];
115};
116
117#define BLK_MAX_CDB 16
118
119struct request {
120 struct list_head queuelist;
121 struct list_head donelist;
122
123 unsigned long flags;
124
125 sector_t sector;
126 unsigned long nr_sectors;
127
128 unsigned int current_nr_sectors;
129
130 sector_t hard_sector;
131 unsigned long hard_nr_sectors;
132
133 unsigned int hard_cur_sectors;
134
135 struct bio *bio;
136 struct bio *biotail;
137
138 void *elevator_private;
139 void *completion_data;
140
141 int rq_status;
142 int errors;
143 struct gendisk *rq_disk;
144 unsigned long start_time;
145
146 unsigned short nr_phys_segments;
147
148 unsigned short nr_hw_segments;
149
150 unsigned short ioprio;
151
152 int tag;
153
154 int ref_count;
155 request_queue_t *q;
156 struct request_list *rl;
157
158 struct completion *waiting;
159 void *special;
160 char *buffer;
161
162 unsigned int cmd_len;
163 unsigned char cmd[BLK_MAX_CDB];
164
165 unsigned int data_len;
166 unsigned int sense_len;
167 void *data;
168 void *sense;
169
170 unsigned int timeout;
171 int retries;
172
173 rq_end_io_fn *end_io;
174 void *end_io_data;
175};
176
177enum rq_flag_bits {
178 __REQ_RW,
179 __REQ_FAILFAST,
180 __REQ_SORTED,
181 __REQ_SOFTBARRIER,
182 __REQ_HARDBARRIER,
183 __REQ_FUA,
184 __REQ_CMD,
185 __REQ_NOMERGE,
186 __REQ_STARTED,
187 __REQ_DONTPREP,
188 __REQ_QUEUED,
189 __REQ_ELVPRIV,
190
191 __REQ_PC,
192 __REQ_BLOCK_PC,
193 __REQ_SENSE,
194
195 __REQ_FAILED,
196 __REQ_QUIET,
197 __REQ_SPECIAL,
198 __REQ_DRIVE_CMD,
199 __REQ_DRIVE_TASK,
200 __REQ_DRIVE_TASKFILE,
201 __REQ_PREEMPT,
202 __REQ_PM_SUSPEND,
203 __REQ_PM_RESUME,
204 __REQ_PM_SHUTDOWN,
205 __REQ_ORDERED_COLOR,
206 __REQ_RW_SYNC,
207 __REQ_NR_BITS,
208};
209
210#define REQ_RW (1 << __REQ_RW)
211#define REQ_FAILFAST (1 << __REQ_FAILFAST)
212#define REQ_SORTED (1 << __REQ_SORTED)
213#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER)
214#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER)
215#define REQ_FUA (1 << __REQ_FUA)
216#define REQ_CMD (1 << __REQ_CMD)
217#define REQ_NOMERGE (1 << __REQ_NOMERGE)
218#define REQ_STARTED (1 << __REQ_STARTED)
219#define REQ_DONTPREP (1 << __REQ_DONTPREP)
220#define REQ_QUEUED (1 << __REQ_QUEUED)
221#define REQ_ELVPRIV (1 << __REQ_ELVPRIV)
222#define REQ_PC (1 << __REQ_PC)
223#define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC)
224#define REQ_SENSE (1 << __REQ_SENSE)
225#define REQ_FAILED (1 << __REQ_FAILED)
226#define REQ_QUIET (1 << __REQ_QUIET)
227#define REQ_SPECIAL (1 << __REQ_SPECIAL)
228#define REQ_DRIVE_CMD (1 << __REQ_DRIVE_CMD)
229#define REQ_DRIVE_TASK (1 << __REQ_DRIVE_TASK)
230#define REQ_DRIVE_TASKFILE (1 << __REQ_DRIVE_TASKFILE)
231#define REQ_PREEMPT (1 << __REQ_PREEMPT)
232#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND)
233#define REQ_PM_RESUME (1 << __REQ_PM_RESUME)
234#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN)
235#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR)
236#define REQ_RW_SYNC (1 << __REQ_RW_SYNC)
237
238struct request_pm_state
239{
240
241 int pm_step;
242
243 u32 pm_state;
244 void* data;
245};
246
247#include <linux/elevator.h>
248
249typedef int (merge_request_fn) (request_queue_t *, struct request *,
250 struct bio *);
251typedef int (merge_requests_fn) (request_queue_t *, struct request *,
252 struct request *);
253typedef void (request_fn_proc) (request_queue_t *q);
254typedef int (make_request_fn) (request_queue_t *q, struct bio *bio);
255typedef int (prep_rq_fn) (request_queue_t *, struct request *);
256typedef void (unplug_fn) (request_queue_t *);
257
258struct bio_vec;
259typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *);
260typedef void (activity_fn) (void *data, int rw);
261typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *);
262typedef void (prepare_flush_fn) (request_queue_t *, struct request *);
263typedef void (softirq_done_fn)(struct request *);
264
265enum blk_queue_state {
266 Queue_down,
267 Queue_up,
268};
269
270struct blk_queue_tag {
271 struct request **tag_index;
272 unsigned long *tag_map;
273 struct list_head busy_list;
274 int busy;
275 int max_depth;
276 int real_max_depth;
277 atomic_t refcnt;
278};
279
280struct request_queue
281{
282
283 struct list_head queue_head;
284 struct request *last_merge;
285 elevator_t *elevator;
286
287 struct request_list rq;
288
289 request_fn_proc *request_fn;
290 merge_request_fn *back_merge_fn;
291 merge_request_fn *front_merge_fn;
292 merge_requests_fn *merge_requests_fn;
293 make_request_fn *make_request_fn;
294 prep_rq_fn *prep_rq_fn;
295 unplug_fn *unplug_fn;
296 merge_bvec_fn *merge_bvec_fn;
297 activity_fn *activity_fn;
298 issue_flush_fn *issue_flush_fn;
299 prepare_flush_fn *prepare_flush_fn;
300 softirq_done_fn *softirq_done_fn;
301
302 sector_t end_sector;
303 struct request *boundary_rq;
304
305 struct timer_list unplug_timer;
306 int unplug_thresh;
307 unsigned long unplug_delay;
308 struct work_struct unplug_work;
309
310 struct backing_dev_info backing_dev_info;
311
312 void *queuedata;
313
314 void *activity_data;
315
316 unsigned long bounce_pfn;
317 gfp_t bounce_gfp;
318
319 unsigned long queue_flags;
320
321 spinlock_t __queue_lock;
322 spinlock_t *queue_lock;
323
324 struct kobject kobj;
325
326 unsigned long nr_requests;
327 unsigned int nr_congestion_on;
328 unsigned int nr_congestion_off;
329 unsigned int nr_batching;
330
331 unsigned int max_sectors;
332 unsigned int max_hw_sectors;
333 unsigned short max_phys_segments;
334 unsigned short max_hw_segments;
335 unsigned short hardsect_size;
336 unsigned int max_segment_size;
337
338 unsigned long seg_boundary_mask;
339 unsigned int dma_alignment;
340
341 struct blk_queue_tag *queue_tags;
342
343 unsigned int nr_sorted;
344 unsigned int in_flight;
345
346 unsigned int sg_timeout;
347 unsigned int sg_reserved_size;
348 int node;
349
350 struct blk_trace *blk_trace;
351
352 unsigned int ordered, next_ordered, ordseq;
353 int orderr, ordcolor;
354 struct request pre_flush_rq, bar_rq, post_flush_rq;
355 struct request *orig_bar_rq;
356 unsigned int bi_size;
357
358 struct mutex sysfs_lock;
359};
360
361#define RQ_INACTIVE (-1)
362#define RQ_ACTIVE 1
363
364#define QUEUE_FLAG_CLUSTER 0
365#define QUEUE_FLAG_QUEUED 1
366#define QUEUE_FLAG_STOPPED 2
367#define QUEUE_FLAG_READFULL 3
368#define QUEUE_FLAG_WRITEFULL 4
369#define QUEUE_FLAG_DEAD 5
370#define QUEUE_FLAG_REENTER 6
371#define QUEUE_FLAG_PLUGGED 7
372#define QUEUE_FLAG_ELVSWITCH 8
373
374enum {
375
376 QUEUE_ORDERED_NONE = 0x00,
377 QUEUE_ORDERED_DRAIN = 0x01,
378 QUEUE_ORDERED_TAG = 0x02,
379
380 QUEUE_ORDERED_PREFLUSH = 0x10,
381 QUEUE_ORDERED_POSTFLUSH = 0x20,
382 QUEUE_ORDERED_FUA = 0x40,
383
384 QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN |
385 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH,
386 QUEUE_ORDERED_DRAIN_FUA = QUEUE_ORDERED_DRAIN |
387 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA,
388 QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG |
389 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH,
390 QUEUE_ORDERED_TAG_FUA = QUEUE_ORDERED_TAG |
391 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA,
392
393 QUEUE_ORDSEQ_STARTED = 0x01,
394 QUEUE_ORDSEQ_DRAIN = 0x02,
395 QUEUE_ORDSEQ_PREFLUSH = 0x04,
396 QUEUE_ORDSEQ_BAR = 0x08,
397 QUEUE_ORDSEQ_POSTFLUSH = 0x10,
398 QUEUE_ORDSEQ_DONE = 0x20,
399};
400
401#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags)
402#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
403#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
404#define blk_queue_flushing(q) ((q)->ordseq)
405
406#define blk_fs_request(rq) ((rq)->flags & REQ_CMD)
407#define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC)
408#define blk_noretry_request(rq) ((rq)->flags & REQ_FAILFAST)
409#define blk_rq_started(rq) ((rq)->flags & REQ_STARTED)
410
411#define blk_account_rq(rq) (blk_rq_started(rq) && blk_fs_request(rq))
412
413#define blk_pm_suspend_request(rq) ((rq)->flags & REQ_PM_SUSPEND)
414#define blk_pm_resume_request(rq) ((rq)->flags & REQ_PM_RESUME)
415#define blk_pm_request(rq)   ((rq)->flags & (REQ_PM_SUSPEND | REQ_PM_RESUME))
416
417#define blk_sorted_rq(rq) ((rq)->flags & REQ_SORTED)
418#define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER)
419#define blk_fua_rq(rq) ((rq)->flags & REQ_FUA)
420
421#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)
422
423#define rq_data_dir(rq) ((rq)->flags & 1)
424
425#define RQ_NOMERGE_FLAGS   (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER)
426#define rq_mergeable(rq)   (!((rq)->flags & RQ_NOMERGE_FLAGS) && blk_fs_request((rq)))
427#define blk_queue_headactive(q, head_active)
428#define BLKPREP_OK 0
429#define BLKPREP_KILL 1
430#define BLKPREP_DEFER 2
431
432#define BLK_BOUNCE_HIGH ((u64)blk_max_low_pfn << PAGE_SHIFT)
433#define BLK_BOUNCE_ANY ((u64)blk_max_pfn << PAGE_SHIFT)
434#define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD)
435
436#define rq_for_each_bio(_bio, rq)   if ((rq->bio))   for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next)
437
438#define end_io_error(uptodate) (unlikely((uptodate) <= 0))
439
440#define blk_queue_tag_depth(q) ((q)->queue_tags->busy)
441#define blk_queue_tag_queue(q) ((q)->queue_tags->busy < (q)->queue_tags->max_depth)
442#define blk_rq_tagged(rq) ((rq)->flags & REQ_QUEUED)
443
444#define MAX_PHYS_SEGMENTS 128
445#define MAX_HW_SEGMENTS 128
446#define SAFE_MAX_SECTORS 255
447#define BLK_DEF_MAX_SECTORS 1024
448
449#define MAX_SEGMENT_SIZE 65536
450
451#define blkdev_entry_to_request(entry) list_entry((entry), struct request, queuelist)
452
453#define blk_finished_io(nsects) do { } while (0)
454#define blk_started_io(nsects) do { } while (0)
455
456#define sector_div(n, b)(  {   int _res;   _res = (n) % (b);   (n) /= (b);   _res;  }  )
457
458#define MODULE_ALIAS_BLOCKDEV(major,minor)   MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
459#define MODULE_ALIAS_BLOCKDEV_MAJOR(major)   MODULE_ALIAS("block-major-" __stringify(major) "-*")
460
461#endif
462