2 * include/linux/backing-dev.h
4 * low-level device information and state which is propagated up through
8 #ifndef _LINUX_BACKING_DEV_H
9 #define _LINUX_BACKING_DEV_H
11 #include <asm/atomic.h>
14 * Bits in backing_dev_info.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 */
23 typedef int (congested_fn
)(void *, int);
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
*);
35 extern struct backing_dev_info default_backing_dev_info
;
36 void default_unplug_io_fn(struct backing_dev_info
*bdi
, struct page
*page
);
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
);
42 static inline int bdi_congested(struct backing_dev_info
*bdi
, int bdi_bits
)
44 if (bdi
->congested_fn
)
45 return bdi
->congested_fn(bdi
->congested_data
, bdi_bits
);
46 return (bdi
->state
& bdi_bits
);
49 static inline int bdi_read_congested(struct backing_dev_info
*bdi
)
51 return bdi_congested(bdi
, 1 << BDI_read_congested
);
54 static inline int bdi_write_congested(struct backing_dev_info
*bdi
)
56 return bdi_congested(bdi
, 1 << BDI_write_congested
);
59 static inline int bdi_rw_congested(struct backing_dev_info
*bdi
)
61 return bdi_congested(bdi
, (1 << BDI_read_congested
)|
62 (1 << BDI_write_congested
));
65 #endif /* _LINUX_BACKING_DEV_H */