aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2011-07-08 08:35:42 -0400
committerChristoph Hellwig <hch@lst.de>2011-07-08 08:35:42 -0400
commit0ba9cd84ef2af58645333a86f9c901684ab1fef6 (patch)
tree0c25f43b83bb77ceb44cf29d207a295ac0b77b31
parentc2066e2662070e794f57a96a129c42575e77cfcb (diff)
xfs: kill struct xfs_dir2_data
Remove the confusing xfs_dir2_data structure. It is supposed to describe an XFS dir2 data btree block, but due to the variable sized nature of almost all elements in it it can't actuall do anything close to that job. In addition to accessing the fixed offset header structure it was only used to get a pointer to the first dir or unused entry after it, which can be trivially replaced by pointer arithmetics on the header pointer. For most users that is actually more natural anyway, as they don't use a typed pointer but rather a character pointer for further arithmetics. 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_dir2_data.c15
-rw-r--r--fs/xfs/xfs_dir2_data.h33
-rw-r--r--fs/xfs/xfs_dir2_leaf.c6
3 files changed, 23 insertions, 31 deletions
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index 2bbc21696944..8e47ac3a3b9d 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -53,7 +53,6 @@ xfs_dir2_data_check(
53 xfs_dir2_data_free_t *bf; /* bestfree table */ 53 xfs_dir2_data_free_t *bf; /* bestfree table */
54 xfs_dir2_block_tail_t *btp=NULL; /* block tail */ 54 xfs_dir2_block_tail_t *btp=NULL; /* block tail */
55 int count; /* count of entries found */ 55 int count; /* count of entries found */
56 xfs_dir2_data_t *d; /* data block pointer */
57 xfs_dir2_data_hdr_t *hdr; /* data block header */ 56 xfs_dir2_data_hdr_t *hdr; /* data block header */
58 xfs_dir2_data_entry_t *dep; /* data entry */ 57 xfs_dir2_data_entry_t *dep; /* data entry */
59 xfs_dir2_data_free_t *dfp; /* bestfree entry */ 58 xfs_dir2_data_free_t *dfp; /* bestfree entry */
@@ -70,10 +69,9 @@ xfs_dir2_data_check(
70 struct xfs_name name; 69 struct xfs_name name;
71 70
72 mp = dp->i_mount; 71 mp = dp->i_mount;
73 d = bp->data; 72 hdr = bp->data;
74 hdr = &d->hdr;
75 bf = hdr->bestfree; 73 bf = hdr->bestfree;
76 p = (char *)d->u; 74 p = (char *)(hdr + 1);
77 75
78 if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { 76 if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) {
79 btp = xfs_dir2_block_tail_p(mp, hdr); 77 btp = xfs_dir2_block_tail_p(mp, hdr);
@@ -336,7 +334,6 @@ xfs_dir2_data_freescan(
336 xfs_dir2_data_hdr_t *hdr, /* data block header */ 334 xfs_dir2_data_hdr_t *hdr, /* data block header */
337 int *loghead) /* out: log data header */ 335 int *loghead) /* out: log data header */
338{ 336{
339 xfs_dir2_data_t *d = (xfs_dir2_data_t *)hdr;
340 xfs_dir2_block_tail_t *btp; /* block tail */ 337 xfs_dir2_block_tail_t *btp; /* block tail */
341 xfs_dir2_data_entry_t *dep; /* active data entry */ 338 xfs_dir2_data_entry_t *dep; /* active data entry */
342 xfs_dir2_data_unused_t *dup; /* unused data entry */ 339 xfs_dir2_data_unused_t *dup; /* unused data entry */
@@ -355,7 +352,7 @@ xfs_dir2_data_freescan(
355 /* 352 /*
356 * Set up pointers. 353 * Set up pointers.
357 */ 354 */
358 p = (char *)d->u; 355 p = (char *)(hdr + 1);
359 if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { 356 if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) {
360 btp = xfs_dir2_block_tail_p(mp, hdr); 357 btp = xfs_dir2_block_tail_p(mp, hdr);
361 endp = (char *)xfs_dir2_block_leaf_p(btp); 358 endp = (char *)xfs_dir2_block_leaf_p(btp);
@@ -398,7 +395,6 @@ xfs_dir2_data_init(
398 xfs_dabuf_t **bpp) /* output block buffer */ 395 xfs_dabuf_t **bpp) /* output block buffer */
399{ 396{
400 xfs_dabuf_t *bp; /* block buffer */ 397 xfs_dabuf_t *bp; /* block buffer */
401 xfs_dir2_data_t *d; /* pointer to block */
402 xfs_dir2_data_hdr_t *hdr; /* data block header */ 398 xfs_dir2_data_hdr_t *hdr; /* data block header */
403 xfs_inode_t *dp; /* incore directory inode */ 399 xfs_inode_t *dp; /* incore directory inode */
404 xfs_dir2_data_unused_t *dup; /* unused entry pointer */ 400 xfs_dir2_data_unused_t *dup; /* unused entry pointer */
@@ -424,8 +420,7 @@ xfs_dir2_data_init(
424 /* 420 /*
425 * Initialize the header. 421 * Initialize the header.
426 */ 422 */
427 d = bp->data; 423 hdr = bp->data;
428 hdr = &d->hdr;
429 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); 424 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
430 hdr->bestfree[0].offset = cpu_to_be16(sizeof(*hdr)); 425 hdr->bestfree[0].offset = cpu_to_be16(sizeof(*hdr));
431 for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { 426 for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) {
@@ -436,7 +431,7 @@ xfs_dir2_data_init(
436 /* 431 /*
437 * Set up an unused entry for the block's body. 432 * Set up an unused entry for the block's body.
438 */ 433 */
439 dup = &d->u[0].unused; 434 dup = (xfs_dir2_data_unused_t *)(hdr + 1);
440 dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); 435 dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
441 436
442 t = mp->m_dirblksize - (uint)sizeof(*hdr); 437 t = mp->m_dirblksize - (uint)sizeof(*hdr);
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h
index aa6bf91c4228..ca02cc71e234 100644
--- a/fs/xfs/xfs_dir2_data.h
+++ b/fs/xfs/xfs_dir2_data.h
@@ -20,6 +20,22 @@
20 20
21/* 21/*
22 * Directory format 2, data block structures. 22 * Directory format 2, data block structures.
23 *
24 * A pure data block 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 * As all the entries are variable size structures the accessors in this
38 * file should be used to iterate over them.
23 */ 39 */
24 40
25struct xfs_dabuf; 41struct xfs_dabuf;
@@ -103,23 +119,6 @@ typedef struct xfs_dir2_data_unused {
103 __be16 tag; /* starting offset of us */ 119 __be16 tag; /* starting offset of us */
104} xfs_dir2_data_unused_t; 120} xfs_dir2_data_unused_t;
105 121
106typedef union {
107 xfs_dir2_data_entry_t entry;
108 xfs_dir2_data_unused_t unused;
109} xfs_dir2_data_union_t;
110
111/*
112 * Generic data block structure, for xfs_db.
113 */
114typedef struct xfs_dir2_data {
115 xfs_dir2_data_hdr_t hdr; /* magic XFS_DIR2_DATA_MAGIC */
116 xfs_dir2_data_union_t u[1];
117} xfs_dir2_data_t;
118
119/*
120 * Macros.
121 */
122
123/* 122/*
124 * Size of a data entry. 123 * Size of a data entry.
125 */ 124 */
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index d7b4d4494f2d..067a6abdeabe 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -785,7 +785,6 @@ xfs_dir2_leaf_getdents(
785 int byteoff; /* offset in current block */ 785 int byteoff; /* offset in current block */
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 */
789 xfs_dir2_data_hdr_t *hdr; /* data block header */ 788 xfs_dir2_data_hdr_t *hdr; /* data block header */
790 xfs_dir2_data_entry_t *dep; /* data entry */ 789 xfs_dir2_data_entry_t *dep; /* data entry */
791 xfs_dir2_data_unused_t *dup; /* unused entry */ 790 xfs_dir2_data_unused_t *dup; /* unused entry */
@@ -1044,13 +1043,12 @@ xfs_dir2_leaf_getdents(
1044 else if (curoff > newoff) 1043 else if (curoff > newoff)
1045 ASSERT(xfs_dir2_byte_to_db(mp, curoff) == 1044 ASSERT(xfs_dir2_byte_to_db(mp, curoff) ==
1046 curdb); 1045 curdb);
1047 data = bp->data; 1046 hdr = bp->data;
1048 hdr = &data->hdr;
1049 xfs_dir2_data_check(dp, bp); 1047 xfs_dir2_data_check(dp, bp);
1050 /* 1048 /*
1051 * Find our position in the block. 1049 * Find our position in the block.
1052 */ 1050 */
1053 ptr = (char *)&data->u; 1051 ptr = (char *)(hdr + 1);
1054 byteoff = xfs_dir2_byte_to_off(mp, curoff); 1052 byteoff = xfs_dir2_byte_to_off(mp, curoff);
1055 /* 1053 /*
1056 * Skip past the header. 1054 * Skip past the header.