7 #ifndef _LINUX_BUFFER_HEAD_H
8 #define _LINUX_BUFFER_HEAD_H
10 #include <linux/types.h>
12 #include <linux/linkage.h>
14 #include <linux/wait.h>
43 #define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
48 typedef void (bh_end_io_t)(
struct buffer_head *bh,
int uptodate);
60 unsigned long b_state;
61 struct buffer_head *b_this_page;
69 bh_end_io_t *b_end_io;
81 #define BUFFER_FNS(bit, name) \
82 static inline void set_buffer_##name(struct buffer_head *bh) \
84 set_bit(BH_##bit, &(bh)->b_state); \
86 static inline void clear_buffer_##name(struct buffer_head *bh) \
88 clear_bit(BH_##bit, &(bh)->b_state); \
90 static inline int buffer_##name(const struct buffer_head *bh) \
92 return test_bit(BH_##bit, &(bh)->b_state); \
98 #define TAS_BUFFER_FNS(bit, name) \
99 static inline int test_set_buffer_##name(struct buffer_head *bh) \
101 return test_and_set_bit(BH_##bit, &(bh)->b_state); \
103 static inline int test_clear_buffer_##name(struct buffer_head *bh) \
105 return test_and_clear_bit(BH_##bit, &(bh)->b_state); \
128 #define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
129 #define touch_buffer(bh) mark_page_accessed(bh->b_page)
132 #define page_buffers(page) \
134 BUG_ON(!PagePrivate(page)); \
135 ((struct buffer_head *)page_private(page)); \
137 #define page_has_buffers(page) PagePrivate(page)
144 void init_buffer(
struct buffer_head *, bh_end_io_t *,
void *);
151 unsigned long b_state);
171 void __brelse(
struct buffer_head *);
180 void ll_rw_block(
int,
int,
struct buffer_head * bh[]);
184 int submit_bh(
int,
struct buffer_head *);
186 sector_t bblock,
unsigned blocksize);
209 loff_t,
unsigned,
unsigned,
210 struct page *,
void *);
212 loff_t,
unsigned,
unsigned,
213 struct page *,
void *);
216 unsigned,
unsigned,
struct page **,
void **,
225 static inline int block_page_mkwrite_return(
int err)
228 return VM_FAULT_LOCKED;
230 return VM_FAULT_NOPAGE;
234 return VM_FAULT_RETRY;
236 return VM_FAULT_SIGBUS;
243 loff_t,
unsigned,
unsigned,
244 struct page *,
void *);
255 static inline void attach_page_buffers(
struct page *
page,
256 struct buffer_head *
head)
259 SetPagePrivate(page);
260 set_page_private(page, (
unsigned long)head);
263 static inline void get_bh(
struct buffer_head *bh)
268 static inline void put_bh(
struct buffer_head *bh)
274 static inline void brelse(
struct buffer_head *bh)
280 static inline void bforget(
struct buffer_head *bh)
286 static inline struct buffer_head *
298 static inline struct buffer_head *
304 static inline struct buffer_head *
313 set_buffer_mapped(bh);
315 bh->b_blocknr =
block;
319 static inline void wait_on_buffer(
struct buffer_head *bh)
322 if (buffer_locked(bh))
326 static inline int trylock_buffer(
struct buffer_head *bh)
331 static inline void lock_buffer(
struct buffer_head *bh)
334 if (!trylock_buffer(bh))