aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_buf.h
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-01-10 23:39:08 -0500
committerNathan Scott <nathans@sgi.com>2006-01-10 23:39:08 -0500
commitce8e922c0e79c8093452ba9a124981332b75706b (patch)
tree0f681391461d4d6bbccd3bf88a7762cc7daa8852 /fs/xfs/linux-2.6/xfs_buf.h
parent68bdb6eabcd2869caa795019961a5445a11b5bc1 (diff)
[XFS] Complete the pagebuf -> xfs_buf naming convention transition,
finally. SGI-PV: 947038 SGI-Modid: xfs-linux-melb:xfs-kern:24866a Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_buf.h')
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h693
1 files changed, 280 insertions, 413 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index f721d47ad4cc..4dd6592d5a4c 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -32,44 +32,47 @@
32 * Base types 32 * Base types
33 */ 33 */
34 34
35#define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL)) 35#define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL))
36 36
37#define page_buf_ctob(pp) ((pp) * PAGE_CACHE_SIZE) 37#define xfs_buf_ctob(pp) ((pp) * PAGE_CACHE_SIZE)
38#define page_buf_btoc(dd) (((dd) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) 38#define xfs_buf_btoc(dd) (((dd) + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT)
39#define page_buf_btoct(dd) ((dd) >> PAGE_CACHE_SHIFT) 39#define xfs_buf_btoct(dd) ((dd) >> PAGE_CACHE_SHIFT)
40#define page_buf_poff(aa) ((aa) & ~PAGE_CACHE_MASK) 40#define xfs_buf_poff(aa) ((aa) & ~PAGE_CACHE_MASK)
41 41
42typedef enum page_buf_rw_e { 42typedef enum {
43 PBRW_READ = 1, /* transfer into target memory */ 43 XBRW_READ = 1, /* transfer into target memory */
44 PBRW_WRITE = 2, /* transfer from target memory */ 44 XBRW_WRITE = 2, /* transfer from target memory */
45 PBRW_ZERO = 3 /* Zero target memory */ 45 XBRW_ZERO = 3, /* Zero target memory */
46} page_buf_rw_t; 46} xfs_buf_rw_t;
47 47
48 48typedef enum {
49typedef enum page_buf_flags_e { /* pb_flags values */ 49 XBF_READ = (1 << 0), /* buffer intended for reading from device */
50 PBF_READ = (1 << 0), /* buffer intended for reading from device */ 50 XBF_WRITE = (1 << 1), /* buffer intended for writing to device */
51 PBF_WRITE = (1 << 1), /* buffer intended for writing to device */ 51 XBF_MAPPED = (1 << 2), /* buffer mapped (b_addr valid) */
52 PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */ 52 XBF_ASYNC = (1 << 4), /* initiator will not wait for completion */
53 PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */ 53 XBF_DONE = (1 << 5), /* all pages in the buffer uptodate */
54 PBF_DONE = (1 << 5), /* all pages in the buffer uptodate */ 54 XBF_DELWRI = (1 << 6), /* buffer has dirty pages */
55 PBF_DELWRI = (1 << 6), /* buffer has dirty pages */ 55 XBF_STALE = (1 << 7), /* buffer has been staled, do not find it */
56 PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */ 56 XBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */
57 PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ 57 XBF_ORDERED = (1 << 11), /* use ordered writes */
58 PBF_ORDERED = (1 << 11), /* use ordered writes */ 58 XBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */
59 PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */
60 59
61 /* flags used only as arguments to access routines */ 60 /* flags used only as arguments to access routines */
62 PBF_LOCK = (1 << 14), /* lock requested */ 61 XBF_LOCK = (1 << 14), /* lock requested */
63 PBF_TRYLOCK = (1 << 15), /* lock requested, but do not wait */ 62 XBF_TRYLOCK = (1 << 15), /* lock requested, but do not wait */
64 PBF_DONT_BLOCK = (1 << 16), /* do not block in current thread */ 63 XBF_DONT_BLOCK = (1 << 16), /* do not block in current thread */
65 64
66 /* flags used only internally */ 65 /* flags used only internally */
67 _PBF_PAGE_CACHE = (1 << 17),/* backed by pagecache */ 66 _XBF_PAGE_CACHE = (1 << 17),/* backed by pagecache */
68 _PBF_KMEM_ALLOC = (1 << 18),/* backed by kmem_alloc() */ 67 _XBF_KMEM_ALLOC = (1 << 18),/* backed by kmem_alloc() */
69 _PBF_RUN_QUEUES = (1 << 19),/* run block device task queue */ 68 _XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */
70 _PBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ 69 _XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */
71} page_buf_flags_t; 70} xfs_buf_flags_t;
72 71
72typedef enum {
73 XBT_FORCE_SLEEP = (0 << 1),
74 XBT_FORCE_FLUSH = (1 << 1),
75} xfs_buftarg_flags_t;
73 76
74typedef struct xfs_bufhash { 77typedef struct xfs_bufhash {
75 struct list_head bh_list; 78 struct list_head bh_list;
@@ -77,14 +80,14 @@ typedef struct xfs_bufhash {
77} xfs_bufhash_t; 80} xfs_bufhash_t;
78 81
79typedef struct xfs_buftarg { 82typedef struct xfs_buftarg {
80 dev_t pbr_dev; 83 dev_t bt_dev;
81 struct block_device *pbr_bdev; 84 struct block_device *bt_bdev;
82 struct address_space *pbr_mapping; 85 struct address_space *bt_mapping;
83 unsigned int pbr_bsize; 86 unsigned int bt_bsize;
84 unsigned int pbr_sshift; 87 unsigned int bt_sshift;
85 size_t pbr_smask; 88 size_t bt_smask;
86 89
87 /* per-device buffer hash table */ 90 /* per device buffer hash table */
88 uint bt_hashmask; 91 uint bt_hashmask;
89 uint bt_hashshift; 92 uint bt_hashshift;
90 xfs_bufhash_t *bt_hash; 93 xfs_bufhash_t *bt_hash;
@@ -94,469 +97,333 @@ typedef struct xfs_buftarg {
94 struct list_head bt_list; 97 struct list_head bt_list;
95 struct list_head bt_delwrite_queue; 98 struct list_head bt_delwrite_queue;
96 spinlock_t bt_delwrite_lock; 99 spinlock_t bt_delwrite_lock;
97 uint bt_flags; 100 unsigned long bt_flags;
98#define BT_FORCE_SLEEP 1
99#define BT_FORCE_FLUSH 2
100} xfs_buftarg_t; 101} xfs_buftarg_t;
101 102
102/* 103/*
103 * xfs_buf_t: Buffer structure for page cache-based buffers 104 * xfs_buf_t: Buffer structure for pagecache-based buffers
104 * 105 *
105 * This buffer structure is used by the page cache buffer management routines 106 * This buffer structure is used by the pagecache buffer management routines
106 * to refer to an assembly of pages forming a logical buffer. The actual I/O 107 * to refer to an assembly of pages forming a logical buffer.
107 * is performed with buffer_head structures, as required by drivers. 108 *
108 * 109 * The buffer structure is used on a temporary basis only, and discarded when
109 * The buffer structure is used on temporary basis only, and discarded when 110 * released. The real data storage is recorded in the pagecache. Buffers are
110 * released. The real data storage is recorded in the page cache. Metadata is
111 * hashed to the block device on which the file system resides. 111 * hashed to the block device on which the file system resides.
112 */ 112 */
113 113
114struct xfs_buf; 114struct xfs_buf;
115typedef void (*xfs_buf_iodone_t)(struct xfs_buf *);
116typedef void (*xfs_buf_relse_t)(struct xfs_buf *);
117typedef int (*xfs_buf_bdstrat_t)(struct xfs_buf *);
115 118
116/* call-back function on I/O completion */ 119#define XB_PAGES 2
117typedef void (*page_buf_iodone_t)(struct xfs_buf *);
118/* call-back function on I/O completion */
119typedef void (*page_buf_relse_t)(struct xfs_buf *);
120/* pre-write function */
121typedef int (*page_buf_bdstrat_t)(struct xfs_buf *);
122
123#define PB_PAGES 2
124 120
125typedef struct xfs_buf { 121typedef struct xfs_buf {
126 struct semaphore pb_sema; /* semaphore for lockables */ 122 struct semaphore b_sema; /* semaphore for lockables */
127 unsigned long pb_queuetime; /* time buffer was queued */ 123 unsigned long b_queuetime; /* time buffer was queued */
128 atomic_t pb_pin_count; /* pin count */ 124 atomic_t b_pin_count; /* pin count */
129 wait_queue_head_t pb_waiters; /* unpin waiters */ 125 wait_queue_head_t b_waiters; /* unpin waiters */
130 struct list_head pb_list; 126 struct list_head b_list;
131 page_buf_flags_t pb_flags; /* status flags */ 127 xfs_buf_flags_t b_flags; /* status flags */
132 struct list_head pb_hash_list; /* hash table list */ 128 struct list_head b_hash_list; /* hash table list */
133 xfs_bufhash_t *pb_hash; /* hash table list start */ 129 xfs_bufhash_t *b_hash; /* hash table list start */
134 xfs_buftarg_t *pb_target; /* buffer target (device) */ 130 xfs_buftarg_t *b_target; /* buffer target (device) */
135 atomic_t pb_hold; /* reference count */ 131 atomic_t b_hold; /* reference count */
136 xfs_daddr_t pb_bn; /* block number for I/O */ 132 xfs_daddr_t b_bn; /* block number for I/O */
137 loff_t pb_file_offset; /* offset in file */ 133 xfs_off_t b_file_offset; /* offset in file */
138 size_t pb_buffer_length; /* size of buffer in bytes */ 134 size_t b_buffer_length;/* size of buffer in bytes */
139 size_t pb_count_desired; /* desired transfer size */ 135 size_t b_count_desired;/* desired transfer size */
140 void *pb_addr; /* virtual address of buffer */ 136 void *b_addr; /* virtual address of buffer */
141 struct work_struct pb_iodone_work; 137 struct work_struct b_iodone_work;
142 atomic_t pb_io_remaining;/* #outstanding I/O requests */ 138 atomic_t b_io_remaining; /* #outstanding I/O requests */
143 page_buf_iodone_t pb_iodone; /* I/O completion function */ 139 xfs_buf_iodone_t b_iodone; /* I/O completion function */
144 page_buf_relse_t pb_relse; /* releasing function */ 140 xfs_buf_relse_t b_relse; /* releasing function */
145 page_buf_bdstrat_t pb_strat; /* pre-write function */ 141 xfs_buf_bdstrat_t b_strat; /* pre-write function */
146 struct semaphore pb_iodonesema; /* Semaphore for I/O waiters */ 142 struct semaphore b_iodonesema; /* Semaphore for I/O waiters */
147 void *pb_fspriv; 143 void *b_fspriv;
148 void *pb_fspriv2; 144 void *b_fspriv2;
149 void *pb_fspriv3; 145 void *b_fspriv3;
150 unsigned short pb_error; /* error code on I/O */ 146 unsigned short b_error; /* error code on I/O */
151 unsigned short pb_locked; /* page array is locked */ 147 unsigned short b_locked; /* page array is locked */
152 unsigned int pb_page_count; /* size of page array */ 148 unsigned int b_page_count; /* size of page array */
153 unsigned int pb_offset; /* page offset in first page */ 149 unsigned int b_offset; /* page offset in first page */
154 struct page **pb_pages; /* array of page pointers */ 150 struct page **b_pages; /* array of page pointers */
155 struct page *pb_page_array[PB_PAGES]; /* inline pages */ 151 struct page *b_page_array[XB_PAGES]; /* inline pages */
156#ifdef PAGEBUF_LOCK_TRACKING 152#ifdef XFS_BUF_LOCK_TRACKING
157 int pb_last_holder; 153 int b_last_holder;
158#endif 154#endif
159} xfs_buf_t; 155} xfs_buf_t;
160 156
161 157
162/* Finding and Reading Buffers */ 158/* Finding and Reading Buffers */
163 159extern xfs_buf_t *_xfs_buf_find(xfs_buftarg_t *, xfs_off_t, size_t,
164extern xfs_buf_t *_pagebuf_find( /* find buffer for block if */ 160 xfs_buf_flags_t, xfs_buf_t *);
165 /* the block is in memory */
166 xfs_buftarg_t *, /* inode for block */
167 loff_t, /* starting offset of range */
168 size_t, /* length of range */
169 page_buf_flags_t, /* PBF_LOCK */
170 xfs_buf_t *); /* newly allocated buffer */
171
172#define xfs_incore(buftarg,blkno,len,lockit) \ 161#define xfs_incore(buftarg,blkno,len,lockit) \
173 _pagebuf_find(buftarg, blkno ,len, lockit, NULL) 162 _xfs_buf_find(buftarg, blkno ,len, lockit, NULL)
174
175extern xfs_buf_t *xfs_buf_get_flags( /* allocate a buffer */
176 xfs_buftarg_t *, /* inode for buffer */
177 loff_t, /* starting offset of range */
178 size_t, /* length of range */
179 page_buf_flags_t); /* PBF_LOCK, PBF_READ, */
180 /* PBF_ASYNC */
181 163
164extern xfs_buf_t *xfs_buf_get_flags(xfs_buftarg_t *, xfs_off_t, size_t,
165 xfs_buf_flags_t);
182#define xfs_buf_get(target, blkno, len, flags) \ 166#define xfs_buf_get(target, blkno, len, flags) \
183 xfs_buf_get_flags((target), (blkno), (len), PBF_LOCK | PBF_MAPPED) 167 xfs_buf_get_flags((target), (blkno), (len), XBF_LOCK | XBF_MAPPED)
184
185extern xfs_buf_t *xfs_buf_read_flags( /* allocate and read a buffer */
186 xfs_buftarg_t *, /* inode for buffer */
187 loff_t, /* starting offset of range */
188 size_t, /* length of range */
189 page_buf_flags_t); /* PBF_LOCK, PBF_ASYNC */
190 168
169extern xfs_buf_t *xfs_buf_read_flags(xfs_buftarg_t *, xfs_off_t, size_t,
170 xfs_buf_flags_t);
191#define xfs_buf_read(target, blkno, len, flags) \ 171#define xfs_buf_read(target, blkno, len, flags) \
192 xfs_buf_read_flags((target), (blkno), (len), PBF_LOCK | PBF_MAPPED) 172 xfs_buf_read_flags((target), (blkno), (len), XBF_LOCK | XBF_MAPPED)
193 173
194extern xfs_buf_t *pagebuf_get_empty( /* allocate pagebuf struct with */ 174extern xfs_buf_t *xfs_buf_get_empty(size_t, xfs_buftarg_t *);
195 /* no memory or disk address */ 175extern xfs_buf_t *xfs_buf_get_noaddr(size_t, xfs_buftarg_t *);
196 size_t len, 176extern int xfs_buf_associate_memory(xfs_buf_t *, void *, size_t);
197 xfs_buftarg_t *); /* mount point "fake" inode */ 177extern void xfs_buf_hold(xfs_buf_t *);
198 178extern void xfs_buf_readahead(xfs_buftarg_t *, xfs_off_t, size_t,
199extern xfs_buf_t *pagebuf_get_no_daddr(/* allocate pagebuf struct */ 179 xfs_buf_flags_t);
200 /* without disk address */
201 size_t len,
202 xfs_buftarg_t *); /* mount point "fake" inode */
203
204extern int pagebuf_associate_memory(
205 xfs_buf_t *,
206 void *,
207 size_t);
208
209extern void pagebuf_hold( /* increment reference count */
210 xfs_buf_t *); /* buffer to hold */
211
212extern void pagebuf_readahead( /* read ahead into cache */
213 xfs_buftarg_t *, /* target for buffer (or NULL) */
214 loff_t, /* starting offset of range */
215 size_t, /* length of range */
216 page_buf_flags_t); /* additional read flags */
217 180
218/* Releasing Buffers */ 181/* Releasing Buffers */
219 182extern void xfs_buf_free(xfs_buf_t *);
220extern void pagebuf_free( /* deallocate a buffer */ 183extern void xfs_buf_rele(xfs_buf_t *);
221 xfs_buf_t *); /* buffer to deallocate */
222
223extern void pagebuf_rele( /* release hold on a buffer */
224 xfs_buf_t *); /* buffer to release */
225 184
226/* Locking and Unlocking Buffers */ 185/* Locking and Unlocking Buffers */
227 186extern int xfs_buf_cond_lock(xfs_buf_t *);
228extern int pagebuf_cond_lock( /* lock buffer, if not locked */ 187extern int xfs_buf_lock_value(xfs_buf_t *);
229 /* (returns -EBUSY if locked) */ 188extern void xfs_buf_lock(xfs_buf_t *);
230 xfs_buf_t *); /* buffer to lock */ 189extern void xfs_buf_unlock(xfs_buf_t *);
231
232extern int pagebuf_lock_value( /* return count on lock */
233 xfs_buf_t *); /* buffer to check */
234
235extern int pagebuf_lock( /* lock buffer */
236 xfs_buf_t *); /* buffer to lock */
237
238extern void pagebuf_unlock( /* unlock buffer */
239 xfs_buf_t *); /* buffer to unlock */
240 190
241/* Buffer Read and Write Routines */ 191/* Buffer Read and Write Routines */
242 192extern void xfs_buf_ioend(xfs_buf_t *, int);
243extern void pagebuf_iodone( /* mark buffer I/O complete */ 193extern void xfs_buf_ioerror(xfs_buf_t *, int);
244 xfs_buf_t *, /* buffer to mark */ 194extern int xfs_buf_iostart(xfs_buf_t *, xfs_buf_flags_t);
245 int); /* run completion locally, or in 195extern int xfs_buf_iorequest(xfs_buf_t *);
246 * a helper thread. */ 196extern int xfs_buf_iowait(xfs_buf_t *);
247 197extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, xfs_caddr_t,
248extern void pagebuf_ioerror( /* mark buffer in error (or not) */ 198 xfs_buf_rw_t);
249 xfs_buf_t *, /* buffer to mark */ 199
250 int); /* error to store (0 if none) */ 200static inline int xfs_buf_iostrategy(xfs_buf_t *bp)
251
252extern int pagebuf_iostart( /* start I/O on a buffer */
253 xfs_buf_t *, /* buffer to start */
254 page_buf_flags_t); /* PBF_LOCK, PBF_ASYNC, */
255 /* PBF_READ, PBF_WRITE, */
256 /* PBF_DELWRI */
257
258extern int pagebuf_iorequest( /* start real I/O */
259 xfs_buf_t *); /* buffer to convey to device */
260
261extern int pagebuf_iowait( /* wait for buffer I/O done */
262 xfs_buf_t *); /* buffer to wait on */
263
264extern void pagebuf_iomove( /* move data in/out of pagebuf */
265 xfs_buf_t *, /* buffer to manipulate */
266 size_t, /* starting buffer offset */
267 size_t, /* length in buffer */
268 caddr_t, /* data pointer */
269 page_buf_rw_t); /* direction */
270
271static inline int pagebuf_iostrategy(xfs_buf_t *pb)
272{ 201{
273 return pb->pb_strat ? pb->pb_strat(pb) : pagebuf_iorequest(pb); 202 return bp->b_strat ? bp->b_strat(bp) : xfs_buf_iorequest(bp);
274} 203}
275 204
276static inline int pagebuf_geterror(xfs_buf_t *pb) 205static inline int xfs_buf_geterror(xfs_buf_t *bp)
277{ 206{
278 return pb ? pb->pb_error : ENOMEM; 207 return bp ? bp->b_error : ENOMEM;
279} 208}
280 209
281/* Buffer Utility Routines */ 210/* Buffer Utility Routines */
282 211extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t);
283extern caddr_t pagebuf_offset( /* pointer at offset in buffer */
284 xfs_buf_t *, /* buffer to offset into */
285 size_t); /* offset */
286 212
287/* Pinning Buffer Storage in Memory */ 213/* Pinning Buffer Storage in Memory */
288 214extern void xfs_buf_pin(xfs_buf_t *);
289extern void pagebuf_pin( /* pin buffer in memory */ 215extern void xfs_buf_unpin(xfs_buf_t *);
290 xfs_buf_t *); /* buffer to pin */ 216extern int xfs_buf_ispin(xfs_buf_t *);
291
292extern void pagebuf_unpin( /* unpin buffered data */
293 xfs_buf_t *); /* buffer to unpin */
294
295extern int pagebuf_ispin( /* check if buffer is pinned */
296 xfs_buf_t *); /* buffer to check */
297 217
298/* Delayed Write Buffer Routines */ 218/* Delayed Write Buffer Routines */
299 219extern void xfs_buf_delwri_dequeue(xfs_buf_t *);
300extern void pagebuf_delwri_dequeue(xfs_buf_t *);
301 220
302/* Buffer Daemon Setup Routines */ 221/* Buffer Daemon Setup Routines */
222extern int xfs_buf_init(void);
223extern void xfs_buf_terminate(void);
303 224
304extern int pagebuf_init(void); 225#ifdef XFS_BUF_TRACE
305extern void pagebuf_terminate(void); 226extern ktrace_t *xfs_buf_trace_buf;
306 227extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *);
307
308#ifdef PAGEBUF_TRACE
309extern ktrace_t *pagebuf_trace_buf;
310extern void pagebuf_trace(
311 xfs_buf_t *, /* buffer being traced */
312 char *, /* description of operation */
313 void *, /* arbitrary diagnostic value */
314 void *); /* return address */
315#else 228#else
316# define pagebuf_trace(pb, id, ptr, ra) do { } while (0) 229#define xfs_buf_trace(bp,id,ptr,ra) do { } while (0)
317#endif 230#endif
318 231
319#define pagebuf_target_name(target) \ 232#define xfs_buf_target_name(target) \
320 ({ char __b[BDEVNAME_SIZE]; bdevname((target)->pbr_bdev, __b); __b; }) 233 ({ char __b[BDEVNAME_SIZE]; bdevname((target)->bt_bdev, __b); __b; })
321 234
322 235
236#define XFS_B_ASYNC XBF_ASYNC
237#define XFS_B_DELWRI XBF_DELWRI
238#define XFS_B_READ XBF_READ
239#define XFS_B_WRITE XBF_WRITE
240#define XFS_B_STALE XBF_STALE
323 241
324/* These are just for xfs_syncsub... it sets an internal variable 242#define XFS_BUF_TRYLOCK XBF_TRYLOCK
325 * then passes it to VOP_FLUSH_PAGES or adds the flags to a newly gotten buf_t 243#define XFS_INCORE_TRYLOCK XBF_TRYLOCK
326 */ 244#define XFS_BUF_LOCK XBF_LOCK
327#define XFS_B_ASYNC PBF_ASYNC 245#define XFS_BUF_MAPPED XBF_MAPPED
328#define XFS_B_DELWRI PBF_DELWRI
329#define XFS_B_READ PBF_READ
330#define XFS_B_WRITE PBF_WRITE
331#define XFS_B_STALE PBF_STALE
332
333#define XFS_BUF_TRYLOCK PBF_TRYLOCK
334#define XFS_INCORE_TRYLOCK PBF_TRYLOCK
335#define XFS_BUF_LOCK PBF_LOCK
336#define XFS_BUF_MAPPED PBF_MAPPED
337
338#define BUF_BUSY PBF_DONT_BLOCK
339
340#define XFS_BUF_BFLAGS(x) ((x)->pb_flags)
341#define XFS_BUF_ZEROFLAGS(x) \
342 ((x)->pb_flags &= ~(PBF_READ|PBF_WRITE|PBF_ASYNC|PBF_DELWRI))
343
344#define XFS_BUF_STALE(x) ((x)->pb_flags |= XFS_B_STALE)
345#define XFS_BUF_UNSTALE(x) ((x)->pb_flags &= ~XFS_B_STALE)
346#define XFS_BUF_ISSTALE(x) ((x)->pb_flags & XFS_B_STALE)
347#define XFS_BUF_SUPER_STALE(x) do { \
348 XFS_BUF_STALE(x); \
349 pagebuf_delwri_dequeue(x); \
350 XFS_BUF_DONE(x); \
351 } while (0)
352 246
353#define XFS_BUF_MANAGE PBF_FS_MANAGED 247#define BUF_BUSY XBF_DONT_BLOCK
354#define XFS_BUF_UNMANAGE(x) ((x)->pb_flags &= ~PBF_FS_MANAGED) 248
355 249#define XFS_BUF_BFLAGS(bp) ((bp)->b_flags)
356#define XFS_BUF_DELAYWRITE(x) ((x)->pb_flags |= PBF_DELWRI) 250#define XFS_BUF_ZEROFLAGS(bp) \
357#define XFS_BUF_UNDELAYWRITE(x) pagebuf_delwri_dequeue(x) 251 ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC|XBF_DELWRI))
358#define XFS_BUF_ISDELAYWRITE(x) ((x)->pb_flags & PBF_DELWRI) 252
359 253#define XFS_BUF_STALE(bp) ((bp)->b_flags |= XFS_B_STALE)
360#define XFS_BUF_ERROR(x,no) pagebuf_ioerror(x,no) 254#define XFS_BUF_UNSTALE(bp) ((bp)->b_flags &= ~XFS_B_STALE)
361#define XFS_BUF_GETERROR(x) pagebuf_geterror(x) 255#define XFS_BUF_ISSTALE(bp) ((bp)->b_flags & XFS_B_STALE)
362#define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0) 256#define XFS_BUF_SUPER_STALE(bp) do { \
363 257 XFS_BUF_STALE(bp); \
364#define XFS_BUF_DONE(x) ((x)->pb_flags |= PBF_DONE) 258 xfs_buf_delwri_dequeue(bp); \
365#define XFS_BUF_UNDONE(x) ((x)->pb_flags &= ~PBF_DONE) 259 XFS_BUF_DONE(bp); \
366#define XFS_BUF_ISDONE(x) ((x)->pb_flags & PBF_DONE) 260 } while (0)
367
368#define XFS_BUF_BUSY(x) do { } while (0)
369#define XFS_BUF_UNBUSY(x) do { } while (0)
370#define XFS_BUF_ISBUSY(x) (1)
371
372#define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC)
373#define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC)
374#define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC)
375
376#define XFS_BUF_ORDERED(x) ((x)->pb_flags |= PBF_ORDERED)
377#define XFS_BUF_UNORDERED(x) ((x)->pb_flags &= ~PBF_ORDERED)
378#define XFS_BUF_ISORDERED(x) ((x)->pb_flags & PBF_ORDERED)
379
380#define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n")
381#define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n")
382#define XFS_BUF_ISSHUT(x) (0)
383
384#define XFS_BUF_HOLD(x) pagebuf_hold(x)
385#define XFS_BUF_READ(x) ((x)->pb_flags |= PBF_READ)
386#define XFS_BUF_UNREAD(x) ((x)->pb_flags &= ~PBF_READ)
387#define XFS_BUF_ISREAD(x) ((x)->pb_flags & PBF_READ)
388
389#define XFS_BUF_WRITE(x) ((x)->pb_flags |= PBF_WRITE)
390#define XFS_BUF_UNWRITE(x) ((x)->pb_flags &= ~PBF_WRITE)
391#define XFS_BUF_ISWRITE(x) ((x)->pb_flags & PBF_WRITE)
392
393#define XFS_BUF_ISUNINITIAL(x) (0)
394#define XFS_BUF_UNUNINITIAL(x) (0)
395
396#define XFS_BUF_BP_ISMAPPED(bp) 1
397
398#define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone
399#define XFS_BUF_SET_IODONE_FUNC(buf, func) \
400 (buf)->pb_iodone = (func)
401#define XFS_BUF_CLR_IODONE_FUNC(buf) \
402 (buf)->pb_iodone = NULL
403#define XFS_BUF_SET_BDSTRAT_FUNC(buf, func) \
404 (buf)->pb_strat = (func)
405#define XFS_BUF_CLR_BDSTRAT_FUNC(buf) \
406 (buf)->pb_strat = NULL
407
408#define XFS_BUF_FSPRIVATE(buf, type) \
409 ((type)(buf)->pb_fspriv)
410#define XFS_BUF_SET_FSPRIVATE(buf, value) \
411 (buf)->pb_fspriv = (void *)(value)
412#define XFS_BUF_FSPRIVATE2(buf, type) \
413 ((type)(buf)->pb_fspriv2)
414#define XFS_BUF_SET_FSPRIVATE2(buf, value) \
415 (buf)->pb_fspriv2 = (void *)(value)
416#define XFS_BUF_FSPRIVATE3(buf, type) \
417 ((type)(buf)->pb_fspriv3)
418#define XFS_BUF_SET_FSPRIVATE3(buf, value) \
419 (buf)->pb_fspriv3 = (void *)(value)
420#define XFS_BUF_SET_START(buf)
421
422#define XFS_BUF_SET_BRELSE_FUNC(buf, value) \
423 (buf)->pb_relse = (value)
424
425#define XFS_BUF_PTR(bp) (xfs_caddr_t)((bp)->pb_addr)
426
427static inline xfs_caddr_t xfs_buf_offset(xfs_buf_t *bp, size_t offset)
428{
429 if (bp->pb_flags & PBF_MAPPED)
430 return XFS_BUF_PTR(bp) + offset;
431 return (xfs_caddr_t) pagebuf_offset(bp, offset);
432}
433 261
434#define XFS_BUF_SET_PTR(bp, val, count) \ 262#define XFS_BUF_MANAGE XBF_FS_MANAGED
435 pagebuf_associate_memory(bp, val, count) 263#define XFS_BUF_UNMANAGE(bp) ((bp)->b_flags &= ~XBF_FS_MANAGED)
436#define XFS_BUF_ADDR(bp) ((bp)->pb_bn) 264
437#define XFS_BUF_SET_ADDR(bp, blk) \ 265#define XFS_BUF_DELAYWRITE(bp) ((bp)->b_flags |= XBF_DELWRI)
438 ((bp)->pb_bn = (xfs_daddr_t)(blk)) 266#define XFS_BUF_UNDELAYWRITE(bp) xfs_buf_delwri_dequeue(bp)
439#define XFS_BUF_OFFSET(bp) ((bp)->pb_file_offset) 267#define XFS_BUF_ISDELAYWRITE(bp) ((bp)->b_flags & XBF_DELWRI)
440#define XFS_BUF_SET_OFFSET(bp, off) \ 268
441 ((bp)->pb_file_offset = (off)) 269#define XFS_BUF_ERROR(bp,no) xfs_buf_ioerror(bp,no)
442#define XFS_BUF_COUNT(bp) ((bp)->pb_count_desired) 270#define XFS_BUF_GETERROR(bp) xfs_buf_geterror(bp)
443#define XFS_BUF_SET_COUNT(bp, cnt) \ 271#define XFS_BUF_ISERROR(bp) (xfs_buf_geterror(bp) ? 1 : 0)
444 ((bp)->pb_count_desired = (cnt)) 272
445#define XFS_BUF_SIZE(bp) ((bp)->pb_buffer_length) 273#define XFS_BUF_DONE(bp) ((bp)->b_flags |= XBF_DONE)
446#define XFS_BUF_SET_SIZE(bp, cnt) \ 274#define XFS_BUF_UNDONE(bp) ((bp)->b_flags &= ~XBF_DONE)
447 ((bp)->pb_buffer_length = (cnt)) 275#define XFS_BUF_ISDONE(bp) ((bp)->b_flags & XBF_DONE)
448#define XFS_BUF_SET_VTYPE_REF(bp, type, ref) 276
449#define XFS_BUF_SET_VTYPE(bp, type) 277#define XFS_BUF_BUSY(bp) do { } while (0)
450#define XFS_BUF_SET_REF(bp, ref) 278#define XFS_BUF_UNBUSY(bp) do { } while (0)
451 279#define XFS_BUF_ISBUSY(bp) (1)
452#define XFS_BUF_ISPINNED(bp) pagebuf_ispin(bp) 280
453 281#define XFS_BUF_ASYNC(bp) ((bp)->b_flags |= XBF_ASYNC)
454#define XFS_BUF_VALUSEMA(bp) pagebuf_lock_value(bp) 282#define XFS_BUF_UNASYNC(bp) ((bp)->b_flags &= ~XBF_ASYNC)
455#define XFS_BUF_CPSEMA(bp) (pagebuf_cond_lock(bp) == 0) 283#define XFS_BUF_ISASYNC(bp) ((bp)->b_flags & XBF_ASYNC)
456#define XFS_BUF_VSEMA(bp) pagebuf_unlock(bp) 284
457#define XFS_BUF_PSEMA(bp,x) pagebuf_lock(bp) 285#define XFS_BUF_ORDERED(bp) ((bp)->b_flags |= XBF_ORDERED)
458#define XFS_BUF_V_IODONESEMA(bp) up(&bp->pb_iodonesema); 286#define XFS_BUF_UNORDERED(bp) ((bp)->b_flags &= ~XBF_ORDERED)
459 287#define XFS_BUF_ISORDERED(bp) ((bp)->b_flags & XBF_ORDERED)
460/* setup the buffer target from a buftarg structure */ 288
461#define XFS_BUF_SET_TARGET(bp, target) \ 289#define XFS_BUF_SHUT(bp) do { } while (0)
462 (bp)->pb_target = (target) 290#define XFS_BUF_UNSHUT(bp) do { } while (0)
463#define XFS_BUF_TARGET(bp) ((bp)->pb_target) 291#define XFS_BUF_ISSHUT(bp) (0)
464#define XFS_BUFTARG_NAME(target) \ 292
465 pagebuf_target_name(target) 293#define XFS_BUF_HOLD(bp) xfs_buf_hold(bp)
466 294#define XFS_BUF_READ(bp) ((bp)->b_flags |= XBF_READ)
467#define XFS_BUF_SET_VTYPE_REF(bp, type, ref) 295#define XFS_BUF_UNREAD(bp) ((bp)->b_flags &= ~XBF_READ)
468#define XFS_BUF_SET_VTYPE(bp, type) 296#define XFS_BUF_ISREAD(bp) ((bp)->b_flags & XBF_READ)
469#define XFS_BUF_SET_REF(bp, ref) 297
470 298#define XFS_BUF_WRITE(bp) ((bp)->b_flags |= XBF_WRITE)
471static inline int xfs_bawrite(void *mp, xfs_buf_t *bp) 299#define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE)
300#define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE)
301
302#define XFS_BUF_ISUNINITIAL(bp) (0)
303#define XFS_BUF_UNUNINITIAL(bp) (0)
304
305#define XFS_BUF_BP_ISMAPPED(bp) (1)
306
307#define XFS_BUF_IODONE_FUNC(bp) ((bp)->b_iodone)
308#define XFS_BUF_SET_IODONE_FUNC(bp, func) ((bp)->b_iodone = (func))
309#define XFS_BUF_CLR_IODONE_FUNC(bp) ((bp)->b_iodone = NULL)
310#define XFS_BUF_SET_BDSTRAT_FUNC(bp, func) ((bp)->b_strat = (func))
311#define XFS_BUF_CLR_BDSTRAT_FUNC(bp) ((bp)->b_strat = NULL)
312
313#define XFS_BUF_FSPRIVATE(bp, type) ((type)(bp)->b_fspriv)
314#define XFS_BUF_SET_FSPRIVATE(bp, val) ((bp)->b_fspriv = (void*)(val))
315#define XFS_BUF_FSPRIVATE2(bp, type) ((type)(bp)->b_fspriv2)
316#define XFS_BUF_SET_FSPRIVATE2(bp, val) ((bp)->b_fspriv2 = (void*)(val))
317#define XFS_BUF_FSPRIVATE3(bp, type) ((type)(bp)->b_fspriv3)
318#define XFS_BUF_SET_FSPRIVATE3(bp, val) ((bp)->b_fspriv3 = (void*)(val))
319#define XFS_BUF_SET_START(bp) do { } while (0)
320#define XFS_BUF_SET_BRELSE_FUNC(bp, func) ((bp)->b_relse = (func))
321
322#define XFS_BUF_PTR(bp) (xfs_caddr_t)((bp)->b_addr)
323#define XFS_BUF_SET_PTR(bp, val, cnt) xfs_buf_associate_memory(bp, val, cnt)
324#define XFS_BUF_ADDR(bp) ((bp)->b_bn)
325#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno))
326#define XFS_BUF_OFFSET(bp) ((bp)->b_file_offset)
327#define XFS_BUF_SET_OFFSET(bp, off) ((bp)->b_file_offset = (off))
328#define XFS_BUF_COUNT(bp) ((bp)->b_count_desired)
329#define XFS_BUF_SET_COUNT(bp, cnt) ((bp)->b_count_desired = (cnt))
330#define XFS_BUF_SIZE(bp) ((bp)->b_buffer_length)
331#define XFS_BUF_SET_SIZE(bp, cnt) ((bp)->b_buffer_length = (cnt))
332
333#define XFS_BUF_SET_VTYPE_REF(bp, type, ref) do { } while (0)
334#define XFS_BUF_SET_VTYPE(bp, type) do { } while (0)
335#define XFS_BUF_SET_REF(bp, ref) do { } while (0)
336
337#define XFS_BUF_ISPINNED(bp) xfs_buf_ispin(bp)
338
339#define XFS_BUF_VALUSEMA(bp) xfs_buf_lock_value(bp)
340#define XFS_BUF_CPSEMA(bp) (xfs_buf_cond_lock(bp) == 0)
341#define XFS_BUF_VSEMA(bp) xfs_buf_unlock(bp)
342#define XFS_BUF_PSEMA(bp,x) xfs_buf_lock(bp)
343#define XFS_BUF_V_IODONESEMA(bp) up(&bp->b_iodonesema);
344
345#define XFS_BUF_SET_TARGET(bp, target) ((bp)->b_target = (target))
346#define XFS_BUF_TARGET(bp) ((bp)->b_target)
347#define XFS_BUFTARG_NAME(target) xfs_buf_target_name(target)
348
349static inline int xfs_bawrite(void *mp, xfs_buf_t *bp)
472{ 350{
473 bp->pb_fspriv3 = mp; 351 bp->b_fspriv3 = mp;
474 bp->pb_strat = xfs_bdstrat_cb; 352 bp->b_strat = xfs_bdstrat_cb;
475 pagebuf_delwri_dequeue(bp); 353 xfs_buf_delwri_dequeue(bp);
476 return pagebuf_iostart(bp, PBF_WRITE | PBF_ASYNC | _PBF_RUN_QUEUES); 354 return xfs_buf_iostart(bp, XBF_WRITE | XBF_ASYNC | _XBF_RUN_QUEUES);
477} 355}
478 356
479static inline void xfs_buf_relse(xfs_buf_t *bp) 357static inline void xfs_buf_relse(xfs_buf_t *bp)
480{ 358{
481 if (!bp->pb_relse) 359 if (!bp->b_relse)
482 pagebuf_unlock(bp); 360 xfs_buf_unlock(bp);
483 pagebuf_rele(bp); 361 xfs_buf_rele(bp);
484} 362}
485 363
486#define xfs_bpin(bp) pagebuf_pin(bp) 364#define xfs_bpin(bp) xfs_buf_pin(bp)
487#define xfs_bunpin(bp) pagebuf_unpin(bp) 365#define xfs_bunpin(bp) xfs_buf_unpin(bp)
488 366
489#define xfs_buftrace(id, bp) \ 367#define xfs_buftrace(id, bp) \
490 pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0)) 368 xfs_buf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
491 369
492#define xfs_biodone(pb) \ 370#define xfs_biodone(bp) xfs_buf_ioend(bp, 0)
493 pagebuf_iodone(pb, 0)
494 371
495#define xfs_biomove(pb, off, len, data, rw) \ 372#define xfs_biomove(bp, off, len, data, rw) \
496 pagebuf_iomove((pb), (off), (len), (data), \ 373 xfs_buf_iomove((bp), (off), (len), (data), \
497 ((rw) == XFS_B_WRITE) ? PBRW_WRITE : PBRW_READ) 374 ((rw) == XFS_B_WRITE) ? XBRW_WRITE : XBRW_READ)
498 375
499#define xfs_biozero(pb, off, len) \ 376#define xfs_biozero(bp, off, len) \
500 pagebuf_iomove((pb), (off), (len), NULL, PBRW_ZERO) 377 xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO)
501 378
502 379
503static inline int XFS_bwrite(xfs_buf_t *pb) 380static inline int XFS_bwrite(xfs_buf_t *bp)
504{ 381{
505 int iowait = (pb->pb_flags & PBF_ASYNC) == 0; 382 int iowait = (bp->b_flags & XBF_ASYNC) == 0;
506 int error = 0; 383 int error = 0;
507 384
508 if (!iowait) 385 if (!iowait)
509 pb->pb_flags |= _PBF_RUN_QUEUES; 386 bp->b_flags |= _XBF_RUN_QUEUES;
510 387
511 pagebuf_delwri_dequeue(pb); 388 xfs_buf_delwri_dequeue(bp);
512 pagebuf_iostrategy(pb); 389 xfs_buf_iostrategy(bp);
513 if (iowait) { 390 if (iowait) {
514 error = pagebuf_iowait(pb); 391 error = xfs_buf_iowait(bp);
515 xfs_buf_relse(pb); 392 xfs_buf_relse(bp);
516 } 393 }
517 return error; 394 return error;
518} 395}
519 396
520#define XFS_bdwrite(pb) \ 397#define XFS_bdwrite(bp) xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC)
521 pagebuf_iostart(pb, PBF_DELWRI | PBF_ASYNC)
522 398
523static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp) 399static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp)
524{ 400{
525 bp->pb_strat = xfs_bdstrat_cb; 401 bp->b_strat = xfs_bdstrat_cb;
526 bp->pb_fspriv3 = mp; 402 bp->b_fspriv3 = mp;
527 403 return xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC);
528 return pagebuf_iostart(bp, PBF_DELWRI | PBF_ASYNC);
529} 404}
530 405
531#define XFS_bdstrat(bp) pagebuf_iorequest(bp) 406#define XFS_bdstrat(bp) xfs_buf_iorequest(bp)
532 407
533#define xfs_iowait(pb) pagebuf_iowait(pb) 408#define xfs_iowait(bp) xfs_buf_iowait(bp)
534 409
535#define xfs_baread(target, rablkno, ralen) \ 410#define xfs_baread(target, rablkno, ralen) \
536 pagebuf_readahead((target), (rablkno), (ralen), PBF_DONT_BLOCK) 411 xfs_buf_readahead((target), (rablkno), (ralen), XBF_DONT_BLOCK)
537
538#define xfs_buf_get_empty(len, target) pagebuf_get_empty((len), (target))
539#define xfs_buf_get_noaddr(len, target) pagebuf_get_no_daddr((len), (target))
540#define xfs_buf_free(bp) pagebuf_free(bp)
541 412
542 413
543/* 414/*
544 * Handling of buftargs. 415 * Handling of buftargs.
545 */ 416 */
546
547extern xfs_buftarg_t *xfs_alloc_buftarg(struct block_device *, int); 417extern xfs_buftarg_t *xfs_alloc_buftarg(struct block_device *, int);
548extern void xfs_free_buftarg(xfs_buftarg_t *, int); 418extern void xfs_free_buftarg(xfs_buftarg_t *, int);
549extern void xfs_wait_buftarg(xfs_buftarg_t *); 419extern void xfs_wait_buftarg(xfs_buftarg_t *);
550extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int); 420extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int);
551extern int xfs_flush_buftarg(xfs_buftarg_t *, int); 421extern int xfs_flush_buftarg(xfs_buftarg_t *, int);
552 422
553#define xfs_getsize_buftarg(buftarg) \ 423#define xfs_getsize_buftarg(buftarg) block_size((buftarg)->bt_bdev)
554 block_size((buftarg)->pbr_bdev) 424#define xfs_readonly_buftarg(buftarg) bdev_read_only((buftarg)->bt_bdev)
555#define xfs_readonly_buftarg(buftarg) \ 425
556 bdev_read_only((buftarg)->pbr_bdev) 426#define xfs_binval(buftarg) xfs_flush_buftarg(buftarg, 1)
557#define xfs_binval(buftarg) \ 427#define XFS_bflush(buftarg) xfs_flush_buftarg(buftarg, 1)
558 xfs_flush_buftarg(buftarg, 1)
559#define XFS_bflush(buftarg) \
560 xfs_flush_buftarg(buftarg, 1)
561 428
562#endif /* __XFS_BUF_H__ */ 429#endif /* __XFS_BUF_H__ */