diff options
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_buf.h')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.h | 119 |
1 files changed, 52 insertions, 67 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index 5fbecefa5dfd..d072e5ff923b 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
@@ -44,57 +44,57 @@ typedef enum { | |||
44 | XBRW_ZERO = 3, /* Zero target memory */ | 44 | XBRW_ZERO = 3, /* Zero target memory */ |
45 | } xfs_buf_rw_t; | 45 | } xfs_buf_rw_t; |
46 | 46 | ||
47 | typedef enum { | 47 | #define XBF_READ (1 << 0) /* buffer intended for reading from device */ |
48 | XBF_READ = (1 << 0), /* buffer intended for reading from device */ | 48 | #define XBF_WRITE (1 << 1) /* buffer intended for writing to device */ |
49 | XBF_WRITE = (1 << 1), /* buffer intended for writing to device */ | 49 | #define XBF_MAPPED (1 << 2) /* buffer mapped (b_addr valid) */ |
50 | XBF_MAPPED = (1 << 2), /* buffer mapped (b_addr valid) */ | 50 | #define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */ |
51 | XBF_ASYNC = (1 << 4), /* initiator will not wait for completion */ | 51 | #define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */ |
52 | XBF_DONE = (1 << 5), /* all pages in the buffer uptodate */ | 52 | #define XBF_DELWRI (1 << 6) /* buffer has dirty pages */ |
53 | XBF_DELWRI = (1 << 6), /* buffer has dirty pages */ | 53 | #define XBF_STALE (1 << 7) /* buffer has been staled, do not find it */ |
54 | XBF_STALE = (1 << 7), /* buffer has been staled, do not find it */ | 54 | #define XBF_FS_MANAGED (1 << 8) /* filesystem controls freeing memory */ |
55 | XBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ | 55 | #define XBF_ORDERED (1 << 11)/* use ordered writes */ |
56 | XBF_ORDERED = (1 << 11), /* use ordered writes */ | 56 | #define XBF_READ_AHEAD (1 << 12)/* asynchronous read-ahead */ |
57 | XBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */ | 57 | #define XBF_LOG_BUFFER (1 << 13)/* this is a buffer used for the log */ |
58 | XBF_LOG_BUFFER = (1 << 13), /* this is a buffer used for the log */ | 58 | |
59 | 59 | /* flags used only as arguments to access routines */ | |
60 | /* flags used only as arguments to access routines */ | 60 | #define XBF_LOCK (1 << 14)/* lock requested */ |
61 | XBF_LOCK = (1 << 14), /* lock requested */ | 61 | #define XBF_TRYLOCK (1 << 15)/* lock requested, but do not wait */ |
62 | XBF_TRYLOCK = (1 << 15), /* lock requested, but do not wait */ | 62 | #define XBF_DONT_BLOCK (1 << 16)/* do not block in current thread */ |
63 | XBF_DONT_BLOCK = (1 << 16), /* do not block in current thread */ | 63 | |
64 | 64 | /* flags used only internally */ | |
65 | /* flags used only internally */ | 65 | #define _XBF_PAGE_CACHE (1 << 17)/* backed by pagecache */ |
66 | _XBF_PAGE_CACHE = (1 << 17),/* backed by pagecache */ | 66 | #define _XBF_PAGES (1 << 18)/* backed by refcounted pages */ |
67 | _XBF_PAGES = (1 << 18), /* backed by refcounted pages */ | 67 | #define _XBF_RUN_QUEUES (1 << 19)/* run block device task queue */ |
68 | _XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */ | 68 | #define _XBF_DELWRI_Q (1 << 21)/* buffer on delwri queue */ |
69 | _XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */ | 69 | |
70 | 70 | /* | |
71 | /* | 71 | * Special flag for supporting metadata blocks smaller than a FSB. |
72 | * Special flag for supporting metadata blocks smaller than a FSB. | 72 | * |
73 | * | 73 | * In this case we can have multiple xfs_buf_t on a single page and |
74 | * In this case we can have multiple xfs_buf_t on a single page and | 74 | * need to lock out concurrent xfs_buf_t readers as they only |
75 | * need to lock out concurrent xfs_buf_t readers as they only | 75 | * serialise access to the buffer. |
76 | * serialise access to the buffer. | 76 | * |
77 | * | 77 | * If the FSB size >= PAGE_CACHE_SIZE case, we have no serialisation |
78 | * If the FSB size >= PAGE_CACHE_SIZE case, we have no serialisation | 78 | * between reads of the page. Hence we can have one thread read the |
79 | * between reads of the page. Hence we can have one thread read the | 79 | * page and modify it, but then race with another thread that thinks |
80 | * page and modify it, but then race with another thread that thinks | 80 | * the page is not up-to-date and hence reads it again. |
81 | * the page is not up-to-date and hence reads it again. | 81 | * |
82 | * | 82 | * The result is that the first modifcation to the page is lost. |
83 | * The result is that the first modifcation to the page is lost. | 83 | * This sort of AGF/AGI reading race can happen when unlinking inodes |
84 | * This sort of AGF/AGI reading race can happen when unlinking inodes | 84 | * that require truncation and results in the AGI unlinked list |
85 | * that require truncation and results in the AGI unlinked list | 85 | * modifications being lost. |
86 | * modifications being lost. | 86 | */ |
87 | */ | 87 | #define _XBF_PAGE_LOCKED (1 << 22) |
88 | _XBF_PAGE_LOCKED = (1 << 22), | 88 | |
89 | 89 | /* | |
90 | /* | 90 | * If we try a barrier write, but it fails we have to communicate |
91 | * If we try a barrier write, but it fails we have to communicate | 91 | * this to the upper layers. Unfortunately b_error gets overwritten |
92 | * this to the upper layers. Unfortunately b_error gets overwritten | 92 | * when the buffer is re-issued so we have to add another flag to |
93 | * when the buffer is re-issued so we have to add another flag to | 93 | * keep this information. |
94 | * keep this information. | 94 | */ |
95 | */ | 95 | #define _XFS_BARRIER_FAILED (1 << 23) |
96 | _XFS_BARRIER_FAILED = (1 << 23), | 96 | |
97 | } xfs_buf_flags_t; | 97 | typedef unsigned int xfs_buf_flags_t; |
98 | 98 | ||
99 | #define XFS_BUF_FLAGS \ | 99 | #define XFS_BUF_FLAGS \ |
100 | { XBF_READ, "READ" }, \ | 100 | { XBF_READ, "READ" }, \ |
@@ -187,7 +187,6 @@ typedef struct xfs_buf { | |||
187 | atomic_t b_io_remaining; /* #outstanding I/O requests */ | 187 | atomic_t b_io_remaining; /* #outstanding I/O requests */ |
188 | xfs_buf_iodone_t b_iodone; /* I/O completion function */ | 188 | xfs_buf_iodone_t b_iodone; /* I/O completion function */ |
189 | xfs_buf_relse_t b_relse; /* releasing function */ | 189 | xfs_buf_relse_t b_relse; /* releasing function */ |
190 | xfs_buf_bdstrat_t b_strat; /* pre-write function */ | ||
191 | struct completion b_iowait; /* queue for I/O waiters */ | 190 | struct completion b_iowait; /* queue for I/O waiters */ |
192 | void *b_fspriv; | 191 | void *b_fspriv; |
193 | void *b_fspriv2; | 192 | void *b_fspriv2; |
@@ -245,11 +244,6 @@ extern int xfs_buf_iowait(xfs_buf_t *); | |||
245 | extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *, | 244 | extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *, |
246 | xfs_buf_rw_t); | 245 | xfs_buf_rw_t); |
247 | 246 | ||
248 | static inline int xfs_buf_iostrategy(xfs_buf_t *bp) | ||
249 | { | ||
250 | return bp->b_strat ? bp->b_strat(bp) : xfs_buf_iorequest(bp); | ||
251 | } | ||
252 | |||
253 | static inline int xfs_buf_geterror(xfs_buf_t *bp) | 247 | static inline int xfs_buf_geterror(xfs_buf_t *bp) |
254 | { | 248 | { |
255 | return bp ? bp->b_error : ENOMEM; | 249 | return bp ? bp->b_error : ENOMEM; |
@@ -258,11 +252,6 @@ static inline int xfs_buf_geterror(xfs_buf_t *bp) | |||
258 | /* Buffer Utility Routines */ | 252 | /* Buffer Utility Routines */ |
259 | extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t); | 253 | extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t); |
260 | 254 | ||
261 | /* Pinning Buffer Storage in Memory */ | ||
262 | extern void xfs_buf_pin(xfs_buf_t *); | ||
263 | extern void xfs_buf_unpin(xfs_buf_t *); | ||
264 | extern int xfs_buf_ispin(xfs_buf_t *); | ||
265 | |||
266 | /* Delayed Write Buffer Routines */ | 255 | /* Delayed Write Buffer Routines */ |
267 | extern void xfs_buf_delwri_dequeue(xfs_buf_t *); | 256 | extern void xfs_buf_delwri_dequeue(xfs_buf_t *); |
268 | extern void xfs_buf_delwri_promote(xfs_buf_t *); | 257 | extern void xfs_buf_delwri_promote(xfs_buf_t *); |
@@ -326,8 +315,6 @@ extern void xfs_buf_terminate(void); | |||
326 | #define XFS_BUF_IODONE_FUNC(bp) ((bp)->b_iodone) | 315 | #define XFS_BUF_IODONE_FUNC(bp) ((bp)->b_iodone) |
327 | #define XFS_BUF_SET_IODONE_FUNC(bp, func) ((bp)->b_iodone = (func)) | 316 | #define XFS_BUF_SET_IODONE_FUNC(bp, func) ((bp)->b_iodone = (func)) |
328 | #define XFS_BUF_CLR_IODONE_FUNC(bp) ((bp)->b_iodone = NULL) | 317 | #define XFS_BUF_CLR_IODONE_FUNC(bp) ((bp)->b_iodone = NULL) |
329 | #define XFS_BUF_SET_BDSTRAT_FUNC(bp, func) ((bp)->b_strat = (func)) | ||
330 | #define XFS_BUF_CLR_BDSTRAT_FUNC(bp) ((bp)->b_strat = NULL) | ||
331 | 318 | ||
332 | #define XFS_BUF_FSPRIVATE(bp, type) ((type)(bp)->b_fspriv) | 319 | #define XFS_BUF_FSPRIVATE(bp, type) ((type)(bp)->b_fspriv) |
333 | #define XFS_BUF_SET_FSPRIVATE(bp, val) ((bp)->b_fspriv = (void*)(val)) | 320 | #define XFS_BUF_SET_FSPRIVATE(bp, val) ((bp)->b_fspriv = (void*)(val)) |
@@ -351,7 +338,7 @@ extern void xfs_buf_terminate(void); | |||
351 | #define XFS_BUF_SET_VTYPE(bp, type) do { } while (0) | 338 | #define XFS_BUF_SET_VTYPE(bp, type) do { } while (0) |
352 | #define XFS_BUF_SET_REF(bp, ref) do { } while (0) | 339 | #define XFS_BUF_SET_REF(bp, ref) do { } while (0) |
353 | 340 | ||
354 | #define XFS_BUF_ISPINNED(bp) xfs_buf_ispin(bp) | 341 | #define XFS_BUF_ISPINNED(bp) atomic_read(&((bp)->b_pin_count)) |
355 | 342 | ||
356 | #define XFS_BUF_VALUSEMA(bp) xfs_buf_lock_value(bp) | 343 | #define XFS_BUF_VALUSEMA(bp) xfs_buf_lock_value(bp) |
357 | #define XFS_BUF_CPSEMA(bp) (xfs_buf_cond_lock(bp) == 0) | 344 | #define XFS_BUF_CPSEMA(bp) (xfs_buf_cond_lock(bp) == 0) |
@@ -370,8 +357,6 @@ static inline void xfs_buf_relse(xfs_buf_t *bp) | |||
370 | xfs_buf_rele(bp); | 357 | xfs_buf_rele(bp); |
371 | } | 358 | } |
372 | 359 | ||
373 | #define xfs_bpin(bp) xfs_buf_pin(bp) | ||
374 | #define xfs_bunpin(bp) xfs_buf_unpin(bp) | ||
375 | #define xfs_biodone(bp) xfs_buf_ioend(bp, 0) | 360 | #define xfs_biodone(bp) xfs_buf_ioend(bp, 0) |
376 | 361 | ||
377 | #define xfs_biomove(bp, off, len, data, rw) \ | 362 | #define xfs_biomove(bp, off, len, data, rw) \ |