diff options
author | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:35:38 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:35:38 -0400 |
commit | c2066e2662070e794f57a96a129c42575e77cfcb (patch) | |
tree | c1261009d7482af80db1b554a96b5a62f35b4877 | |
parent | a64b04179735de6bfd9f00c130a68ed7f20d18ef (diff) |
xfs: avoid usage of struct xfs_dir2_data
In most places we can simply pass around and use the struct xfs_dir2_data_hdr,
which is the first and most important member of struct xfs_dir2_data instead
of the full structure.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 11 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_data.c | 308 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_data.h | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 76 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_node.c | 50 |
6 files changed, 236 insertions, 231 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 6102ac6d1dff..efb906f8a9c9 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -2079,16 +2079,13 @@ xfs_da_do_buf( | |||
2079 | * For read_buf, check the magic number. | 2079 | * For read_buf, check the magic number. |
2080 | */ | 2080 | */ |
2081 | if (caller == 1) { | 2081 | if (caller == 1) { |
2082 | xfs_dir2_data_t *data; | 2082 | xfs_dir2_data_hdr_t *hdr = rbp->data; |
2083 | xfs_dir2_free_t *free; | 2083 | xfs_dir2_free_t *free = rbp->data; |
2084 | xfs_da_blkinfo_t *info; | 2084 | xfs_da_blkinfo_t *info = rbp->data; |
2085 | uint magic, magic1; | 2085 | uint magic, magic1; |
2086 | 2086 | ||
2087 | info = rbp->data; | ||
2088 | data = rbp->data; | ||
2089 | free = rbp->data; | ||
2090 | magic = be16_to_cpu(info->magic); | 2087 | magic = be16_to_cpu(info->magic); |
2091 | magic1 = be32_to_cpu(data->hdr.magic); | 2088 | magic1 = be32_to_cpu(hdr->magic); |
2092 | if (unlikely( | 2089 | if (unlikely( |
2093 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && | 2090 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && |
2094 | (magic != XFS_ATTR_LEAF_MAGIC) && | 2091 | (magic != XFS_ATTR_LEAF_MAGIC) && |
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index 9adaf803957a..c9fdabe5e1ad 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -282,7 +282,7 @@ xfs_dir2_block_addname( | |||
282 | * This needs to happen before the next call to use_free. | 282 | * This needs to happen before the next call to use_free. |
283 | */ | 283 | */ |
284 | if (needscan) { | 284 | if (needscan) { |
285 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); | 285 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
286 | needscan = 0; | 286 | needscan = 0; |
287 | } | 287 | } |
288 | } | 288 | } |
@@ -331,8 +331,7 @@ xfs_dir2_block_addname( | |||
331 | * This needs to happen before the next call to use_free. | 331 | * This needs to happen before the next call to use_free. |
332 | */ | 332 | */ |
333 | if (needscan) { | 333 | if (needscan) { |
334 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, | 334 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
335 | &needlog); | ||
336 | needscan = 0; | 335 | needscan = 0; |
337 | } | 336 | } |
338 | /* | 337 | /* |
@@ -417,7 +416,7 @@ xfs_dir2_block_addname( | |||
417 | * Clean up the bestfree array and log the header, tail, and entry. | 416 | * Clean up the bestfree array and log the header, tail, and entry. |
418 | */ | 417 | */ |
419 | if (needscan) | 418 | if (needscan) |
420 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); | 419 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
421 | if (needlog) | 420 | if (needlog) |
422 | xfs_dir2_data_log_header(tp, bp); | 421 | xfs_dir2_data_log_header(tp, bp); |
423 | xfs_dir2_block_log_tail(tp, bp); | 422 | xfs_dir2_block_log_tail(tp, bp); |
@@ -783,7 +782,7 @@ xfs_dir2_block_removename( | |||
783 | * Fix up bestfree, log the header if necessary. | 782 | * Fix up bestfree, log the header if necessary. |
784 | */ | 783 | */ |
785 | if (needscan) | 784 | if (needscan) |
786 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); | 785 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
787 | if (needlog) | 786 | if (needlog) |
788 | xfs_dir2_data_log_header(tp, bp); | 787 | xfs_dir2_data_log_header(tp, bp); |
789 | xfs_dir2_data_check(dp, bp); | 788 | xfs_dir2_data_check(dp, bp); |
@@ -982,7 +981,7 @@ xfs_dir2_leaf_to_block( | |||
982 | * Scan the bestfree if we need it and log the data block header. | 981 | * Scan the bestfree if we need it and log the data block header. |
983 | */ | 982 | */ |
984 | if (needscan) | 983 | if (needscan) |
985 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); | 984 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
986 | if (needlog) | 985 | if (needlog) |
987 | xfs_dir2_data_log_header(tp, dbp); | 986 | xfs_dir2_data_log_header(tp, dbp); |
988 | /* | 987 | /* |
@@ -1177,8 +1176,7 @@ xfs_dir2_sf_to_block( | |||
1177 | *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16( | 1176 | *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16( |
1178 | ((char *)dup - (char *)hdr)); | 1177 | ((char *)dup - (char *)hdr)); |
1179 | xfs_dir2_data_log_unused(tp, bp, dup); | 1178 | xfs_dir2_data_log_unused(tp, bp, dup); |
1180 | (void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)hdr, | 1179 | xfs_dir2_data_freeinsert(hdr, dup, &dummy); |
1181 | dup, &dummy); | ||
1182 | offset += be16_to_cpu(dup->length); | 1180 | offset += be16_to_cpu(dup->length); |
1183 | continue; | 1181 | continue; |
1184 | } | 1182 | } |
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c index 46ccb83bdab4..2bbc21696944 100644 --- a/fs/xfs/xfs_dir2_data.c +++ b/fs/xfs/xfs_dir2_data.c | |||
@@ -35,6 +35,9 @@ | |||
35 | #include "xfs_dir2_block.h" | 35 | #include "xfs_dir2_block.h" |
36 | #include "xfs_error.h" | 36 | #include "xfs_error.h" |
37 | 37 | ||
38 | STATIC xfs_dir2_data_free_t * | ||
39 | xfs_dir2_data_freefind(xfs_dir2_data_hdr_t *hdr, xfs_dir2_data_unused_t *dup); | ||
40 | |||
38 | #ifdef DEBUG | 41 | #ifdef DEBUG |
39 | /* | 42 | /* |
40 | * Check the consistency of the data block. | 43 | * Check the consistency of the data block. |
@@ -51,6 +54,7 @@ xfs_dir2_data_check( | |||
51 | xfs_dir2_block_tail_t *btp=NULL; /* block tail */ | 54 | xfs_dir2_block_tail_t *btp=NULL; /* block tail */ |
52 | int count; /* count of entries found */ | 55 | int count; /* count of entries found */ |
53 | xfs_dir2_data_t *d; /* data block pointer */ | 56 | xfs_dir2_data_t *d; /* data block pointer */ |
57 | xfs_dir2_data_hdr_t *hdr; /* data block header */ | ||
54 | xfs_dir2_data_entry_t *dep; /* data entry */ | 58 | xfs_dir2_data_entry_t *dep; /* data entry */ |
55 | xfs_dir2_data_free_t *dfp; /* bestfree entry */ | 59 | xfs_dir2_data_free_t *dfp; /* bestfree entry */ |
56 | xfs_dir2_data_unused_t *dup; /* unused entry */ | 60 | xfs_dir2_data_unused_t *dup; /* unused entry */ |
@@ -67,16 +71,19 @@ xfs_dir2_data_check( | |||
67 | 71 | ||
68 | mp = dp->i_mount; | 72 | mp = dp->i_mount; |
69 | d = bp->data; | 73 | d = bp->data; |
70 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 74 | hdr = &d->hdr; |
71 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 75 | bf = hdr->bestfree; |
72 | bf = d->hdr.bestfree; | ||
73 | p = (char *)d->u; | 76 | p = (char *)d->u; |
74 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | 77 | |
75 | btp = xfs_dir2_block_tail_p(mp, &d->hdr); | 78 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { |
79 | btp = xfs_dir2_block_tail_p(mp, hdr); | ||
76 | lep = xfs_dir2_block_leaf_p(btp); | 80 | lep = xfs_dir2_block_leaf_p(btp); |
77 | endp = (char *)lep; | 81 | endp = (char *)lep; |
78 | } else | 82 | } else { |
79 | endp = (char *)d + mp->m_dirblksize; | 83 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); |
84 | endp = (char *)hdr + mp->m_dirblksize; | ||
85 | } | ||
86 | |||
80 | count = lastfree = freeseen = 0; | 87 | count = lastfree = freeseen = 0; |
81 | /* | 88 | /* |
82 | * Account for zero bestfree entries. | 89 | * Account for zero bestfree entries. |
@@ -108,8 +115,8 @@ xfs_dir2_data_check( | |||
108 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { | 115 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
109 | ASSERT(lastfree == 0); | 116 | ASSERT(lastfree == 0); |
110 | ASSERT(be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) == | 117 | ASSERT(be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) == |
111 | (char *)dup - (char *)d); | 118 | (char *)dup - (char *)hdr); |
112 | dfp = xfs_dir2_data_freefind(d, dup); | 119 | dfp = xfs_dir2_data_freefind(hdr, dup); |
113 | if (dfp) { | 120 | if (dfp) { |
114 | i = (int)(dfp - bf); | 121 | i = (int)(dfp - bf); |
115 | ASSERT((freeseen & (1 << i)) == 0); | 122 | ASSERT((freeseen & (1 << i)) == 0); |
@@ -132,13 +139,13 @@ xfs_dir2_data_check( | |||
132 | ASSERT(dep->namelen != 0); | 139 | ASSERT(dep->namelen != 0); |
133 | ASSERT(xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)) == 0); | 140 | ASSERT(xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)) == 0); |
134 | ASSERT(be16_to_cpu(*xfs_dir2_data_entry_tag_p(dep)) == | 141 | ASSERT(be16_to_cpu(*xfs_dir2_data_entry_tag_p(dep)) == |
135 | (char *)dep - (char *)d); | 142 | (char *)dep - (char *)hdr); |
136 | count++; | 143 | count++; |
137 | lastfree = 0; | 144 | lastfree = 0; |
138 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | 145 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { |
139 | addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 146 | addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, |
140 | (xfs_dir2_data_aoff_t) | 147 | (xfs_dir2_data_aoff_t) |
141 | ((char *)dep - (char *)d)); | 148 | ((char *)dep - (char *)hdr)); |
142 | name.name = dep->name; | 149 | name.name = dep->name; |
143 | name.len = dep->namelen; | 150 | name.len = dep->namelen; |
144 | hash = mp->m_dirnameops->hashname(&name); | 151 | hash = mp->m_dirnameops->hashname(&name); |
@@ -155,7 +162,7 @@ xfs_dir2_data_check( | |||
155 | * Need to have seen all the entries and all the bestfree slots. | 162 | * Need to have seen all the entries and all the bestfree slots. |
156 | */ | 163 | */ |
157 | ASSERT(freeseen == 7); | 164 | ASSERT(freeseen == 7); |
158 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | 165 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { |
159 | for (i = stale = 0; i < be32_to_cpu(btp->count); i++) { | 166 | for (i = stale = 0; i < be32_to_cpu(btp->count); i++) { |
160 | if (be32_to_cpu(lep[i].address) == XFS_DIR2_NULL_DATAPTR) | 167 | if (be32_to_cpu(lep[i].address) == XFS_DIR2_NULL_DATAPTR) |
161 | stale++; | 168 | stale++; |
@@ -172,9 +179,9 @@ xfs_dir2_data_check( | |||
172 | * Given a data block and an unused entry from that block, | 179 | * Given a data block and an unused entry from that block, |
173 | * return the bestfree entry if any that corresponds to it. | 180 | * return the bestfree entry if any that corresponds to it. |
174 | */ | 181 | */ |
175 | xfs_dir2_data_free_t * | 182 | STATIC xfs_dir2_data_free_t * |
176 | xfs_dir2_data_freefind( | 183 | xfs_dir2_data_freefind( |
177 | xfs_dir2_data_t *d, /* data block */ | 184 | xfs_dir2_data_hdr_t *hdr, /* data block */ |
178 | xfs_dir2_data_unused_t *dup) /* data unused entry */ | 185 | xfs_dir2_data_unused_t *dup) /* data unused entry */ |
179 | { | 186 | { |
180 | xfs_dir2_data_free_t *dfp; /* bestfree entry */ | 187 | xfs_dir2_data_free_t *dfp; /* bestfree entry */ |
@@ -184,17 +191,17 @@ xfs_dir2_data_freefind( | |||
184 | int seenzero; /* saw a 0 bestfree entry */ | 191 | int seenzero; /* saw a 0 bestfree entry */ |
185 | #endif | 192 | #endif |
186 | 193 | ||
187 | off = (xfs_dir2_data_aoff_t)((char *)dup - (char *)d); | 194 | off = (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr); |
188 | #if defined(DEBUG) && defined(__KERNEL__) | 195 | #if defined(DEBUG) && defined(__KERNEL__) |
189 | /* | 196 | /* |
190 | * Validate some consistency in the bestfree table. | 197 | * Validate some consistency in the bestfree table. |
191 | * Check order, non-overlapping entries, and if we find the | 198 | * Check order, non-overlapping entries, and if we find the |
192 | * one we're looking for it has to be exact. | 199 | * one we're looking for it has to be exact. |
193 | */ | 200 | */ |
194 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 201 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || |
195 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 202 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); |
196 | for (dfp = &d->hdr.bestfree[0], seenzero = matched = 0; | 203 | for (dfp = &hdr->bestfree[0], seenzero = matched = 0; |
197 | dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT]; | 204 | dfp < &hdr->bestfree[XFS_DIR2_DATA_FD_COUNT]; |
198 | dfp++) { | 205 | dfp++) { |
199 | if (!dfp->offset) { | 206 | if (!dfp->offset) { |
200 | ASSERT(!dfp->length); | 207 | ASSERT(!dfp->length); |
@@ -210,7 +217,7 @@ xfs_dir2_data_freefind( | |||
210 | else | 217 | else |
211 | ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off); | 218 | ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off); |
212 | ASSERT(matched || be16_to_cpu(dfp->length) >= be16_to_cpu(dup->length)); | 219 | ASSERT(matched || be16_to_cpu(dfp->length) >= be16_to_cpu(dup->length)); |
213 | if (dfp > &d->hdr.bestfree[0]) | 220 | if (dfp > &hdr->bestfree[0]) |
214 | ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length)); | 221 | ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length)); |
215 | } | 222 | } |
216 | #endif | 223 | #endif |
@@ -219,13 +226,13 @@ xfs_dir2_data_freefind( | |||
219 | * it can't be there since they're sorted. | 226 | * it can't be there since they're sorted. |
220 | */ | 227 | */ |
221 | if (be16_to_cpu(dup->length) < | 228 | if (be16_to_cpu(dup->length) < |
222 | be16_to_cpu(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length)) | 229 | be16_to_cpu(hdr->bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length)) |
223 | return NULL; | 230 | return NULL; |
224 | /* | 231 | /* |
225 | * Look at the three bestfree entries for our guy. | 232 | * Look at the three bestfree entries for our guy. |
226 | */ | 233 | */ |
227 | for (dfp = &d->hdr.bestfree[0]; | 234 | for (dfp = &hdr->bestfree[0]; |
228 | dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT]; | 235 | dfp < &hdr->bestfree[XFS_DIR2_DATA_FD_COUNT]; |
229 | dfp++) { | 236 | dfp++) { |
230 | if (!dfp->offset) | 237 | if (!dfp->offset) |
231 | return NULL; | 238 | return NULL; |
@@ -243,7 +250,7 @@ xfs_dir2_data_freefind( | |||
243 | */ | 250 | */ |
244 | xfs_dir2_data_free_t * /* entry inserted */ | 251 | xfs_dir2_data_free_t * /* entry inserted */ |
245 | xfs_dir2_data_freeinsert( | 252 | xfs_dir2_data_freeinsert( |
246 | xfs_dir2_data_t *d, /* data block pointer */ | 253 | xfs_dir2_data_hdr_t *hdr, /* data block pointer */ |
247 | xfs_dir2_data_unused_t *dup, /* unused space */ | 254 | xfs_dir2_data_unused_t *dup, /* unused space */ |
248 | int *loghead) /* log the data header (out) */ | 255 | int *loghead) /* log the data header (out) */ |
249 | { | 256 | { |
@@ -251,12 +258,13 @@ xfs_dir2_data_freeinsert( | |||
251 | xfs_dir2_data_free_t new; /* new bestfree entry */ | 258 | xfs_dir2_data_free_t new; /* new bestfree entry */ |
252 | 259 | ||
253 | #ifdef __KERNEL__ | 260 | #ifdef __KERNEL__ |
254 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 261 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || |
255 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 262 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); |
256 | #endif | 263 | #endif |
257 | dfp = d->hdr.bestfree; | 264 | dfp = hdr->bestfree; |
258 | new.length = dup->length; | 265 | new.length = dup->length; |
259 | new.offset = cpu_to_be16((char *)dup - (char *)d); | 266 | new.offset = cpu_to_be16((char *)dup - (char *)hdr); |
267 | |||
260 | /* | 268 | /* |
261 | * Insert at position 0, 1, or 2; or not at all. | 269 | * Insert at position 0, 1, or 2; or not at all. |
262 | */ | 270 | */ |
@@ -286,36 +294,36 @@ xfs_dir2_data_freeinsert( | |||
286 | */ | 294 | */ |
287 | STATIC void | 295 | STATIC void |
288 | xfs_dir2_data_freeremove( | 296 | xfs_dir2_data_freeremove( |
289 | xfs_dir2_data_t *d, /* data block pointer */ | 297 | xfs_dir2_data_hdr_t *hdr, /* data block header */ |
290 | xfs_dir2_data_free_t *dfp, /* bestfree entry pointer */ | 298 | xfs_dir2_data_free_t *dfp, /* bestfree entry pointer */ |
291 | int *loghead) /* out: log data header */ | 299 | int *loghead) /* out: log data header */ |
292 | { | 300 | { |
293 | #ifdef __KERNEL__ | 301 | #ifdef __KERNEL__ |
294 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 302 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || |
295 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 303 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); |
296 | #endif | 304 | #endif |
297 | /* | 305 | /* |
298 | * It's the first entry, slide the next 2 up. | 306 | * It's the first entry, slide the next 2 up. |
299 | */ | 307 | */ |
300 | if (dfp == &d->hdr.bestfree[0]) { | 308 | if (dfp == &hdr->bestfree[0]) { |
301 | d->hdr.bestfree[0] = d->hdr.bestfree[1]; | 309 | hdr->bestfree[0] = hdr->bestfree[1]; |
302 | d->hdr.bestfree[1] = d->hdr.bestfree[2]; | 310 | hdr->bestfree[1] = hdr->bestfree[2]; |
303 | } | 311 | } |
304 | /* | 312 | /* |
305 | * It's the second entry, slide the 3rd entry up. | 313 | * It's the second entry, slide the 3rd entry up. |
306 | */ | 314 | */ |
307 | else if (dfp == &d->hdr.bestfree[1]) | 315 | else if (dfp == &hdr->bestfree[1]) |
308 | d->hdr.bestfree[1] = d->hdr.bestfree[2]; | 316 | hdr->bestfree[1] = hdr->bestfree[2]; |
309 | /* | 317 | /* |
310 | * Must be the last entry. | 318 | * Must be the last entry. |
311 | */ | 319 | */ |
312 | else | 320 | else |
313 | ASSERT(dfp == &d->hdr.bestfree[2]); | 321 | ASSERT(dfp == &hdr->bestfree[2]); |
314 | /* | 322 | /* |
315 | * Clear the 3rd entry, must be zero now. | 323 | * Clear the 3rd entry, must be zero now. |
316 | */ | 324 | */ |
317 | d->hdr.bestfree[2].length = 0; | 325 | hdr->bestfree[2].length = 0; |
318 | d->hdr.bestfree[2].offset = 0; | 326 | hdr->bestfree[2].offset = 0; |
319 | *loghead = 1; | 327 | *loghead = 1; |
320 | } | 328 | } |
321 | 329 | ||
@@ -325,9 +333,10 @@ xfs_dir2_data_freeremove( | |||
325 | void | 333 | void |
326 | xfs_dir2_data_freescan( | 334 | xfs_dir2_data_freescan( |
327 | xfs_mount_t *mp, /* filesystem mount point */ | 335 | xfs_mount_t *mp, /* filesystem mount point */ |
328 | xfs_dir2_data_t *d, /* data block pointer */ | 336 | xfs_dir2_data_hdr_t *hdr, /* data block header */ |
329 | int *loghead) /* out: log data header */ | 337 | int *loghead) /* out: log data header */ |
330 | { | 338 | { |
339 | xfs_dir2_data_t *d = (xfs_dir2_data_t *)hdr; | ||
331 | xfs_dir2_block_tail_t *btp; /* block tail */ | 340 | xfs_dir2_block_tail_t *btp; /* block tail */ |
332 | xfs_dir2_data_entry_t *dep; /* active data entry */ | 341 | xfs_dir2_data_entry_t *dep; /* active data entry */ |
333 | xfs_dir2_data_unused_t *dup; /* unused data entry */ | 342 | xfs_dir2_data_unused_t *dup; /* unused data entry */ |
@@ -335,23 +344,23 @@ xfs_dir2_data_freescan( | |||
335 | char *p; /* current entry pointer */ | 344 | char *p; /* current entry pointer */ |
336 | 345 | ||
337 | #ifdef __KERNEL__ | 346 | #ifdef __KERNEL__ |
338 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 347 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || |
339 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 348 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); |
340 | #endif | 349 | #endif |
341 | /* | 350 | /* |
342 | * Start by clearing the table. | 351 | * Start by clearing the table. |
343 | */ | 352 | */ |
344 | memset(d->hdr.bestfree, 0, sizeof(d->hdr.bestfree)); | 353 | memset(hdr->bestfree, 0, sizeof(hdr->bestfree)); |
345 | *loghead = 1; | 354 | *loghead = 1; |
346 | /* | 355 | /* |
347 | * Set up pointers. | 356 | * Set up pointers. |
348 | */ | 357 | */ |
349 | p = (char *)d->u; | 358 | p = (char *)d->u; |
350 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | 359 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { |
351 | btp = xfs_dir2_block_tail_p(mp, &d->hdr); | 360 | btp = xfs_dir2_block_tail_p(mp, hdr); |
352 | endp = (char *)xfs_dir2_block_leaf_p(btp); | 361 | endp = (char *)xfs_dir2_block_leaf_p(btp); |
353 | } else | 362 | } else |
354 | endp = (char *)d + mp->m_dirblksize; | 363 | endp = (char *)hdr + mp->m_dirblksize; |
355 | /* | 364 | /* |
356 | * Loop over the block's entries. | 365 | * Loop over the block's entries. |
357 | */ | 366 | */ |
@@ -361,9 +370,9 @@ xfs_dir2_data_freescan( | |||
361 | * If it's a free entry, insert it. | 370 | * If it's a free entry, insert it. |
362 | */ | 371 | */ |
363 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { | 372 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
364 | ASSERT((char *)dup - (char *)d == | 373 | ASSERT((char *)dup - (char *)hdr == |
365 | be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup))); | 374 | be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup))); |
366 | xfs_dir2_data_freeinsert(d, dup, loghead); | 375 | xfs_dir2_data_freeinsert(hdr, dup, loghead); |
367 | p += be16_to_cpu(dup->length); | 376 | p += be16_to_cpu(dup->length); |
368 | } | 377 | } |
369 | /* | 378 | /* |
@@ -371,7 +380,7 @@ xfs_dir2_data_freescan( | |||
371 | */ | 380 | */ |
372 | else { | 381 | else { |
373 | dep = (xfs_dir2_data_entry_t *)p; | 382 | dep = (xfs_dir2_data_entry_t *)p; |
374 | ASSERT((char *)dep - (char *)d == | 383 | ASSERT((char *)dep - (char *)hdr == |
375 | be16_to_cpu(*xfs_dir2_data_entry_tag_p(dep))); | 384 | be16_to_cpu(*xfs_dir2_data_entry_tag_p(dep))); |
376 | p += xfs_dir2_data_entsize(dep->namelen); | 385 | p += xfs_dir2_data_entsize(dep->namelen); |
377 | } | 386 | } |
@@ -390,6 +399,7 @@ xfs_dir2_data_init( | |||
390 | { | 399 | { |
391 | xfs_dabuf_t *bp; /* block buffer */ | 400 | xfs_dabuf_t *bp; /* block buffer */ |
392 | xfs_dir2_data_t *d; /* pointer to block */ | 401 | xfs_dir2_data_t *d; /* pointer to block */ |
402 | xfs_dir2_data_hdr_t *hdr; /* data block header */ | ||
393 | xfs_inode_t *dp; /* incore directory inode */ | 403 | xfs_inode_t *dp; /* incore directory inode */ |
394 | xfs_dir2_data_unused_t *dup; /* unused entry pointer */ | 404 | xfs_dir2_data_unused_t *dup; /* unused entry pointer */ |
395 | int error; /* error return value */ | 405 | int error; /* error return value */ |
@@ -410,26 +420,29 @@ xfs_dir2_data_init( | |||
410 | return error; | 420 | return error; |
411 | } | 421 | } |
412 | ASSERT(bp != NULL); | 422 | ASSERT(bp != NULL); |
423 | |||
413 | /* | 424 | /* |
414 | * Initialize the header. | 425 | * Initialize the header. |
415 | */ | 426 | */ |
416 | d = bp->data; | 427 | d = bp->data; |
417 | d->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); | 428 | hdr = &d->hdr; |
418 | d->hdr.bestfree[0].offset = cpu_to_be16(sizeof(d->hdr)); | 429 | hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); |
430 | hdr->bestfree[0].offset = cpu_to_be16(sizeof(*hdr)); | ||
419 | for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { | 431 | for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { |
420 | d->hdr.bestfree[i].length = 0; | 432 | hdr->bestfree[i].length = 0; |
421 | d->hdr.bestfree[i].offset = 0; | 433 | hdr->bestfree[i].offset = 0; |
422 | } | 434 | } |
435 | |||
423 | /* | 436 | /* |
424 | * Set up an unused entry for the block's body. | 437 | * Set up an unused entry for the block's body. |
425 | */ | 438 | */ |
426 | dup = &d->u[0].unused; | 439 | dup = &d->u[0].unused; |
427 | dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); | 440 | dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
428 | 441 | ||
429 | t=mp->m_dirblksize - (uint)sizeof(d->hdr); | 442 | t = mp->m_dirblksize - (uint)sizeof(*hdr); |
430 | d->hdr.bestfree[0].length = cpu_to_be16(t); | 443 | hdr->bestfree[0].length = cpu_to_be16(t); |
431 | dup->length = cpu_to_be16(t); | 444 | dup->length = cpu_to_be16(t); |
432 | *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)d); | 445 | *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)hdr); |
433 | /* | 446 | /* |
434 | * Log it and return it. | 447 | * Log it and return it. |
435 | */ | 448 | */ |
@@ -448,14 +461,14 @@ xfs_dir2_data_log_entry( | |||
448 | xfs_dabuf_t *bp, /* block buffer */ | 461 | xfs_dabuf_t *bp, /* block buffer */ |
449 | xfs_dir2_data_entry_t *dep) /* data entry pointer */ | 462 | xfs_dir2_data_entry_t *dep) /* data entry pointer */ |
450 | { | 463 | { |
451 | xfs_dir2_data_t *d; /* data block pointer */ | 464 | xfs_dir2_data_hdr_t *hdr = bp->data; |
452 | 465 | ||
453 | d = bp->data; | 466 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || |
454 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 467 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); |
455 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 468 | |
456 | xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d), | 469 | xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr), |
457 | (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) - | 470 | (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) - |
458 | (char *)d - 1)); | 471 | (char *)hdr - 1)); |
459 | } | 472 | } |
460 | 473 | ||
461 | /* | 474 | /* |
@@ -466,13 +479,12 @@ xfs_dir2_data_log_header( | |||
466 | xfs_trans_t *tp, /* transaction pointer */ | 479 | xfs_trans_t *tp, /* transaction pointer */ |
467 | xfs_dabuf_t *bp) /* block buffer */ | 480 | xfs_dabuf_t *bp) /* block buffer */ |
468 | { | 481 | { |
469 | xfs_dir2_data_t *d; /* data block pointer */ | 482 | xfs_dir2_data_hdr_t *hdr = bp->data; |
470 | 483 | ||
471 | d = bp->data; | 484 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || |
472 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 485 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); |
473 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 486 | |
474 | xfs_da_log_buf(tp, bp, (uint)((char *)&d->hdr - (char *)d), | 487 | xfs_da_log_buf(tp, bp, 0, sizeof(*hdr) - 1); |
475 | (uint)(sizeof(d->hdr) - 1)); | ||
476 | } | 488 | } |
477 | 489 | ||
478 | /* | 490 | /* |
@@ -484,23 +496,23 @@ xfs_dir2_data_log_unused( | |||
484 | xfs_dabuf_t *bp, /* block buffer */ | 496 | xfs_dabuf_t *bp, /* block buffer */ |
485 | xfs_dir2_data_unused_t *dup) /* data unused pointer */ | 497 | xfs_dir2_data_unused_t *dup) /* data unused pointer */ |
486 | { | 498 | { |
487 | xfs_dir2_data_t *d; /* data block pointer */ | 499 | xfs_dir2_data_hdr_t *hdr = bp->data; |
500 | |||
501 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || | ||
502 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); | ||
488 | 503 | ||
489 | d = bp->data; | ||
490 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | ||
491 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | ||
492 | /* | 504 | /* |
493 | * Log the first part of the unused entry. | 505 | * Log the first part of the unused entry. |
494 | */ | 506 | */ |
495 | xfs_da_log_buf(tp, bp, (uint)((char *)dup - (char *)d), | 507 | xfs_da_log_buf(tp, bp, (uint)((char *)dup - (char *)hdr), |
496 | (uint)((char *)&dup->length + sizeof(dup->length) - | 508 | (uint)((char *)&dup->length + sizeof(dup->length) - |
497 | 1 - (char *)d)); | 509 | 1 - (char *)hdr)); |
498 | /* | 510 | /* |
499 | * Log the end (tag) of the unused entry. | 511 | * Log the end (tag) of the unused entry. |
500 | */ | 512 | */ |
501 | xfs_da_log_buf(tp, bp, | 513 | xfs_da_log_buf(tp, bp, |
502 | (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)d), | 514 | (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr), |
503 | (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)d + | 515 | (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr + |
504 | sizeof(xfs_dir2_data_off_t) - 1)); | 516 | sizeof(xfs_dir2_data_off_t) - 1)); |
505 | } | 517 | } |
506 | 518 | ||
@@ -517,7 +529,7 @@ xfs_dir2_data_make_free( | |||
517 | int *needlogp, /* out: log header */ | 529 | int *needlogp, /* out: log header */ |
518 | int *needscanp) /* out: regen bestfree */ | 530 | int *needscanp) /* out: regen bestfree */ |
519 | { | 531 | { |
520 | xfs_dir2_data_t *d; /* data block pointer */ | 532 | xfs_dir2_data_hdr_t *hdr; /* data block pointer */ |
521 | xfs_dir2_data_free_t *dfp; /* bestfree pointer */ | 533 | xfs_dir2_data_free_t *dfp; /* bestfree pointer */ |
522 | char *endptr; /* end of data area */ | 534 | char *endptr; /* end of data area */ |
523 | xfs_mount_t *mp; /* filesystem mount point */ | 535 | xfs_mount_t *mp; /* filesystem mount point */ |
@@ -527,28 +539,29 @@ xfs_dir2_data_make_free( | |||
527 | xfs_dir2_data_unused_t *prevdup; /* unused entry before us */ | 539 | xfs_dir2_data_unused_t *prevdup; /* unused entry before us */ |
528 | 540 | ||
529 | mp = tp->t_mountp; | 541 | mp = tp->t_mountp; |
530 | d = bp->data; | 542 | hdr = bp->data; |
543 | |||
531 | /* | 544 | /* |
532 | * Figure out where the end of the data area is. | 545 | * Figure out where the end of the data area is. |
533 | */ | 546 | */ |
534 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC) | 547 | if (be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC) |
535 | endptr = (char *)d + mp->m_dirblksize; | 548 | endptr = (char *)hdr + mp->m_dirblksize; |
536 | else { | 549 | else { |
537 | xfs_dir2_block_tail_t *btp; /* block tail */ | 550 | xfs_dir2_block_tail_t *btp; /* block tail */ |
538 | 551 | ||
539 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 552 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); |
540 | btp = xfs_dir2_block_tail_p(mp, &d->hdr); | 553 | btp = xfs_dir2_block_tail_p(mp, hdr); |
541 | endptr = (char *)xfs_dir2_block_leaf_p(btp); | 554 | endptr = (char *)xfs_dir2_block_leaf_p(btp); |
542 | } | 555 | } |
543 | /* | 556 | /* |
544 | * If this isn't the start of the block, then back up to | 557 | * If this isn't the start of the block, then back up to |
545 | * the previous entry and see if it's free. | 558 | * the previous entry and see if it's free. |
546 | */ | 559 | */ |
547 | if (offset > sizeof(d->hdr)) { | 560 | if (offset > sizeof(*hdr)) { |
548 | __be16 *tagp; /* tag just before us */ | 561 | __be16 *tagp; /* tag just before us */ |
549 | 562 | ||
550 | tagp = (__be16 *)((char *)d + offset) - 1; | 563 | tagp = (__be16 *)((char *)hdr + offset) - 1; |
551 | prevdup = (xfs_dir2_data_unused_t *)((char *)d + be16_to_cpu(*tagp)); | 564 | prevdup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); |
552 | if (be16_to_cpu(prevdup->freetag) != XFS_DIR2_DATA_FREE_TAG) | 565 | if (be16_to_cpu(prevdup->freetag) != XFS_DIR2_DATA_FREE_TAG) |
553 | prevdup = NULL; | 566 | prevdup = NULL; |
554 | } else | 567 | } else |
@@ -557,9 +570,9 @@ xfs_dir2_data_make_free( | |||
557 | * If this isn't the end of the block, see if the entry after | 570 | * If this isn't the end of the block, see if the entry after |
558 | * us is free. | 571 | * us is free. |
559 | */ | 572 | */ |
560 | if ((char *)d + offset + len < endptr) { | 573 | if ((char *)hdr + offset + len < endptr) { |
561 | postdup = | 574 | postdup = |
562 | (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 575 | (xfs_dir2_data_unused_t *)((char *)hdr + offset + len); |
563 | if (be16_to_cpu(postdup->freetag) != XFS_DIR2_DATA_FREE_TAG) | 576 | if (be16_to_cpu(postdup->freetag) != XFS_DIR2_DATA_FREE_TAG) |
564 | postdup = NULL; | 577 | postdup = NULL; |
565 | } else | 578 | } else |
@@ -576,21 +589,21 @@ xfs_dir2_data_make_free( | |||
576 | /* | 589 | /* |
577 | * See if prevdup and/or postdup are in bestfree table. | 590 | * See if prevdup and/or postdup are in bestfree table. |
578 | */ | 591 | */ |
579 | dfp = xfs_dir2_data_freefind(d, prevdup); | 592 | dfp = xfs_dir2_data_freefind(hdr, prevdup); |
580 | dfp2 = xfs_dir2_data_freefind(d, postdup); | 593 | dfp2 = xfs_dir2_data_freefind(hdr, postdup); |
581 | /* | 594 | /* |
582 | * We need a rescan unless there are exactly 2 free entries | 595 | * We need a rescan unless there are exactly 2 free entries |
583 | * namely our two. Then we know what's happening, otherwise | 596 | * namely our two. Then we know what's happening, otherwise |
584 | * since the third bestfree is there, there might be more | 597 | * since the third bestfree is there, there might be more |
585 | * entries. | 598 | * entries. |
586 | */ | 599 | */ |
587 | needscan = (d->hdr.bestfree[2].length != 0); | 600 | needscan = (hdr->bestfree[2].length != 0); |
588 | /* | 601 | /* |
589 | * Fix up the new big freespace. | 602 | * Fix up the new big freespace. |
590 | */ | 603 | */ |
591 | be16_add_cpu(&prevdup->length, len + be16_to_cpu(postdup->length)); | 604 | be16_add_cpu(&prevdup->length, len + be16_to_cpu(postdup->length)); |
592 | *xfs_dir2_data_unused_tag_p(prevdup) = | 605 | *xfs_dir2_data_unused_tag_p(prevdup) = |
593 | cpu_to_be16((char *)prevdup - (char *)d); | 606 | cpu_to_be16((char *)prevdup - (char *)hdr); |
594 | xfs_dir2_data_log_unused(tp, bp, prevdup); | 607 | xfs_dir2_data_log_unused(tp, bp, prevdup); |
595 | if (!needscan) { | 608 | if (!needscan) { |
596 | /* | 609 | /* |
@@ -600,18 +613,18 @@ xfs_dir2_data_make_free( | |||
600 | * Remove entry 1 first then entry 0. | 613 | * Remove entry 1 first then entry 0. |
601 | */ | 614 | */ |
602 | ASSERT(dfp && dfp2); | 615 | ASSERT(dfp && dfp2); |
603 | if (dfp == &d->hdr.bestfree[1]) { | 616 | if (dfp == &hdr->bestfree[1]) { |
604 | dfp = &d->hdr.bestfree[0]; | 617 | dfp = &hdr->bestfree[0]; |
605 | ASSERT(dfp2 == dfp); | 618 | ASSERT(dfp2 == dfp); |
606 | dfp2 = &d->hdr.bestfree[1]; | 619 | dfp2 = &hdr->bestfree[1]; |
607 | } | 620 | } |
608 | xfs_dir2_data_freeremove(d, dfp2, needlogp); | 621 | xfs_dir2_data_freeremove(hdr, dfp2, needlogp); |
609 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 622 | xfs_dir2_data_freeremove(hdr, dfp, needlogp); |
610 | /* | 623 | /* |
611 | * Now insert the new entry. | 624 | * Now insert the new entry. |
612 | */ | 625 | */ |
613 | dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp); | 626 | dfp = xfs_dir2_data_freeinsert(hdr, prevdup, needlogp); |
614 | ASSERT(dfp == &d->hdr.bestfree[0]); | 627 | ASSERT(dfp == &hdr->bestfree[0]); |
615 | ASSERT(dfp->length == prevdup->length); | 628 | ASSERT(dfp->length == prevdup->length); |
616 | ASSERT(!dfp[1].length); | 629 | ASSERT(!dfp[1].length); |
617 | ASSERT(!dfp[2].length); | 630 | ASSERT(!dfp[2].length); |
@@ -621,10 +634,10 @@ xfs_dir2_data_make_free( | |||
621 | * The entry before us is free, merge with it. | 634 | * The entry before us is free, merge with it. |
622 | */ | 635 | */ |
623 | else if (prevdup) { | 636 | else if (prevdup) { |
624 | dfp = xfs_dir2_data_freefind(d, prevdup); | 637 | dfp = xfs_dir2_data_freefind(hdr, prevdup); |
625 | be16_add_cpu(&prevdup->length, len); | 638 | be16_add_cpu(&prevdup->length, len); |
626 | *xfs_dir2_data_unused_tag_p(prevdup) = | 639 | *xfs_dir2_data_unused_tag_p(prevdup) = |
627 | cpu_to_be16((char *)prevdup - (char *)d); | 640 | cpu_to_be16((char *)prevdup - (char *)hdr); |
628 | xfs_dir2_data_log_unused(tp, bp, prevdup); | 641 | xfs_dir2_data_log_unused(tp, bp, prevdup); |
629 | /* | 642 | /* |
630 | * If the previous entry was in the table, the new entry | 643 | * If the previous entry was in the table, the new entry |
@@ -632,27 +645,27 @@ xfs_dir2_data_make_free( | |||
632 | * the old one and add the new one. | 645 | * the old one and add the new one. |
633 | */ | 646 | */ |
634 | if (dfp) { | 647 | if (dfp) { |
635 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 648 | xfs_dir2_data_freeremove(hdr, dfp, needlogp); |
636 | (void)xfs_dir2_data_freeinsert(d, prevdup, needlogp); | 649 | xfs_dir2_data_freeinsert(hdr, prevdup, needlogp); |
637 | } | 650 | } |
638 | /* | 651 | /* |
639 | * Otherwise we need a scan if the new entry is big enough. | 652 | * Otherwise we need a scan if the new entry is big enough. |
640 | */ | 653 | */ |
641 | else { | 654 | else { |
642 | needscan = be16_to_cpu(prevdup->length) > | 655 | needscan = be16_to_cpu(prevdup->length) > |
643 | be16_to_cpu(d->hdr.bestfree[2].length); | 656 | be16_to_cpu(hdr->bestfree[2].length); |
644 | } | 657 | } |
645 | } | 658 | } |
646 | /* | 659 | /* |
647 | * The following entry is free, merge with it. | 660 | * The following entry is free, merge with it. |
648 | */ | 661 | */ |
649 | else if (postdup) { | 662 | else if (postdup) { |
650 | dfp = xfs_dir2_data_freefind(d, postdup); | 663 | dfp = xfs_dir2_data_freefind(hdr, postdup); |
651 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); | 664 | newdup = (xfs_dir2_data_unused_t *)((char *)hdr + offset); |
652 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); | 665 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
653 | newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length)); | 666 | newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length)); |
654 | *xfs_dir2_data_unused_tag_p(newdup) = | 667 | *xfs_dir2_data_unused_tag_p(newdup) = |
655 | cpu_to_be16((char *)newdup - (char *)d); | 668 | cpu_to_be16((char *)newdup - (char *)hdr); |
656 | xfs_dir2_data_log_unused(tp, bp, newdup); | 669 | xfs_dir2_data_log_unused(tp, bp, newdup); |
657 | /* | 670 | /* |
658 | * If the following entry was in the table, the new entry | 671 | * If the following entry was in the table, the new entry |
@@ -660,28 +673,28 @@ xfs_dir2_data_make_free( | |||
660 | * the old one and add the new one. | 673 | * the old one and add the new one. |
661 | */ | 674 | */ |
662 | if (dfp) { | 675 | if (dfp) { |
663 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 676 | xfs_dir2_data_freeremove(hdr, dfp, needlogp); |
664 | (void)xfs_dir2_data_freeinsert(d, newdup, needlogp); | 677 | xfs_dir2_data_freeinsert(hdr, newdup, needlogp); |
665 | } | 678 | } |
666 | /* | 679 | /* |
667 | * Otherwise we need a scan if the new entry is big enough. | 680 | * Otherwise we need a scan if the new entry is big enough. |
668 | */ | 681 | */ |
669 | else { | 682 | else { |
670 | needscan = be16_to_cpu(newdup->length) > | 683 | needscan = be16_to_cpu(newdup->length) > |
671 | be16_to_cpu(d->hdr.bestfree[2].length); | 684 | be16_to_cpu(hdr->bestfree[2].length); |
672 | } | 685 | } |
673 | } | 686 | } |
674 | /* | 687 | /* |
675 | * Neither neighbor is free. Make a new entry. | 688 | * Neither neighbor is free. Make a new entry. |
676 | */ | 689 | */ |
677 | else { | 690 | else { |
678 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); | 691 | newdup = (xfs_dir2_data_unused_t *)((char *)hdr + offset); |
679 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); | 692 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
680 | newdup->length = cpu_to_be16(len); | 693 | newdup->length = cpu_to_be16(len); |
681 | *xfs_dir2_data_unused_tag_p(newdup) = | 694 | *xfs_dir2_data_unused_tag_p(newdup) = |
682 | cpu_to_be16((char *)newdup - (char *)d); | 695 | cpu_to_be16((char *)newdup - (char *)hdr); |
683 | xfs_dir2_data_log_unused(tp, bp, newdup); | 696 | xfs_dir2_data_log_unused(tp, bp, newdup); |
684 | (void)xfs_dir2_data_freeinsert(d, newdup, needlogp); | 697 | xfs_dir2_data_freeinsert(hdr, newdup, needlogp); |
685 | } | 698 | } |
686 | *needscanp = needscan; | 699 | *needscanp = needscan; |
687 | } | 700 | } |
@@ -699,7 +712,7 @@ xfs_dir2_data_use_free( | |||
699 | int *needlogp, /* out: need to log header */ | 712 | int *needlogp, /* out: need to log header */ |
700 | int *needscanp) /* out: need regen bestfree */ | 713 | int *needscanp) /* out: need regen bestfree */ |
701 | { | 714 | { |
702 | xfs_dir2_data_t *d; /* data block */ | 715 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
703 | xfs_dir2_data_free_t *dfp; /* bestfree pointer */ | 716 | xfs_dir2_data_free_t *dfp; /* bestfree pointer */ |
704 | int matchback; /* matches end of freespace */ | 717 | int matchback; /* matches end of freespace */ |
705 | int matchfront; /* matches start of freespace */ | 718 | int matchfront; /* matches start of freespace */ |
@@ -708,24 +721,24 @@ xfs_dir2_data_use_free( | |||
708 | xfs_dir2_data_unused_t *newdup2; /* another new unused entry */ | 721 | xfs_dir2_data_unused_t *newdup2; /* another new unused entry */ |
709 | int oldlen; /* old unused entry's length */ | 722 | int oldlen; /* old unused entry's length */ |
710 | 723 | ||
711 | d = bp->data; | 724 | hdr = bp->data; |
712 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 725 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || |
713 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 726 | be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); |
714 | ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); | 727 | ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); |
715 | ASSERT(offset >= (char *)dup - (char *)d); | 728 | ASSERT(offset >= (char *)dup - (char *)hdr); |
716 | ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)d); | 729 | ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)hdr); |
717 | ASSERT((char *)dup - (char *)d == be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup))); | 730 | ASSERT((char *)dup - (char *)hdr == be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup))); |
718 | /* | 731 | /* |
719 | * Look up the entry in the bestfree table. | 732 | * Look up the entry in the bestfree table. |
720 | */ | 733 | */ |
721 | dfp = xfs_dir2_data_freefind(d, dup); | 734 | dfp = xfs_dir2_data_freefind(hdr, dup); |
722 | oldlen = be16_to_cpu(dup->length); | 735 | oldlen = be16_to_cpu(dup->length); |
723 | ASSERT(dfp || oldlen <= be16_to_cpu(d->hdr.bestfree[2].length)); | 736 | ASSERT(dfp || oldlen <= be16_to_cpu(hdr->bestfree[2].length)); |
724 | /* | 737 | /* |
725 | * Check for alignment with front and back of the entry. | 738 | * Check for alignment with front and back of the entry. |
726 | */ | 739 | */ |
727 | matchfront = (char *)dup - (char *)d == offset; | 740 | matchfront = (char *)dup - (char *)hdr == offset; |
728 | matchback = (char *)dup + oldlen - (char *)d == offset + len; | 741 | matchback = (char *)dup + oldlen - (char *)hdr == offset + len; |
729 | ASSERT(*needscanp == 0); | 742 | ASSERT(*needscanp == 0); |
730 | needscan = 0; | 743 | needscan = 0; |
731 | /* | 744 | /* |
@@ -734,9 +747,9 @@ xfs_dir2_data_use_free( | |||
734 | */ | 747 | */ |
735 | if (matchfront && matchback) { | 748 | if (matchfront && matchback) { |
736 | if (dfp) { | 749 | if (dfp) { |
737 | needscan = (d->hdr.bestfree[2].offset != 0); | 750 | needscan = (hdr->bestfree[2].offset != 0); |
738 | if (!needscan) | 751 | if (!needscan) |
739 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 752 | xfs_dir2_data_freeremove(hdr, dfp, needlogp); |
740 | } | 753 | } |
741 | } | 754 | } |
742 | /* | 755 | /* |
@@ -744,27 +757,27 @@ xfs_dir2_data_use_free( | |||
744 | * Make a new entry with the remaining freespace. | 757 | * Make a new entry with the remaining freespace. |
745 | */ | 758 | */ |
746 | else if (matchfront) { | 759 | else if (matchfront) { |
747 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 760 | newdup = (xfs_dir2_data_unused_t *)((char *)hdr + offset + len); |
748 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); | 761 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
749 | newdup->length = cpu_to_be16(oldlen - len); | 762 | newdup->length = cpu_to_be16(oldlen - len); |
750 | *xfs_dir2_data_unused_tag_p(newdup) = | 763 | *xfs_dir2_data_unused_tag_p(newdup) = |
751 | cpu_to_be16((char *)newdup - (char *)d); | 764 | cpu_to_be16((char *)newdup - (char *)hdr); |
752 | xfs_dir2_data_log_unused(tp, bp, newdup); | 765 | xfs_dir2_data_log_unused(tp, bp, newdup); |
753 | /* | 766 | /* |
754 | * If it was in the table, remove it and add the new one. | 767 | * If it was in the table, remove it and add the new one. |
755 | */ | 768 | */ |
756 | if (dfp) { | 769 | if (dfp) { |
757 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 770 | xfs_dir2_data_freeremove(hdr, dfp, needlogp); |
758 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); | 771 | dfp = xfs_dir2_data_freeinsert(hdr, newdup, needlogp); |
759 | ASSERT(dfp != NULL); | 772 | ASSERT(dfp != NULL); |
760 | ASSERT(dfp->length == newdup->length); | 773 | ASSERT(dfp->length == newdup->length); |
761 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); | 774 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)hdr); |
762 | /* | 775 | /* |
763 | * If we got inserted at the last slot, | 776 | * If we got inserted at the last slot, |
764 | * that means we don't know if there was a better | 777 | * that means we don't know if there was a better |
765 | * choice for the last slot, or not. Rescan. | 778 | * choice for the last slot, or not. Rescan. |
766 | */ | 779 | */ |
767 | needscan = dfp == &d->hdr.bestfree[2]; | 780 | needscan = dfp == &hdr->bestfree[2]; |
768 | } | 781 | } |
769 | } | 782 | } |
770 | /* | 783 | /* |
@@ -773,25 +786,25 @@ xfs_dir2_data_use_free( | |||
773 | */ | 786 | */ |
774 | else if (matchback) { | 787 | else if (matchback) { |
775 | newdup = dup; | 788 | newdup = dup; |
776 | newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup); | 789 | newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup); |
777 | *xfs_dir2_data_unused_tag_p(newdup) = | 790 | *xfs_dir2_data_unused_tag_p(newdup) = |
778 | cpu_to_be16((char *)newdup - (char *)d); | 791 | cpu_to_be16((char *)newdup - (char *)hdr); |
779 | xfs_dir2_data_log_unused(tp, bp, newdup); | 792 | xfs_dir2_data_log_unused(tp, bp, newdup); |
780 | /* | 793 | /* |
781 | * If it was in the table, remove it and add the new one. | 794 | * If it was in the table, remove it and add the new one. |
782 | */ | 795 | */ |
783 | if (dfp) { | 796 | if (dfp) { |
784 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 797 | xfs_dir2_data_freeremove(hdr, dfp, needlogp); |
785 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); | 798 | dfp = xfs_dir2_data_freeinsert(hdr, newdup, needlogp); |
786 | ASSERT(dfp != NULL); | 799 | ASSERT(dfp != NULL); |
787 | ASSERT(dfp->length == newdup->length); | 800 | ASSERT(dfp->length == newdup->length); |
788 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); | 801 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)hdr); |
789 | /* | 802 | /* |
790 | * If we got inserted at the last slot, | 803 | * If we got inserted at the last slot, |
791 | * that means we don't know if there was a better | 804 | * that means we don't know if there was a better |
792 | * choice for the last slot, or not. Rescan. | 805 | * choice for the last slot, or not. Rescan. |
793 | */ | 806 | */ |
794 | needscan = dfp == &d->hdr.bestfree[2]; | 807 | needscan = dfp == &hdr->bestfree[2]; |
795 | } | 808 | } |
796 | } | 809 | } |
797 | /* | 810 | /* |
@@ -800,15 +813,15 @@ xfs_dir2_data_use_free( | |||
800 | */ | 813 | */ |
801 | else { | 814 | else { |
802 | newdup = dup; | 815 | newdup = dup; |
803 | newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup); | 816 | newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup); |
804 | *xfs_dir2_data_unused_tag_p(newdup) = | 817 | *xfs_dir2_data_unused_tag_p(newdup) = |
805 | cpu_to_be16((char *)newdup - (char *)d); | 818 | cpu_to_be16((char *)newdup - (char *)hdr); |
806 | xfs_dir2_data_log_unused(tp, bp, newdup); | 819 | xfs_dir2_data_log_unused(tp, bp, newdup); |
807 | newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 820 | newdup2 = (xfs_dir2_data_unused_t *)((char *)hdr + offset + len); |
808 | newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); | 821 | newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
809 | newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length)); | 822 | newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length)); |
810 | *xfs_dir2_data_unused_tag_p(newdup2) = | 823 | *xfs_dir2_data_unused_tag_p(newdup2) = |
811 | cpu_to_be16((char *)newdup2 - (char *)d); | 824 | cpu_to_be16((char *)newdup2 - (char *)hdr); |
812 | xfs_dir2_data_log_unused(tp, bp, newdup2); | 825 | xfs_dir2_data_log_unused(tp, bp, newdup2); |
813 | /* | 826 | /* |
814 | * If the old entry was in the table, we need to scan | 827 | * If the old entry was in the table, we need to scan |
@@ -819,13 +832,12 @@ xfs_dir2_data_use_free( | |||
819 | * the 2 new will work. | 832 | * the 2 new will work. |
820 | */ | 833 | */ |
821 | if (dfp) { | 834 | if (dfp) { |
822 | needscan = (d->hdr.bestfree[2].length != 0); | 835 | needscan = (hdr->bestfree[2].length != 0); |
823 | if (!needscan) { | 836 | if (!needscan) { |
824 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 837 | xfs_dir2_data_freeremove(hdr, dfp, needlogp); |
825 | (void)xfs_dir2_data_freeinsert(d, newdup, | 838 | xfs_dir2_data_freeinsert(hdr, newdup, needlogp); |
826 | needlogp); | 839 | xfs_dir2_data_freeinsert(hdr, newdup2, |
827 | (void)xfs_dir2_data_freeinsert(d, newdup2, | 840 | needlogp); |
828 | needlogp); | ||
829 | } | 841 | } |
830 | } | 842 | } |
831 | } | 843 | } |
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h index efbc290c7fec..aa6bf91c4228 100644 --- a/fs/xfs/xfs_dir2_data.h +++ b/fs/xfs/xfs_dir2_data.h | |||
@@ -157,12 +157,10 @@ extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp); | |||
157 | #else | 157 | #else |
158 | #define xfs_dir2_data_check(dp,bp) | 158 | #define xfs_dir2_data_check(dp,bp) |
159 | #endif | 159 | #endif |
160 | extern xfs_dir2_data_free_t *xfs_dir2_data_freefind(xfs_dir2_data_t *d, | 160 | extern xfs_dir2_data_free_t *xfs_dir2_data_freeinsert(xfs_dir2_data_hdr_t *hdr, |
161 | xfs_dir2_data_unused_t *dup); | ||
162 | extern xfs_dir2_data_free_t *xfs_dir2_data_freeinsert(xfs_dir2_data_t *d, | ||
163 | xfs_dir2_data_unused_t *dup, int *loghead); | 161 | xfs_dir2_data_unused_t *dup, int *loghead); |
164 | extern void xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d, | 162 | extern void xfs_dir2_data_freescan(struct xfs_mount *mp, |
165 | int *loghead); | 163 | xfs_dir2_data_hdr_t *hdr, int *loghead); |
166 | extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, | 164 | extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, |
167 | struct xfs_dabuf **bpp); | 165 | struct xfs_dabuf **bpp); |
168 | extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp, | 166 | extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp, |
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index 1b048dad360f..d7b4d4494f2d 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -132,7 +132,7 @@ xfs_dir2_block_to_leaf( | |||
132 | */ | 132 | */ |
133 | hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); | 133 | hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); |
134 | if (needscan) | 134 | if (needscan) |
135 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); | 135 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
136 | /* | 136 | /* |
137 | * Set up leaf tail and bests table. | 137 | * Set up leaf tail and bests table. |
138 | */ | 138 | */ |
@@ -278,7 +278,7 @@ xfs_dir2_leaf_addname( | |||
278 | { | 278 | { |
279 | __be16 *bestsp; /* freespace table in leaf */ | 279 | __be16 *bestsp; /* freespace table in leaf */ |
280 | int compact; /* need to compact leaves */ | 280 | int compact; /* need to compact leaves */ |
281 | xfs_dir2_data_t *data; /* data block structure */ | 281 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
282 | xfs_dabuf_t *dbp; /* data block buffer */ | 282 | xfs_dabuf_t *dbp; /* data block buffer */ |
283 | xfs_dir2_data_entry_t *dep; /* data block entry */ | 283 | xfs_dir2_data_entry_t *dep; /* data block entry */ |
284 | xfs_inode_t *dp; /* incore directory inode */ | 284 | xfs_inode_t *dp; /* incore directory inode */ |
@@ -486,8 +486,8 @@ xfs_dir2_leaf_addname( | |||
486 | */ | 486 | */ |
487 | else | 487 | else |
488 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); | 488 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); |
489 | data = dbp->data; | 489 | hdr = dbp->data; |
490 | bestsp[use_block] = data->hdr.bestfree[0].length; | 490 | bestsp[use_block] = hdr->bestfree[0].length; |
491 | grown = 1; | 491 | grown = 1; |
492 | } | 492 | } |
493 | /* | 493 | /* |
@@ -501,7 +501,7 @@ xfs_dir2_leaf_addname( | |||
501 | xfs_da_brelse(tp, lbp); | 501 | xfs_da_brelse(tp, lbp); |
502 | return error; | 502 | return error; |
503 | } | 503 | } |
504 | data = dbp->data; | 504 | hdr = dbp->data; |
505 | grown = 0; | 505 | grown = 0; |
506 | } | 506 | } |
507 | xfs_dir2_data_check(dp, dbp); | 507 | xfs_dir2_data_check(dp, dbp); |
@@ -509,14 +509,14 @@ xfs_dir2_leaf_addname( | |||
509 | * Point to the biggest freespace in our data block. | 509 | * Point to the biggest freespace in our data block. |
510 | */ | 510 | */ |
511 | dup = (xfs_dir2_data_unused_t *) | 511 | dup = (xfs_dir2_data_unused_t *) |
512 | ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); | 512 | ((char *)hdr + be16_to_cpu(hdr->bestfree[0].offset)); |
513 | ASSERT(be16_to_cpu(dup->length) >= length); | 513 | ASSERT(be16_to_cpu(dup->length) >= length); |
514 | needscan = needlog = 0; | 514 | needscan = needlog = 0; |
515 | /* | 515 | /* |
516 | * Mark the initial part of our freespace in use for the new entry. | 516 | * Mark the initial part of our freespace in use for the new entry. |
517 | */ | 517 | */ |
518 | xfs_dir2_data_use_free(tp, dbp, dup, | 518 | xfs_dir2_data_use_free(tp, dbp, dup, |
519 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)data), length, | 519 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, |
520 | &needlog, &needscan); | 520 | &needlog, &needscan); |
521 | /* | 521 | /* |
522 | * Initialize our new entry (at last). | 522 | * Initialize our new entry (at last). |
@@ -526,12 +526,12 @@ xfs_dir2_leaf_addname( | |||
526 | dep->namelen = args->namelen; | 526 | dep->namelen = args->namelen; |
527 | memcpy(dep->name, args->name, dep->namelen); | 527 | memcpy(dep->name, args->name, dep->namelen); |
528 | tagp = xfs_dir2_data_entry_tag_p(dep); | 528 | tagp = xfs_dir2_data_entry_tag_p(dep); |
529 | *tagp = cpu_to_be16((char *)dep - (char *)data); | 529 | *tagp = cpu_to_be16((char *)dep - (char *)hdr); |
530 | /* | 530 | /* |
531 | * Need to scan fix up the bestfree table. | 531 | * Need to scan fix up the bestfree table. |
532 | */ | 532 | */ |
533 | if (needscan) | 533 | if (needscan) |
534 | xfs_dir2_data_freescan(mp, data, &needlog); | 534 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
535 | /* | 535 | /* |
536 | * Need to log the data block's header. | 536 | * Need to log the data block's header. |
537 | */ | 537 | */ |
@@ -542,8 +542,8 @@ xfs_dir2_leaf_addname( | |||
542 | * If the bests table needs to be changed, do it. | 542 | * If the bests table needs to be changed, do it. |
543 | * Log the change unless we've already done that. | 543 | * Log the change unless we've already done that. |
544 | */ | 544 | */ |
545 | if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(data->hdr.bestfree[0].length)) { | 545 | if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(hdr->bestfree[0].length)) { |
546 | bestsp[use_block] = data->hdr.bestfree[0].length; | 546 | bestsp[use_block] = hdr->bestfree[0].length; |
547 | if (!grown) | 547 | if (!grown) |
548 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); | 548 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); |
549 | } | 549 | } |
@@ -786,6 +786,7 @@ xfs_dir2_leaf_getdents( | |||
786 | xfs_dir2_db_t curdb; /* db for current block */ | 786 | xfs_dir2_db_t curdb; /* db for current block */ |
787 | xfs_dir2_off_t curoff; /* current overall offset */ | 787 | xfs_dir2_off_t curoff; /* current overall offset */ |
788 | xfs_dir2_data_t *data; /* data block structure */ | 788 | xfs_dir2_data_t *data; /* data block structure */ |
789 | xfs_dir2_data_hdr_t *hdr; /* data block header */ | ||
789 | xfs_dir2_data_entry_t *dep; /* data entry */ | 790 | xfs_dir2_data_entry_t *dep; /* data entry */ |
790 | xfs_dir2_data_unused_t *dup; /* unused entry */ | 791 | xfs_dir2_data_unused_t *dup; /* unused entry */ |
791 | int error = 0; /* error return value */ | 792 | int error = 0; /* error return value */ |
@@ -1044,6 +1045,7 @@ xfs_dir2_leaf_getdents( | |||
1044 | ASSERT(xfs_dir2_byte_to_db(mp, curoff) == | 1045 | ASSERT(xfs_dir2_byte_to_db(mp, curoff) == |
1045 | curdb); | 1046 | curdb); |
1046 | data = bp->data; | 1047 | data = bp->data; |
1048 | hdr = &data->hdr; | ||
1047 | xfs_dir2_data_check(dp, bp); | 1049 | xfs_dir2_data_check(dp, bp); |
1048 | /* | 1050 | /* |
1049 | * Find our position in the block. | 1051 | * Find our position in the block. |
@@ -1054,12 +1056,12 @@ xfs_dir2_leaf_getdents( | |||
1054 | * Skip past the header. | 1056 | * Skip past the header. |
1055 | */ | 1057 | */ |
1056 | if (byteoff == 0) | 1058 | if (byteoff == 0) |
1057 | curoff += (uint)sizeof(data->hdr); | 1059 | curoff += (uint)sizeof(*hdr); |
1058 | /* | 1060 | /* |
1059 | * Skip past entries until we reach our offset. | 1061 | * Skip past entries until we reach our offset. |
1060 | */ | 1062 | */ |
1061 | else { | 1063 | else { |
1062 | while ((char *)ptr - (char *)data < byteoff) { | 1064 | while ((char *)ptr - (char *)hdr < byteoff) { |
1063 | dup = (xfs_dir2_data_unused_t *)ptr; | 1065 | dup = (xfs_dir2_data_unused_t *)ptr; |
1064 | 1066 | ||
1065 | if (be16_to_cpu(dup->freetag) | 1067 | if (be16_to_cpu(dup->freetag) |
@@ -1080,8 +1082,8 @@ xfs_dir2_leaf_getdents( | |||
1080 | curoff = | 1082 | curoff = |
1081 | xfs_dir2_db_off_to_byte(mp, | 1083 | xfs_dir2_db_off_to_byte(mp, |
1082 | xfs_dir2_byte_to_db(mp, curoff), | 1084 | xfs_dir2_byte_to_db(mp, curoff), |
1083 | (char *)ptr - (char *)data); | 1085 | (char *)ptr - (char *)hdr); |
1084 | if (ptr >= (char *)data + mp->m_dirblksize) { | 1086 | if (ptr >= (char *)hdr + mp->m_dirblksize) { |
1085 | continue; | 1087 | continue; |
1086 | } | 1088 | } |
1087 | } | 1089 | } |
@@ -1462,7 +1464,7 @@ xfs_dir2_leaf_removename( | |||
1462 | xfs_da_args_t *args) /* operation arguments */ | 1464 | xfs_da_args_t *args) /* operation arguments */ |
1463 | { | 1465 | { |
1464 | __be16 *bestsp; /* leaf block best freespace */ | 1466 | __be16 *bestsp; /* leaf block best freespace */ |
1465 | xfs_dir2_data_t *data; /* data block structure */ | 1467 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
1466 | xfs_dir2_db_t db; /* data block number */ | 1468 | xfs_dir2_db_t db; /* data block number */ |
1467 | xfs_dabuf_t *dbp; /* data block buffer */ | 1469 | xfs_dabuf_t *dbp; /* data block buffer */ |
1468 | xfs_dir2_data_entry_t *dep; /* data entry structure */ | 1470 | xfs_dir2_data_entry_t *dep; /* data entry structure */ |
@@ -1492,7 +1494,7 @@ xfs_dir2_leaf_removename( | |||
1492 | tp = args->trans; | 1494 | tp = args->trans; |
1493 | mp = dp->i_mount; | 1495 | mp = dp->i_mount; |
1494 | leaf = lbp->data; | 1496 | leaf = lbp->data; |
1495 | data = dbp->data; | 1497 | hdr = dbp->data; |
1496 | xfs_dir2_data_check(dp, dbp); | 1498 | xfs_dir2_data_check(dp, dbp); |
1497 | /* | 1499 | /* |
1498 | * Point to the leaf entry, use that to point to the data entry. | 1500 | * Point to the leaf entry, use that to point to the data entry. |
@@ -1500,9 +1502,9 @@ xfs_dir2_leaf_removename( | |||
1500 | lep = &leaf->ents[index]; | 1502 | lep = &leaf->ents[index]; |
1501 | db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); | 1503 | db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); |
1502 | dep = (xfs_dir2_data_entry_t *) | 1504 | dep = (xfs_dir2_data_entry_t *) |
1503 | ((char *)data + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); | 1505 | ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); |
1504 | needscan = needlog = 0; | 1506 | needscan = needlog = 0; |
1505 | oldbest = be16_to_cpu(data->hdr.bestfree[0].length); | 1507 | oldbest = be16_to_cpu(hdr->bestfree[0].length); |
1506 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); | 1508 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); |
1507 | bestsp = xfs_dir2_leaf_bests_p(ltp); | 1509 | bestsp = xfs_dir2_leaf_bests_p(ltp); |
1508 | ASSERT(be16_to_cpu(bestsp[db]) == oldbest); | 1510 | ASSERT(be16_to_cpu(bestsp[db]) == oldbest); |
@@ -1510,7 +1512,7 @@ xfs_dir2_leaf_removename( | |||
1510 | * Mark the former data entry unused. | 1512 | * Mark the former data entry unused. |
1511 | */ | 1513 | */ |
1512 | xfs_dir2_data_make_free(tp, dbp, | 1514 | xfs_dir2_data_make_free(tp, dbp, |
1513 | (xfs_dir2_data_aoff_t)((char *)dep - (char *)data), | 1515 | (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), |
1514 | xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); | 1516 | xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); |
1515 | /* | 1517 | /* |
1516 | * We just mark the leaf entry stale by putting a null in it. | 1518 | * We just mark the leaf entry stale by putting a null in it. |
@@ -1524,23 +1526,23 @@ xfs_dir2_leaf_removename( | |||
1524 | * log the data block header if necessary. | 1526 | * log the data block header if necessary. |
1525 | */ | 1527 | */ |
1526 | if (needscan) | 1528 | if (needscan) |
1527 | xfs_dir2_data_freescan(mp, data, &needlog); | 1529 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
1528 | if (needlog) | 1530 | if (needlog) |
1529 | xfs_dir2_data_log_header(tp, dbp); | 1531 | xfs_dir2_data_log_header(tp, dbp); |
1530 | /* | 1532 | /* |
1531 | * If the longest freespace in the data block has changed, | 1533 | * If the longest freespace in the data block has changed, |
1532 | * put the new value in the bests table and log that. | 1534 | * put the new value in the bests table and log that. |
1533 | */ | 1535 | */ |
1534 | if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) { | 1536 | if (be16_to_cpu(hdr->bestfree[0].length) != oldbest) { |
1535 | bestsp[db] = data->hdr.bestfree[0].length; | 1537 | bestsp[db] = hdr->bestfree[0].length; |
1536 | xfs_dir2_leaf_log_bests(tp, lbp, db, db); | 1538 | xfs_dir2_leaf_log_bests(tp, lbp, db, db); |
1537 | } | 1539 | } |
1538 | xfs_dir2_data_check(dp, dbp); | 1540 | xfs_dir2_data_check(dp, dbp); |
1539 | /* | 1541 | /* |
1540 | * If the data block is now empty then get rid of the data block. | 1542 | * If the data block is now empty then get rid of the data block. |
1541 | */ | 1543 | */ |
1542 | if (be16_to_cpu(data->hdr.bestfree[0].length) == | 1544 | if (be16_to_cpu(hdr->bestfree[0].length) == |
1543 | mp->m_dirblksize - (uint)sizeof(data->hdr)) { | 1545 | mp->m_dirblksize - (uint)sizeof(*hdr)) { |
1544 | ASSERT(db != mp->m_dirdatablk); | 1546 | ASSERT(db != mp->m_dirdatablk); |
1545 | if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { | 1547 | if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { |
1546 | /* | 1548 | /* |
@@ -1711,9 +1713,6 @@ xfs_dir2_leaf_trim_data( | |||
1711 | xfs_dir2_db_t db) /* data block number */ | 1713 | xfs_dir2_db_t db) /* data block number */ |
1712 | { | 1714 | { |
1713 | __be16 *bestsp; /* leaf bests table */ | 1715 | __be16 *bestsp; /* leaf bests table */ |
1714 | #ifdef DEBUG | ||
1715 | xfs_dir2_data_t *data; /* data block structure */ | ||
1716 | #endif | ||
1717 | xfs_dabuf_t *dbp; /* data block buffer */ | 1716 | xfs_dabuf_t *dbp; /* data block buffer */ |
1718 | xfs_inode_t *dp; /* incore directory inode */ | 1717 | xfs_inode_t *dp; /* incore directory inode */ |
1719 | int error; /* error return value */ | 1718 | int error; /* error return value */ |
@@ -1732,20 +1731,21 @@ xfs_dir2_leaf_trim_data( | |||
1732 | XFS_DATA_FORK))) { | 1731 | XFS_DATA_FORK))) { |
1733 | return error; | 1732 | return error; |
1734 | } | 1733 | } |
1735 | #ifdef DEBUG | ||
1736 | data = dbp->data; | ||
1737 | ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); | ||
1738 | #endif | ||
1739 | /* this seems to be an error | ||
1740 | * data is only valid if DEBUG is defined? | ||
1741 | * RMC 09/08/1999 | ||
1742 | */ | ||
1743 | 1734 | ||
1744 | leaf = lbp->data; | 1735 | leaf = lbp->data; |
1745 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); | 1736 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); |
1746 | ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) == | 1737 | |
1747 | mp->m_dirblksize - (uint)sizeof(data->hdr)); | 1738 | #ifdef DEBUG |
1739 | { | ||
1740 | struct xfs_dir2_data_hdr *hdr = dbp->data; | ||
1741 | |||
1742 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC); | ||
1743 | ASSERT(be16_to_cpu(hdr->bestfree[0].length) == | ||
1744 | mp->m_dirblksize - (uint)sizeof(*hdr)); | ||
1748 | ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); | 1745 | ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); |
1746 | } | ||
1747 | #endif | ||
1748 | |||
1749 | /* | 1749 | /* |
1750 | * Get rid of the data block. | 1750 | * Get rid of the data block. |
1751 | */ | 1751 | */ |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 02da7b7a005a..8d4b54c1bedb 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -842,7 +842,7 @@ xfs_dir2_leafn_remove( | |||
842 | xfs_da_state_blk_t *dblk, /* data block */ | 842 | xfs_da_state_blk_t *dblk, /* data block */ |
843 | int *rval) /* resulting block needs join */ | 843 | int *rval) /* resulting block needs join */ |
844 | { | 844 | { |
845 | xfs_dir2_data_t *data; /* data block structure */ | 845 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
846 | xfs_dir2_db_t db; /* data block number */ | 846 | xfs_dir2_db_t db; /* data block number */ |
847 | xfs_dabuf_t *dbp; /* data block buffer */ | 847 | xfs_dabuf_t *dbp; /* data block buffer */ |
848 | xfs_dir2_data_entry_t *dep; /* data block entry */ | 848 | xfs_dir2_data_entry_t *dep; /* data block entry */ |
@@ -887,9 +887,9 @@ xfs_dir2_leafn_remove( | |||
887 | * in the data block in case it changes. | 887 | * in the data block in case it changes. |
888 | */ | 888 | */ |
889 | dbp = dblk->bp; | 889 | dbp = dblk->bp; |
890 | data = dbp->data; | 890 | hdr = dbp->data; |
891 | dep = (xfs_dir2_data_entry_t *)((char *)data + off); | 891 | dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); |
892 | longest = be16_to_cpu(data->hdr.bestfree[0].length); | 892 | longest = be16_to_cpu(hdr->bestfree[0].length); |
893 | needlog = needscan = 0; | 893 | needlog = needscan = 0; |
894 | xfs_dir2_data_make_free(tp, dbp, off, | 894 | xfs_dir2_data_make_free(tp, dbp, off, |
895 | xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); | 895 | xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); |
@@ -898,7 +898,7 @@ xfs_dir2_leafn_remove( | |||
898 | * Log the data block header if needed. | 898 | * Log the data block header if needed. |
899 | */ | 899 | */ |
900 | if (needscan) | 900 | if (needscan) |
901 | xfs_dir2_data_freescan(mp, data, &needlog); | 901 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
902 | if (needlog) | 902 | if (needlog) |
903 | xfs_dir2_data_log_header(tp, dbp); | 903 | xfs_dir2_data_log_header(tp, dbp); |
904 | xfs_dir2_data_check(dp, dbp); | 904 | xfs_dir2_data_check(dp, dbp); |
@@ -906,7 +906,7 @@ xfs_dir2_leafn_remove( | |||
906 | * If the longest data block freespace changes, need to update | 906 | * If the longest data block freespace changes, need to update |
907 | * the corresponding freeblock entry. | 907 | * the corresponding freeblock entry. |
908 | */ | 908 | */ |
909 | if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) { | 909 | if (longest < be16_to_cpu(hdr->bestfree[0].length)) { |
910 | int error; /* error return value */ | 910 | int error; /* error return value */ |
911 | xfs_dabuf_t *fbp; /* freeblock buffer */ | 911 | xfs_dabuf_t *fbp; /* freeblock buffer */ |
912 | xfs_dir2_db_t fdb; /* freeblock block number */ | 912 | xfs_dir2_db_t fdb; /* freeblock block number */ |
@@ -932,19 +932,19 @@ xfs_dir2_leafn_remove( | |||
932 | * Calculate which entry we need to fix. | 932 | * Calculate which entry we need to fix. |
933 | */ | 933 | */ |
934 | findex = xfs_dir2_db_to_fdindex(mp, db); | 934 | findex = xfs_dir2_db_to_fdindex(mp, db); |
935 | longest = be16_to_cpu(data->hdr.bestfree[0].length); | 935 | longest = be16_to_cpu(hdr->bestfree[0].length); |
936 | /* | 936 | /* |
937 | * If the data block is now empty we can get rid of it | 937 | * If the data block is now empty we can get rid of it |
938 | * (usually). | 938 | * (usually). |
939 | */ | 939 | */ |
940 | if (longest == mp->m_dirblksize - (uint)sizeof(data->hdr)) { | 940 | if (longest == mp->m_dirblksize - (uint)sizeof(*hdr)) { |
941 | /* | 941 | /* |
942 | * Try to punch out the data block. | 942 | * Try to punch out the data block. |
943 | */ | 943 | */ |
944 | error = xfs_dir2_shrink_inode(args, db, dbp); | 944 | error = xfs_dir2_shrink_inode(args, db, dbp); |
945 | if (error == 0) { | 945 | if (error == 0) { |
946 | dblk->bp = NULL; | 946 | dblk->bp = NULL; |
947 | data = NULL; | 947 | hdr = NULL; |
948 | } | 948 | } |
949 | /* | 949 | /* |
950 | * We can get ENOSPC if there's no space reservation. | 950 | * We can get ENOSPC if there's no space reservation. |
@@ -960,7 +960,7 @@ xfs_dir2_leafn_remove( | |||
960 | * If we got rid of the data block, we can eliminate that entry | 960 | * If we got rid of the data block, we can eliminate that entry |
961 | * in the free block. | 961 | * in the free block. |
962 | */ | 962 | */ |
963 | if (data == NULL) { | 963 | if (hdr == NULL) { |
964 | /* | 964 | /* |
965 | * One less used entry in the free table. | 965 | * One less used entry in the free table. |
966 | */ | 966 | */ |
@@ -1356,7 +1356,7 @@ xfs_dir2_node_addname_int( | |||
1356 | xfs_da_args_t *args, /* operation arguments */ | 1356 | xfs_da_args_t *args, /* operation arguments */ |
1357 | xfs_da_state_blk_t *fblk) /* optional freespace block */ | 1357 | xfs_da_state_blk_t *fblk) /* optional freespace block */ |
1358 | { | 1358 | { |
1359 | xfs_dir2_data_t *data; /* data block structure */ | 1359 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
1360 | xfs_dir2_db_t dbno; /* data block number */ | 1360 | xfs_dir2_db_t dbno; /* data block number */ |
1361 | xfs_dabuf_t *dbp; /* data block buffer */ | 1361 | xfs_dabuf_t *dbp; /* data block buffer */ |
1362 | xfs_dir2_data_entry_t *dep; /* data entry pointer */ | 1362 | xfs_dir2_data_entry_t *dep; /* data entry pointer */ |
@@ -1641,8 +1641,8 @@ xfs_dir2_node_addname_int( | |||
1641 | * We haven't allocated the data entry yet so this will | 1641 | * We haven't allocated the data entry yet so this will |
1642 | * change again. | 1642 | * change again. |
1643 | */ | 1643 | */ |
1644 | data = dbp->data; | 1644 | hdr = dbp->data; |
1645 | free->bests[findex] = data->hdr.bestfree[0].length; | 1645 | free->bests[findex] = hdr->bestfree[0].length; |
1646 | logfree = 1; | 1646 | logfree = 1; |
1647 | } | 1647 | } |
1648 | /* | 1648 | /* |
@@ -1667,21 +1667,21 @@ xfs_dir2_node_addname_int( | |||
1667 | xfs_da_buf_done(fbp); | 1667 | xfs_da_buf_done(fbp); |
1668 | return error; | 1668 | return error; |
1669 | } | 1669 | } |
1670 | data = dbp->data; | 1670 | hdr = dbp->data; |
1671 | logfree = 0; | 1671 | logfree = 0; |
1672 | } | 1672 | } |
1673 | ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length); | 1673 | ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length); |
1674 | /* | 1674 | /* |
1675 | * Point to the existing unused space. | 1675 | * Point to the existing unused space. |
1676 | */ | 1676 | */ |
1677 | dup = (xfs_dir2_data_unused_t *) | 1677 | dup = (xfs_dir2_data_unused_t *) |
1678 | ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); | 1678 | ((char *)hdr + be16_to_cpu(hdr->bestfree[0].offset)); |
1679 | needscan = needlog = 0; | 1679 | needscan = needlog = 0; |
1680 | /* | 1680 | /* |
1681 | * Mark the first part of the unused space, inuse for us. | 1681 | * Mark the first part of the unused space, inuse for us. |
1682 | */ | 1682 | */ |
1683 | xfs_dir2_data_use_free(tp, dbp, dup, | 1683 | xfs_dir2_data_use_free(tp, dbp, dup, |
1684 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)data), length, | 1684 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, |
1685 | &needlog, &needscan); | 1685 | &needlog, &needscan); |
1686 | /* | 1686 | /* |
1687 | * Fill in the new entry and log it. | 1687 | * Fill in the new entry and log it. |
@@ -1691,13 +1691,13 @@ xfs_dir2_node_addname_int( | |||
1691 | dep->namelen = args->namelen; | 1691 | dep->namelen = args->namelen; |
1692 | memcpy(dep->name, args->name, dep->namelen); | 1692 | memcpy(dep->name, args->name, dep->namelen); |
1693 | tagp = xfs_dir2_data_entry_tag_p(dep); | 1693 | tagp = xfs_dir2_data_entry_tag_p(dep); |
1694 | *tagp = cpu_to_be16((char *)dep - (char *)data); | 1694 | *tagp = cpu_to_be16((char *)dep - (char *)hdr); |
1695 | xfs_dir2_data_log_entry(tp, dbp, dep); | 1695 | xfs_dir2_data_log_entry(tp, dbp, dep); |
1696 | /* | 1696 | /* |
1697 | * Rescan the block for bestfree if needed. | 1697 | * Rescan the block for bestfree if needed. |
1698 | */ | 1698 | */ |
1699 | if (needscan) | 1699 | if (needscan) |
1700 | xfs_dir2_data_freescan(mp, data, &needlog); | 1700 | xfs_dir2_data_freescan(mp, hdr, &needlog); |
1701 | /* | 1701 | /* |
1702 | * Log the data block header if needed. | 1702 | * Log the data block header if needed. |
1703 | */ | 1703 | */ |
@@ -1706,8 +1706,8 @@ xfs_dir2_node_addname_int( | |||
1706 | /* | 1706 | /* |
1707 | * If the freespace entry is now wrong, update it. | 1707 | * If the freespace entry is now wrong, update it. |
1708 | */ | 1708 | */ |
1709 | if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(data->hdr.bestfree[0].length)) { | 1709 | if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(hdr->bestfree[0].length)) { |
1710 | free->bests[findex] = data->hdr.bestfree[0].length; | 1710 | free->bests[findex] = hdr->bestfree[0].length; |
1711 | logfree = 1; | 1711 | logfree = 1; |
1712 | } | 1712 | } |
1713 | /* | 1713 | /* |
@@ -1857,7 +1857,7 @@ xfs_dir2_node_replace( | |||
1857 | xfs_da_args_t *args) /* operation arguments */ | 1857 | xfs_da_args_t *args) /* operation arguments */ |
1858 | { | 1858 | { |
1859 | xfs_da_state_blk_t *blk; /* leaf block */ | 1859 | xfs_da_state_blk_t *blk; /* leaf block */ |
1860 | xfs_dir2_data_t *data; /* data block structure */ | 1860 | xfs_dir2_data_hdr_t *hdr; /* data block header */ |
1861 | xfs_dir2_data_entry_t *dep; /* data entry changed */ | 1861 | xfs_dir2_data_entry_t *dep; /* data entry changed */ |
1862 | int error; /* error return value */ | 1862 | int error; /* error return value */ |
1863 | int i; /* btree level */ | 1863 | int i; /* btree level */ |
@@ -1901,10 +1901,10 @@ xfs_dir2_node_replace( | |||
1901 | /* | 1901 | /* |
1902 | * Point to the data entry. | 1902 | * Point to the data entry. |
1903 | */ | 1903 | */ |
1904 | data = state->extrablk.bp->data; | 1904 | hdr = state->extrablk.bp->data; |
1905 | ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); | 1905 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC); |
1906 | dep = (xfs_dir2_data_entry_t *) | 1906 | dep = (xfs_dir2_data_entry_t *) |
1907 | ((char *)data + | 1907 | ((char *)hdr + |
1908 | xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); | 1908 | xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); |
1909 | ASSERT(inum != be64_to_cpu(dep->inumber)); | 1909 | ASSERT(inum != be64_to_cpu(dep->inumber)); |
1910 | /* | 1910 | /* |