diff options
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 12 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_block.h | 44 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_sf.c | 14 |
3 files changed, 34 insertions, 36 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index a0037cc4dd8c..9adaf803957a 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -437,7 +437,6 @@ xfs_dir2_block_getdents( | |||
437 | xfs_off_t *offset, | 437 | xfs_off_t *offset, |
438 | filldir_t filldir) | 438 | filldir_t filldir) |
439 | { | 439 | { |
440 | xfs_dir2_block_t *block; /* directory block structure */ | ||
441 | xfs_dir2_data_hdr_t *hdr; /* block header */ | 440 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
442 | xfs_dabuf_t *bp; /* buffer for block */ | 441 | xfs_dabuf_t *bp; /* buffer for block */ |
443 | xfs_dir2_block_tail_t *btp; /* block tail */ | 442 | xfs_dir2_block_tail_t *btp; /* block tail */ |
@@ -471,14 +470,13 @@ xfs_dir2_block_getdents( | |||
471 | * We'll skip entries before this. | 470 | * We'll skip entries before this. |
472 | */ | 471 | */ |
473 | wantoff = xfs_dir2_dataptr_to_off(mp, *offset); | 472 | wantoff = xfs_dir2_dataptr_to_off(mp, *offset); |
474 | block = bp->data; | 473 | hdr = bp->data; |
475 | hdr = &block->hdr; | ||
476 | xfs_dir2_data_check(dp, bp); | 474 | xfs_dir2_data_check(dp, bp); |
477 | /* | 475 | /* |
478 | * Set up values for the loop. | 476 | * Set up values for the loop. |
479 | */ | 477 | */ |
480 | btp = xfs_dir2_block_tail_p(mp, hdr); | 478 | btp = xfs_dir2_block_tail_p(mp, hdr); |
481 | ptr = (char *)block->u; | 479 | ptr = (char *)(hdr + 1); |
482 | endptr = (char *)xfs_dir2_block_leaf_p(btp); | 480 | endptr = (char *)xfs_dir2_block_leaf_p(btp); |
483 | 481 | ||
484 | /* | 482 | /* |
@@ -1020,7 +1018,6 @@ xfs_dir2_sf_to_block( | |||
1020 | xfs_da_args_t *args) /* operation arguments */ | 1018 | xfs_da_args_t *args) /* operation arguments */ |
1021 | { | 1019 | { |
1022 | xfs_dir2_db_t blkno; /* dir-relative block # (0) */ | 1020 | xfs_dir2_db_t blkno; /* dir-relative block # (0) */ |
1023 | xfs_dir2_block_t *block; /* block structure */ | ||
1024 | xfs_dir2_data_hdr_t *hdr; /* block header */ | 1021 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
1025 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ | 1022 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ |
1026 | xfs_dabuf_t *bp; /* block buffer */ | 1023 | xfs_dabuf_t *bp; /* block buffer */ |
@@ -1091,8 +1088,7 @@ xfs_dir2_sf_to_block( | |||
1091 | kmem_free(sfp); | 1088 | kmem_free(sfp); |
1092 | return error; | 1089 | return error; |
1093 | } | 1090 | } |
1094 | block = bp->data; | 1091 | hdr = bp->data; |
1095 | hdr = &block->hdr; | ||
1096 | hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | 1092 | hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); |
1097 | /* | 1093 | /* |
1098 | * Compute size of block "tail" area. | 1094 | * Compute size of block "tail" area. |
@@ -1103,7 +1099,7 @@ xfs_dir2_sf_to_block( | |||
1103 | * The whole thing is initialized to free by the init routine. | 1099 | * The whole thing is initialized to free by the init routine. |
1104 | * Say we're using the leaf and tail area. | 1100 | * Say we're using the leaf and tail area. |
1105 | */ | 1101 | */ |
1106 | dup = (xfs_dir2_data_unused_t *)block->u; | 1102 | dup = (xfs_dir2_data_unused_t *)(hdr + 1); |
1107 | needlog = needscan = 0; | 1103 | needlog = needscan = 0; |
1108 | xfs_dir2_data_use_free(tp, bp, dup, mp->m_dirblksize - i, i, &needlog, | 1104 | xfs_dir2_data_use_free(tp, bp, dup, mp->m_dirblksize - i, i, &needlog, |
1109 | &needscan); | 1105 | &needscan); |
diff --git a/fs/xfs/xfs_dir2_block.h b/fs/xfs/xfs_dir2_block.h index fe91f88f880c..de59677e38ba 100644 --- a/fs/xfs/xfs_dir2_block.h +++ b/fs/xfs/xfs_dir2_block.h | |||
@@ -19,10 +19,30 @@ | |||
19 | #define __XFS_DIR2_BLOCK_H__ | 19 | #define __XFS_DIR2_BLOCK_H__ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * xfs_dir2_block.h | 22 | * Directory version 2, single block format structures. |
23 | * Directory version 2, single block format structures | 23 | * |
24 | * The single block format looks like the following drawing on disk: | ||
25 | * | ||
26 | * +-------------------------------------------------+ | ||
27 | * | xfs_dir2_data_hdr_t | | ||
28 | * +-------------------------------------------------+ | ||
29 | * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t | | ||
30 | * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t | | ||
31 | * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t | | ||
32 | * | ... | | ||
33 | * +-------------------------------------------------+ | ||
34 | * | unused space | | ||
35 | * +-------------------------------------------------+ | ||
36 | * | ... | | ||
37 | * | xfs_dir2_leaf_entry_t | | ||
38 | * | xfs_dir2_leaf_entry_t | | ||
39 | * +-------------------------------------------------+ | ||
40 | * | xfs_dir2_block_tail_t | | ||
41 | * +-------------------------------------------------+ | ||
42 | * | ||
43 | * As all the entries are variable size structures the accessors in this | ||
44 | * file and xfs_dir2_data.h should be used to iterate over them. | ||
24 | */ | 45 | */ |
25 | |||
26 | struct uio; | 46 | struct uio; |
27 | struct xfs_dabuf; | 47 | struct xfs_dabuf; |
28 | struct xfs_da_args; | 48 | struct xfs_da_args; |
@@ -32,14 +52,6 @@ struct xfs_inode; | |||
32 | struct xfs_mount; | 52 | struct xfs_mount; |
33 | struct xfs_trans; | 53 | struct xfs_trans; |
34 | 54 | ||
35 | /* | ||
36 | * The single block format is as follows: | ||
37 | * xfs_dir2_data_hdr_t structure | ||
38 | * xfs_dir2_data_entry_t and xfs_dir2_data_unused_t structures | ||
39 | * xfs_dir2_leaf_entry_t structures | ||
40 | * xfs_dir2_block_tail_t structure | ||
41 | */ | ||
42 | |||
43 | #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */ | 55 | #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */ |
44 | 56 | ||
45 | typedef struct xfs_dir2_block_tail { | 57 | typedef struct xfs_dir2_block_tail { |
@@ -48,16 +60,6 @@ typedef struct xfs_dir2_block_tail { | |||
48 | } xfs_dir2_block_tail_t; | 60 | } xfs_dir2_block_tail_t; |
49 | 61 | ||
50 | /* | 62 | /* |
51 | * Generic single-block structure, for xfs_db. | ||
52 | */ | ||
53 | typedef struct xfs_dir2_block { | ||
54 | xfs_dir2_data_hdr_t hdr; /* magic XFS_DIR2_BLOCK_MAGIC */ | ||
55 | xfs_dir2_data_union_t u[1]; | ||
56 | xfs_dir2_leaf_entry_t leaf[1]; | ||
57 | xfs_dir2_block_tail_t tail; | ||
58 | } xfs_dir2_block_t; | ||
59 | |||
60 | /* | ||
61 | * Pointer to the leaf header embedded in a data block (1-block format) | 63 | * Pointer to the leaf header embedded in a data block (1-block format) |
62 | */ | 64 | */ |
63 | static inline xfs_dir2_block_tail_t * | 65 | static inline xfs_dir2_block_tail_t * |
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c index 515efa5d29ca..b47a99c8f244 100644 --- a/fs/xfs/xfs_dir2_sf.c +++ b/fs/xfs/xfs_dir2_sf.c | |||
@@ -226,7 +226,7 @@ xfs_dir2_block_to_sf( | |||
226 | int size, /* shortform directory size */ | 226 | int size, /* shortform directory size */ |
227 | xfs_dir2_sf_hdr_t *sfhp) /* shortform directory hdr */ | 227 | xfs_dir2_sf_hdr_t *sfhp) /* shortform directory hdr */ |
228 | { | 228 | { |
229 | xfs_dir2_block_t *block; /* block structure */ | 229 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
230 | xfs_dir2_block_tail_t *btp; /* block tail pointer */ | 230 | xfs_dir2_block_tail_t *btp; /* block tail pointer */ |
231 | xfs_dir2_data_entry_t *dep; /* data entry pointer */ | 231 | xfs_dir2_data_entry_t *dep; /* data entry pointer */ |
232 | xfs_inode_t *dp; /* incore directory inode */ | 232 | xfs_inode_t *dp; /* incore directory inode */ |
@@ -248,8 +248,8 @@ xfs_dir2_block_to_sf( | |||
248 | * Make a copy of the block data, so we can shrink the inode | 248 | * Make a copy of the block data, so we can shrink the inode |
249 | * and add local data. | 249 | * and add local data. |
250 | */ | 250 | */ |
251 | block = kmem_alloc(mp->m_dirblksize, KM_SLEEP); | 251 | hdr = kmem_alloc(mp->m_dirblksize, KM_SLEEP); |
252 | memcpy(block, bp->data, mp->m_dirblksize); | 252 | memcpy(hdr, bp->data, mp->m_dirblksize); |
253 | logflags = XFS_ILOG_CORE; | 253 | logflags = XFS_ILOG_CORE; |
254 | if ((error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp))) { | 254 | if ((error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp))) { |
255 | ASSERT(error != ENOSPC); | 255 | ASSERT(error != ENOSPC); |
@@ -277,8 +277,8 @@ xfs_dir2_block_to_sf( | |||
277 | /* | 277 | /* |
278 | * Set up to loop over the block's entries. | 278 | * Set up to loop over the block's entries. |
279 | */ | 279 | */ |
280 | btp = xfs_dir2_block_tail_p(mp, &block->hdr); | 280 | btp = xfs_dir2_block_tail_p(mp, hdr); |
281 | ptr = (char *)block->u; | 281 | ptr = (char *)(hdr + 1); |
282 | endptr = (char *)xfs_dir2_block_leaf_p(btp); | 282 | endptr = (char *)xfs_dir2_block_leaf_p(btp); |
283 | sfep = xfs_dir2_sf_firstentry(sfp); | 283 | sfep = xfs_dir2_sf_firstentry(sfp); |
284 | /* | 284 | /* |
@@ -314,7 +314,7 @@ xfs_dir2_block_to_sf( | |||
314 | sfep->namelen = dep->namelen; | 314 | sfep->namelen = dep->namelen; |
315 | xfs_dir2_sf_put_offset(sfep, | 315 | xfs_dir2_sf_put_offset(sfep, |
316 | (xfs_dir2_data_aoff_t) | 316 | (xfs_dir2_data_aoff_t) |
317 | ((char *)dep - (char *)block)); | 317 | ((char *)dep - (char *)hdr)); |
318 | memcpy(sfep->name, dep->name, dep->namelen); | 318 | memcpy(sfep->name, dep->name, dep->namelen); |
319 | xfs_dir2_sfe_put_ino(sfp, sfep, | 319 | xfs_dir2_sfe_put_ino(sfp, sfep, |
320 | be64_to_cpu(dep->inumber)); | 320 | be64_to_cpu(dep->inumber)); |
@@ -327,7 +327,7 @@ xfs_dir2_block_to_sf( | |||
327 | xfs_dir2_sf_check(args); | 327 | xfs_dir2_sf_check(args); |
328 | out: | 328 | out: |
329 | xfs_trans_log_inode(args->trans, dp, logflags); | 329 | xfs_trans_log_inode(args->trans, dp, logflags); |
330 | kmem_free(block); | 330 | kmem_free(hdr); |
331 | return error; | 331 | return error; |
332 | } | 332 | } |
333 | 333 | ||