aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorBarry Naujok <bnaujok@sgi.com>2008-10-30 02:05:38 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:05:38 -0400
commit847fff5ca881670ca8ec617afeb943950f0c804b (patch)
treecd03cf7a3422842978332a22de51c91827821841 /fs/xfs
parent24ee0e49c9cce23acb1758728cb09e8d2b53bd33 (diff)
[XFS] Sync up kernel and user-space headers
SGI-PV: 986558 SGI-Modid: xfs-linux-melb:xfs-kern:32231a Signed-off-by: Barry Naujok <bnaujok@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_ag.h5
-rw-r--r--fs/xfs/xfs_alloc.h27
-rw-r--r--fs/xfs/xfs_arch.h39
-rw-r--r--fs/xfs/xfs_bit.h3
-rw-r--r--fs/xfs/xfs_bmap.h61
-rw-r--r--fs/xfs/xfs_bmap_btree.h3
-rw-r--r--fs/xfs/xfs_btree.h4
-rw-r--r--fs/xfs/xfs_da_btree.h4
-rw-r--r--fs/xfs/xfs_ialloc.h3
-rw-r--r--fs/xfs/xfs_imap.h2
-rw-r--r--fs/xfs/xfs_inode.h246
-rw-r--r--fs/xfs/xfs_inode_item.h41
-rw-r--r--fs/xfs/xfs_mount.h17
-rw-r--r--fs/xfs/xfs_trans.h317
14 files changed, 383 insertions, 389 deletions
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h
index 61b292a9fb41..729ee3eb39ad 100644
--- a/fs/xfs/xfs_ag.h
+++ b/fs/xfs/xfs_ag.h
@@ -192,15 +192,16 @@ typedef struct xfs_perag
192 xfs_agino_t pagi_freecount; /* number of free inodes */ 192 xfs_agino_t pagi_freecount; /* number of free inodes */
193 xfs_agino_t pagi_count; /* number of allocated inodes */ 193 xfs_agino_t pagi_count; /* number of allocated inodes */
194 int pagb_count; /* pagb slots in use */ 194 int pagb_count; /* pagb slots in use */
195 xfs_perag_busy_t *pagb_list; /* unstable blocks */
195#ifdef __KERNEL__ 196#ifdef __KERNEL__
196 spinlock_t pagb_lock; /* lock for pagb_list */ 197 spinlock_t pagb_lock; /* lock for pagb_list */
197#endif 198
198 xfs_perag_busy_t *pagb_list; /* unstable blocks */
199 atomic_t pagf_fstrms; /* # of filestreams active in this AG */ 199 atomic_t pagf_fstrms; /* # of filestreams active in this AG */
200 200
201 int pag_ici_init; /* incore inode cache initialised */ 201 int pag_ici_init; /* incore inode cache initialised */
202 rwlock_t pag_ici_lock; /* incore inode lock */ 202 rwlock_t pag_ici_lock; /* incore inode lock */
203 struct radix_tree_root pag_ici_root; /* incore inode cache root */ 203 struct radix_tree_root pag_ici_root; /* incore inode cache root */
204#endif
204} xfs_perag_t; 205} xfs_perag_t;
205 206
206#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels) 207#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
diff --git a/fs/xfs/xfs_alloc.h b/fs/xfs/xfs_alloc.h
index 5aec15d0651e..588172796f7b 100644
--- a/fs/xfs/xfs_alloc.h
+++ b/fs/xfs/xfs_alloc.h
@@ -121,6 +121,19 @@ extern ktrace_t *xfs_alloc_trace_buf;
121#define XFS_ALLOC_KTRACE_BUSYSEARCH 6 121#define XFS_ALLOC_KTRACE_BUSYSEARCH 6
122#endif 122#endif
123 123
124void
125xfs_alloc_mark_busy(xfs_trans_t *tp,
126 xfs_agnumber_t agno,
127 xfs_agblock_t bno,
128 xfs_extlen_t len);
129
130void
131xfs_alloc_clear_busy(xfs_trans_t *tp,
132 xfs_agnumber_t ag,
133 int idx);
134
135#endif /* __KERNEL__ */
136
124/* 137/*
125 * Compute and fill in value of m_ag_maxlevels. 138 * Compute and fill in value of m_ag_maxlevels.
126 */ 139 */
@@ -196,18 +209,4 @@ xfs_free_extent(
196 xfs_fsblock_t bno, /* starting block number of extent */ 209 xfs_fsblock_t bno, /* starting block number of extent */
197 xfs_extlen_t len); /* length of extent */ 210 xfs_extlen_t len); /* length of extent */
198 211
199void
200xfs_alloc_mark_busy(xfs_trans_t *tp,
201 xfs_agnumber_t agno,
202 xfs_agblock_t bno,
203 xfs_extlen_t len);
204
205void
206xfs_alloc_clear_busy(xfs_trans_t *tp,
207 xfs_agnumber_t ag,
208 int idx);
209
210
211#endif /* __KERNEL__ */
212
213#endif /* __XFS_ALLOC_H__ */ 212#endif /* __XFS_ALLOC_H__ */
diff --git a/fs/xfs/xfs_arch.h b/fs/xfs/xfs_arch.h
index 0b3b5efe848c..53d5e70d1360 100644
--- a/fs/xfs/xfs_arch.h
+++ b/fs/xfs/xfs_arch.h
@@ -41,21 +41,36 @@
41#endif 41#endif
42 42
43#ifdef XFS_NATIVE_HOST 43#ifdef XFS_NATIVE_HOST
44#define cpu_to_be16(val) ((__be16)(val)) 44#define cpu_to_be16(val) ((__force __be16)(__u16)(val))
45#define cpu_to_be32(val) ((__be32)(val)) 45#define cpu_to_be32(val) ((__force __be32)(__u32)(val))
46#define cpu_to_be64(val) ((__be64)(val)) 46#define cpu_to_be64(val) ((__force __be64)(__u64)(val))
47#define be16_to_cpu(val) ((__uint16_t)(val)) 47#define be16_to_cpu(val) ((__force __u16)(__be16)(val))
48#define be32_to_cpu(val) ((__uint32_t)(val)) 48#define be32_to_cpu(val) ((__force __u32)(__be32)(val))
49#define be64_to_cpu(val) ((__uint64_t)(val)) 49#define be64_to_cpu(val) ((__force __u64)(__be64)(val))
50#else 50#else
51#define cpu_to_be16(val) (__swab16((__uint16_t)(val))) 51#define cpu_to_be16(val) ((__force __be16)__swab16((__u16)(val)))
52#define cpu_to_be32(val) (__swab32((__uint32_t)(val))) 52#define cpu_to_be32(val) ((__force __be32)__swab32((__u32)(val)))
53#define cpu_to_be64(val) (__swab64((__uint64_t)(val))) 53#define cpu_to_be64(val) ((__force __be64)__swab64((__u64)(val)))
54#define be16_to_cpu(val) (__swab16((__be16)(val))) 54#define be16_to_cpu(val) (__swab16((__force __u16)(__be16)(val)))
55#define be32_to_cpu(val) (__swab32((__be32)(val))) 55#define be32_to_cpu(val) (__swab32((__force __u32)(__be32)(val)))
56#define be64_to_cpu(val) (__swab64((__be64)(val))) 56#define be64_to_cpu(val) (__swab64((__force __u64)(__be64)(val)))
57#endif 57#endif
58 58
59static inline void be16_add_cpu(__be16 *a, __s16 b)
60{
61 *a = cpu_to_be16(be16_to_cpu(*a) + b);
62}
63
64static inline void be32_add_cpu(__be32 *a, __s32 b)
65{
66 *a = cpu_to_be32(be32_to_cpu(*a) + b);
67}
68
69static inline void be64_add_cpu(__be64 *a, __s64 b)
70{
71 *a = cpu_to_be64(be64_to_cpu(*a) + b);
72}
73
59#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
60 75
61/* do we need conversion? */ 76/* do we need conversion? */
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h
index 8e0e463dae2d..bca7b243c319 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/xfs_bit.h
@@ -61,8 +61,7 @@ static inline int xfs_highbit64(__uint64_t v)
61/* Get low bit set out of 32-bit argument, -1 if none set */ 61/* Get low bit set out of 32-bit argument, -1 if none set */
62static inline int xfs_lowbit32(__uint32_t v) 62static inline int xfs_lowbit32(__uint32_t v)
63{ 63{
64 unsigned long t = v; 64 return ffs(v) - 1;
65 return (v) ? find_first_bit(&t, 32) : -1;
66} 65}
67 66
68/* Get low bit set out of 64-bit argument, -1 if none set */ 67/* Get low bit set out of 64-bit argument, -1 if none set */
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index 9f3e3a836d15..7c9d12cd7a47 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -137,9 +137,7 @@ typedef struct xfs_bmalloca {
137 char conv; /* overwriting unwritten extents */ 137 char conv; /* overwriting unwritten extents */
138} xfs_bmalloca_t; 138} xfs_bmalloca_t;
139 139
140#ifdef __KERNEL__ 140#if defined(__KERNEL__) && defined(XFS_BMAP_TRACE)
141
142#if defined(XFS_BMAP_TRACE)
143/* 141/*
144 * Trace operations for bmap extent tracing 142 * Trace operations for bmap extent tracing
145 */ 143 */
@@ -163,9 +161,12 @@ xfs_bmap_trace_exlist(
163 int whichfork); /* data or attr fork */ 161 int whichfork); /* data or attr fork */
164#define XFS_BMAP_TRACE_EXLIST(ip,c,w) \ 162#define XFS_BMAP_TRACE_EXLIST(ip,c,w) \
165 xfs_bmap_trace_exlist(__func__,ip,c,w) 163 xfs_bmap_trace_exlist(__func__,ip,c,w)
166#else 164
165#else /* __KERNEL__ && XFS_BMAP_TRACE */
166
167#define XFS_BMAP_TRACE_EXLIST(ip,c,w) 167#define XFS_BMAP_TRACE_EXLIST(ip,c,w)
168#endif 168
169#endif /* __KERNEL__ && XFS_BMAP_TRACE */
169 170
170/* 171/*
171 * Convert inode from non-attributed to attributed. 172 * Convert inode from non-attributed to attributed.
@@ -206,20 +207,6 @@ xfs_bmap_compute_maxlevels(
206 int whichfork); /* data or attr fork */ 207 int whichfork); /* data or attr fork */
207 208
208/* 209/*
209 * Routine to be called at transaction's end by xfs_bmapi, xfs_bunmapi
210 * caller. Frees all the extents that need freeing, which must be done
211 * last due to locking considerations.
212 *
213 * Return 1 if the given transaction was committed and a new one allocated,
214 * and 0 otherwise.
215 */
216int /* error */
217xfs_bmap_finish(
218 struct xfs_trans **tp, /* transaction pointer addr */
219 xfs_bmap_free_t *flist, /* i/o: list extents to free */
220 int *committed); /* xact committed or not */
221
222/*
223 * Returns the file-relative block number of the first unused block in the file. 210 * Returns the file-relative block number of the first unused block in the file.
224 * This is the lowest-address hole if the file has holes, else the first block 211 * This is the lowest-address hole if the file has holes, else the first block
225 * past the end of file. 212 * past the end of file.
@@ -344,6 +331,32 @@ xfs_bunmapi(
344 int *done); /* set if not done yet */ 331 int *done); /* set if not done yet */
345 332
346/* 333/*
334 * Check an extent list, which has just been read, for
335 * any bit in the extent flag field.
336 */
337int
338xfs_check_nostate_extents(
339 struct xfs_ifork *ifp,
340 xfs_extnum_t idx,
341 xfs_extnum_t num);
342
343#ifdef __KERNEL__
344
345/*
346 * Routine to be called at transaction's end by xfs_bmapi, xfs_bunmapi
347 * caller. Frees all the extents that need freeing, which must be done
348 * last due to locking considerations.
349 *
350 * Return 1 if the given transaction was committed and a new one allocated,
351 * and 0 otherwise.
352 */
353int /* error */
354xfs_bmap_finish(
355 struct xfs_trans **tp, /* transaction pointer addr */
356 xfs_bmap_free_t *flist, /* i/o: list extents to free */
357 int *committed); /* xact committed or not */
358
359/*
347 * Fcntl interface to xfs_bmapi. 360 * Fcntl interface to xfs_bmapi.
348 */ 361 */
349int /* error code */ 362int /* error code */
@@ -375,16 +388,6 @@ xfs_bmap_count_blocks(
375 int *count); 388 int *count);
376 389
377/* 390/*
378 * Check an extent list, which has just been read, for
379 * any bit in the extent flag field.
380 */
381int
382xfs_check_nostate_extents(
383 struct xfs_ifork *ifp,
384 xfs_extnum_t idx,
385 xfs_extnum_t num);
386
387/*
388 * Search the extent records for the entry containing block bno. 391 * Search the extent records for the entry containing block bno.
389 * If bno lies in a hole, point to the next entry. If bno lies 392 * If bno lies in a hole, point to the next entry. If bno lies
390 * past eof, *eofp will be set, and *prevp will contain the last 393 * past eof, *eofp will be set, and *prevp will contain the last
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 6f38e2505701..5669242b52d3 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -231,8 +231,6 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;
231 be16_to_cpu((bb)->bb_numrecs) <= (mp)->m_bmap_dmxr[(level) != 0]) 231 be16_to_cpu((bb)->bb_numrecs) <= (mp)->m_bmap_dmxr[(level) != 0])
232 232
233 233
234#ifdef __KERNEL__
235
236/* 234/*
237 * Prototypes for xfs_bmap.c to call. 235 * Prototypes for xfs_bmap.c to call.
238 */ 236 */
@@ -264,6 +262,5 @@ extern void xfs_bmbt_to_bmdr(xfs_bmbt_block_t *, int, xfs_bmdr_block_t *, int);
264extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *, 262extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
265 struct xfs_trans *, struct xfs_inode *, int); 263 struct xfs_trans *, struct xfs_inode *, int);
266 264
267#endif /* __KERNEL__ */
268 265
269#endif /* __XFS_BMAP_BTREE_H__ */ 266#endif /* __XFS_BMAP_BTREE_H__ */
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 2a22c587f1ae..7425b2b4a254 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -327,8 +327,6 @@ typedef struct xfs_btree_cur
327#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp)) 327#define XFS_BUF_TO_SBLOCK(bp) ((xfs_btree_sblock_t *)XFS_BUF_PTR(bp))
328 328
329 329
330#ifdef __KERNEL__
331
332/* 330/*
333 * Check that long form block header is ok. 331 * Check that long form block header is ok.
334 */ 332 */
@@ -515,8 +513,6 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
515 return be16_to_cpu(block->bb_level); 513 return be16_to_cpu(block->bb_level);
516} 514}
517 515
518#endif /* __KERNEL__ */
519
520 516
521/* 517/*
522 * Min and max functions for extlen, agblock, fileoff, and filblks types. 518 * Min and max functions for extlen, agblock, fileoff, and filblks types.
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index 599e270e6959..70b710c1792d 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -206,9 +206,8 @@ struct xfs_nameops {
206}; 206};
207 207
208 208
209#ifdef __KERNEL__
210/*======================================================================== 209/*========================================================================
211 * Function prototypes for the kernel. 210 * Function prototypes.
212 *========================================================================*/ 211 *========================================================================*/
213 212
214/* 213/*
@@ -269,6 +268,5 @@ xfs_daddr_t xfs_da_blkno(xfs_dabuf_t *dabuf);
269 268
270extern struct kmem_zone *xfs_da_state_zone; 269extern struct kmem_zone *xfs_da_state_zone;
271extern struct kmem_zone *xfs_dabuf_zone; 270extern struct kmem_zone *xfs_dabuf_zone;
272#endif /* __KERNEL__ */
273 271
274#endif /* __XFS_DA_BTREE_H__ */ 272#endif /* __XFS_DA_BTREE_H__ */
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index c5745f6d94ec..ccf554a6e0a1 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -56,7 +56,6 @@ static inline int xfs_ialloc_find_free(xfs_inofree_t *fp)
56} 56}
57 57
58 58
59#ifdef __KERNEL__
60/* 59/*
61 * Allocate an inode on disk. 60 * Allocate an inode on disk.
62 * Mode is used to tell whether the new inode will need space, and whether 61 * Mode is used to tell whether the new inode will need space, and whether
@@ -174,6 +173,4 @@ int xfs_inobt_lookup_le(struct xfs_btree_cur *cur, xfs_agino_t ino,
174extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, xfs_agino_t *ino, 173extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, xfs_agino_t *ino,
175 __int32_t *fcnt, xfs_inofree_t *free, int *stat); 174 __int32_t *fcnt, xfs_inofree_t *free, int *stat);
176 175
177#endif /* __KERNEL__ */
178
179#endif /* __XFS_IALLOC_H__ */ 176#endif /* __XFS_IALLOC_H__ */
diff --git a/fs/xfs/xfs_imap.h b/fs/xfs/xfs_imap.h
index d36450003983..f9ce62890ea5 100644
--- a/fs/xfs/xfs_imap.h
+++ b/fs/xfs/xfs_imap.h
@@ -30,11 +30,9 @@ typedef struct xfs_imap {
30 ushort im_boffset; /* inode offset in block in bytes */ 30 ushort im_boffset; /* inode offset in block in bytes */
31} xfs_imap_t; 31} xfs_imap_t;
32 32
33#ifdef __KERNEL__
34struct xfs_mount; 33struct xfs_mount;
35struct xfs_trans; 34struct xfs_trans;
36int xfs_imap(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 35int xfs_imap(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
37 xfs_imap_t *, uint); 36 xfs_imap_t *, uint);
38#endif
39 37
40#endif /* __XFS_IMAP_H__ */ 38#endif /* __XFS_IMAP_H__ */
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 2a69a7dee228..a8f1e6833aa6 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -20,7 +20,7 @@
20 20
21struct xfs_dinode; 21struct xfs_dinode;
22struct xfs_dinode_core; 22struct xfs_dinode_core;
23 23struct xfs_inode;
24 24
25/* 25/*
26 * Fork identifiers. 26 * Fork identifiers.
@@ -84,54 +84,6 @@ typedef struct xfs_ifork {
84} xfs_ifork_t; 84} xfs_ifork_t;
85 85
86/* 86/*
87 * Flags for xfs_ichgtime().
88 */
89#define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */
90#define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */
91
92/*
93 * Per-fork incore inode flags.
94 */
95#define XFS_IFINLINE 0x01 /* Inline data is read in */
96#define XFS_IFEXTENTS 0x02 /* All extent pointers are read in */
97#define XFS_IFBROOT 0x04 /* i_broot points to the bmap b-tree root */
98#define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */
99
100/*
101 * Flags for xfs_itobp(), xfs_imap() and xfs_dilocate().
102 */
103#define XFS_IMAP_LOOKUP 0x1
104#define XFS_IMAP_BULKSTAT 0x2
105
106#ifdef __KERNEL__
107struct bhv_desc;
108struct cred;
109struct ktrace;
110struct xfs_buf;
111struct xfs_bmap_free;
112struct xfs_bmbt_irec;
113struct xfs_bmbt_block;
114struct xfs_inode;
115struct xfs_inode_log_item;
116struct xfs_mount;
117struct xfs_trans;
118struct xfs_dquot;
119
120#if defined(XFS_ILOCK_TRACE)
121#define XFS_ILOCK_KTRACE_SIZE 32
122extern ktrace_t *xfs_ilock_trace_buf;
123extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
124#else
125#define xfs_ilock_trace(i,n,f,ra)
126#endif
127
128typedef struct dm_attrs_s {
129 __uint32_t da_dmevmask; /* DMIG event mask */
130 __uint16_t da_dmstate; /* DMIG state info */
131 __uint16_t da_pad; /* DMIG extra padding */
132} dm_attrs_t;
133
134/*
135 * This is the xfs in-core inode structure. 87 * This is the xfs in-core inode structure.
136 * Most of the on-disk inode is embedded in the i_d field. 88 * Most of the on-disk inode is embedded in the i_d field.
137 * 89 *
@@ -191,6 +143,96 @@ typedef struct xfs_icdinode {
191 __uint32_t di_gen; /* generation number */ 143 __uint32_t di_gen; /* generation number */
192} xfs_icdinode_t; 144} xfs_icdinode_t;
193 145
146/*
147 * Flags for xfs_ichgtime().
148 */
149#define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */
150#define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */
151
152/*
153 * Per-fork incore inode flags.
154 */
155#define XFS_IFINLINE 0x01 /* Inline data is read in */
156#define XFS_IFEXTENTS 0x02 /* All extent pointers are read in */
157#define XFS_IFBROOT 0x04 /* i_broot points to the bmap b-tree root */
158#define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */
159
160/*
161 * Flags for xfs_itobp(), xfs_imap() and xfs_dilocate().
162 */
163#define XFS_IMAP_LOOKUP 0x1
164#define XFS_IMAP_BULKSTAT 0x2
165
166/*
167 * Fork handling.
168 */
169
170#define XFS_IFORK_Q(ip) ((ip)->i_d.di_forkoff != 0)
171#define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3))
172
173#define XFS_IFORK_PTR(ip,w) \
174 ((w) == XFS_DATA_FORK ? \
175 &(ip)->i_df : \
176 (ip)->i_afp)
177#define XFS_IFORK_DSIZE(ip) \
178 (XFS_IFORK_Q(ip) ? \
179 XFS_IFORK_BOFF(ip) : \
180 XFS_LITINO((ip)->i_mount))
181#define XFS_IFORK_ASIZE(ip) \
182 (XFS_IFORK_Q(ip) ? \
183 XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : \
184 0)
185#define XFS_IFORK_SIZE(ip,w) \
186 ((w) == XFS_DATA_FORK ? \
187 XFS_IFORK_DSIZE(ip) : \
188 XFS_IFORK_ASIZE(ip))
189#define XFS_IFORK_FORMAT(ip,w) \
190 ((w) == XFS_DATA_FORK ? \
191 (ip)->i_d.di_format : \
192 (ip)->i_d.di_aformat)
193#define XFS_IFORK_FMT_SET(ip,w,n) \
194 ((w) == XFS_DATA_FORK ? \
195 ((ip)->i_d.di_format = (n)) : \
196 ((ip)->i_d.di_aformat = (n)))
197#define XFS_IFORK_NEXTENTS(ip,w) \
198 ((w) == XFS_DATA_FORK ? \
199 (ip)->i_d.di_nextents : \
200 (ip)->i_d.di_anextents)
201#define XFS_IFORK_NEXT_SET(ip,w,n) \
202 ((w) == XFS_DATA_FORK ? \
203 ((ip)->i_d.di_nextents = (n)) : \
204 ((ip)->i_d.di_anextents = (n)))
205
206
207
208#ifdef __KERNEL__
209
210struct bhv_desc;
211struct cred;
212struct ktrace;
213struct xfs_buf;
214struct xfs_bmap_free;
215struct xfs_bmbt_irec;
216struct xfs_bmbt_block;
217struct xfs_inode_log_item;
218struct xfs_mount;
219struct xfs_trans;
220struct xfs_dquot;
221
222#if defined(XFS_ILOCK_TRACE)
223#define XFS_ILOCK_KTRACE_SIZE 32
224extern ktrace_t *xfs_ilock_trace_buf;
225extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
226#else
227#define xfs_ilock_trace(i,n,f,ra)
228#endif
229
230typedef struct dm_attrs_s {
231 __uint32_t da_dmevmask; /* DMIG event mask */
232 __uint16_t da_dmstate; /* DMIG state info */
233 __uint16_t da_pad; /* DMIG extra padding */
234} dm_attrs_t;
235
194typedef struct { 236typedef struct {
195 struct xfs_inode *ip_mnext; /* next inode in mount list */ 237 struct xfs_inode *ip_mnext; /* next inode in mount list */
196 struct xfs_inode *ip_mprev; /* ptr to prev inode */ 238 struct xfs_inode *ip_mprev; /* ptr to prev inode */
@@ -327,50 +369,26 @@ xfs_iflags_test_and_clear(xfs_inode_t *ip, unsigned short flags)
327 spin_unlock(&ip->i_flags_lock); 369 spin_unlock(&ip->i_flags_lock);
328 return ret; 370 return ret;
329} 371}
330#endif /* __KERNEL__ */
331
332 372
333/* 373/*
334 * Fork handling. 374 * Manage the i_flush queue embedded in the inode. This completion
375 * queue synchronizes processes attempting to flush the in-core
376 * inode back to disk.
335 */ 377 */
378static inline void xfs_iflock(xfs_inode_t *ip)
379{
380 wait_for_completion(&ip->i_flush);
381}
336 382
337#define XFS_IFORK_Q(ip) ((ip)->i_d.di_forkoff != 0) 383static inline int xfs_iflock_nowait(xfs_inode_t *ip)
338#define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3)) 384{
339 385 return try_wait_for_completion(&ip->i_flush);
340#define XFS_IFORK_PTR(ip,w) \ 386}
341 ((w) == XFS_DATA_FORK ? \
342 &(ip)->i_df : \
343 (ip)->i_afp)
344#define XFS_IFORK_DSIZE(ip) \
345 (XFS_IFORK_Q(ip) ? \
346 XFS_IFORK_BOFF(ip) : \
347 XFS_LITINO((ip)->i_mount))
348#define XFS_IFORK_ASIZE(ip) \
349 (XFS_IFORK_Q(ip) ? \
350 XFS_LITINO((ip)->i_mount) - XFS_IFORK_BOFF(ip) : \
351 0)
352#define XFS_IFORK_SIZE(ip,w) \
353 ((w) == XFS_DATA_FORK ? \
354 XFS_IFORK_DSIZE(ip) : \
355 XFS_IFORK_ASIZE(ip))
356#define XFS_IFORK_FORMAT(ip,w) \
357 ((w) == XFS_DATA_FORK ? \
358 (ip)->i_d.di_format : \
359 (ip)->i_d.di_aformat)
360#define XFS_IFORK_FMT_SET(ip,w,n) \
361 ((w) == XFS_DATA_FORK ? \
362 ((ip)->i_d.di_format = (n)) : \
363 ((ip)->i_d.di_aformat = (n)))
364#define XFS_IFORK_NEXTENTS(ip,w) \
365 ((w) == XFS_DATA_FORK ? \
366 (ip)->i_d.di_nextents : \
367 (ip)->i_d.di_anextents)
368#define XFS_IFORK_NEXT_SET(ip,w,n) \
369 ((w) == XFS_DATA_FORK ? \
370 ((ip)->i_d.di_nextents = (n)) : \
371 ((ip)->i_d.di_anextents = (n)))
372 387
373#ifdef __KERNEL__ 388static inline void xfs_ifunlock(xfs_inode_t *ip)
389{
390 complete(&ip->i_flush);
391}
374 392
375/* 393/*
376 * In-core inode flags. 394 * In-core inode flags.
@@ -490,19 +508,11 @@ int xfs_finish_reclaim_all(struct xfs_mount *, int);
490/* 508/*
491 * xfs_inode.c prototypes. 509 * xfs_inode.c prototypes.
492 */ 510 */
493int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
494 xfs_inode_t *, struct xfs_dinode **, struct xfs_buf **,
495 xfs_daddr_t, uint, uint);
496int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 511int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
497 xfs_inode_t **, xfs_daddr_t, uint); 512 xfs_inode_t **, xfs_daddr_t, uint);
498int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
499int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t, 513int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, mode_t,
500 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t, 514 xfs_nlink_t, xfs_dev_t, struct cred *, xfs_prid_t,
501 int, struct xfs_buf **, boolean_t *, xfs_inode_t **); 515 int, struct xfs_buf **, boolean_t *, xfs_inode_t **);
502void xfs_dinode_from_disk(struct xfs_icdinode *,
503 struct xfs_dinode_core *);
504void xfs_dinode_to_disk(struct xfs_dinode_core *,
505 struct xfs_icdinode *);
506 516
507uint xfs_ip2xflags(struct xfs_inode *); 517uint xfs_ip2xflags(struct xfs_inode *);
508uint xfs_dic2xflags(struct xfs_dinode *); 518uint xfs_dic2xflags(struct xfs_dinode *);
@@ -514,15 +524,11 @@ int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *,
514int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); 524int xfs_iunlink(struct xfs_trans *, xfs_inode_t *);
515 525
516struct xfs_inode * xfs_inode_alloc(struct xfs_mount *, xfs_ino_t); 526struct xfs_inode * xfs_inode_alloc(struct xfs_mount *, xfs_ino_t);
517void xfs_idestroy_fork(xfs_inode_t *, int);
518void xfs_idestroy(xfs_inode_t *); 527void xfs_idestroy(xfs_inode_t *);
519void xfs_idata_realloc(xfs_inode_t *, int, int);
520void xfs_iextract(xfs_inode_t *); 528void xfs_iextract(xfs_inode_t *);
521void xfs_iext_realloc(xfs_inode_t *, int, int); 529void xfs_iext_realloc(xfs_inode_t *, int, int);
522void xfs_iroot_realloc(xfs_inode_t *, int, int);
523void xfs_ipin(xfs_inode_t *); 530void xfs_ipin(xfs_inode_t *);
524void xfs_iunpin(xfs_inode_t *); 531void xfs_iunpin(xfs_inode_t *);
525int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int);
526int xfs_iflush(xfs_inode_t *, uint); 532int xfs_iflush(xfs_inode_t *, uint);
527void xfs_iflush_all(struct xfs_mount *); 533void xfs_iflush_all(struct xfs_mount *);
528void xfs_ichgtime(xfs_inode_t *, int); 534void xfs_ichgtime(xfs_inode_t *, int);
@@ -533,6 +539,21 @@ void xfs_lock_two_inodes(xfs_inode_t *, xfs_inode_t *, uint);
533void xfs_synchronize_atime(xfs_inode_t *); 539void xfs_synchronize_atime(xfs_inode_t *);
534void xfs_mark_inode_dirty_sync(xfs_inode_t *); 540void xfs_mark_inode_dirty_sync(xfs_inode_t *);
535 541
542#endif /* __KERNEL__ */
543
544int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
545 struct xfs_inode *, struct xfs_dinode **,
546 struct xfs_buf **, xfs_daddr_t, uint, uint);
547void xfs_dinode_from_disk(struct xfs_icdinode *,
548 struct xfs_dinode_core *);
549void xfs_dinode_to_disk(struct xfs_dinode_core *,
550 struct xfs_icdinode *);
551void xfs_idestroy_fork(struct xfs_inode *, int);
552void xfs_idata_realloc(struct xfs_inode *, int, int);
553void xfs_iroot_realloc(struct xfs_inode *, int, int);
554int xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int);
555int xfs_iextents_copy(struct xfs_inode *, xfs_bmbt_rec_t *, int);
556
536xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); 557xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t);
537void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t, 558void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t,
538 xfs_bmbt_irec_t *); 559 xfs_bmbt_irec_t *);
@@ -562,7 +583,8 @@ void xfs_iext_irec_update_extoffs(xfs_ifork_t *, int, int);
562#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount)) 583#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount))
563 584
564#ifdef DEBUG 585#ifdef DEBUG
565void xfs_isize_check(struct xfs_mount *, xfs_inode_t *, xfs_fsize_t); 586void xfs_isize_check(struct xfs_mount *, struct xfs_inode *,
587 xfs_fsize_t);
566#else /* DEBUG */ 588#else /* DEBUG */
567#define xfs_isize_check(mp, ip, isize) 589#define xfs_isize_check(mp, ip, isize)
568#endif /* DEBUG */ 590#endif /* DEBUG */
@@ -577,26 +599,4 @@ extern struct kmem_zone *xfs_ifork_zone;
577extern struct kmem_zone *xfs_inode_zone; 599extern struct kmem_zone *xfs_inode_zone;
578extern struct kmem_zone *xfs_ili_zone; 600extern struct kmem_zone *xfs_ili_zone;
579 601
580/*
581 * Manage the i_flush queue embedded in the inode. This completion
582 * queue synchronizes processes attempting to flush the in-core
583 * inode back to disk.
584 */
585static inline void xfs_iflock(xfs_inode_t *ip)
586{
587 wait_for_completion(&ip->i_flush);
588}
589
590static inline int xfs_iflock_nowait(xfs_inode_t *ip)
591{
592 return try_wait_for_completion(&ip->i_flush);
593}
594
595static inline void xfs_ifunlock(xfs_inode_t *ip)
596{
597 complete(&ip->i_flush);
598}
599
600#endif /* __KERNEL__ */
601
602#endif /* __XFS_INODE_H__ */ 602#endif /* __XFS_INODE_H__ */
diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h
index 40513077ab36..1ff04cc323ad 100644
--- a/fs/xfs/xfs_inode_item.h
+++ b/fs/xfs/xfs_inode_item.h
@@ -112,6 +112,24 @@ typedef struct xfs_inode_log_format_64 {
112#define XFS_ILI_IOLOCKED_ANY (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED) 112#define XFS_ILI_IOLOCKED_ANY (XFS_ILI_IOLOCKED_EXCL | XFS_ILI_IOLOCKED_SHARED)
113 113
114 114
115#define XFS_ILOG_FBROOT(w) xfs_ilog_fbroot(w)
116static inline int xfs_ilog_fbroot(int w)
117{
118 return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
119}
120
121#define XFS_ILOG_FEXT(w) xfs_ilog_fext(w)
122static inline int xfs_ilog_fext(int w)
123{
124 return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
125}
126
127#define XFS_ILOG_FDATA(w) xfs_ilog_fdata(w)
128static inline int xfs_ilog_fdata(int w)
129{
130 return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
131}
132
115#ifdef __KERNEL__ 133#ifdef __KERNEL__
116 134
117struct xfs_buf; 135struct xfs_buf;
@@ -148,26 +166,6 @@ typedef struct xfs_inode_log_item {
148} xfs_inode_log_item_t; 166} xfs_inode_log_item_t;
149 167
150 168
151#define XFS_ILOG_FDATA(w) xfs_ilog_fdata(w)
152static inline int xfs_ilog_fdata(int w)
153{
154 return (w == XFS_DATA_FORK ? XFS_ILOG_DDATA : XFS_ILOG_ADATA);
155}
156
157#endif /* __KERNEL__ */
158
159#define XFS_ILOG_FBROOT(w) xfs_ilog_fbroot(w)
160static inline int xfs_ilog_fbroot(int w)
161{
162 return (w == XFS_DATA_FORK ? XFS_ILOG_DBROOT : XFS_ILOG_ABROOT);
163}
164
165#define XFS_ILOG_FEXT(w) xfs_ilog_fext(w)
166static inline int xfs_ilog_fext(int w)
167{
168 return (w == XFS_DATA_FORK ? XFS_ILOG_DEXT : XFS_ILOG_AEXT);
169}
170
171static inline int xfs_inode_clean(xfs_inode_t *ip) 169static inline int xfs_inode_clean(xfs_inode_t *ip)
172{ 170{
173 return (!ip->i_itemp || 171 return (!ip->i_itemp ||
@@ -175,9 +173,6 @@ static inline int xfs_inode_clean(xfs_inode_t *ip)
175 !ip->i_update_core; 173 !ip->i_update_core;
176} 174}
177 175
178
179#ifdef __KERNEL__
180
181extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *); 176extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
182extern void xfs_inode_item_destroy(struct xfs_inode *); 177extern void xfs_inode_item_destroy(struct xfs_inode *);
183extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *); 178extern void xfs_iflush_done(struct xfs_buf *, xfs_inode_log_item_t *);
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 49d647e730e1..56c3b122e532 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -44,14 +44,14 @@ typedef struct xfs_trans_reservations {
44} xfs_trans_reservations_t; 44} xfs_trans_reservations_t;
45 45
46#ifndef __KERNEL__ 46#ifndef __KERNEL__
47/* 47
48 * Moved here from xfs_ag.h to avoid reordering header files
49 */
50#define XFS_DADDR_TO_AGNO(mp,d) \ 48#define XFS_DADDR_TO_AGNO(mp,d) \
51 ((xfs_agnumber_t)(XFS_BB_TO_FSBT(mp, d) / (mp)->m_sb.sb_agblocks)) 49 ((xfs_agnumber_t)(XFS_BB_TO_FSBT(mp, d) / (mp)->m_sb.sb_agblocks))
52#define XFS_DADDR_TO_AGBNO(mp,d) \ 50#define XFS_DADDR_TO_AGBNO(mp,d) \
53 ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp, d) % (mp)->m_sb.sb_agblocks)) 51 ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp, d) % (mp)->m_sb.sb_agblocks))
54#else 52
53#else /* __KERNEL__ */
54
55struct cred; 55struct cred;
56struct log; 56struct log;
57struct xfs_mount_args; 57struct xfs_mount_args;
@@ -507,7 +507,6 @@ typedef struct xfs_mod_sb {
507#define XFS_MOUNT_ILOCK(mp) mutex_lock(&((mp)->m_ilock)) 507#define XFS_MOUNT_ILOCK(mp) mutex_lock(&((mp)->m_ilock))
508#define XFS_MOUNT_IUNLOCK(mp) mutex_unlock(&((mp)->m_ilock)) 508#define XFS_MOUNT_IUNLOCK(mp) mutex_unlock(&((mp)->m_ilock))
509 509
510extern void xfs_mod_sb(xfs_trans_t *, __int64_t);
511extern int xfs_log_sbcount(xfs_mount_t *, uint); 510extern int xfs_log_sbcount(xfs_mount_t *, uint);
512extern int xfs_mountfs(xfs_mount_t *mp); 511extern int xfs_mountfs(xfs_mount_t *mp);
513extern void xfs_mountfs_check_barriers(xfs_mount_t *mp); 512extern void xfs_mountfs_check_barriers(xfs_mount_t *mp);
@@ -526,9 +525,6 @@ extern void xfs_freesb(xfs_mount_t *);
526extern int xfs_fs_writable(xfs_mount_t *); 525extern int xfs_fs_writable(xfs_mount_t *);
527extern int xfs_syncsub(xfs_mount_t *, int, int *); 526extern int xfs_syncsub(xfs_mount_t *, int, int *);
528extern int xfs_sync_inodes(xfs_mount_t *, int, int *); 527extern int xfs_sync_inodes(xfs_mount_t *, int, int *);
529extern xfs_agnumber_t xfs_initialize_perag(xfs_mount_t *, xfs_agnumber_t);
530extern void xfs_sb_from_disk(struct xfs_sb *, struct xfs_dsb *);
531extern void xfs_sb_to_disk(struct xfs_dsb *, struct xfs_sb *, __int64_t);
532extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t); 528extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t);
533 529
534extern int xfs_dmops_get(struct xfs_mount *, struct xfs_mount_args *); 530extern int xfs_dmops_get(struct xfs_mount *, struct xfs_mount_args *);
@@ -540,4 +536,9 @@ extern struct xfs_dmops xfs_dmcore_xfs;
540 536
541#endif /* __KERNEL__ */ 537#endif /* __KERNEL__ */
542 538
539extern void xfs_mod_sb(struct xfs_trans *, __int64_t);
540extern xfs_agnumber_t xfs_initialize_perag(struct xfs_mount *, xfs_agnumber_t);
541extern void xfs_sb_from_disk(struct xfs_sb *, struct xfs_dsb *);
542extern void xfs_sb_to_disk(struct xfs_dsb *, struct xfs_sb *, __int64_t);
543
543#endif /* __XFS_MOUNT_H__ */ 544#endif /* __XFS_MOUNT_H__ */
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 74c80bd2b0ec..1d89d50a5b99 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -18,6 +18,8 @@
18#ifndef __XFS_TRANS_H__ 18#ifndef __XFS_TRANS_H__
19#define __XFS_TRANS_H__ 19#define __XFS_TRANS_H__
20 20
21struct xfs_log_item;
22
21/* 23/*
22 * This is the structure written in the log at the head of 24 * This is the structure written in the log at the head of
23 * every transaction. It identifies the type and id of the 25 * every transaction. It identifies the type and id of the
@@ -98,76 +100,6 @@ typedef struct xfs_trans_header {
98#define XFS_TRANS_TYPE_MAX 41 100#define XFS_TRANS_TYPE_MAX 41
99/* new transaction types need to be reflected in xfs_logprint(8) */ 101/* new transaction types need to be reflected in xfs_logprint(8) */
100 102
101
102#ifdef __KERNEL__
103struct xfs_buf;
104struct xfs_buftarg;
105struct xfs_efd_log_item;
106struct xfs_efi_log_item;
107struct xfs_inode;
108struct xfs_item_ops;
109struct xfs_log_iovec;
110struct xfs_log_item;
111struct xfs_log_item_desc;
112struct xfs_mount;
113struct xfs_trans;
114struct xfs_dquot_acct;
115
116typedef struct xfs_log_item {
117 struct list_head li_ail; /* AIL pointers */
118 xfs_lsn_t li_lsn; /* last on-disk lsn */
119 struct xfs_log_item_desc *li_desc; /* ptr to current desc*/
120 struct xfs_mount *li_mountp; /* ptr to fs mount */
121 uint li_type; /* item type */
122 uint li_flags; /* misc flags */
123 struct xfs_log_item *li_bio_list; /* buffer item list */
124 void (*li_cb)(struct xfs_buf *,
125 struct xfs_log_item *);
126 /* buffer item iodone */
127 /* callback func */
128 struct xfs_item_ops *li_ops; /* function list */
129} xfs_log_item_t;
130
131#define XFS_LI_IN_AIL 0x1
132#define XFS_LI_ABORTED 0x2
133
134typedef struct xfs_item_ops {
135 uint (*iop_size)(xfs_log_item_t *);
136 void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *);
137 void (*iop_pin)(xfs_log_item_t *);
138 void (*iop_unpin)(xfs_log_item_t *, int);
139 void (*iop_unpin_remove)(xfs_log_item_t *, struct xfs_trans *);
140 uint (*iop_trylock)(xfs_log_item_t *);
141 void (*iop_unlock)(xfs_log_item_t *);
142 xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
143 void (*iop_push)(xfs_log_item_t *);
144 void (*iop_pushbuf)(xfs_log_item_t *);
145 void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
146} xfs_item_ops_t;
147
148#define IOP_SIZE(ip) (*(ip)->li_ops->iop_size)(ip)
149#define IOP_FORMAT(ip,vp) (*(ip)->li_ops->iop_format)(ip, vp)
150#define IOP_PIN(ip) (*(ip)->li_ops->iop_pin)(ip)
151#define IOP_UNPIN(ip, flags) (*(ip)->li_ops->iop_unpin)(ip, flags)
152#define IOP_UNPIN_REMOVE(ip,tp) (*(ip)->li_ops->iop_unpin_remove)(ip, tp)
153#define IOP_TRYLOCK(ip) (*(ip)->li_ops->iop_trylock)(ip)
154#define IOP_UNLOCK(ip) (*(ip)->li_ops->iop_unlock)(ip)
155#define IOP_COMMITTED(ip, lsn) (*(ip)->li_ops->iop_committed)(ip, lsn)
156#define IOP_PUSH(ip) (*(ip)->li_ops->iop_push)(ip)
157#define IOP_PUSHBUF(ip) (*(ip)->li_ops->iop_pushbuf)(ip)
158#define IOP_COMMITTING(ip, lsn) (*(ip)->li_ops->iop_committing)(ip, lsn)
159
160/*
161 * Return values for the IOP_TRYLOCK() routines.
162 */
163#define XFS_ITEM_SUCCESS 0
164#define XFS_ITEM_PINNED 1
165#define XFS_ITEM_LOCKED 2
166#define XFS_ITEM_FLUSHING 3
167#define XFS_ITEM_PUSHBUF 4
168
169#endif /* __KERNEL__ */
170
171/* 103/*
172 * This structure is used to track log items associated with 104 * This structure is used to track log items associated with
173 * a transaction. It points to the log item and keeps some 105 * a transaction. It points to the log item and keeps some
@@ -176,7 +108,7 @@ typedef struct xfs_item_ops {
176 * once we get to commit processing (see xfs_trans_commit()). 108 * once we get to commit processing (see xfs_trans_commit()).
177 */ 109 */
178typedef struct xfs_log_item_desc { 110typedef struct xfs_log_item_desc {
179 xfs_log_item_t *lid_item; 111 struct xfs_log_item *lid_item;
180 ushort lid_size; 112 ushort lid_size;
181 unsigned char lid_flags; 113 unsigned char lid_flags;
182 unsigned char lid_index; 114 unsigned char lid_index;
@@ -276,94 +208,6 @@ xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp)
276 (xfs_caddr_t)(((xfs_log_item_chunk_t*)0)->lic_descs)); 208 (xfs_caddr_t)(((xfs_log_item_chunk_t*)0)->lic_descs));
277} 209}
278 210
279#ifdef __KERNEL__
280/*
281 * This structure is used to maintain a list of block ranges that have been
282 * freed in the transaction. The ranges are listed in the perag[] busy list
283 * between when they're freed and the transaction is committed to disk.
284 */
285
286typedef struct xfs_log_busy_slot {
287 xfs_agnumber_t lbc_ag;
288 ushort lbc_idx; /* index in perag.busy[] */
289} xfs_log_busy_slot_t;
290
291#define XFS_LBC_NUM_SLOTS 31
292typedef struct xfs_log_busy_chunk {
293 struct xfs_log_busy_chunk *lbc_next;
294 uint lbc_free; /* free slots bitmask */
295 ushort lbc_unused; /* first unused */
296 xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS];
297} xfs_log_busy_chunk_t;
298
299#define XFS_LBC_MAX_SLOT (XFS_LBC_NUM_SLOTS - 1)
300#define XFS_LBC_FREEMASK ((1U << XFS_LBC_NUM_SLOTS) - 1)
301
302#define XFS_LBC_INIT(cp) ((cp)->lbc_free = XFS_LBC_FREEMASK)
303#define XFS_LBC_CLAIM(cp, slot) ((cp)->lbc_free &= ~(1 << (slot)))
304#define XFS_LBC_SLOT(cp, slot) (&((cp)->lbc_busy[(slot)]))
305#define XFS_LBC_VACANCY(cp) (((cp)->lbc_free) & XFS_LBC_FREEMASK)
306#define XFS_LBC_ISFREE(cp, slot) ((cp)->lbc_free & (1 << (slot)))
307
308/*
309 * This is the type of function which can be given to xfs_trans_callback()
310 * to be called upon the transaction's commit to disk.
311 */
312typedef void (*xfs_trans_callback_t)(struct xfs_trans *, void *);
313
314/*
315 * This is the structure maintained for every active transaction.
316 */
317typedef struct xfs_trans {
318 unsigned int t_magic; /* magic number */
319 xfs_log_callback_t t_logcb; /* log callback struct */
320 unsigned int t_type; /* transaction type */
321 unsigned int t_log_res; /* amt of log space resvd */
322 unsigned int t_log_count; /* count for perm log res */
323 unsigned int t_blk_res; /* # of blocks resvd */
324 unsigned int t_blk_res_used; /* # of resvd blocks used */
325 unsigned int t_rtx_res; /* # of rt extents resvd */
326 unsigned int t_rtx_res_used; /* # of resvd rt extents used */
327 xfs_log_ticket_t t_ticket; /* log mgr ticket */
328 xfs_lsn_t t_lsn; /* log seq num of start of
329 * transaction. */
330 xfs_lsn_t t_commit_lsn; /* log seq num of end of
331 * transaction. */
332 struct xfs_mount *t_mountp; /* ptr to fs mount struct */
333 struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
334 xfs_trans_callback_t t_callback; /* transaction callback */
335 void *t_callarg; /* callback arg */
336 unsigned int t_flags; /* misc flags */
337 int64_t t_icount_delta; /* superblock icount change */
338 int64_t t_ifree_delta; /* superblock ifree change */
339 int64_t t_fdblocks_delta; /* superblock fdblocks chg */
340 int64_t t_res_fdblocks_delta; /* on-disk only chg */
341 int64_t t_frextents_delta;/* superblock freextents chg*/
342 int64_t t_res_frextents_delta; /* on-disk only chg */
343#ifdef DEBUG
344 int64_t t_ag_freeblks_delta; /* debugging counter */
345 int64_t t_ag_flist_delta; /* debugging counter */
346 int64_t t_ag_btree_delta; /* debugging counter */
347#endif
348 int64_t t_dblocks_delta;/* superblock dblocks change */
349 int64_t t_agcount_delta;/* superblock agcount change */
350 int64_t t_imaxpct_delta;/* superblock imaxpct change */
351 int64_t t_rextsize_delta;/* superblock rextsize chg */
352 int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */
353 int64_t t_rblocks_delta;/* superblock rblocks change */
354 int64_t t_rextents_delta;/* superblocks rextents chg */
355 int64_t t_rextslog_delta;/* superblocks rextslog chg */
356 unsigned int t_items_free; /* log item descs free */
357 xfs_log_item_chunk_t t_items; /* first log item desc chunk */
358 xfs_trans_header_t t_header; /* header for in-log trans */
359 unsigned int t_busy_free; /* busy descs free */
360 xfs_log_busy_chunk_t t_busy; /* busy/async free blocks */
361 unsigned long t_pflags; /* saved process flags state */
362} xfs_trans_t;
363
364#endif /* __KERNEL__ */
365
366
367#define XFS_TRANS_MAGIC 0x5452414E /* 'TRAN' */ 211#define XFS_TRANS_MAGIC 0x5452414E /* 'TRAN' */
368/* 212/*
369 * Values for t_flags. 213 * Values for t_flags.
@@ -906,6 +750,156 @@ typedef struct xfs_trans {
906#define XFS_DQUOT_REF 1 750#define XFS_DQUOT_REF 1
907 751
908#ifdef __KERNEL__ 752#ifdef __KERNEL__
753
754struct xfs_buf;
755struct xfs_buftarg;
756struct xfs_efd_log_item;
757struct xfs_efi_log_item;
758struct xfs_inode;
759struct xfs_item_ops;
760struct xfs_log_iovec;
761struct xfs_log_item_desc;
762struct xfs_mount;
763struct xfs_trans;
764struct xfs_dquot_acct;
765
766typedef struct xfs_log_item {
767 struct list_head li_ail; /* AIL pointers */
768 xfs_lsn_t li_lsn; /* last on-disk lsn */
769 struct xfs_log_item_desc *li_desc; /* ptr to current desc*/
770 struct xfs_mount *li_mountp; /* ptr to fs mount */
771 uint li_type; /* item type */
772 uint li_flags; /* misc flags */
773 struct xfs_log_item *li_bio_list; /* buffer item list */
774 void (*li_cb)(struct xfs_buf *,
775 struct xfs_log_item *);
776 /* buffer item iodone */
777 /* callback func */
778 struct xfs_item_ops *li_ops; /* function list */
779} xfs_log_item_t;
780
781#define XFS_LI_IN_AIL 0x1
782#define XFS_LI_ABORTED 0x2
783
784typedef struct xfs_item_ops {
785 uint (*iop_size)(xfs_log_item_t *);
786 void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *);
787 void (*iop_pin)(xfs_log_item_t *);
788 void (*iop_unpin)(xfs_log_item_t *, int);
789 void (*iop_unpin_remove)(xfs_log_item_t *, struct xfs_trans *);
790 uint (*iop_trylock)(xfs_log_item_t *);
791 void (*iop_unlock)(xfs_log_item_t *);
792 xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
793 void (*iop_push)(xfs_log_item_t *);
794 void (*iop_pushbuf)(xfs_log_item_t *);
795 void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
796} xfs_item_ops_t;
797
798#define IOP_SIZE(ip) (*(ip)->li_ops->iop_size)(ip)
799#define IOP_FORMAT(ip,vp) (*(ip)->li_ops->iop_format)(ip, vp)
800#define IOP_PIN(ip) (*(ip)->li_ops->iop_pin)(ip)
801#define IOP_UNPIN(ip, flags) (*(ip)->li_ops->iop_unpin)(ip, flags)
802#define IOP_UNPIN_REMOVE(ip,tp) (*(ip)->li_ops->iop_unpin_remove)(ip, tp)
803#define IOP_TRYLOCK(ip) (*(ip)->li_ops->iop_trylock)(ip)
804#define IOP_UNLOCK(ip) (*(ip)->li_ops->iop_unlock)(ip)
805#define IOP_COMMITTED(ip, lsn) (*(ip)->li_ops->iop_committed)(ip, lsn)
806#define IOP_PUSH(ip) (*(ip)->li_ops->iop_push)(ip)
807#define IOP_PUSHBUF(ip) (*(ip)->li_ops->iop_pushbuf)(ip)
808#define IOP_COMMITTING(ip, lsn) (*(ip)->li_ops->iop_committing)(ip, lsn)
809
810/*
811 * Return values for the IOP_TRYLOCK() routines.
812 */
813#define XFS_ITEM_SUCCESS 0
814#define XFS_ITEM_PINNED 1
815#define XFS_ITEM_LOCKED 2
816#define XFS_ITEM_FLUSHING 3
817#define XFS_ITEM_PUSHBUF 4
818
819/*
820 * This structure is used to maintain a list of block ranges that have been
821 * freed in the transaction. The ranges are listed in the perag[] busy list
822 * between when they're freed and the transaction is committed to disk.
823 */
824
825typedef struct xfs_log_busy_slot {
826 xfs_agnumber_t lbc_ag;
827 ushort lbc_idx; /* index in perag.busy[] */
828} xfs_log_busy_slot_t;
829
830#define XFS_LBC_NUM_SLOTS 31
831typedef struct xfs_log_busy_chunk {
832 struct xfs_log_busy_chunk *lbc_next;
833 uint lbc_free; /* free slots bitmask */
834 ushort lbc_unused; /* first unused */
835 xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS];
836} xfs_log_busy_chunk_t;
837
838#define XFS_LBC_MAX_SLOT (XFS_LBC_NUM_SLOTS - 1)
839#define XFS_LBC_FREEMASK ((1U << XFS_LBC_NUM_SLOTS) - 1)
840
841#define XFS_LBC_INIT(cp) ((cp)->lbc_free = XFS_LBC_FREEMASK)
842#define XFS_LBC_CLAIM(cp, slot) ((cp)->lbc_free &= ~(1 << (slot)))
843#define XFS_LBC_SLOT(cp, slot) (&((cp)->lbc_busy[(slot)]))
844#define XFS_LBC_VACANCY(cp) (((cp)->lbc_free) & XFS_LBC_FREEMASK)
845#define XFS_LBC_ISFREE(cp, slot) ((cp)->lbc_free & (1 << (slot)))
846
847/*
848 * This is the type of function which can be given to xfs_trans_callback()
849 * to be called upon the transaction's commit to disk.
850 */
851typedef void (*xfs_trans_callback_t)(struct xfs_trans *, void *);
852
853/*
854 * This is the structure maintained for every active transaction.
855 */
856typedef struct xfs_trans {
857 unsigned int t_magic; /* magic number */
858 xfs_log_callback_t t_logcb; /* log callback struct */
859 unsigned int t_type; /* transaction type */
860 unsigned int t_log_res; /* amt of log space resvd */
861 unsigned int t_log_count; /* count for perm log res */
862 unsigned int t_blk_res; /* # of blocks resvd */
863 unsigned int t_blk_res_used; /* # of resvd blocks used */
864 unsigned int t_rtx_res; /* # of rt extents resvd */
865 unsigned int t_rtx_res_used; /* # of resvd rt extents used */
866 xfs_log_ticket_t t_ticket; /* log mgr ticket */
867 xfs_lsn_t t_lsn; /* log seq num of start of
868 * transaction. */
869 xfs_lsn_t t_commit_lsn; /* log seq num of end of
870 * transaction. */
871 struct xfs_mount *t_mountp; /* ptr to fs mount struct */
872 struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */
873 xfs_trans_callback_t t_callback; /* transaction callback */
874 void *t_callarg; /* callback arg */
875 unsigned int t_flags; /* misc flags */
876 int64_t t_icount_delta; /* superblock icount change */
877 int64_t t_ifree_delta; /* superblock ifree change */
878 int64_t t_fdblocks_delta; /* superblock fdblocks chg */
879 int64_t t_res_fdblocks_delta; /* on-disk only chg */
880 int64_t t_frextents_delta;/* superblock freextents chg*/
881 int64_t t_res_frextents_delta; /* on-disk only chg */
882#ifdef DEBUG
883 int64_t t_ag_freeblks_delta; /* debugging counter */
884 int64_t t_ag_flist_delta; /* debugging counter */
885 int64_t t_ag_btree_delta; /* debugging counter */
886#endif
887 int64_t t_dblocks_delta;/* superblock dblocks change */
888 int64_t t_agcount_delta;/* superblock agcount change */
889 int64_t t_imaxpct_delta;/* superblock imaxpct change */
890 int64_t t_rextsize_delta;/* superblock rextsize chg */
891 int64_t t_rbmblocks_delta;/* superblock rbmblocks chg */
892 int64_t t_rblocks_delta;/* superblock rblocks change */
893 int64_t t_rextents_delta;/* superblocks rextents chg */
894 int64_t t_rextslog_delta;/* superblocks rextslog chg */
895 unsigned int t_items_free; /* log item descs free */
896 xfs_log_item_chunk_t t_items; /* first log item desc chunk */
897 xfs_trans_header_t t_header; /* header for in-log trans */
898 unsigned int t_busy_free; /* busy descs free */
899 xfs_log_busy_chunk_t t_busy; /* busy/async free blocks */
900 unsigned long t_pflags; /* saved process flags state */
901} xfs_trans_t;
902
909/* 903/*
910 * XFS transaction mechanism exported interfaces that are 904 * XFS transaction mechanism exported interfaces that are
911 * actually macros. 905 * actually macros.
@@ -928,7 +922,6 @@ typedef struct xfs_trans {
928/* 922/*
929 * XFS transaction mechanism exported interfaces. 923 * XFS transaction mechanism exported interfaces.
930 */ 924 */
931void xfs_trans_init(struct xfs_mount *);
932xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint); 925xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint);
933xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint); 926xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint);
934xfs_trans_t *xfs_trans_dup(xfs_trans_t *); 927xfs_trans_t *xfs_trans_dup(xfs_trans_t *);
@@ -975,7 +968,6 @@ int _xfs_trans_commit(xfs_trans_t *,
975 int *); 968 int *);
976#define xfs_trans_commit(tp, flags) _xfs_trans_commit(tp, flags, NULL) 969#define xfs_trans_commit(tp, flags) _xfs_trans_commit(tp, flags, NULL)
977void xfs_trans_cancel(xfs_trans_t *, int); 970void xfs_trans_cancel(xfs_trans_t *, int);
978int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);
979int xfs_trans_ail_init(struct xfs_mount *); 971int xfs_trans_ail_init(struct xfs_mount *);
980void xfs_trans_ail_destroy(struct xfs_mount *); 972void xfs_trans_ail_destroy(struct xfs_mount *);
981void xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t); 973void xfs_trans_push_ail(struct xfs_mount *, xfs_lsn_t);
@@ -990,4 +982,7 @@ extern kmem_zone_t *xfs_trans_zone;
990 982
991#endif /* __KERNEL__ */ 983#endif /* __KERNEL__ */
992 984
985void xfs_trans_init(struct xfs_mount *);
986int xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);
987
993#endif /* __XFS_TRANS_H__ */ 988#endif /* __XFS_TRANS_H__ */