patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / linux / backing-dev.h
1 /*
2  * include/linux/backing-dev.h
3  *
4  * low-level device information and state which is propagated up through
5  * to high-level code.
6  */
7
8 #ifndef _LINUX_BACKING_DEV_H
9 #define _LINUX_BACKING_DEV_H
10
11 #include <asm/atomic.h>
12
13 /*
14  * Bits in backing_dev_info.state
15  */
16 enum bdi_state {
17         BDI_pdflush,            /* A pdflush thread is working this device */
18         BDI_write_congested,    /* The write queue is getting full */
19         BDI_read_congested,     /* The read queue is getting full */
20         BDI_unused,             /* Available bits start here */
21 };
22
23 typedef int (congested_fn)(void *, int);
24
25 struct backing_dev_info {
26         unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */
27         unsigned long state;    /* Always use atomic bitops on this */
28         int memory_backed;      /* Cannot clean pages with writepage */
29         congested_fn *congested_fn; /* Function pointer if device is md/dm */
30         void *congested_data;   /* Pointer to aux data for congested func */
31         void (*unplug_io_fn)(struct backing_dev_info *, struct page *);
32         void *unplug_io_data;
33 };
34
35 extern struct backing_dev_info default_backing_dev_info;
36 void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page);
37
38 int writeback_acquire(struct backing_dev_info *bdi);
39 int writeback_in_progress(struct backing_dev_info *bdi);
40 void writeback_release(struct backing_dev_info *bdi);
41
42 static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits)
43 {
44         if (bdi->congested_fn)
45                 return bdi->congested_fn(bdi->congested_data, bdi_bits);
46         return (bdi->state & bdi_bits);
47 }
48
49 static inline int bdi_read_congested(struct backing_dev_info *bdi)
50 {
51         return bdi_congested(bdi, 1 << BDI_read_congested);
52 }
53
54 static inline int bdi_write_congested(struct backing_dev_info *bdi)
55 {
56         return bdi_congested(bdi, 1 << BDI_write_congested);
57 }
58
59 static inline int bdi_rw_congested(struct backing_dev_info *bdi)
60 {
61         return bdi_congested(bdi, (1 << BDI_read_congested)|
62                                   (1 << BDI_write_congested));
63 }
64
65 #endif          /* _LINUX_BACKING_DEV_H */